Search in sources :

Example 6 with OnPreferenceClickListener

use of android.preference.Preference.OnPreferenceClickListener in project Aegis by Decad3nce.

the class AdvancedSettingsFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.advanced_preferences);
    final Preference removeAdmin = findPreference("remove_admin");
    final Preference installToSystem = findPreference("install_to_system");
    final DevicePolicyManager mDPM = (DevicePolicyManager) getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
    if (mDPM.getActiveAdmins() == null || !mDPM.isAdminActive(AegisActivity.DEVICE_ADMIN_COMPONENT)) {
        PreferenceCategory mCategory = (PreferenceCategory) findPreference("advanced_category");
        mCategory.removePreference(removeAdmin);
    }
    Preference.OnPreferenceClickListener preferenceListener = (new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (preference.getKey().equals(ADVANCED_PREFERENCES_REMOVE_ADMIN)) {
                if (mDPM.isAdminActive(AegisActivity.DEVICE_ADMIN_COMPONENT)) {
                    removeAdmin(mDPM, removeAdmin);
                }
            }
            if (preference.getKey().equals(ADVANCED_PREFERENCES_INSTALL_TO_SYSTEM)) {
                DialogFragment dialog = new InstallToSystemDialogFragment();
                dialog.show(getActivity().getFragmentManager(), "InstallToSystemDialogFragment");
            }
            return false;
        }
    });
    removeAdmin.setOnPreferenceClickListener(preferenceListener);
    installToSystem.setOnPreferenceClickListener(preferenceListener);
}
Also used : DevicePolicyManager(android.app.admin.DevicePolicyManager) OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) DialogFragment(android.app.DialogFragment)

Example 7 with OnPreferenceClickListener

use of android.preference.Preference.OnPreferenceClickListener in project AndroidChromium by JackyAndroid.

the class AccountManagementFragment method configureGoogleActivityControls.

private void configureGoogleActivityControls() {
    Preference pref = findPreference(PREF_GOOGLE_ACTIVITY_CONTROLS);
    pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            Activity activity = getActivity();
            ((ChromeApplication) (activity.getApplicationContext())).createGoogleActivityController().openWebAndAppActivitySettings(activity, ChromeSigninController.get(activity).getSignedInAccountName());
            RecordUserAction.record("Signin_AccountSettings_GoogleActivityControlsClicked");
            return true;
        }
    });
}
Also used : OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) ChromeApplication(org.chromium.chrome.browser.ChromeApplication) ChromeBasePreference(org.chromium.chrome.browser.preferences.ChromeBasePreference) SyncPreference(org.chromium.chrome.browser.preferences.SyncPreference) Preference(android.preference.Preference) Activity(android.app.Activity)

Example 8 with OnPreferenceClickListener

use of android.preference.Preference.OnPreferenceClickListener in project AndroidChromium by JackyAndroid.

the class AccountManagementFragment method configureSyncSettings.

private void configureSyncSettings() {
    final Preferences preferences = (Preferences) getActivity();
    final Account account = ChromeSigninController.get(getActivity()).getSignedInUser();
    findPreference(PREF_SYNC_SETTINGS).setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (!isVisible() || !isResumed())
                return false;
            if (ProfileSyncService.get() == null)
                return true;
            Bundle args = new Bundle();
            args.putString(SyncCustomizationFragment.ARGUMENT_ACCOUNT, account.name);
            preferences.startFragment(SyncCustomizationFragment.class.getName(), args);
            return true;
        }
    });
}
Also used : OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) Account(android.accounts.Account) ChromeBasePreference(org.chromium.chrome.browser.preferences.ChromeBasePreference) SyncPreference(org.chromium.chrome.browser.preferences.SyncPreference) Preference(android.preference.Preference) Bundle(android.os.Bundle) Preferences(org.chromium.chrome.browser.preferences.Preferences)

Example 9 with OnPreferenceClickListener

use of android.preference.Preference.OnPreferenceClickListener in project AndroidChromium by JackyAndroid.

the class AccountManagementFragment method configureAddAccountPreference.

private void configureAddAccountPreference() {
    ChromeBasePreference addAccount = (ChromeBasePreference) findPreference(PREF_ADD_ACCOUNT);
    if (ChildAccountService.isChildAccount()) {
        getPreferenceScreen().removePreference(addAccount);
    } else {
        addAccount.setTitle(getResources().getString(R.string.account_management_add_account_title));
        addAccount.setOnPreferenceClickListener(new OnPreferenceClickListener() {

            @Override
            public boolean onPreferenceClick(Preference preference) {
                if (!isVisible() || !isResumed())
                    return false;
                AccountManagementScreenHelper.logEvent(ProfileAccountManagementMetrics.ADD_ACCOUNT, mGaiaServiceType);
                AccountAdder.getInstance().addAccount(getActivity(), AccountAdder.ADD_ACCOUNT_RESULT);
                // Return to the last opened tab if triggered from the content area.
                if (mGaiaServiceType != AccountManagementScreenHelper.GAIA_SERVICE_TYPE_NONE) {
                    if (isAdded())
                        getActivity().finish();
                }
                return true;
            }
        });
        addAccount.setManagedPreferenceDelegate(new ManagedPreferenceDelegate() {

            @Override
            public boolean isPreferenceControlledByPolicy(Preference preference) {
                return !canAddAccounts();
            }
        });
    }
}
Also used : OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) ChromeBasePreference(org.chromium.chrome.browser.preferences.ChromeBasePreference) ManagedPreferenceDelegate(org.chromium.chrome.browser.preferences.ManagedPreferenceDelegate) ChromeBasePreference(org.chromium.chrome.browser.preferences.ChromeBasePreference) SyncPreference(org.chromium.chrome.browser.preferences.SyncPreference) Preference(android.preference.Preference)

Example 10 with OnPreferenceClickListener

use of android.preference.Preference.OnPreferenceClickListener in project AndroidChromium by JackyAndroid.

the class PhysicalWebPreferenceFragment method initLaunchButton.

private void initLaunchButton() {
    ButtonPreference physicalWebLaunch = (ButtonPreference) findPreference(PREF_PHYSICAL_WEB_LAUNCH);
    physicalWebLaunch.setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            startActivity(createListUrlsIntent(getActivity()));
            return true;
        }
    });
}
Also used : OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) ButtonPreference(org.chromium.chrome.browser.preferences.ButtonPreference) ChromeSwitchPreference(org.chromium.chrome.browser.preferences.ChromeSwitchPreference) Preference(android.preference.Preference) ButtonPreference(org.chromium.chrome.browser.preferences.ButtonPreference)

Aggregations

OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)22 Preference (android.preference.Preference)21 CheckBoxPreference (android.preference.CheckBoxPreference)6 OnPreferenceChangeListener (android.preference.Preference.OnPreferenceChangeListener)6 Intent (android.content.Intent)5 SharedPreferences (android.content.SharedPreferences)5 ListPreference (android.preference.ListPreference)5 DialogInterface (android.content.DialogInterface)4 PreferenceCategory (android.preference.PreferenceCategory)4 PreferenceScreen (android.preference.PreferenceScreen)4 AlertDialog (android.app.AlertDialog)3 Uri (android.net.Uri)3 Bundle (android.os.Bundle)3 View (android.view.View)3 ChromeBasePreference (org.chromium.chrome.browser.preferences.ChromeBasePreference)3 SyncPreference (org.chromium.chrome.browser.preferences.SyncPreference)3 Activity (android.app.Activity)2 Dialog (android.app.Dialog)2 OnClickListener (android.content.DialogInterface.OnClickListener)2 EditTextPreference (android.preference.EditTextPreference)2