Java Code Examples for android.preference.CheckBoxPreference#setSummary()

The following examples show how to use android.preference.CheckBoxPreference#setSummary() . 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: FakeSignatureGlobalUI.java    From haystack with GNU General Public License v3.0 6 votes vote down vote up
static CheckBoxPreference addPreference(PreferenceFragment fragment) {
//>5.1// static SwitchPreference addPreference(PreferenceFragment fragment) {
    PreferenceGroup pg = (PreferenceGroup) fragment.findPreference(PREFERENCE_CATEGORY_KEY);
    if (pg != null) {
        /*<5.1*/ CheckBoxPreference p = new CheckBoxPreference(pg.getContext());
        //>5.1// SwitchPreference p = new SwitchPreference(pg.getContext());
        p.setKey(PREFERENCE_KEY);
        p.setTitle(PREFERENCE_TITLE);
        p.setSummary(PREFERENCE_SUMMARY);
        p.setPersistent(false);
        pg.addPreference(p);
        return p;
    } else {
        Log.e("FakeSignatureGlobalUI", "cannot find '" + PREFERENCE_CATEGORY_KEY +"' preference category");
        return null;
    }
}
 
Example 2
Source File: FakeSignatureGlobalUI.java    From haystack with GNU General Public License v3.0 6 votes vote down vote up
static CheckBoxPreference addPreference(PreferenceFragment fragment) {
//>5.1// static SwitchPreference addPreference(PreferenceFragment fragment) {
    PreferenceGroup pg = (PreferenceGroup) fragment.findPreference(PREFERENCE_CATEGORY_KEY);
    if (pg != null) {
        /*<5.1*/ CheckBoxPreference p = new CheckBoxPreference(pg.getContext());
        //>5.1// SwitchPreference p = new SwitchPreference(pg.getContext());
        p.setKey(PREFERENCE_KEY);
        p.setTitle(PREFERENCE_TITLE);
        p.setSummary(PREFERENCE_SUMMARY);
        p.setPersistent(false);
        pg.addPreference(p);
        return p;
    } else {
        Log.e("FakeSignatureGlobalUI", "cannot find '" + PREFERENCE_CATEGORY_KEY +"' preference category");
        return null;
    }
}
 
Example 3
Source File: DvachModule.java    From Overchan-Android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
    Context context = preferenceGroup.getContext();
    addPasswordPreference(preferenceGroup);
    CheckBoxPreference onionPref = new LazyPreferences.CheckBoxPreference(context);
    onionPref.setTitle(R.string.pref_use_onion);
    onionPref.setSummary(R.string.pref_use_onion_summary);
    onionPref.setKey(getSharedKey(PREF_KEY_USE_ONION));
    onionPref.setDefaultValue(false);
    onionPref.setDisableDependentsState(true);
    preferenceGroup.addPreference(onionPref);
    EditTextPreference domainPref = new EditTextPreference(context);
    domainPref.setTitle(R.string.pref_domain);
    domainPref.setDialogTitle(R.string.pref_domain);
    domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT));
    domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN));
    domainPref.getEditText().setHint(DEFAULT_DOMAIN);
    domainPref.getEditText().setSingleLine();
    domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    preferenceGroup.addPreference(domainPref);
    domainPref.setDependency(getSharedKey(PREF_KEY_USE_ONION));
    addProxyPreferences(preferenceGroup);
}
 
Example 4
Source File: CloudflareChanModule.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
protected void addCloudflareRecaptchaFallbackPreference(PreferenceGroup preferenceGroup) {
    if (canCloudflare()) {
        Context context = preferenceGroup.getContext();
        CheckBoxPreference fallbackPref = new LazyPreferences.CheckBoxPreference(context);
        fallbackPref.setTitle(R.string.pref_cf_recaptcha_fallback);
        fallbackPref.setSummary(R.string.pref_cf_recaptcha_fallback_summary);
        fallbackPref.setKey(getSharedKey(PREF_KEY_CLOUDFLARE_RECAPTCHA_FALLBACK));
        fallbackPref.setDefaultValue(false);
        preferenceGroup.addPreference(fallbackPref);
    }
}
 
Example 5
Source File: MakabaModule.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
/** Добавить категорию настроек домена (в т.ч. https) */
private void addDomainPreferences(PreferenceGroup group) {
    Context context = group.getContext();
    Preference.OnPreferenceChangeListener updateDomainListener = new Preference.OnPreferenceChangeListener() {
        @Override
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (preference.getKey().equals(getSharedKey(PREF_KEY_DOMAIN))) {
                updateDomain((String) newValue, preferences.getBoolean(getSharedKey(PREF_KEY_USE_HTTPS_MAKABA), true));
                return true;
            } else if (preference.getKey().equals(getSharedKey(PREF_KEY_USE_HTTPS_MAKABA))) {
                updateDomain(preferences.getString(getSharedKey(PREF_KEY_DOMAIN), DEFAULT_DOMAIN), (boolean)newValue);
                return true;
            }
            return false;
        }
    };
    PreferenceCategory domainCat = new PreferenceCategory(context);
    domainCat.setTitle(R.string.makaba_prefs_domain_category);
    group.addPreference(domainCat);
    EditTextPreference domainPref = new EditTextPreference(context); //поле ввода домена
    domainPref.setTitle(R.string.pref_domain);
    domainPref.setDialogTitle(R.string.pref_domain);
    domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT));
    domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN));
    domainPref.getEditText().setHint(DEFAULT_DOMAIN);
    domainPref.getEditText().setSingleLine();
    domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    domainPref.setOnPreferenceChangeListener(updateDomainListener);
    domainCat.addPreference(domainPref);
    CheckBoxPreference httpsPref = new LazyPreferences.CheckBoxPreference(context); //чекбокс "использовать https"
    httpsPref.setTitle(R.string.pref_use_https);
    httpsPref.setSummary(R.string.pref_use_https_summary);
    httpsPref.setKey(getSharedKey(PREF_KEY_USE_HTTPS_MAKABA));
    httpsPref.setDefaultValue(true);
    httpsPref.setOnPreferenceChangeListener(updateDomainListener);
    domainCat.addPreference(httpsPref);
}
 
Example 6
Source File: MakabaModule.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
private void addMobileAPIPreference(PreferenceGroup group) {
    final Context context = group.getContext();
    CheckBoxPreference mobileAPIPref = new LazyPreferences.CheckBoxPreference(context);
    mobileAPIPref.setTitle(R.string.makaba_prefs_mobile_api);
    mobileAPIPref.setSummary(R.string.pref_only_new_posts_summary);
    mobileAPIPref.setKey(getSharedKey(PREF_KEY_MOBILE_API));
    mobileAPIPref.setDefaultValue(true);
    group.addPreference(mobileAPIPref);
}
 
Example 7
Source File: InfinityModule.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
    Context context = preferenceGroup.getContext();
    addPasswordPreference(preferenceGroup);
    CheckBoxPreference httpsPref = addHttpsPreference(preferenceGroup, true);
    CheckBoxPreference onionPref = new LazyPreferences.CheckBoxPreference(context);
    onionPref.setTitle(R.string.pref_use_onion);
    onionPref.setSummary(R.string.pref_use_onion_summary);
    onionPref.setKey(getSharedKey(PREF_KEY_USE_ONION));
    onionPref.setDefaultValue(false);
    onionPref.setDisableDependentsState(true);
    preferenceGroup.addPreference(onionPref);
    httpsPref.setDependency(getSharedKey(PREF_KEY_USE_ONION));
    addProxyPreferences(preferenceGroup);
}
 
Example 8
Source File: Pref.java    From GeoLog with Apache License 2.0 5 votes vote down vote up
public static CheckBoxPreference Check(Context context, PreferenceCategory category, String caption, String summary, String key, Object defaultValue, boolean enabled) {
	CheckBoxPreference retval = new CheckBoxPreference(context);
	retval.setTitle(caption);
	retval.setSummary(summary);
	retval.setEnabled(enabled);
	retval.setKey(key);
	retval.setDefaultValue(defaultValue);
	if (category != null) category.addPreference(retval);
	return retval;
}
 
Example 9
Source File: DobroModule.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
private void addCaptchaPreference(PreferenceGroup group) {
    Context context = group.getContext();
    CheckBoxPreference showCaptchaPreference = new LazyPreferences.CheckBoxPreference(context);
    showCaptchaPreference.setTitle(R.string.dobrochan_prefs_show_captcha);
    showCaptchaPreference.setSummary(R.string.dobrochan_prefs_show_captcha_summary);
    showCaptchaPreference.setKey(getSharedKey(PREF_KEY_SHOW_CAPTCHA));
    showCaptchaPreference.setDefaultValue(false);
    group.addPreference(showCaptchaPreference);
}
 
Example 10
Source File: AbstractChanModule.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Добавить в группу параметров (на экран/в категорию) настройку выбора использования инкрементальной загрузки (загрузки только новых постов).
 * Для хранения используется ключ общих параметров {@link #PREF_KEY_ONLY_NEW_POSTS} ({@link #getSharedKey(String)}).
 * См. также: {@link #loadOnlyNewPosts(boolean)} - для получения значения параметра.
 * @param group группа, на которую добавляется параметр
 * @param defaultValue значение параметра по умолчанию
 * return объект {@link CheckBoxPreference} с параметром
 */
protected CheckBoxPreference addOnlyNewPostsPreference(PreferenceGroup group, boolean defaultValue) {
    final Context context = group.getContext();
    CheckBoxPreference onlyNewPostsPref = new LazyPreferences.CheckBoxPreference(context);
    onlyNewPostsPref.setTitle(R.string.pref_only_new_posts);
    onlyNewPostsPref.setSummary(R.string.pref_only_new_posts_summary);
    onlyNewPostsPref.setKey(getSharedKey(PREF_KEY_ONLY_NEW_POSTS));
    onlyNewPostsPref.setDefaultValue(defaultValue);
    group.addPreference(onlyNewPostsPref);
    return onlyNewPostsPref;
}
 
Example 11
Source File: BasePreferenceFragment.java    From Dashchan with Apache License 2.0 5 votes vote down vote up
public CheckBoxPreference makeCheckBox(PreferenceGroup parent, boolean persistent, String key,
		boolean defaultValue, CharSequence title, CharSequence summary) {
	CheckBoxPreference preference = new CheckBoxPreference(getActivity());
	preference.setPersistent(persistent);
	preference.setKey(key);
	preference.setTitle(title);
	if (summary != null) {
		preference.setSummary(summary);
	}
	preference.setDefaultValue(defaultValue);
	addPreference(parent, preference);
	return preference;
}
 
Example 12
Source File: AbstractChanModule.java    From Overchan-Android with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Добавить в группу параметров (на экран/в категорию) новую категорию настроек прокси-сервера
 * @param group группа, на которую добавляются параметры
 */
protected void addProxyPreferences(PreferenceGroup group) {
    final Context context = group.getContext();
    PreferenceCategory proxyCat = new PreferenceCategory(context); //категория настроек прокси
    proxyCat.setTitle(R.string.pref_cat_proxy);
    group.addPreference(proxyCat);
    CheckBoxPreference useProxyPref = new LazyPreferences.CheckBoxPreference(context); //чекбокс "использовать ли прокси вообще"
    useProxyPref.setTitle(R.string.pref_use_proxy);
    useProxyPref.setSummary(R.string.pref_use_proxy_summary);
    useProxyPref.setKey(getSharedKey(PREF_KEY_USE_PROXY));
    useProxyPref.setDefaultValue(false);
    useProxyPref.setOnPreferenceChangeListener(updateHttpListener);
    proxyCat.addPreference(useProxyPref);
    EditTextPreference proxyHostPref = new LazyPreferences.EditTextPreference(context); //поле ввода адреса прокси-сервера
    proxyHostPref.setTitle(R.string.pref_proxy_host);
    proxyHostPref.setDialogTitle(R.string.pref_proxy_host);
    proxyHostPref.setSummary(R.string.pref_proxy_host_summary);
    proxyHostPref.setKey(getSharedKey(PREF_KEY_PROXY_HOST));
    proxyHostPref.setDefaultValue(DEFAULT_PROXY_HOST);
    proxyHostPref.getEditText().setSingleLine();
    proxyHostPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    proxyHostPref.setOnPreferenceChangeListener(updateHttpListener);
    proxyCat.addPreference(proxyHostPref);
    proxyHostPref.setDependency(getSharedKey(PREF_KEY_USE_PROXY));
    EditTextPreference proxyHostPort = new LazyPreferences.EditTextPreference(context); //поле ввода порта прокси-сервера
    proxyHostPort.setTitle(R.string.pref_proxy_port);
    proxyHostPort.setDialogTitle(R.string.pref_proxy_port);
    proxyHostPort.setSummary(R.string.pref_proxy_port_summary);
    proxyHostPort.setKey(getSharedKey(PREF_KEY_PROXY_PORT));
    proxyHostPort.setDefaultValue(DEFAULT_PROXY_PORT);
    proxyHostPort.getEditText().setSingleLine();
    proxyHostPort.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
    proxyHostPort.setOnPreferenceChangeListener(updateHttpListener);
    proxyCat.addPreference(proxyHostPort);
    proxyHostPort.setDependency(getSharedKey(PREF_KEY_USE_PROXY));
}
 
Example 13
Source File: ActiveScreenActivity.java    From GravityBox with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mPrefs = SharedPreferencesUtils.getSharedPreferences(getPreferenceManager(), "ledcontrol");
    addPreferencesFromResource(R.xml.led_control_active_screen_settings);

    mPrefPocketMode = (CheckBoxPreference) findPreference(
            LedSettings.PREF_KEY_ACTIVE_SCREEN_POCKET_MODE);

    if (LedSettings.isProximityWakeUpEnabled(getActivity())) {
        mPrefPocketMode.setSummary(R.string.pref_unc_as_pocket_mode_summary_overriden);
        mPrefPocketMode.setEnabled(false);
    }
}
 
Example 14
Source File: FetchingPrefFragment.java    From Onosendai with Apache License 2.0 5 votes vote down vote up
private void addSyncScroll () {
	final CheckBoxPreference pref = new CheckBoxPreference(getActivity());
	pref.setKey(KEY_SYNC_SCROLL);
	pref.setTitle("Sync column scroll position"); //ES
	pref.setSummary("But only if last scroll was upward."); //ES
	getPreferenceScreen().addPreference(pref);
}
 
Example 15
Source File: PreferenceMatchersTest.java    From android-test with Apache License 2.0 5 votes vote down vote up
@Test
public void withSummaryTest() {
  CheckBoxPreference pref = new CheckBoxPreference(getApplicationContext());
  pref.setSummary(R.string.something);
  assertThat(pref, withSummary(R.string.something));
  assertThat(pref, not(withSummary(R.string.other_string)));
  assertThat(pref, withSummaryText("Hello World"));
  assertThat(pref, not(withSummaryText("Hello Mars")));
  assertThat(pref, withSummaryText(is("Hello World")));
}
 
Example 16
Source File: Pref.java    From GeoLog with Apache License 2.0 5 votes vote down vote up
public static CheckBoxPreference Check(Context context, PreferenceCategory category, int caption, int summary, String key, Object defaultValue, boolean enabled) {
	CheckBoxPreference retval = new CheckBoxPreference(context);
	if (caption > 0) retval.setTitle(caption);
	if (summary > 0) retval.setSummary(summary);
	retval.setEnabled(enabled);
	retval.setKey(key);
	retval.setDefaultValue(defaultValue);
	if (category != null) category.addPreference(retval);
	return retval;
}
 
Example 17
Source File: AdvancedPrefFragment.java    From Onosendai with Apache License 2.0 5 votes vote down vote up
private void addThreadInspector () {
	final CheckBoxPreference pref = new CheckBoxPreference(getActivity());
	pref.setKey(KEY_THREAD_INSPECTOR);
	pref.setTitle("Thread Inspector"); //ES
	pref.setSummary("For debugging issues with worker threads."); //ES
	getPreferenceScreen().addPreference(pref);
}
 
Example 18
Source File: PrivacySettingsFragment.java    From JumpGo with Mozilla Public License 2.0 4 votes vote down vote up
private void initPrefs() {
    Preference clearcache = findPreference(SETTINGS_CLEARCACHE);
    Preference clearhistory = findPreference(SETTINGS_CLEARHISTORY);
    Preference clearcookies = findPreference(SETTINGS_CLEARCOOKIES);
    Preference clearwebstorage = findPreference(SETTINGS_CLEARWEBSTORAGE);

    CheckBoxPreference cblocation = (CheckBoxPreference) findPreference(SETTINGS_LOCATION);
    CheckBoxPreference cb3cookies = (CheckBoxPreference) findPreference(SETTINGS_THIRDPCOOKIES);
    CheckBoxPreference cbsavepasswords = (CheckBoxPreference) findPreference(SETTINGS_SAVEPASSWORD);
    CheckBoxPreference cbcacheexit = (CheckBoxPreference) findPreference(SETTINGS_CACHEEXIT);
    CheckBoxPreference cbhistoryexit = (CheckBoxPreference) findPreference(SETTINGS_HISTORYEXIT);
    CheckBoxPreference cbcookiesexit = (CheckBoxPreference) findPreference(SETTINGS_COOKIEEXIT);
    CheckBoxPreference cbwebstorageexit = (CheckBoxPreference) findPreference(SETTINGS_WEBSTORAGEEXIT);
    CheckBoxPreference cbDoNotTrack = (CheckBoxPreference) findPreference(SETTINGS_DONOTTRACK);
    CheckBoxPreference cbIdentifyingHeaders = (CheckBoxPreference) findPreference(SETTINGS_IDENTIFYINGHEADERS);

    clearcache.setOnPreferenceClickListener(this);
    clearhistory.setOnPreferenceClickListener(this);
    clearcookies.setOnPreferenceClickListener(this);
    clearwebstorage.setOnPreferenceClickListener(this);

    cblocation.setOnPreferenceChangeListener(this);
    cb3cookies.setOnPreferenceChangeListener(this);
    cbsavepasswords.setOnPreferenceChangeListener(this);
    cbcacheexit.setOnPreferenceChangeListener(this);
    cbhistoryexit.setOnPreferenceChangeListener(this);
    cbcookiesexit.setOnPreferenceChangeListener(this);
    cbwebstorageexit.setOnPreferenceChangeListener(this);
    cbDoNotTrack.setOnPreferenceChangeListener(this);
    cbIdentifyingHeaders.setOnPreferenceChangeListener(this);

    cblocation.setChecked(mPreferenceManager.getLocationEnabled());
    cbsavepasswords.setChecked(mPreferenceManager.getSavePasswordsEnabled());
    cbcacheexit.setChecked(mPreferenceManager.getClearCacheExit());
    cbhistoryexit.setChecked(mPreferenceManager.getClearHistoryExitEnabled());
    cbcookiesexit.setChecked(mPreferenceManager.getClearCookiesExitEnabled());
    cb3cookies.setChecked(mPreferenceManager.getBlockThirdPartyCookiesEnabled());
    cbwebstorageexit.setChecked(mPreferenceManager.getClearWebStorageExitEnabled());
    cbDoNotTrack.setChecked(mPreferenceManager.getDoNotTrackEnabled() && Utils.doesSupportHeaders());
    cbIdentifyingHeaders.setChecked(mPreferenceManager.getRemoveIdentifyingHeadersEnabled() && Utils.doesSupportHeaders());

    cbDoNotTrack.setEnabled(Utils.doesSupportHeaders());
    cbIdentifyingHeaders.setEnabled(Utils.doesSupportHeaders());

    String identifyingHeadersSummary = LightningView.HEADER_REQUESTED_WITH + ", " + LightningView.HEADER_WAP_PROFILE;
    cbIdentifyingHeaders.setSummary(identifyingHeadersSummary);

    cb3cookies.setEnabled(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP);

}
 
Example 19
Source File: MaxLockPreferenceFragment.java    From MaxLock with GNU General Public License v3.0 4 votes vote down vote up
@SuppressLint("WorldReadableFiles")
@SuppressWarnings("deprecation")
@Override
public void onCreate(Bundle paramBundle) {
    super.onCreate(paramBundle);
    if (getArguments() != null) {
        screen = Screen.valueOf(getArguments().getString(Screen.KEY, Screen.MAIN.toString()));
    } else {
        screen = Screen.MAIN;
    }
    prefs = MLPreferences.getPreferences(getActivity());
    setTitle();
    if (screen == Screen.IMOD) {
        getPreferenceManager().setSharedPreferencesName(Common.PREFS_APPS);
    }
    addPreferencesFromResource(screen.preferenceXML);
    switch (screen) {
        case MAIN:
            updateImplementationStatus();
            PreferenceCategory catAppUI = (PreferenceCategory) findPreference(Common.CATEGORY_APPLICATION_UI);
            CheckBoxPreference useDark = (CheckBoxPreference) findPreference(Common.USE_DARK_STYLE);
            if (!useDark.isChecked()) {
                catAppUI.removePreference(findPreference(Common.USE_AMOLED_BLACK));
            }
            if (SDK_INT >= Build.VERSION_CODES.O) {
                catAppUI.removePreference(findPreference(Common.NEW_APP_NOTIFICATION));
            }
            break;
        case TYPE:
            FingerprintManagerCompat fpm = FingerprintManagerCompat.from(getActivity());
            if (!fpm.isHardwareDetected()) {
                getPreferenceScreen().removePreference(findPreference(Common.SHADOW_FINGERPRINT));
                getPreferenceScreen().removePreference(findPreference(Common.CATEGORY_FINGERPRINT));
            } else {
                CheckBoxPreference disableFP = (CheckBoxPreference) findPreference(Common.DISABLE_FINGERPRINT);
                if (!fpm.hasEnrolledFingerprints() && !disableFP.isChecked()) {
                    disableFP.setSummary(disableFP.getSummary() + getResources().getString(R.string.pref_fingerprint_summary_non_enrolled));
                }
            }
            break;
        case UI:
            ListPreference lp = (ListPreference) findPreference(Common.BACKGROUND);
            findPreference(Common.BACKGROUND_COLOR).setEnabled(lp.getValue().equals("color"));
            lp.setOnPreferenceChangeListener((preference, newValue) -> {
                if (preference.getKey().equals(Common.BACKGROUND)) {
                    if (newValue.toString().equals("custom")) {
                        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
                        intent.setType("image/*");
                        startActivityForResult(intent, WALLPAPER_REQUEST_CODE);
                    } else
                        FileUtils.deleteQuietly(new File(getActivity().getFilesDir(), "background"));
                    findPreference(Common.BACKGROUND_COLOR).setEnabled(newValue.toString().equals("color"));
                }
                return true;
            });
            break;
        case OPTIONS:
            Preference el = findPreference(Common.ENABLE_LOGGING);
            el.setEnabled(prefs.getBoolean(Common.ENABLE_PRO, false));
            if (!prefs.getBoolean(Common.ENABLE_PRO, false)) {
                el.setSummary(R.string.toast_pro_required);
            }
            if (MLImplementation.getImplementation(prefs) != MLImplementation.DEFAULT) {
                PreferenceCategory catOther = (PreferenceCategory) findPreference(Common.CATEGORY_OTHER);
                catOther.removePreference(findPreference(Common.HIDE_RECENTS_THUMBNAILS));
            }
            break;
        case IMOD:
            // I.Mod - Pro setup
            Preference iModDelayGlobal = findPreference(Common.ENABLE_DELAY_GENERAL);
            Preference iModDelayPerApp = findPreference(Common.ENABLE_DELAY_PER_APP);
            iModDelayGlobal.setEnabled(prefs.getBoolean(Common.ENABLE_PRO, false));
            iModDelayPerApp.setEnabled(prefs.getBoolean(Common.ENABLE_PRO, false));
            if (!prefs.getBoolean(Common.ENABLE_PRO, false)) {
                iModDelayGlobal.setTitle(R.string.pref_delay_needpro);
                iModDelayPerApp.setTitle(R.string.pref_delay_needpro);
            }
            break;
    }
}
 
Example 20
Source File: NotifySettingsActivity.java    From AndroidPNClient with Apache License 2.0 4 votes vote down vote up
private PreferenceScreen createPreferenceHierarchy() {
    Log.d(LOGTAG, "createSettingsPreferenceScreen()...");

    PreferenceManager preferenceManager = getPreferenceManager();
    preferenceManager
            .setSharedPreferencesName(Constants.SHARED_PREFERENCE_NAME);
    preferenceManager.setSharedPreferencesMode(Context.MODE_PRIVATE);

    PreferenceScreen root = preferenceManager.createPreferenceScreen(this);

    //        PreferenceCategory prefCat = new PreferenceCategory(this);
    //        // inlinePrefCat.setTitle("");
    //        root.addPreference(prefCat);

    CheckBoxPreference notifyPref = new CheckBoxPreference(this);
    notifyPref.setKey(Constants.SETTINGS_NOTIFICATION_ENABLED);
    notifyPref.setTitle(R.string.notifications_enabled);
    notifyPref.setSummaryOn(R.string.receive_push_messages);
    notifyPref.setSummaryOff(R.string.do_not_receive_push_messages);
    notifyPref.setDefaultValue(Boolean.TRUE);
    notifyPref
            .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
                public boolean onPreferenceChange(Preference preference,
                        Object newValue) {
                    boolean checked = Boolean.valueOf(newValue.toString());
                    if (checked) {
                        preference.setTitle(R.string.notifications_enabled);
                    } else {
                        preference.setTitle(R.string.notifications_disabled);
                    }
                    return true;
                }
            });

    CheckBoxPreference soundPref = new CheckBoxPreference(this);
    soundPref.setKey(Constants.SETTINGS_SOUND_ENABLED);
    soundPref.setTitle(R.string.sound);
    soundPref.setSummary(R.string.play_sound_for_notifications);
    soundPref.setDefaultValue(Boolean.TRUE);
    // soundPref.setDependency(Constants.SETTINGS_NOTIFICATION_ENABLED);

    CheckBoxPreference vibratePref = new CheckBoxPreference(this);
    vibratePref.setKey(Constants.SETTINGS_VIBRATE_ENABLED);
    vibratePref.setTitle(R.string.vibrate);
    vibratePref.setSummary(R.string.vibrate_the_phone_for_notifications);
    vibratePref.setDefaultValue(Boolean.TRUE);
    // vibratePref.setDependency(Constants.SETTINGS_NOTIFICATION_ENABLED);

    root.addPreference(notifyPref);
    root.addPreference(soundPref);
    root.addPreference(vibratePref);

    //        prefCat.addPreference(notifyPref);
    //        prefCat.addPreference(soundPref);
    //        prefCat.addPreference(vibratePref);
    //        root.addPreference(prefCat);

    return root;
}