Java Code Examples for de.robv.android.xposed.XSharedPreferences#getBoolean()

The following examples show how to use de.robv.android.xposed.XSharedPreferences#getBoolean() . 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: BatteryStyleController.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
private void initPreferences(XSharedPreferences prefs) {
    mPrefs = prefs;
    mBatteryStyle = Integer.valueOf(prefs.getString(
            GravityBoxSettings.PREF_KEY_BATTERY_STYLE, "1"));
    mBatteryPercentTextEnabledSb = prefs.getBoolean(
            GravityBoxSettings.PREF_KEY_BATTERY_PERCENT_TEXT_STATUSBAR, false);
    mBatteryPercentTextHeaderHide = prefs.getBoolean(
            GravityBoxSettings.PREF_KEY_BATTERY_PERCENT_TEXT_HEADER_HIDE, false);
    mBatteryPercentTextKgMode = KeyguardMode.valueOf(prefs.getString(
            GravityBoxSettings.PREF_KEY_BATTERY_PERCENT_TEXT_KEYGUARD, "DEFAULT"));
    mMtkPercentTextEnabled = Utils.isMtkDevice() ?
            Settings.Secure.getInt(mContext.getContentResolver(),
                    SETTING_MTK_BATTERY_PERCENTAGE, 0) == 1 : false;
    mBatterySaverIndicationDisabled = prefs.getBoolean(
            GravityBoxSettings.PREF_KEY_BATTERY_SAVER_INDICATION_DISABLE, false);
}
 
Example 2
Source File: LockscreenAppBar.java    From GravityBox with Apache License 2.0 6 votes vote down vote up
public LockscreenAppBar(Context ctx, Context gbCtx, ViewGroup container,
        Object statusBar, XSharedPreferences prefs) {
    mContext = ctx;
    mGbContext = gbCtx;
    mContainer = container;
    mStatusBar = statusBar;
    mPrefs = prefs;
    mPm = mContext.getPackageManager();
    mHandler = new Handler();
    mSafeLaunchEnabled = prefs.getBoolean(
            GravityBoxSettings.PREF_KEY_LOCKSCREEN_SHORTCUT_SAFE_LAUNCH, false);
    mShowBadges = prefs.getBoolean(
            GravityBoxSettings.PREF_KEY_LOCKSCREEN_SHORTCUT_SHOW_BADGES, false);

    mNdMonitor = SysUiManagers.NotifDataMonitor;
    if (mNdMonitor != null) {
        mNdMonitor.registerListener(this);
    }

    initAppSlots();

    mKgMonitor = SysUiManagers.KeyguardMonitor;
    mKgMonitor.registerListener(this);
}
 
Example 3
Source File: ProgressBarController.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
public ProgressBarController(Context ctx, XSharedPreferences prefs) {
    mContext = ctx;
    mListeners = new ArrayList<ProgressStateListener>();
    mProgressList = new LinkedHashMap<String, ProgressInfo>();

    mMode = Mode.valueOf(prefs.getString(GravityBoxSettings.PREF_KEY_STATUSBAR_DOWNLOAD_PROGRESS, "OFF"));
    mSoundEnabled = prefs.getBoolean(GravityBoxSettings.PREF_KEY_STATUSBAR_DOWNLOAD_PROGRESS_SOUND_ENABLE, false);
    mSoundUri = prefs.getString(GravityBoxSettings.PREF_KEY_STATUSBAR_DOWNLOAD_PROGRESS_SOUND,
            "content://settings/system/notification_sound");
    mSoundWhenScreenOffOnly = prefs.getBoolean(
            GravityBoxSettings.PREF_KEY_STATUSBAR_DOWNLOAD_PROGRESS_SOUND_SCREEN_OFF, false);

    mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
    mHandler = new Handler();
}
 
Example 4
Source File: ModVolumeKeySkipTrack.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
private static void updatePreference(final XSharedPreferences prefs) {
    prefs.reload();
    allowSkipTrack = prefs.getBoolean(GravityBoxSettings.PREF_KEY_VOL_MUSIC_CONTROLS, false);
    mShoudTriggerWakeUp = "enabled".equals(
            prefs.getString(GravityBoxSettings.PREF_KEY_VOLUME_ROCKER_WAKE, "default")) &&
            prefs.getBoolean(GravityBoxSettings.PREF_KEY_VOLUME_ROCKER_WAKE_ALLOW_MUSIC, false);
    if (DEBUG) log("allowSkipTrack = " + allowSkipTrack + "; " +
            "mShoudTriggerWakeUp=" + mShoudTriggerWakeUp);
}
 
Example 5
Source File: TrafficMeterOmni.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
@Override
protected void onInitialize(XSharedPreferences prefs) throws Throwable {
    mGbContext = Utils.getGbContext(getContext());
    SYMBOLS.put("b/s", mGbContext.getString(R.string.bit_per_sec_abbr));
    SYMBOLS.put("B/s", mGbContext.getString(R.string.byte_per_sec_abbr));
    SYMBOLS.put("k", mGbContext.getString(R.string.kilo_abbr));
    SYMBOLS.put("M", mGbContext.getString(R.string.mega_abbr));
    SYMBOLS.put("G", mGbContext.getString(R.string.giga_abbr));

    mMode = Mode.valueOf(prefs.getString(GravityBoxSettings.PREF_KEY_DATA_TRAFFIC_OMNI_MODE, "IN_OUT"));
    mShowIcon = prefs.getBoolean(GravityBoxSettings.PREF_KEY_DATA_TRAFFIC_OMNI_SHOW_ICON, true);
    mAutoHide = prefs.getBoolean(GravityBoxSettings.PREF_KEY_DATA_TRAFFIC_OMNI_AUTOHIDE, false);
    mAutoHideThreshold = prefs.getInt(GravityBoxSettings.PREF_KEY_DATA_TRAFFIC_OMNI_AUTOHIDE_TH, 10);
    setSize();
}
 
Example 6
Source File: Lockscreen.java    From android-lockscreen-disabler with Apache License 2.0 5 votes vote down vote up
@Override
public void initZygote(StartupParam startupParam) throws Throwable {
    prefs = new XSharedPreferences("com.lr.keyguarddisabler");
    prefs.makeWorldReadable();
    lockScreenTimeoutToEnforce = Integer.parseInt(prefs.getString("lockscreentimeout", "1")) * 60 * 1000;
    LOG = prefs.getBoolean("logtofile", false);
    lockScreenType = prefs.getString("lockscreentype", LOCK_SCREEN_TYPE_SLIDE);
    lockonBootup = prefs.getBoolean("lockscreenonboot", false);
    // Make sure we start any bootup locked...
}
 
Example 7
Source File: XSPUtils.java    From XposedSmsCode with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 是否复制到剪切板
 */
public static boolean copyToClipboardEnabled(XSharedPreferences preferences) {
    return preferences.getBoolean(PrefConst.KEY_COPY_TO_CLIPBOARD, false);
}
 
Example 8
Source File: XSPUtils.java    From XposedSmsCode with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 是否记录短信验证码
 */
public static boolean recordSmsCodeEnabled(XSharedPreferences preferences) {
    return preferences.getBoolean(PrefConst.KEY_ENABLE_CODE_RECORDS, true);
}
 
Example 9
Source File: XSPUtils.java    From XMiTools with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 是否在有系统时钟widget的桌面中显示状态栏时间
 */
public static boolean alwaysShowStatusBarClock(XSharedPreferences xsp) {
    return xsp.getBoolean(ALWAYS_SHOW_STATUS_BAR_CLOCK, false);
}
 
Example 10
Source File: XSPUtils.java    From XMiTools with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 信号是否左对齐
 */
public static boolean isSignalAlignLeft(XSharedPreferences xsp) {
    return xsp.getBoolean(STATUS_BAR_SIGNAL_ALIGN_LEFT, false);
}
 
Example 11
Source File: SystemWideResources.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
public static void initResources(final XSharedPreferences prefs) {
    try {
        Resources systemRes = XResources.getSystem();

        int translucentDecor = Integer.valueOf(prefs.getString(GravityBoxSettings.PREF_KEY_TRANSLUCENT_DECOR, "0"));
        if (translucentDecor != 0) {
            XResources.setSystemWideReplacement("android", "bool", "config_enableTranslucentDecor", translucentDecor == 1);
        }

        if (prefs.getBoolean(GravityBoxSettings.PREF_KEY_NAVBAR_OVERRIDE, false)) {
            XResources.setSystemWideReplacement("android", "bool", "config_showNavigationBar",
                    prefs.getBoolean(GravityBoxSettings.PREF_KEY_NAVBAR_ENABLE,
                            SystemPropertyProvider.getSystemConfigBool(systemRes,
                                    "config_showNavigationBar")));
        }

        XResources.setSystemWideReplacement("android", "bool", "config_unplugTurnsOnScreen",
                prefs.getBoolean(GravityBoxSettings.PREF_KEY_UNPLUG_TURNS_ON_SCREEN,
                        SystemPropertyProvider.getSystemConfigBool(systemRes,
                                "config_unplugTurnsOnScreen")));

        if (!Utils.isVerneeApolloDevice()) {
            int pulseNotificationDelay = prefs.getInt(GravityBoxSettings.PREF_KEY_PULSE_NOTIFICATION_DELAY, -1);
            if (pulseNotificationDelay != -1) {
                XResources.setSystemWideReplacement("android", "integer", "config_defaultNotificationLedOff",
                        (pulseNotificationDelay));;
            }
        }

        XResources.setSystemWideReplacement("android", "bool", "config_sip_wifi_only", false);

        if (prefs.getBoolean(GravityBoxSettings.PREF_KEY_BRIGHTNESS_MASTER_SWITCH, false)) {
            int brightnessMin = prefs.getInt(GravityBoxSettings.PREF_KEY_BRIGHTNESS_MIN, 20);
            XResources.setSystemWideReplacement(
                "android", "integer", "config_screenBrightnessSettingMinimum", brightnessMin);
            if (DEBUG) log("Minimum brightness value set to: " + brightnessMin);

            int screenDim = prefs.getInt(GravityBoxSettings.PREF_KEY_SCREEN_DIM_LEVEL, 10);
            XResources.setSystemWideReplacement(
                    "android", "integer", "config_screenBrightnessDim", screenDim);
            if (DEBUG) log("Screen dim level set to: " + screenDim);
        }

        // Safe media volume
        Utils.TriState triState = Utils.TriState.valueOf(prefs.getString(
                GravityBoxSettings.PREF_KEY_SAFE_MEDIA_VOLUME, "DEFAULT"));
        if (DEBUG) log(GravityBoxSettings.PREF_KEY_SAFE_MEDIA_VOLUME + ": " + triState);
        if (triState != Utils.TriState.DEFAULT) {
            XResources.setSystemWideReplacement("android", "bool", "config_safe_media_volume_enabled",
                    triState == Utils.TriState.ENABLED);
            if (DEBUG) log("config_safe_media_volume_enabled: " + (triState == Utils.TriState.ENABLED));
        }
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 12
Source File: XSPUtils.java    From XposedSmsCode with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 验证码提取成功后是否杀掉模块进程
 */
public static boolean killMeEnabled(XSharedPreferences preferences) {
    return preferences.getBoolean(PrefConst.KEY_KILL_ME, false);
}
 
Example 13
Source File: XSPUtils.java    From XposedSmsCode with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 日志模式是否是verbose log模式
 */
public static boolean isVerboseLogMode(XSharedPreferences preferences) {
    return preferences.getBoolean(PrefConst.KEY_VERBOSE_LOG_MODE, false);
}
 
Example 14
Source File: ModSmartRadio.java    From GravityBox with Apache License 2.0 4 votes vote down vote up
public static void init(final XSharedPreferences prefs, final ClassLoader classLoader) {
    try {
        final Class<?> classSystemUIService = XposedHelpers.findClass(
                "com.android.systemui.SystemUIService", classLoader);

        mNormalMode = prefs.getInt(GravityBoxSettings.PREF_KEY_SMART_RADIO_NORMAL_MODE, -1);
        mPowerSavingMode = prefs.getInt(GravityBoxSettings.PREF_KEY_SMART_RADIO_POWER_SAVING_MODE, -1);
        mPowerSaveWhenScreenOff = prefs.getBoolean(GravityBoxSettings.PREF_KEY_SMART_RADIO_SCREEN_OFF, false);
        mIgnoreWhileLocked = prefs.getBoolean(GravityBoxSettings.PREF_KEY_SMART_RADIO_IGNORE_LOCKED, true);
        mModeChangeDelay = prefs.getInt(GravityBoxSettings.PREF_KEY_SMART_RADIO_MODE_CHANGE_DELAY, 5);
        mScreenOffDelay = prefs.getInt(GravityBoxSettings.PREF_KEY_SMART_RADIO_SCREEN_OFF_DELAY, 0);
        mIgnoreMobileDataAvailability = prefs.getBoolean(GravityBoxSettings.PREF_KEY_SMART_RADIO_MDA_IGNORE, false);
        mAdaptiveDelayThreshold = prefs.getInt(GravityBoxSettings.PREF_KEY_SMART_RADIO_ADAPTIVE_DELAY, 0);

        XposedHelpers.findAndHookMethod(classSystemUIService, "onCreate", new XC_MethodHook() {
            @Override
            protected void afterHookedMethod(final MethodHookParam param) throws Throwable {
                mContext = (Context) param.thisObject;
                if (mContext != null) {
                    if (DEBUG) log("Initializing SmartRadio");

                    mSmartRadioEnabled = Settings.System.getInt(mContext.getContentResolver(),
                            SETTING_SMART_RADIO_ENABLED, 1) == 1;
                    mConnManager = (ConnectivityManager) mContext.getSystemService(Context.CONNECTIVITY_SERVICE);
                    mKeyguardManager = (KeyguardManager) mContext.getSystemService(Context.KEYGUARD_SERVICE);
                    mNetworkModeChanger = new NetworkModeChanger(mContext, new Handler());
                    Settings.System.putString(mContext.getContentResolver(), 
                            SETTING_SMART_RADIO_STATE, mCurrentState.toString());

                    IntentFilter intentFilter = new IntentFilter();
                    intentFilter.addAction(GravityBoxSettings.ACTION_PREF_SMART_RADIO_CHANGED);
                    intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
                    intentFilter.addAction(Intent.ACTION_SCREEN_ON);
                    intentFilter.addAction(Intent.ACTION_SCREEN_OFF);
                    intentFilter.addAction(Intent.ACTION_USER_PRESENT);
                    intentFilter.addAction(NetworkModeChanger.ACTION_CHANGE_MODE_ALARM);
                    intentFilter.addAction(ACTION_TOGGLE_SMART_RADIO);
                    intentFilter.addAction(TelephonyManager.ACTION_PHONE_STATE_CHANGED);
                    intentFilter.addAction(PhoneWrapper.ACTION_NETWORK_TYPE_CHANGED);
                    mContext.registerReceiver(mBroadcastReceiver, intentFilter);
                }
            }
        });
    } catch (Throwable t) {
        XposedBridge.log(t);
    }
}
 
Example 15
Source File: XSPUtils.java    From XposedSmsCode with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 标记为已读是否打开
 */
public static boolean markAsReadEnabled(XSharedPreferences preferences) {
    return preferences.getBoolean(PrefConst.KEY_MARK_AS_READ, false);
}
 
Example 16
Source File: DataHook.java    From XposedNavigationBar with GNU General Public License v3.0 4 votes vote down vote up
public static void init(IXposedHookZygoteInit.StartupParam startupParam) throws Throwable {
    XSharedPreferences pre = new XSharedPreferences(BuildConfig.APPLICATION_ID, "xpnavbar");
    pre.makeWorldReadable();

    String json = pre.getString(ConstantStr.SHORT_CUT_DATA, "");
    XpLog.i("short_cut_data " + json);
    expandStatusBarWithRoot = pre.getBoolean(SPUtil.ROOT_DOWN, false);
    clearMenLevel = pre.getInt(SPUtil.CLEAR_MEM_LEVEL, 200);
    //获取主导行栏小点的位置
    homePointPosition = pre.getInt(ConstantStr.HOME_POINT, 0);
    chameleonNavbar = pre.getBoolean(SPUtil.CHAMELEON_NAVBAR, false);
    rootDown = pre.getBoolean(SPUtil.ROOT_DOWN, false);
    vibrate = pre.getBoolean(SPUtil.NAVBAR_VIBRATE, false);
    //获取快捷按钮设置数据
    Gson gson = new Gson();
    //在第一次激活重新启动的时候,可能因为没有设置任何快捷按钮,导致这里报错
    try {
        shortCutList = gson.fromJson(json, ShortCutData.class).getData();
    } catch (Exception e) {
        shortCutList = new ArrayList<>();
    }

    //获取图片缩放大小
    iconScale = pre.getInt(ConstantStr.ICON_SIZE, 40);

    navbarHeight = pre.getInt(SPUtil.NAVBAR_HEIGHT, 100);

    navbarOpt = pre.getBoolean(SPUtil.NAVBAR_HEIGHT_OPT, false);

    goHomeAfterClick = pre.getBoolean(SPUtil.GO_HOME_AFTER_CLICK, false);

    //加载图片资源文件
    Resources res = XModuleResources.createInstance(startupParam.modulePath, null);
    byte[] backImg = XposedHelpers.assetAsByteArray(res, "back.png");
    byte[] clearMenImg = XposedHelpers.assetAsByteArray(res, "clear_mem.png");
    byte[] clearNotificationImg = XposedHelpers.assetAsByteArray(res, "clear_notification.png");
    byte[] downImg = XposedHelpers.assetAsByteArray(res, "down.png");
    byte[] lightImg = XposedHelpers.assetAsByteArray(res, "light.png");
    byte[] quickNoticesImg = XposedHelpers.assetAsByteArray(res, "quick_notices.png");
    byte[] screenOffImg = XposedHelpers.assetAsByteArray(res, "screenoff.png");
    //  byte[] upImg = XposedHelpers.assetAsByteArray(res, "up.png");
    byte[] volume = XposedHelpers.assetAsByteArray(res, "volume.png");
    byte[] smallPonit = XposedHelpers.assetAsByteArray(res, "small_point.png");
    byte[] home = XposedHelpers.assetAsByteArray(res, "ic_home.png");
    byte[] startActs = XposedHelpers.assetAsByteArray(res, "start_acts.png");
    byte[] playMusic = XposedHelpers.assetAsByteArray(res, "ic_music.png");
    byte[] pauseMusic = XposedHelpers.assetAsByteArray(res, "ic_pause.png");
    byte[] previousMusic = XposedHelpers.assetAsByteArray(res, "ic_previous.png");
    byte[] nextMusic = XposedHelpers.assetAsByteArray(res, "ic_next.png");
    byte[] scanWeChat = XposedHelpers.assetAsByteArray(res, "wechat_qr.png");
    byte[] scanAlipay = XposedHelpers.assetAsByteArray(res, "alipay_qr.png");
    byte[] screenshot = XposedHelpers.assetAsByteArray(res, "ic_image.png");
    byte[] navBack = XposedHelpers.assetAsByteArray(res, "ic_sysbar_back.png");
    byte[] navHome = XposedHelpers.assetAsByteArray(res, "ic_sysbar_home.png");
    byte[] navRecent = XposedHelpers.assetAsByteArray(res, "ic_sysbar_recent.png");
    byte[] clipBoard = XposedHelpers.assetAsByteArray(res, "ic_clipboard.png");
    byte[] command = XposedHelpers.assetAsByteArray(res, "ic_command.png");
    byte[] navHide = XposedHelpers.assetAsByteArray(res, "ic_nav_down.png");

    mapImgRes.put(ConstantStr.FUNC_BACK_CODE, backImg);
    mapImgRes.put(ConstantStr.FUNC_CLEAR_MEM_CODE, clearMenImg);
    mapImgRes.put(ConstantStr.FUNC_CLEAR_NOTIFICATION_CODE, clearNotificationImg);
    mapImgRes.put(ConstantStr.FUNC_DOWN_CODE, downImg);
    mapImgRes.put(ConstantStr.FUNC_LIGHT_CODE, lightImg);
    mapImgRes.put(ConstantStr.FUNC_QUICK_NOTICE_CODE, quickNoticesImg);
    mapImgRes.put(ConstantStr.FUNC_SCREEN_OFF_CODE, screenOffImg);
    //  mapImgRes.put(ConstantStr.UP, upImg);
    mapImgRes.put(ConstantStr.FUNC_VOLUME_CODE, volume);
    mapImgRes.put(ConstantStr.FUNC_SMALL_POINT_CODE, smallPonit);
    mapImgRes.put(ConstantStr.FUNC_HOME_CODE, home);
    mapImgRes.put(ConstantStr.FUNC_START_ACTS_CODE, startActs);
    mapImgRes.put(ConstantStr.FUNC_PLAY_MUSIC_CODE, playMusic);
    mapImgRes.put(ConstantStr.FUNC_NEXT_PLAY_CODE, nextMusic);
    mapImgRes.put(ConstantStr.FUNC_PREVIOUS_PLAY_CODE, previousMusic);
    mapImgRes.put(ConstantStr.FUNC_WECHAT_SACNNER_CODE, scanWeChat);
    mapImgRes.put(ConstantStr.FUNC_ALIPAY_SACNNER_CODE, scanAlipay);
    mapImgRes.put(ConstantStr.FUNC_SCREEN_SHOT_CODE, screenshot);
    mapImgRes.put(ConstantStr.FUNC_NAV_BACK_CODE, navBack);
    mapImgRes.put(ConstantStr.FUNC_NAV_HOME_CODE, navHome);
    mapImgRes.put(ConstantStr.FUNC_NAV_RECENT_CODE, navRecent);
    mapImgRes.put(ConstantStr.FUNC_CLIPBOARD_CODE, clipBoard);
    mapImgRes.put(ConstantStr.FUNC_COMMAND_CODE, command);
    mapImgRes.put(ConstantStr.FUNC_NAV_HIDE_CODE, navHide);
}
 
Example 17
Source File: XSPUtils.java    From XMiTools with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 是否启用一言
 */
public static boolean oneSentenceEnabled(XSharedPreferences xsp) {
    return xsp.getBoolean(PrefConst.ONE_SENTENCE_ENABLE, false);
}
 
Example 18
Source File: XSPUtils.java    From XMiTools with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 是否显示一言 Hitokoto 来源
 */
public static boolean getShowHitokotoSource(XSharedPreferences xsp) {
    return xsp.getBoolean(PrefConst.SHOW_HITOKOTO_SOURCE, false);
}
 
Example 19
Source File: XSPUtils.java    From XMiTools with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 是否显示今日诗词作者
 */
public static boolean getShowPoemAuthor(XSharedPreferences xsp) {
    return xsp.getBoolean(PrefConst.SHOW_POEM_AUTHOR, false);
}
 
Example 20
Source File: XSPUtils.java    From XposedSmsCode with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 总开关是否打开
 */
public static boolean isEnabled(XSharedPreferences preferences) {
    return preferences.getBoolean(PrefConst.KEY_ENABLE, true);
}