Search in sources :

Example 46 with OnPreferenceClickListener

use of android.preference.Preference.OnPreferenceClickListener in project newsrob by marianokamp.

the class SettingsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    final EntryManager em = EntryManager.getInstance(this);
    addPreferencesFromResource(R.xml.settings);
    getPreferenceScreen().setOnPreferenceChangeListener(em);
    if (SDKVersionUtil.getVersion() < 8)
        disableSetting(em, EntryManager.SETTINGS_PLUGINS, "Froyo+");
    if (SDKVersionUtil.getVersion() < 11) {
        disableSetting(em, EntryManager.SETTINGS_HW_ACCEL_LISTS_ENABLED, "HC+ only");
        disableSetting(em, EntryManager.SETTINGS_HW_ACCEL_ADV_ENABLED, "HC+ only");
    }
    if (!em.isProVersion()) {
        disableSetting(em, EntryManager.SETTINGS_KEEP_STARRED);
        disableSetting(em, EntryManager.SETTINGS_KEEP_SHARED);
        disableSetting(em, EntryManager.SETTINGS_KEEP_NOTES);
        disableSetting(em, EntryManager.SETTINGS_UI_THEME);
        disableSetting(em, EntryManager.SETTINGS_SYNC_NEWSROB_ONLY_ENABLED);
    }
    if (em.shouldHWZoomControlsBeDisabled()) {
        Preference pref = getPreferenceScreen().findPreference(EntryManager.SETTINGS_HOVERING_ZOOM_CONTROLS_ENABLED);
        if (pref != null) {
            pref.setEnabled(false);
            if (pref.getSummary() != null)
                pref.setSummary("Disabled until HTC fixes a bug that hurts this function. Sorry.");
        }
    }
    if (em.shouldSyncInProgressNotificationBeDisabled()) {
        Preference pref = getPreferenceScreen().findPreference(EntryManager.SETTINGS_SYNC_IN_PROGRESS_NOTIFICATION);
        if (pref != null) {
            pref.setEnabled(false);
            if (pref.getSummary() != null)
                pref.setSummary("Disabled until HTC/Dell fixes a bug that hurts this function. Sorry.");
        }
    }
    if (em.shouldActionBarLocationOnlyAllowGone()) {
        ListPreference pref = (ListPreference) getPreferenceScreen().findPreference(EntryManager.SETTINGS_UI_ACTION_BAR_LOCATION);
        if (pref != null) {
            pref.setEnabled(false);
            CharSequence[] seq = pref.getEntries();
            CharSequence[] newSeq = new CharSequence[] { seq[2] };
            pref.setEntries(newSeq);
            getPreferenceScreen().removePreference(pref);
        }
    }
    final Preference p = getPreferenceScreen().findPreference(EntryManager.SETTINGS_USAGE_DATA_PERMISSION_GRANTED);
    p.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            Dialog dialog = DashboardListActivity.createUsageDataCollectionPermissionDialog(em, SettingsActivity.this);
            dialog.show();
            return true;
        }
    });
}
Also used : OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) Preference(android.preference.Preference) ListPreference(com.newsrob.preference.ListPreference) Dialog(android.app.Dialog) ListPreference(com.newsrob.preference.ListPreference) EntryManager(com.newsrob.EntryManager)

Aggregations

OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)46 Preference (android.preference.Preference)45 Intent (android.content.Intent)23 ListPreference (android.preference.ListPreference)20 CheckBoxPreference (android.preference.CheckBoxPreference)14 SwitchPreference (android.preference.SwitchPreference)12 DialogInterface (android.content.DialogInterface)8 SharedPreferences (android.content.SharedPreferences)8 PreferenceCategory (android.preference.PreferenceCategory)8 PreferenceScreen (android.preference.PreferenceScreen)8 EditTextPreference (android.preference.EditTextPreference)7 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)7 AlertDialog (android.app.AlertDialog)6 Bundle (android.os.Bundle)6 Uri (android.net.Uri)5 View (android.view.View)5 OnClickListener (android.content.DialogInterface.OnClickListener)4 TextView (android.widget.TextView)4 Activity (android.app.Activity)3 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)3