use of android.support.v7.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ManageDomainUrls method onRebuildComplete.
@Override
public void onRebuildComplete(ArrayList<AppEntry> apps) {
if (getContext() == null) {
return;
}
final boolean disableWebActions = Global.getInt(getContext().getContentResolver(), Global.ENABLE_EPHEMERAL_FEATURE, 1) == 0;
if (disableWebActions) {
mDomainAppList = getPreferenceScreen();
} else {
final PreferenceGroup preferenceScreen = getPreferenceScreen();
if (preferenceScreen.getPreferenceCount() == 0) {
// add preferences
final PreferenceCategory webActionCategory = new PreferenceCategory(getPrefContext());
webActionCategory.setTitle(R.string.web_action_section_title);
preferenceScreen.addPreference(webActionCategory);
// toggle to enable / disable Web Actions [aka Instant Apps]
mWebAction = new SwitchPreference(getPrefContext());
mWebAction.setTitle(R.string.web_action_enable_title);
mWebAction.setSummary(R.string.web_action_enable_summary);
mWebAction.setChecked(Settings.Secure.getInt(getContentResolver(), Settings.Secure.WEB_ACTION_ENABLED, 1) != 0);
mWebAction.setOnPreferenceChangeListener(this);
webActionCategory.addPreference(mWebAction);
// list to manage link handling per app
mDomainAppList = new PreferenceCategory(getPrefContext());
mDomainAppList.setTitle(R.string.domain_url_section_title);
preferenceScreen.addPreference(mDomainAppList);
}
}
rebuildAppList(mDomainAppList, apps);
}
use of android.support.v7.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PowerUsageDetail method addHorizontalPreference.
private void addHorizontalPreference(PreferenceCategory parent, CharSequence title, CharSequence summary) {
Preference pref = new Preference(getPrefContext());
pref.setLayoutResource(R.layout.horizontal_preference);
pref.setTitle(title);
pref.setSummary(summary);
pref.setSelectable(false);
parent.addPreference(pref);
}
use of android.support.v7.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DisplaySettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Activity activity = getActivity();
final ContentResolver resolver = activity.getContentResolver();
addPreferencesFromResource(R.xml.display_settings);
PreferenceCategory displayPrefs = (PreferenceCategory) findPreference(KEY_CATEGORY_DISPLAY);
mScreenSaverPreference = findPreference(KEY_SCREEN_SAVER);
if (mScreenSaverPreference != null && getResources().getBoolean(com.android.internal.R.bool.config_dreamsSupported) == false) {
getPreferenceScreen().removePreference(mScreenSaverPreference);
}
mScreenTimeoutPreference = (TimeoutListPreference) findPreference(KEY_SCREEN_TIMEOUT);
if (displayPrefs != null) {
mAutoBrightnessPreference = (SwitchPreference) findPreference(KEY_AUTO_BRIGHTNESS);
if (mAutoBrightnessPreference != null) {
if (isAutomaticBrightnessAvailable(getResources())) {
mAutoBrightnessPreference.setOnPreferenceChangeListener(this);
} else {
displayPrefs.removePreference(mAutoBrightnessPreference);
}
}
if (!NightDisplayController.isAvailable(activity)) {
removePreference(KEY_NIGHT_DISPLAY);
}
mLiftToWakePreference = (SwitchPreference) findPreference(KEY_LIFT_TO_WAKE);
if (mLiftToWakePreference != null) {
if (isLiftToWakeAvailable(activity)) {
mLiftToWakePreference.setOnPreferenceChangeListener(this);
} else {
displayPrefs.removePreference(mLiftToWakePreference);
}
}
mTapToWakePreference = (SwitchPreference) findPreference(KEY_TAP_TO_WAKE);
if (mTapToWakePreference != null) {
if (isTapToWakeAvailable(getResources())) {
mTapToWakePreference.setOnPreferenceChangeListener(this);
} else {
displayPrefs.removePreference(mTapToWakePreference);
}
}
mCameraGesturePreference = (SwitchPreference) findPreference(KEY_CAMERA_GESTURE);
if (mCameraGesturePreference != null) {
if (isCameraGestureAvailable(getResources())) {
mCameraGesturePreference.setOnPreferenceChangeListener(this);
} else {
displayPrefs.removePreference(mCameraGesturePreference);
}
}
DropDownPreference rotatePreference = (DropDownPreference) findPreference(KEY_AUTO_ROTATE);
if (rotatePreference != null) {
if (RotationPolicy.isRotationLockToggleVisible(activity)) {
int rotateLockedResourceId;
// rotation), then we use a different string to include this information.
if (allowAllRotations(activity)) {
rotateLockedResourceId = R.string.display_auto_rotate_stay_in_current;
} else {
if (RotationPolicy.getRotationLockOrientation(activity) == Configuration.ORIENTATION_PORTRAIT) {
rotateLockedResourceId = R.string.display_auto_rotate_stay_in_portrait;
} else {
rotateLockedResourceId = R.string.display_auto_rotate_stay_in_landscape;
}
}
rotatePreference.setEntries(new CharSequence[] { activity.getString(R.string.display_auto_rotate_rotate), activity.getString(rotateLockedResourceId) });
rotatePreference.setEntryValues(new CharSequence[] { "0", "1" });
rotatePreference.setValueIndex(RotationPolicy.isRotationLocked(activity) ? 1 : 0);
rotatePreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
final boolean locked = Integer.parseInt((String) newValue) != 0;
MetricsLogger.action(getActivity(), MetricsEvent.ACTION_ROTATION_LOCK, locked);
RotationPolicy.setRotationLock(activity, locked);
return true;
}
});
} else {
displayPrefs.removePreference(rotatePreference);
}
}
DropDownPreference vrDisplayPref = (DropDownPreference) findPreference(KEY_VR_DISPLAY_PREF);
if (vrDisplayPref != null) {
if (isVrDisplayModeAvailable(activity)) {
vrDisplayPref.setEntries(new CharSequence[] { activity.getString(R.string.display_vr_pref_low_persistence), activity.getString(R.string.display_vr_pref_off) });
vrDisplayPref.setEntryValues(new CharSequence[] { "0", "1" });
final Context c = activity;
int currentUser = ActivityManager.getCurrentUser();
int current = Settings.Secure.getIntForUser(c.getContentResolver(), Settings.Secure.VR_DISPLAY_MODE, /*default*/
Settings.Secure.VR_DISPLAY_MODE_LOW_PERSISTENCE, currentUser);
vrDisplayPref.setValueIndex(current);
vrDisplayPref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
int i = Integer.parseInt((String) newValue);
int u = ActivityManager.getCurrentUser();
if (!Settings.Secure.putIntForUser(c.getContentResolver(), Settings.Secure.VR_DISPLAY_MODE, i, u)) {
Log.e(TAG, "Could not change setting for " + Settings.Secure.VR_DISPLAY_MODE);
}
return true;
}
});
} else {
displayPrefs.removePreference(vrDisplayPref);
}
}
}
mNightModePreference = (ListPreference) findPreference(KEY_NIGHT_MODE);
if (mNightModePreference != null) {
final UiModeManager uiManager = (UiModeManager) getSystemService(Context.UI_MODE_SERVICE);
final int currentNightMode = uiManager.getNightMode();
mNightModePreference.setValue(String.valueOf(currentNightMode));
mNightModePreference.setOnPreferenceChangeListener(this);
}
}
use of android.support.v7.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WirelessSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState != null) {
mManageMobilePlanMessage = savedInstanceState.getString(SAVED_MANAGE_MOBILE_PLAN_MSG);
}
log("onCreate: mManageMobilePlanMessage=" + mManageMobilePlanMessage);
mContext = getActivity();
mCm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
mTm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
mPm = getPackageManager();
mUm = (UserManager) getSystemService(Context.USER_SERVICE);
addPreferencesFromResource(R.xml.wireless_settings);
final boolean isAdmin = mUm.isAdminUser();
final Activity activity = getActivity();
mAirplaneModePreference = (SwitchPreference) findPreference(KEY_TOGGLE_AIRPLANE);
SwitchPreference nfc = (SwitchPreference) findPreference(KEY_TOGGLE_NFC);
RestrictedPreference androidBeam = (RestrictedPreference) findPreference(KEY_ANDROID_BEAM_SETTINGS);
PreferenceScreen nfcPayment = (PreferenceScreen) findPreference(KEY_NFC_PAYMENT_SETTINGS);
PreferenceCategory nfcCategory = (PreferenceCategory) findPreference(KEY_NFC_CATEGORY_SETTINGS);
mAirplaneModeEnabler = new AirplaneModeEnabler(activity, mAirplaneModePreference);
mNfcEnabler = new NfcEnabler(activity, nfc, androidBeam, nfcPayment);
mButtonWfc = (PreferenceScreen) findPreference(KEY_WFC_SETTINGS);
String toggleable = Settings.Global.getString(activity.getContentResolver(), Settings.Global.AIRPLANE_MODE_TOGGLEABLE_RADIOS);
//enable/disable wimax depending on the value in config.xml
final boolean isWimaxEnabled = isAdmin && this.getResources().getBoolean(com.android.internal.R.bool.config_wimaxEnabled);
if (!isWimaxEnabled || RestrictedLockUtils.hasBaseUserRestriction(activity, UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS, UserHandle.myUserId())) {
PreferenceScreen root = getPreferenceScreen();
Preference ps = findPreference(KEY_WIMAX_SETTINGS);
if (ps != null)
root.removePreference(ps);
} else {
if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_WIMAX) && isWimaxEnabled) {
Preference ps = findPreference(KEY_WIMAX_SETTINGS);
ps.setDependency(KEY_TOGGLE_AIRPLANE);
}
}
// Manually set dependencies for Wifi when not toggleable.
if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_WIFI)) {
findPreference(KEY_VPN_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
}
// TODO: http://b/23693383
if (!isAdmin || RestrictedLockUtils.hasBaseUserRestriction(activity, UserManager.DISALLOW_CONFIG_VPN, UserHandle.myUserId())) {
removePreference(KEY_VPN_SETTINGS);
}
// Manually set dependencies for Bluetooth when not toggleable.
if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_BLUETOOTH)) {
// No bluetooth-dependent items in the list. Code kept in case one is added later.
}
// Manually set dependencies for NFC when not toggleable.
if (toggleable == null || !toggleable.contains(Settings.Global.RADIO_NFC)) {
findPreference(KEY_TOGGLE_NFC).setDependency(KEY_TOGGLE_AIRPLANE);
findPreference(KEY_ANDROID_BEAM_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
findPreference(KEY_NFC_PAYMENT_SETTINGS).setDependency(KEY_TOGGLE_AIRPLANE);
}
// Remove NFC if not available
mNfcAdapter = NfcAdapter.getDefaultAdapter(activity);
if (mNfcAdapter == null) {
getPreferenceScreen().removePreference(nfcCategory);
mNfcEnabler = null;
} else if (!mPm.hasSystemFeature(PackageManager.FEATURE_NFC_HOST_CARD_EMULATION)) {
// Only show if we have the HCE feature
nfcCategory.removePreference(nfcPayment);
}
// if it's a wifi-only device, or for MSIM devices
if (!isAdmin || Utils.isWifiOnly(getActivity()) || Utils.showSimCardTile(getActivity()) || RestrictedLockUtils.hasBaseUserRestriction(activity, UserManager.DISALLOW_CONFIG_MOBILE_NETWORKS, UserHandle.myUserId())) {
removePreference(KEY_MOBILE_NETWORK_SETTINGS);
removePreference(KEY_MANAGE_MOBILE_PLAN);
}
// Remove Mobile Network Settings and Manage Mobile Plan
// if config_show_mobile_plan sets false.
final boolean isMobilePlanEnabled = this.getResources().getBoolean(R.bool.config_show_mobile_plan);
if (!isMobilePlanEnabled) {
Preference pref = findPreference(KEY_MANAGE_MOBILE_PLAN);
if (pref != null) {
removePreference(KEY_MANAGE_MOBILE_PLAN);
}
}
// Remove Airplane Mode settings if it's a stationary device such as a TV.
if (mPm.hasSystemFeature(PackageManager.FEATURE_TELEVISION)) {
removePreference(KEY_TOGGLE_AIRPLANE);
}
// Enable Proxy selector settings if allowed.
Preference mGlobalProxy = findPreference(KEY_PROXY_SETTINGS);
final DevicePolicyManager mDPM = (DevicePolicyManager) activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
// proxy UI disabled until we have better app support
getPreferenceScreen().removePreference(mGlobalProxy);
mGlobalProxy.setEnabled(mDPM.getGlobalProxyAdmin() == null);
// Disable Tethering if it's not allowed or if it's a wifi-only device
final ConnectivityManager cm = (ConnectivityManager) activity.getSystemService(Context.CONNECTIVITY_SERVICE);
final boolean adminDisallowedTetherConfig = RestrictedLockUtils.checkIfRestrictionEnforced(activity, UserManager.DISALLOW_CONFIG_TETHERING, UserHandle.myUserId()) != null;
if ((!cm.isTetheringSupported() && !adminDisallowedTetherConfig) || RestrictedLockUtils.hasBaseUserRestriction(activity, UserManager.DISALLOW_CONFIG_TETHERING, UserHandle.myUserId())) {
getPreferenceScreen().removePreference(findPreference(KEY_TETHER_SETTINGS));
} else if (!adminDisallowedTetherConfig) {
Preference p = findPreference(KEY_TETHER_SETTINGS);
p.setTitle(com.android.settingslib.Utils.getTetheringLabel(cm));
// Grey out if provisioning is not available.
p.setEnabled(!TetherSettings.isProvisioningNeededButUnavailable(getActivity()));
}
// Remove network reset if not allowed
if (RestrictedLockUtils.hasBaseUserRestriction(activity, UserManager.DISALLOW_NETWORK_RESET, UserHandle.myUserId())) {
removePreference(KEY_NETWORK_RESET);
}
// Enable link to CMAS app settings depending on the value in config.xml.
boolean isCellBroadcastAppLinkEnabled = this.getResources().getBoolean(com.android.internal.R.bool.config_cellBroadcastAppLinks);
try {
if (isCellBroadcastAppLinkEnabled) {
if (mPm.getApplicationEnabledSetting("com.android.cellbroadcastreceiver") == PackageManager.COMPONENT_ENABLED_STATE_DISABLED) {
// CMAS app disabled
isCellBroadcastAppLinkEnabled = false;
}
}
} catch (IllegalArgumentException ignored) {
// CMAS app not installed
isCellBroadcastAppLinkEnabled = false;
}
if (!mUm.isAdminUser() || !isCellBroadcastAppLinkEnabled || RestrictedLockUtils.hasBaseUserRestriction(mContext, UserManager.DISALLOW_CONFIG_CELL_BROADCASTS, UserHandle.myUserId())) {
removePreference(KEY_CELL_BROADCAST_SETTINGS);
}
}
use of android.support.v7.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class AppStorageSettings method setupViews.
private void setupViews() {
mComputingStr = getActivity().getText(R.string.computing_size);
mInvalidSizeStr = getActivity().getText(R.string.invalid_size_value);
// Set default values on sizes
mTotalSize = findPreference(KEY_TOTAL_SIZE);
mAppSize = findPreference(KEY_APP_SIZE);
mDataSize = findPreference(KEY_DATA_SIZE);
mExternalCodeSize = findPreference(KEY_EXTERNAL_CODE_SIZE);
mExternalDataSize = findPreference(KEY_EXTERNAL_DATA_SIZE);
if (Environment.isExternalStorageEmulated()) {
PreferenceCategory category = (PreferenceCategory) findPreference(KEY_STORAGE_CATEGORY);
category.removePreference(mExternalCodeSize);
category.removePreference(mExternalDataSize);
}
mClearDataButton = (Button) ((LayoutPreference) findPreference(KEY_CLEAR_DATA)).findViewById(R.id.button);
mStorageUsed = findPreference(KEY_STORAGE_USED);
mChangeStorageButton = (Button) ((LayoutPreference) findPreference(KEY_CHANGE_STORAGE)).findViewById(R.id.button);
mChangeStorageButton.setText(R.string.change);
mChangeStorageButton.setOnClickListener(this);
// Cache section
mCacheSize = findPreference(KEY_CACHE_SIZE);
mClearCacheButton = (Button) ((LayoutPreference) findPreference(KEY_CLEAR_CACHE)).findViewById(R.id.button);
mClearCacheButton.setText(R.string.clear_cache_btn_text);
// URI permissions section
mUri = (PreferenceCategory) findPreference(KEY_URI_CATEGORY);
mClearUri = (LayoutPreference) mUri.findPreference(KEY_CLEAR_URI);
mClearUriButton = (Button) mClearUri.findViewById(R.id.button);
mClearUriButton.setText(R.string.clear_uri_btn_text);
mClearUriButton.setOnClickListener(this);
}
Aggregations