Search in sources :

Example 16 with Preference

use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiSettings method onCreateContextMenu.

@Override
public void onCreateContextMenu(ContextMenu menu, View view, ContextMenuInfo info) {
    Preference preference = (Preference) view.getTag();
    if (preference instanceof LongPressAccessPointPreference) {
        mSelectedAccessPoint = ((LongPressAccessPointPreference) preference).getAccessPoint();
        menu.setHeaderTitle(mSelectedAccessPoint.getSsid());
        if (mSelectedAccessPoint.isConnectable()) {
            menu.add(Menu.NONE, MENU_ID_CONNECT, 0, R.string.wifi_menu_connect);
        }
        WifiConfiguration config = mSelectedAccessPoint.getConfig();
        // Some configs are ineditable
        if (isEditabilityLockedDown(getActivity(), config)) {
            return;
        }
        if (mSelectedAccessPoint.isSaved() || mSelectedAccessPoint.isEphemeral()) {
            // Allow forgetting a network if either the network is saved or ephemerally
            // connected. (In the latter case, "forget" blacklists the network so it won't
            // be used again, ephemerally).
            menu.add(Menu.NONE, MENU_ID_FORGET, 0, R.string.wifi_menu_forget);
        }
        // current connected AP, add a disconnect option to it
        if (getResources().getBoolean(R.bool.config_auto_connect_wifi_enabled)) {
            if (mSelectedAccessPoint.isActive()) {
                menu.add(Menu.NONE, MENU_ID_DISCONNECT, 0, R.string.wifi_menu_disconnect);
            }
        }
        if (mSelectedAccessPoint.isSaved()) {
            menu.add(Menu.NONE, MENU_ID_MODIFY, 0, R.string.wifi_menu_modify);
            NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(getActivity());
            if (nfcAdapter != null && nfcAdapter.isEnabled() && mSelectedAccessPoint.getSecurity() != AccessPoint.SECURITY_NONE) {
                // Only allow writing of NFC tags for password-protected networks.
                menu.add(Menu.NONE, MENU_ID_WRITE_NFC, 0, R.string.wifi_menu_write_to_nfc);
            }
        }
    }
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration) AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference) Preference(android.support.v7.preference.Preference) NfcAdapter(android.nfc.NfcAdapter)

Example 17 with Preference

use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class WifiSettings method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.wifi_settings);
    mAddPreference = new Preference(getContext());
    mAddPreference.setIcon(R.drawable.ic_menu_add_inset);
    mAddPreference.setTitle(R.string.wifi_add_network);
    mUserBadgeCache = new AccessPointPreference.UserBadgeCache(getPackageManager());
    mBgThread = new HandlerThread(TAG, Process.THREAD_PRIORITY_BACKGROUND);
    mBgThread.start();
}
Also used : HandlerThread(android.os.HandlerThread) AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference) Preference(android.support.v7.preference.Preference) AccessPointPreference(com.android.settingslib.wifi.AccessPointPreference)

Example 18 with Preference

use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class ApplicationSettings method onCreate.

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.application_settings);
    mToggleAdvancedSettings = (CheckBoxPreference) findPreference(KEY_TOGGLE_ADVANCED_SETTINGS);
    mToggleAdvancedSettings.setChecked(isAdvancedSettingsEnabled());
    getPreferenceScreen().removePreference(mToggleAdvancedSettings);
    // not ready for prime time yet
    if (false) {
        getPreferenceScreen().removePreference(mInstallLocation);
    }
    mInstallLocation = (ListPreference) findPreference(KEY_APP_INSTALL_LOCATION);
    // Is app default install location set?
    boolean userSetInstLocation = (Settings.Global.getInt(getContentResolver(), Settings.Global.SET_INSTALL_LOCATION, 0) != 0);
    if (!userSetInstLocation) {
        getPreferenceScreen().removePreference(mInstallLocation);
    } else {
        mInstallLocation.setValue(getAppInstallLocation());
        mInstallLocation.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

            public boolean onPreferenceChange(Preference preference, Object newValue) {
                String value = (String) newValue;
                handleUpdateAppInstallLocation(value);
                return false;
            }
        });
    }
}
Also used : Preference(android.support.v7.preference.Preference) CheckBoxPreference(android.support.v7.preference.CheckBoxPreference) ListPreference(android.support.v7.preference.ListPreference) OnPreferenceChangeListener(android.support.v7.preference.Preference.OnPreferenceChangeListener)

Example 19 with Preference

use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class PrivacySettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Don't allow any access if this is not an admin user.
    // TODO: backup/restore currently only works with owner user b/22760572
    mEnabled = UserManager.get(getActivity()).isAdminUser();
    if (!mEnabled) {
        return;
    }
    addPreferencesFromResource(R.xml.privacy_settings);
    final PreferenceScreen screen = getPreferenceScreen();
    mBackupManager = IBackupManager.Stub.asInterface(ServiceManager.getService(Context.BACKUP_SERVICE));
    mBackup = (PreferenceScreen) screen.findPreference(BACKUP_DATA);
    mAutoRestore = (SwitchPreference) screen.findPreference(AUTO_RESTORE);
    mAutoRestore.setOnPreferenceChangeListener(preferenceChangeListener);
    mConfigure = (PreferenceScreen) screen.findPreference(CONFIGURE_ACCOUNT);
    mManageData = (PreferenceScreen) screen.findPreference(DATA_MANAGEMENT);
    Set<String> keysToRemove = new HashSet<>();
    getNonVisibleKeys(getActivity(), keysToRemove);
    final int screenPreferenceCount = screen.getPreferenceCount();
    for (int i = screenPreferenceCount - 1; i >= 0; --i) {
        Preference preference = screen.getPreference(i);
        if (keysToRemove.contains(preference.getKey())) {
            screen.removePreference(preference);
        }
    }
    updateToggles();
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) RestrictedPreference(com.android.settingslib.RestrictedPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) HashSet(java.util.HashSet)

Example 20 with Preference

use of android.support.v7.preference.Preference in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class LegalSettings method onCreate.

public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.about_legal);
    final Activity act = getActivity();
    // These are contained in the "container" preference group
    PreferenceGroup parentPreference = getPreferenceScreen();
    Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference, KEY_TERMS, Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
    Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference, KEY_LICENSE, Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
    Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference, KEY_COPYRIGHT, Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
    Utils.updatePreferenceToSpecificActivityOrRemove(act, parentPreference, KEY_WEBVIEW_LICENSE, Utils.UPDATE_PREFERENCE_FLAG_SET_TITLE_TO_MATCHING_ACTIVITY);
}
Also used : Activity(android.app.Activity) PreferenceGroup(android.support.v7.preference.PreferenceGroup)

Aggregations

Preference (android.support.v7.preference.Preference)122 PreferenceScreen (android.support.v7.preference.PreferenceScreen)44 SwitchPreference (android.support.v14.preference.SwitchPreference)33 Intent (android.content.Intent)27 ListPreference (android.support.v7.preference.ListPreference)27 Context (android.content.Context)17 PreferenceCategory (android.support.v7.preference.PreferenceCategory)17 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)15 ArrayList (java.util.ArrayList)14 PackageManager (android.content.pm.PackageManager)11 OnPreferenceClickListener (android.support.v7.preference.Preference.OnPreferenceClickListener)11 PreferenceGroup (android.support.v7.preference.PreferenceGroup)11 TwoStatePreference (android.support.v7.preference.TwoStatePreference)11 Activity (android.app.Activity)10 View (android.view.View)10 Bundle (android.os.Bundle)9 TextView (android.widget.TextView)8 AlertDialog (android.support.v7.app.AlertDialog)7 CheckBoxPreference (android.support.v7.preference.CheckBoxPreference)7 DimmableIconPreference (com.android.settings.DimmableIconPreference)7