Java Code Examples for android.preference.PreferenceScreen#setOnPreferenceClickListener()

The following examples show how to use android.preference.PreferenceScreen#setOnPreferenceClickListener() . 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: DeviceAdminSample.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.device_admin_lock_wipe);

    mLockWipeCategory = (PreferenceCategory) findPreference(KEY_CATEGORY_LOCK_WIPE);
    mMaxTimeScreenLock = (EditTextPreference) findPreference(KEY_MAX_TIME_SCREEN_LOCK);
    mMaxFailures = (EditTextPreference) findPreference(KEY_MAX_FAILS_BEFORE_WIPE);
    mLockScreen = (PreferenceScreen) findPreference(KEY_LOCK_SCREEN);
    mWipeData = (PreferenceScreen) findPreference(KEY_WIPE_DATA);
    mWipeAppData = (PreferenceScreen) findPreference(KEY_WIP_DATA_ALL);

    mMaxTimeScreenLock.setOnPreferenceChangeListener(this);
    mMaxFailures.setOnPreferenceChangeListener(this);
    mLockScreen.setOnPreferenceClickListener(this);
    mWipeData.setOnPreferenceClickListener(this);
    mWipeAppData.setOnPreferenceClickListener(this);
}
 
Example 2
Source File: SettingsFragment.java    From Audinaut with GNU General Public License v3.0 6 votes vote down vote up
private PreferenceScreen addServer(final int instance) {
    final PreferenceScreen screen = this.getPreferenceManager().createPreferenceScreen(context);
    screen.setKey(Constants.PREFERENCES_KEY_SERVER_KEY + instance);
    screen.setOrder(instance);

    screen.setOnPreferenceClickListener(preference -> {
        SettingsFragment newFragment = new SettingsFragment();

        Bundle args = new Bundle();
        args.putInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, instance);
        newFragment.setArguments(args);

        replaceFragment(newFragment);
        return false;
    });

    return screen;
}
 
Example 3
Source File: DeviceAdminSample.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    // Retrieve the useful instance variables
    mActivity = (DeviceAdminSample) getActivity();
    mDPM = mActivity.mDPM;
    mDeviceAdminSample = mActivity.mDeviceAdminSample;
    mAdminActive = mActivity.isActiveAdmin();

    // Configure the shared UI elements (if they exist)
    mResetPassword = (EditTextPreference) findPreference(KEY_RESET_PASSWORD);
    mSetPassword = (PreferenceScreen) findPreference(KEY_SET_PASSWORD);

    if (mResetPassword != null) {
        mResetPassword.setOnPreferenceChangeListener(this);
    }
    if (mSetPassword != null) {
        mSetPassword.setOnPreferenceClickListener(this);
    }
}
 
Example 4
Source File: FragmentSettings.java    From rss with GNU General Public License v3.0 6 votes vote down vote up
@Override
public
void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);

    for(CharSequence key : new String[]{"ONE", "TWO", "THREE"})
    {
        PreferenceScreen preferenceScreen = (PreferenceScreen) findPreference(key);
        if(null != preferenceScreen)
        {
            preferenceScreen.setOnPreferenceClickListener(new preferenceClickListener(preferenceScreen));
        }
    }
}
 
Example 5
Source File: SettingsFragment.java    From Popeens-DSub with GNU General Public License v3.0 6 votes vote down vote up
private PreferenceScreen addServer(final int instance) {
	final PreferenceScreen screen = this.getPreferenceManager().createPreferenceScreen(context);
	screen.setKey(Constants.PREFERENCES_KEY_SERVER_KEY + instance);
	screen.setOrder(instance);

	screen.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
		@Override
		public boolean onPreferenceClick(Preference preference) {
			SettingsFragment newFragment = new SettingsFragment();

			Bundle args = new Bundle();
			args.putInt(Constants.PREFERENCES_KEY_SERVER_INSTANCE, instance);
			newFragment.setArguments(args);

			replaceFragment(newFragment);
			return false;
		}
	});

	return screen;
}
 
Example 6
Source File: PBPreferenceFragment.java    From client-android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    migratePreferences();

    // create preferences
    addPreferencesFromResource(R.xml.preferences);

    // add click listeners to launch activities on click
    // Intents were historically defined into preferences.xml but as build variants cannot
    // inject applicationId as intent packageName properly, it was done this way now...
    setOnClickListener(PBConstants.PREF_ABOUT, PBAboutActivity.class);
    setOnClickListener(PBConstants.PREF_UPLOAD_JOURNAL, PBJournalActivity.class);

    final PreferenceScreen mediasPreferenceScreen = (PreferenceScreen) findPreference(PBConstants.PREF_MEDIAS_TO_BACKUP);
    mediasPreferenceScreen.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            checkPermissions(PBConstants.PERM_ORIGIN_MEDIAS);
            return true;
        }
    });
    setHasOptionsMenu(true);
}
 
Example 7
Source File: SavePasswordsPreferences.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void passwordListAvailable(int count) {
    resetList(PREF_CATEGORY_SAVED_PASSWORDS);
    resetList(PREF_CATEGORY_SAVED_PASSWORDS_NO_TEXT);

    mNoPasswords = count == 0;
    if (mNoPasswords) {
        if (mNoPasswordExceptions) displayEmptyScreenMessage();
        return;
    }

    displayManageAccountLink();

    PreferenceCategory profileCategory = new PreferenceCategory(getActivity());
    profileCategory.setKey(PREF_CATEGORY_SAVED_PASSWORDS);
    profileCategory.setTitle(R.string.section_saved_passwords);
    profileCategory.setOrder(ORDER_SAVED_PASSWORDS);
    getPreferenceScreen().addPreference(profileCategory);
    for (int i = 0; i < count; i++) {
        PasswordUIView.SavedPasswordEntry saved =
                mPasswordManagerHandler.getSavedPasswordEntry(i);
        PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity());
        String url = saved.getUrl();
        String name = saved.getUserName();
        screen.setTitle(url);
        screen.setOnPreferenceClickListener(this);
        screen.setSummary(name);
        Bundle args = screen.getExtras();
        args.putString(PASSWORD_LIST_NAME, name);
        args.putString(PASSWORD_LIST_URL, url);
        args.putInt(PASSWORD_LIST_ID, i);
        profileCategory.addPreference(screen);
    }
}
 
Example 8
Source File: DeviceAdminSample.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.device_admin_encryption);

    mEncryptionCategory = (PreferenceCategory) findPreference(KEY_CATEGORY_ENCRYPTION);
    mRequireEncryption = (CheckBoxPreference) findPreference(KEY_REQUIRE_ENCRYPTION);
    mActivateEncryption = (PreferenceScreen) findPreference(KEY_ACTIVATE_ENCRYPTION);

    mRequireEncryption.setOnPreferenceChangeListener(this);
    mActivateEncryption.setOnPreferenceClickListener(this);
}
 
Example 9
Source File: DeviceAdminSample.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.device_admin_expiration);

    mExpirationCategory = (PreferenceCategory) findPreference(KEY_CATEGORY_EXPIRATION);
    mHistory = (EditTextPreference) findPreference(KEY_HISTORY);
    mExpirationTimeout = (EditTextPreference) findPreference(KEY_EXPIRATION_TIMEOUT);
    mExpirationStatus = (PreferenceScreen) findPreference(KEY_EXPIRATION_STATUS);

    mHistory.setOnPreferenceChangeListener(this);
    mExpirationTimeout.setOnPreferenceChangeListener(this);
    mExpirationStatus.setOnPreferenceClickListener(this);
}
 
Example 10
Source File: SavePasswordsPreferences.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void passwordExceptionListAvailable(int count) {
    resetList(PREF_CATEGORY_EXCEPTIONS);
    resetList(PREF_CATEGORY_SAVED_PASSWORDS_NO_TEXT);

    mNoPasswordExceptions = count == 0;
    if (mNoPasswordExceptions) {
        if (mNoPasswords) displayEmptyScreenMessage();
        return;
    }

    displayManageAccountLink();

    PreferenceCategory profileCategory = new PreferenceCategory(getActivity());
    profileCategory.setKey(PREF_CATEGORY_EXCEPTIONS);
    profileCategory.setTitle(R.string.section_saved_passwords_exceptions);
    profileCategory.setOrder(ORDER_EXCEPTIONS);
    getPreferenceScreen().addPreference(profileCategory);
    for (int i = 0; i < count; i++) {
        String exception = mPasswordManagerHandler.getSavedPasswordException(i);
        PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity());
        screen.setTitle(exception);
        screen.setOnPreferenceClickListener(this);
        Bundle args = screen.getExtras();
        args.putString(PASSWORD_LIST_URL, exception);
        args.putInt(PASSWORD_LIST_ID, i);
        profileCategory.addPreference(screen);
    }
}
 
Example 11
Source File: AppAboutActivity.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
private void initView() {
    mCheckVersion = (PreferenceScreen) findPreference("check_version");
    mToMarket = (PreferenceScreen) findPreference("to_market");

    mCheckVersion.setOnPreferenceClickListener(this);
    mToMarket.setOnPreferenceClickListener(this);
}
 
Example 12
Source File: TalkBackKeyboardShortcutPreferencesActivity.java    From talkback with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  keymap = getArguments().getString(BUNDLE_KEYMAP);

  PreferenceSettingsUtils.addPreferencesFromResource(this, getPreferenceResourceId(keymap));

  PreferenceScreen resetKeymapPreferenceScreen =
      (PreferenceScreen) findPreference(getString(R.string.pref_reset_keymap_key));
  resetKeymapPreferenceScreen.setOnPreferenceClickListener(resetKeymapPreferenceClickListener);

  boolean isArc = FeatureSupport.isArc();

  // Hide select keymap preference in Arc if current keymap is already set to default
  // keymap.
  if (isArc && getKeyComboManager().getKeyComboModel() instanceof DefaultKeyComboModel) {
    PreferenceCategory keymapPreferenceCategory =
        (PreferenceCategory)
            getPreferenceScreen().findPreference(getString(R.string.pref_keymap_category_key));
    ListPreference keymapListPreference =
        (ListPreference)
            keymapPreferenceCategory.findPreference(getString(R.string.pref_select_keymap_key));
    keymapPreferenceCategory.removePreference(keymapListPreference);
  }

  int[] hiddenShortcutKeyIds =
      isArc ? HIDDEN_SHORTCUT_KEY_IDS_IN_ARC : HIDDEN_SHORTCUT_KEY_IDS_IN_NON_ARC;
  Set<String> hiddenShortcutKeys = new HashSet<>();
  for (int id : hiddenShortcutKeyIds) {
    hiddenShortcutKeys.add(getString(id));
  }

  initPreferenceUIs(getPreferenceScreen(), hiddenShortcutKeys);
}
 
Example 13
Source File: SavePasswordsPreferences.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void passwordExceptionListAvailable(int count) {
    resetList(PREF_CATEGORY_EXCEPTIONS);
    mNoPasswordExceptions = count == 0;
    if (mNoPasswordExceptions) {
        if (mNoPasswords) displayEmptyScreenMessage();
        return;
    }

    displayManageAccountLink();

    PreferenceCategory profileCategory = new PreferenceCategory(getActivity());
    profileCategory.setKey(PREF_CATEGORY_EXCEPTIONS);
    profileCategory.setTitle(R.string.section_saved_passwords_exceptions);
    profileCategory.setOrder(ORDER_EXCEPTIONS);
    getPreferenceScreen().addPreference(profileCategory);
    for (int i = 0; i < count; i++) {
        String exception = mPasswordManagerHandler.getSavedPasswordException(i);
        PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity());
        screen.setTitle(exception);
        screen.setOnPreferenceClickListener(this);
        Bundle args = screen.getExtras();
        args.putString(PASSWORD_LIST_URL, exception);
        args.putInt(PASSWORD_LIST_ID, i);
        profileCategory.addPreference(screen);
    }
}
 
Example 14
Source File: SavePasswordsPreferences.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void passwordListAvailable(int count) {
    resetList(PREF_CATEGORY_SAVED_PASSWORDS);
    mNoPasswords = count == 0;
    if (mNoPasswords) {
        if (mNoPasswordExceptions) displayEmptyScreenMessage();
        return;
    }

    displayManageAccountLink();

    PreferenceCategory profileCategory = new PreferenceCategory(getActivity());
    profileCategory.setKey(PREF_CATEGORY_SAVED_PASSWORDS);
    profileCategory.setTitle(R.string.section_saved_passwords);
    profileCategory.setOrder(ORDER_SAVED_PASSWORDS);
    getPreferenceScreen().addPreference(profileCategory);
    for (int i = 0; i < count; i++) {
        PasswordUIView.SavedPasswordEntry saved =
                mPasswordManagerHandler.getSavedPasswordEntry(i);
        PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity());
        String url = saved.getUrl();
        String name = saved.getUserName();
        screen.setTitle(url);
        screen.setOnPreferenceClickListener(this);
        screen.setSummary(name);
        Bundle args = screen.getExtras();
        args.putString(PASSWORD_LIST_NAME, name);
        args.putString(PASSWORD_LIST_URL, url);
        args.putInt(PASSWORD_LIST_ID, i);
        profileCategory.addPreference(screen);
    }
}
 
Example 15
Source File: SavePasswordsPreferences.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void passwordExceptionListAvailable(int count) {
    resetList(PREF_CATEGORY_EXCEPTIONS);
    mNoPasswordExceptions = count == 0;
    if (mNoPasswordExceptions) {
        if (mNoPasswords) displayEmptyScreenMessage();
        return;
    }

    displayManageAccountLink();

    PreferenceCategory profileCategory = new PreferenceCategory(getActivity());
    profileCategory.setKey(PREF_CATEGORY_EXCEPTIONS);
    profileCategory.setTitle(R.string.section_saved_passwords_exceptions);
    profileCategory.setOrder(ORDER_EXCEPTIONS);
    getPreferenceScreen().addPreference(profileCategory);
    for (int i = 0; i < count; i++) {
        String exception = mPasswordManagerHandler.getSavedPasswordException(i);
        PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity());
        screen.setTitle(exception);
        screen.setOnPreferenceClickListener(this);
        Bundle args = screen.getExtras();
        args.putString(PASSWORD_LIST_URL, exception);
        args.putInt(PASSWORD_LIST_ID, i);
        profileCategory.addPreference(screen);
    }
}
 
Example 16
Source File: SavePasswordsPreferences.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void passwordListAvailable(int count) {
    resetList(PREF_CATEGORY_SAVED_PASSWORDS);
    mNoPasswords = count == 0;
    if (mNoPasswords) {
        if (mNoPasswordExceptions) displayEmptyScreenMessage();
        return;
    }

    displayManageAccountLink();

    PreferenceCategory profileCategory = new PreferenceCategory(getActivity());
    profileCategory.setKey(PREF_CATEGORY_SAVED_PASSWORDS);
    profileCategory.setTitle(R.string.section_saved_passwords);
    profileCategory.setOrder(ORDER_SAVED_PASSWORDS);
    getPreferenceScreen().addPreference(profileCategory);
    for (int i = 0; i < count; i++) {
        PasswordUIView.SavedPasswordEntry saved =
                mPasswordManagerHandler.getSavedPasswordEntry(i);
        PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(getActivity());
        String url = saved.getUrl();
        String name = saved.getUserName();
        screen.setTitle(url);
        screen.setOnPreferenceClickListener(this);
        screen.setSummary(name);
        Bundle args = screen.getExtras();
        args.putString(PASSWORD_LIST_NAME, name);
        args.putString(PASSWORD_LIST_URL, url);
        args.putInt(PASSWORD_LIST_ID, i);
        profileCategory.addPreference(screen);
    }
}
 
Example 17
Source File: LockSettingActivity.java    From SuperNote with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.pref_lock);
    mPreLock=(PreferenceScreen)findPreference("modify_lock");
    mPreLock.setOnPreferenceClickListener(this);
}