Search in sources :

Example 76 with PreferenceScreen

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

the class WifiDisplaySettings method buildCertificationMenu.

private void buildCertificationMenu(final PreferenceScreen preferenceScreen) {
    if (mCertCategory == null) {
        mCertCategory = new PreferenceCategory(getPrefContext());
        mCertCategory.setTitle(R.string.wifi_display_certification_heading);
        mCertCategory.setOrder(ORDER_CERTIFICATION);
    } else {
        mCertCategory.removeAll();
    }
    preferenceScreen.addPreference(mCertCategory);
    // display session info if there is an active p2p session
    if (!mWifiDisplayStatus.getSessionInfo().getGroupId().isEmpty()) {
        Preference p = new Preference(getPrefContext());
        p.setTitle(R.string.wifi_display_session_info);
        p.setSummary(mWifiDisplayStatus.getSessionInfo().toString());
        mCertCategory.addPreference(p);
        // show buttons for Pause/Resume when a WFD session is established
        if (mWifiDisplayStatus.getSessionInfo().getSessionId() != 0) {
            mCertCategory.addPreference(new Preference(getPrefContext()) {

                @Override
                public void onBindViewHolder(PreferenceViewHolder view) {
                    super.onBindViewHolder(view);
                    Button b = (Button) view.findViewById(R.id.left_button);
                    b.setText(R.string.wifi_display_pause);
                    b.setOnClickListener(new OnClickListener() {

                        @Override
                        public void onClick(View v) {
                            mDisplayManager.pauseWifiDisplay();
                        }
                    });
                    b = (Button) view.findViewById(R.id.right_button);
                    b.setText(R.string.wifi_display_resume);
                    b.setOnClickListener(new OnClickListener() {

                        @Override
                        public void onClick(View v) {
                            mDisplayManager.resumeWifiDisplay();
                        }
                    });
                }
            });
            mCertCategory.setLayoutResource(R.layout.two_buttons_panel);
        }
    }
    // switch for Listen Mode
    SwitchPreference pref = new SwitchPreference(getPrefContext()) {

        @Override
        protected void onClick() {
            mListen = !mListen;
            setListenMode(mListen);
            setChecked(mListen);
        }
    };
    pref.setTitle(R.string.wifi_display_listen_mode);
    pref.setChecked(mListen);
    mCertCategory.addPreference(pref);
    // switch for Autonomous GO
    pref = new SwitchPreference(getPrefContext()) {

        @Override
        protected void onClick() {
            mAutoGO = !mAutoGO;
            if (mAutoGO) {
                startAutoGO();
            } else {
                stopAutoGO();
            }
            setChecked(mAutoGO);
        }
    };
    pref.setTitle(R.string.wifi_display_autonomous_go);
    pref.setChecked(mAutoGO);
    mCertCategory.addPreference(pref);
    // Drop down list for choosing WPS method (PBC/KEYPAD/DISPLAY)
    ListPreference lp = new ListPreference(getPrefContext());
    lp.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object value) {
            int wpsConfig = Integer.parseInt((String) value);
            if (wpsConfig != mWpsConfig) {
                mWpsConfig = wpsConfig;
                getActivity().invalidateOptionsMenu();
                Settings.Global.putInt(getActivity().getContentResolver(), Settings.Global.WIFI_DISPLAY_WPS_CONFIG, mWpsConfig);
            }
            return true;
        }
    });
    mWpsConfig = Settings.Global.getInt(getActivity().getContentResolver(), Settings.Global.WIFI_DISPLAY_WPS_CONFIG, WpsInfo.INVALID);
    String[] wpsEntries = { "Default", "PBC", "KEYPAD", "DISPLAY" };
    String[] wpsValues = { "" + WpsInfo.INVALID, "" + WpsInfo.PBC, "" + WpsInfo.KEYPAD, "" + WpsInfo.DISPLAY };
    lp.setKey("wps");
    lp.setTitle(R.string.wifi_display_wps_config);
    lp.setEntries(wpsEntries);
    lp.setEntryValues(wpsValues);
    lp.setValue("" + mWpsConfig);
    lp.setSummary("%1$s");
    mCertCategory.addPreference(lp);
    // Drop down list for choosing listen channel
    lp = new ListPreference(getPrefContext());
    lp.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object value) {
            int channel = Integer.parseInt((String) value);
            if (channel != mListenChannel) {
                mListenChannel = channel;
                getActivity().invalidateOptionsMenu();
                setWifiP2pChannels(mListenChannel, mOperatingChannel);
            }
            return true;
        }
    });
    String[] lcEntries = { "Auto", "1", "6", "11" };
    String[] lcValues = { "0", "1", "6", "11" };
    lp.setKey("listening_channel");
    lp.setTitle(R.string.wifi_display_listen_channel);
    lp.setEntries(lcEntries);
    lp.setEntryValues(lcValues);
    lp.setValue("" + mListenChannel);
    lp.setSummary("%1$s");
    mCertCategory.addPreference(lp);
    // Drop down list for choosing operating channel
    lp = new ListPreference(getPrefContext());
    lp.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

        @Override
        public boolean onPreferenceChange(Preference preference, Object value) {
            int channel = Integer.parseInt((String) value);
            if (channel != mOperatingChannel) {
                mOperatingChannel = channel;
                getActivity().invalidateOptionsMenu();
                setWifiP2pChannels(mListenChannel, mOperatingChannel);
            }
            return true;
        }
    });
    String[] ocEntries = { "Auto", "1", "6", "11", "36" };
    String[] ocValues = { "0", "1", "6", "11", "36" };
    lp.setKey("operating_channel");
    lp.setTitle(R.string.wifi_display_operating_channel);
    lp.setEntries(ocEntries);
    lp.setEntryValues(ocValues);
    lp.setValue("" + mOperatingChannel);
    lp.setSummary("%1$s");
    mCertCategory.addPreference(lp);
}
Also used : SwitchPreference(android.support.v14.preference.SwitchPreference) ListPreference(android.support.v7.preference.ListPreference) OnPreferenceChangeListener(android.support.v7.preference.Preference.OnPreferenceChangeListener) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) PreferenceCategory(android.support.v7.preference.PreferenceCategory) ListPreference(android.support.v7.preference.ListPreference) Preference(android.support.v7.preference.Preference) SwitchPreference(android.support.v14.preference.SwitchPreference) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) PreferenceViewHolder(android.support.v7.preference.PreferenceViewHolder)

Example 77 with PreferenceScreen

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

the class WifiDisplaySettings method update.

private void update(int changes) {
    boolean invalidateOptions = false;
    // Update settings.
    if ((changes & CHANGE_SETTINGS) != 0) {
        mWifiDisplayOnSetting = Settings.Global.getInt(getContentResolver(), Settings.Global.WIFI_DISPLAY_ON, 0) != 0;
        mWifiDisplayCertificationOn = Settings.Global.getInt(getContentResolver(), Settings.Global.WIFI_DISPLAY_CERTIFICATION_ON, 0) != 0;
        mWpsConfig = Settings.Global.getInt(getContentResolver(), Settings.Global.WIFI_DISPLAY_WPS_CONFIG, WpsInfo.INVALID);
        // The wifi display enabled setting may have changed.
        invalidateOptions = true;
    }
    // Update wifi display state.
    if ((changes & CHANGE_WIFI_DISPLAY_STATUS) != 0) {
        mWifiDisplayStatus = mDisplayManager.getWifiDisplayStatus();
        // The wifi display feature state may have changed.
        invalidateOptions = true;
    }
    // Rebuild the routes.
    final PreferenceScreen preferenceScreen = getPreferenceScreen();
    preferenceScreen.removeAll();
    // Add all known remote display routes.
    final int routeCount = mRouter.getRouteCount();
    for (int i = 0; i < routeCount; i++) {
        MediaRouter.RouteInfo route = mRouter.getRouteAt(i);
        if (route.matchesTypes(MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY)) {
            preferenceScreen.addPreference(createRoutePreference(route));
        }
    }
    // Additional features for wifi display routes.
    if (mWifiDisplayStatus != null && mWifiDisplayStatus.getFeatureState() == WifiDisplayStatus.FEATURE_STATE_ON) {
        // Add all unpaired wifi displays.
        for (WifiDisplay display : mWifiDisplayStatus.getDisplays()) {
            if (!display.isRemembered() && display.isAvailable() && !display.equals(mWifiDisplayStatus.getActiveDisplay())) {
                preferenceScreen.addPreference(new UnpairedWifiDisplayPreference(getPrefContext(), display));
            }
        }
        // Add the certification menu if enabled in developer options.
        if (mWifiDisplayCertificationOn) {
            buildCertificationMenu(preferenceScreen);
        }
    }
    // Invalidate menu options if needed.
    if (invalidateOptions) {
        getActivity().invalidateOptionsMenu();
    }
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) RouteInfo(android.media.MediaRouter.RouteInfo) WifiDisplay(android.hardware.display.WifiDisplay) MediaRouter(android.media.MediaRouter)

Example 78 with PreferenceScreen

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

the class TestingSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.testing_settings);
    final UserManager um = UserManager.get(getContext());
    if (!um.isAdminUser()) {
        PreferenceScreen preferenceScreen = (PreferenceScreen) findPreference("radio_info_settings");
        getPreferenceScreen().removePreference(preferenceScreen);
    }
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen) UserManager(android.os.UserManager)

Example 79 with PreferenceScreen

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

the class PublicVolumeSettings method update.

public void update() {
    if (!isVolumeValid()) {
        getActivity().finish();
        return;
    }
    getActivity().setTitle(mStorageManager.getBestVolumeDescription(mVolume));
    final Context context = getActivity();
    final PreferenceScreen screen = getPreferenceScreen();
    screen.removeAll();
    if (mVolume.isMountedReadable()) {
        addPreference(mSummary);
        final File file = mVolume.getPath();
        final long totalBytes = file.getTotalSpace();
        final long freeBytes = file.getFreeSpace();
        final long usedBytes = totalBytes - freeBytes;
        final BytesResult result = Formatter.formatBytes(getResources(), usedBytes, 0);
        mSummary.setTitle(TextUtils.expandTemplate(getText(R.string.storage_size_large), result.value, result.units));
        mSummary.setSummary(getString(R.string.storage_volume_used, Formatter.formatFileSize(context, totalBytes)));
        mSummary.setPercent((int) ((usedBytes * 100) / totalBytes));
    }
    if (mVolume.getState() == VolumeInfo.STATE_UNMOUNTED) {
        addPreference(mMount);
    }
    if (!mDisk.isNonRemovable() && mVolume.isMountedReadable()) {
        getButtonBar().setVisibility(View.VISIBLE);
    }
    addPreference(mFormatPublic);
    if (mDisk.isAdoptable() && mIsPermittedToAdopt) {
        addPreference(mFormatPrivate);
    }
}
Also used : Context(android.content.Context) PreferenceScreen(android.support.v7.preference.PreferenceScreen) BytesResult(android.text.format.Formatter.BytesResult) File(java.io.File)

Example 80 with PreferenceScreen

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

the class ZenModeSettings method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.zen_mode_settings);
    final PreferenceScreen root = getPreferenceScreen();
    mPrioritySettings = root.findPreference(KEY_PRIORITY_SETTINGS);
    mVisualSettings = root.findPreference(KEY_VISUAL_SETTINGS);
    mPolicy = NotificationManager.from(mContext).getNotificationPolicy();
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen)

Aggregations

PreferenceScreen (android.support.v7.preference.PreferenceScreen)115 Preference (android.support.v7.preference.Preference)42 ContentResolver (android.content.ContentResolver)35 SwitchPreference (android.support.v14.preference.SwitchPreference)21 Context (android.content.Context)19 Resources (android.content.res.Resources)16 PreferenceCategory (android.support.v7.preference.PreferenceCategory)14 Intent (android.content.Intent)12 ArrayList (java.util.ArrayList)9 ListPreference (android.support.v7.preference.ListPreference)8 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)7 PreferenceGroup (android.support.v7.preference.PreferenceGroup)7 PackageManager (android.content.pm.PackageManager)6 OnPreferenceClickListener (android.support.v7.preference.Preference.OnPreferenceClickListener)6 PreferenceManager (android.support.v7.preference.PreferenceManager)6 Activity (android.app.Activity)5 SharedPreferences (android.content.SharedPreferences)4 Bundle (android.os.Bundle)4 InputMethodInfo (android.view.inputmethod.InputMethodInfo)4 ComponentName (android.content.ComponentName)3