Java Code Examples for de.robv.android.xposed.XposedHelpers#getIntField()

The following examples show how to use de.robv.android.xposed.XposedHelpers#getIntField() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StatusbarBattery.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
public StatusbarBattery(View batteryView) {
        mBattery = batteryView;
        createHooks();
        try {
            Object drawable = getDrawable();
            final int[] colors = (int[]) XposedHelpers.getObjectField(drawable, "mColors");
            mDefaultColor = colors[colors.length - 1];
            if (Utils.isLineageOs()) {

                Drawable frameDrawable = (Drawable) XposedHelpers.getObjectField(drawable, "mFrameDrawable");
//                mDefaultFrameColor = frameDrawable.setTint();
                mFrameAlpha = frameDrawable.getAlpha();
            } else {
                final Paint framePaint = (Paint) XposedHelpers.getObjectField(drawable, "mFramePaint");
                mDefaultFrameColor = framePaint.getColor();
                mFrameAlpha = framePaint.getAlpha();
            }

            mDefaultChargeColor = XposedHelpers.getIntField(drawable, "mChargeColor");
        } catch (Throwable t) {
            log("Error backing up original colors: " + t.getMessage());
        }
        if (SysUiManagers.IconManager != null) {
            SysUiManagers.IconManager.registerListener(this);
        }
    }
 
Example 2
Source File: CellularTile.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
private boolean isSignalNull(Object info) {
    try {
        boolean noSim = XposedHelpers.getBooleanField(info, "noSim");
        boolean enabled = XposedHelpers.getBooleanField(info, "enabled");
        boolean airplane = XposedHelpers.getBooleanField(info, "airplaneModeEnabled");
        int iconId = 1;
        try {
            iconId = XposedHelpers.getIntField(info, "mobileSignalIconId");
        } catch (Throwable t1) {
            iconId = XposedHelpers.getIntField(info, "mobileSimIconId");
        }
        return (noSim || !enabled || airplane || iconId <= 0);
    } catch (Throwable t2) {
        return false;
    }
}
 
Example 3
Source File: StatusbarSignalCluster.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
protected void updateBatteryPadding() {
    if (Utils.isXperiaDevice()) return;

    try {
        if (mBatteryPaddingOriginal == null) {
            mBatteryPaddingOriginal = XposedHelpers.getIntField(mView, "mEndPadding");
        }
        int padding = mBatteryPaddingOriginal;
        if (mBatteryStyle == GravityBoxSettings.BATTERY_STYLE_NONE) {
            if ((mContainerType == ContainerType.STATUSBAR && !mPercentTextSb) ||
                    (mContainerType == ContainerType.KEYGUARD)) {
                padding = Math.round((float) mBatteryPaddingOriginal / 4f);
            }
        }
        XposedHelpers.setIntField(mView, "mEndPadding", padding);
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 4
Source File: PhoneWindowManagerHook.java    From XposedNavigationBar with GNU General Public License v3.0 6 votes vote down vote up
public static void setNavBarDimensions(Object sPhoneWindowManager, int hp, int defaultNavbarH) {
    if (hp == -1) {
        hp = defaultNavbarH;
    }

    int[] navigationBarHeightForRotation;
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.M) {
        navigationBarHeightForRotation = (int[]) XposedHelpers.getObjectField(
                sPhoneWindowManager, "mNavigationBarHeightForRotation");
    } else {
        navigationBarHeightForRotation = (int[]) XposedHelpers.getObjectField(
                sPhoneWindowManager, "mNavigationBarHeightForRotationDefault");
    }

    final int portraitRotation = XposedHelpers.getIntField(sPhoneWindowManager, "mPortraitRotation");
    final int upsideDownRotation = XposedHelpers.getIntField(sPhoneWindowManager, "mUpsideDownRotation");
    if (navigationBarHeightForRotation[portraitRotation] == hp)
        return;

    navigationBarHeightForRotation[portraitRotation] =
            navigationBarHeightForRotation[upsideDownRotation] =
                    hp;
    XposedHelpers.callMethod(sPhoneWindowManager, "updateRotation", false);
}
 
Example 5
Source File: XposedHelpersWraper.java    From MIUIAnesthetist with MIT License 5 votes vote down vote up
public static int getIntField(Object obj, String fieldName) {
    try {
        return XposedHelpers.getIntField(obj, fieldName);
    } catch (Throwable t) {
        log(t);
    }
    return 0;
}
 
Example 6
Source File: ModVolumePanel.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private static boolean isRingerSliderEnabled() {
    try {
        List<?> rows = (List<?>) XposedHelpers.getObjectField(mVolumePanel, "mRows");
        for (Object row : rows) {
            if (XposedHelpers.getIntField(row, "stream") == AudioManager.STREAM_RING) {
                return ((View) XposedHelpers.getObjectField(row, "slider")).isEnabled();
            }
        }
        return true;
    } catch (Throwable t) {
        XposedBridge.log(t);
        return true;
    }
}
 
Example 7
Source File: KeyguardStateMonitor.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
public int getCurrentUserId() {
    try {
        return XposedHelpers.getIntField(mMonitor, "mCurrentUser");
    } catch (Throwable t) {
        return 0;
    }
}
 
Example 8
Source File: ModNavigationBar.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private static void setCustomKeyVisibility() {
    try {
        final int disabledFlags = XposedHelpers.getIntField(mNavigationBarView, "mDisabledFlags");
        final boolean visible = mCustomKeyEnabled &&
                !((disabledFlags & STATUS_BAR_DISABLE_RECENT) != 0);
        for (int i = 0; i <= 1; i++) {
            if (mNavbarViewInfo[i] == null) continue;

            if (mNavbarViewInfo[i].visible != visible) {
                if (mNavbarViewInfo[i].originalView != null) {
                    mNavbarViewInfo[i].navButtons.removeViewAt(mNavbarViewInfo[i].customKeyPosition);
                    mNavbarViewInfo[i].navButtons.addView(visible ?
                                    mNavbarViewInfo[i].customKey : mNavbarViewInfo[i].originalView,
                            mNavbarViewInfo[i].customKeyPosition);
                } else {
                    if (visible) {
                        mNavbarViewInfo[i].navButtons.addView(mNavbarViewInfo[i].customKey,
                                mNavbarViewInfo[i].customKeyPosition);
                    } else {
                        mNavbarViewInfo[i].navButtons.removeView(mNavbarViewInfo[i].customKey);
                    }
                }
                mNavbarViewInfo[i].visible = visible;
                if (DEBUG) log("setAppKeyVisibility: visible=" + visible);
            }

            // swap / unswap with menu key if necessary
            if ((!mCustomKeyEnabled || !mCustomKeySwapEnabled) &&
                    mNavbarViewInfo[i].menuCustomSwapped) {
                swapMenuAndCustom(mNavbarViewInfo[i]);
            } else if (mCustomKeyEnabled && mCustomKeySwapEnabled &&
                    !mNavbarViewInfo[i].menuCustomSwapped) {
                swapMenuAndCustom(mNavbarViewInfo[i]);
            }
        }
    } catch (Throwable t) {
        log("Error setting app key visibility: " + t.getMessage());
    }
}
 
Example 9
Source File: ModNavigationBar.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private static void setMenuKeyVisibility() {
    try {
        final boolean showMenu = XposedHelpers.getBooleanField(mNavigationBarView, "mShowMenu");
        final int disabledFlags = XposedHelpers.getIntField(mNavigationBarView, "mDisabledFlags");
        final boolean visible = (showMenu || mAlwaysShowMenukey) &&
                !((disabledFlags & STATUS_BAR_DISABLE_RECENT) != 0);
        int menuResId = mResources.getIdentifier("menu", "id", PACKAGE_NAME);
        int imeSwitcherResId = mResources.getIdentifier("ime_switcher", "id", PACKAGE_NAME);
        for (int i = 0; i <= 1; i++) {
            if (mNavbarViewInfo[i] == null) continue;

            boolean isImeSwitcherVisible = false;
            View v = null;
            if (imeSwitcherResId != 0) {
                v = mNavbarViewInfo[i].navButtons.findViewById(imeSwitcherResId);
                if (v != null) {
                    isImeSwitcherVisible = v.getVisibility() == View.VISIBLE;
                }
            }
            v = mNavbarViewInfo[i].navButtons.findViewById(menuResId);
            if (v != null) {
                v.setVisibility(mDpadKeysVisible || isImeSwitcherVisible ? View.GONE :
                        visible ? View.VISIBLE : View.INVISIBLE);
            }
        }
    } catch (Throwable t) {
        log("Error setting menu key visibility:" + t.getMessage());
    }

}
 
Example 10
Source File: BaseTile.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateTileView(View tileView) throws Throwable {
    XposedHelpers.setAdditionalInstanceField(tileView, TILE_KEY_NAME, mKey);

    mScalingFactor = QsPanel.getScalingFactor(Integer.valueOf(mPrefs.getString(
            GravityBoxSettings.PREF_KEY_QUICK_SETTINGS_TILES_PER_ROW, "0")),
            mPrefs.getInt(GravityBoxSettings.PREF_KEY_QS_SCALE_CORRECTION, 0));
    if (mScalingFactor != 1f) {
        int iconSizePx = XposedHelpers.getIntField(tileView, "mIconSizePx");
        XposedHelpers.setIntField(tileView, "mIconSizePx", Math.round(iconSizePx*mScalingFactor));
        int tileSpacingPx = XposedHelpers.getIntField(tileView, "mTileSpacingPx");
        XposedHelpers.setIntField(tileView, "mTileSpacingPx", Math.round(tileSpacingPx*mScalingFactor));
        int tilePaddingBelowIconPx = XposedHelpers.getIntField(tileView, "mTilePaddingBelowIconPx");
        XposedHelpers.setIntField(tileView, "mTilePaddingBelowIconPx",
                Math.round(tilePaddingBelowIconPx*mScalingFactor));
        int dualTileVerticalPaddingPx = XposedHelpers.getIntField(tileView, "mDualTileVerticalPaddingPx");
        XposedHelpers.setIntField(tileView, "mDualTileVerticalPaddingPx", 
                Math.round(dualTileVerticalPaddingPx*mScalingFactor));

        updateLabelLayout(tileView);
        updatePaddingTop(tileView);

        if (tileView.getClass().getName().equals(CLASS_SIGNAL_TILE_VIEW) &&
                Utils.isMotoXtDevice()) {
            updateMotoXtSignalIconLayout(tileView);
        }
    }
}
 
Example 11
Source File: CellularTile.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private boolean isDataTypeIconVisible(Object state) {
    try {
        return (XposedHelpers.getIntField(state, "overlayIconId") != 0);
    } catch (Throwable t) {
        return false;
    }
}
 
Example 12
Source File: ModNavigationBar.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
private static void setDpadKeyVisibility() {
    if (!mCursorControlEnabled) return;
    try {
        final int iconHints = XposedHelpers.getIntField(mNavigationBarView, "mNavigationIconHints");
        final int disabledFlags = XposedHelpers.getIntField(mNavigationBarView, "mDisabledFlags");
        mDpadKeysVisible = !((disabledFlags & STATUS_BAR_DISABLE_RECENT) != 0) &&
                (iconHints & NAVIGATION_HINT_BACK_ALT) != 0;

        for (int i = 0; i <= 1; i++) {
            // hide/unhide app key or whatever view at that position
            View v = mNavbarViewInfo[i].navButtons.getChildAt(mNavbarViewInfo[i].customKeyPosition);
            if (v != null) {
                v.setVisibility(mDpadKeysVisible ? View.GONE : View.VISIBLE);
            }
            // hide/unhide menu key
            int menuResId = mResources.getIdentifier("menu", "id", PACKAGE_NAME);
            v = mNavbarViewInfo[i].navButtons.findViewById(menuResId);
            if (v != null) {
                if (mDpadKeysVisible) {
                    v.setVisibility(View.GONE);
                } else {
                    setMenuKeyVisibility();
                }
            }
            // Hide view group holding menu/customkey and ime switcher if all children hidden
            if (mNavbarViewInfo[i].menuImeGroup != null) {
                boolean allHidden = true;
                for (int j = 0; j < mNavbarViewInfo[i].menuImeGroup.getChildCount(); j++) {
                    allHidden &= mNavbarViewInfo[i].menuImeGroup.getChildAt(j)
                            .getVisibility() != View.VISIBLE;
                }
                mNavbarViewInfo[i].menuImeGroup.setVisibility(
                        mDpadKeysVisible && allHidden ? View.GONE : View.VISIBLE);
            }
            mNavbarViewInfo[i].dpadLeft.setVisibility(mDpadKeysVisible ? View.VISIBLE : View.GONE);
            mNavbarViewInfo[i].dpadRight.setVisibility(mDpadKeysVisible ? View.VISIBLE : View.GONE);
            if (DEBUG) log("setDpadKeyVisibility: visible=" + mDpadKeysVisible);
        }
    } catch (Throwable t) {
        log("Error setting dpad key visibility: " + t.getMessage());
    }
}
 
Example 13
Source File: ModExpandedDesktop.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
private static void updateSettings() {
    if (mContext == null || mPhoneWindowManager == null) return;

    try {
        final boolean expandedDesktop = Settings.Global.getInt(mContext.getContentResolver(),
                SETTING_EXPANDED_DESKTOP_STATE, 0) == 1;
        if (mExpandedDesktopMode == GravityBoxSettings.ED_DISABLED && expandedDesktop) {
            Settings.Global.putInt(mContext.getContentResolver(),
                    SETTING_EXPANDED_DESKTOP_STATE, 0);
            return;
        }

        if (mExpandedDesktop != expandedDesktop) {
            mExpandedDesktop = expandedDesktop;
        }

        XposedHelpers.callMethod(mPhoneWindowManager, "updateSettings");

        int[] navigationBarWidthForRotation = (int[]) XposedHelpers.getObjectField(
                mPhoneWindowManager, "mNavigationBarWidthForRotationDefault");
        int[] navigationBarHeightForRotation = (int[]) XposedHelpers.getObjectField(
                mPhoneWindowManager, "mNavigationBarHeightForRotationDefault");
        final int portraitRotation = XposedHelpers.getIntField(mPhoneWindowManager, "mPortraitRotation");
        final int upsideDownRotation = XposedHelpers.getIntField(mPhoneWindowManager, "mUpsideDownRotation");
        final int landscapeRotation = XposedHelpers.getIntField(mPhoneWindowManager, "mLandscapeRotation");
        final int seascapeRotation = XposedHelpers.getIntField(mPhoneWindowManager, "mSeascapeRotation");

        if (isNavbarHidden()) {
            navigationBarWidthForRotation[portraitRotation]
                    = navigationBarWidthForRotation[upsideDownRotation]
                    = navigationBarWidthForRotation[landscapeRotation]
                    = navigationBarWidthForRotation[seascapeRotation]
                    = navigationBarHeightForRotation[portraitRotation]
                    = navigationBarHeightForRotation[upsideDownRotation]
                    = navigationBarHeightForRotation[landscapeRotation]
                    = navigationBarHeightForRotation[seascapeRotation] = 0;
        } else if (mNavbarDimensions != null) {
            navigationBarHeightForRotation[portraitRotation] =
                    navigationBarHeightForRotation[upsideDownRotation] =
                            mNavbarDimensions.hPort;
            navigationBarHeightForRotation[landscapeRotation] =
                    navigationBarHeightForRotation[seascapeRotation] =
                            mNavbarDimensions.hLand;

            navigationBarWidthForRotation[portraitRotation] =
                    navigationBarWidthForRotation[upsideDownRotation] =
                            navigationBarWidthForRotation[landscapeRotation] =
                                    navigationBarWidthForRotation[seascapeRotation] =
                                            mNavbarDimensions.wPort;
        }

        XposedHelpers.callMethod(mPhoneWindowManager, "updateRotation", false);
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 14
Source File: ModExpandedDesktop.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
private static int getInt(String field) {
    return XposedHelpers.getIntField(mPhoneWindowManager, field);
}
 
Example 15
Source File: BaseTile.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
private void updatePaddingTop(View tileView) {
    int tilePaddingTopPx = XposedHelpers.getIntField(tileView, "mTilePaddingTopPx");
    XposedHelpers.setIntField(tileView, "mTilePaddingTopPx",
            Math.round(tilePaddingTopPx*mScalingFactor));
}
 
Example 16
Source File: QuickAppTile.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
@Override
public boolean handleLongClick() {
    LayoutInflater inflater = LayoutInflater.from(mGbContext);
    View appv = inflater.inflate(R.layout.quick_settings_app_dialog, null);
    int count = 0;
    AppInfo lastAppInfo = null;
    for (AppInfo ai : mAppSlots) {
        TextView tv = (TextView) appv.findViewById(ai.getResId());
        if (ai.getValue() == null) {
            tv.setVisibility(View.GONE);
            continue;
        }

        tv.setText(ai.getAppName());
        tv.setTextSize(1, 10);
        tv.setMaxLines(2);
        tv.setEllipsize(TruncateAt.END);
        tv.setCompoundDrawablesWithIntrinsicBounds(null, ai.getAppIcon(), null, null);
        tv.setClickable(true);
        tv.setOnClickListener(mOnSlotClick);
        count++;
        lastAppInfo = ai;
    }

    if (count == 1) {
        try {
            startActivity(lastAppInfo.getIntent());
        } catch (Throwable t) {
            log(getKey() + ": Unable to start activity: " + t.getMessage());
        }
    } else if (count > 1) {
        mDialog = new Dialog(mContext, android.R.style.Theme_Material_Dialog_NoActionBar);
        mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        mDialog.setContentView(appv);
        mDialog.setCanceledOnTouchOutside(true);
        mDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_STATUS_BAR_PANEL);
        int pf = XposedHelpers.getIntField(mDialog.getWindow().getAttributes(), "privateFlags");
        pf |= 0x00000010;
        XposedHelpers.setIntField(mDialog.getWindow().getAttributes(), "privateFlags", pf);
        mDialog.getWindow().clearFlags(LayoutParams.FLAG_DIM_BEHIND);
        mDialog.show();
        mHandler.removeCallbacks(mDismissDialogRunnable);
        mHandler.postDelayed(mDismissDialogRunnable, 4000);
    }
    return true;
}