use of android.support.v7.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class InputMethodAndSubtypeEnabler method addInputMethodSubtypePreferences.
private void addInputMethodSubtypePreferences(final InputMethodInfo imi, final PreferenceScreen root) {
final Context context = getPrefContext();
final int subtypeCount = imi.getSubtypeCount();
if (subtypeCount <= 1) {
return;
}
final String imiId = imi.getId();
final PreferenceCategory keyboardSettingsCategory = new PreferenceCategory(getPrefContext());
root.addPreference(keyboardSettingsCategory);
final PackageManager pm = getPackageManager();
final CharSequence label = imi.loadLabel(pm);
keyboardSettingsCategory.setTitle(label);
keyboardSettingsCategory.setKey(imiId);
// TODO: Use toggle Preference if images are ready.
final TwoStatePreference autoSelectionPref = new SwitchWithNoTextPreference(getPrefContext());
mAutoSelectionPrefsMap.put(imiId, autoSelectionPref);
keyboardSettingsCategory.addPreference(autoSelectionPref);
autoSelectionPref.setOnPreferenceChangeListener(this);
final PreferenceCategory activeInputMethodsCategory = new PreferenceCategory(getPrefContext());
activeInputMethodsCategory.setTitle(R.string.active_input_method_subtypes);
root.addPreference(activeInputMethodsCategory);
CharSequence autoSubtypeLabel = null;
final ArrayList<Preference> subtypePreferences = new ArrayList<>();
for (int index = 0; index < subtypeCount; ++index) {
final InputMethodSubtype subtype = imi.getSubtypeAt(index);
if (subtype.overridesImplicitlyEnabledSubtype()) {
if (autoSubtypeLabel == null) {
autoSubtypeLabel = InputMethodAndSubtypeUtil.getSubtypeLocaleNameAsSentence(subtype, context, imi);
}
} else {
final Preference subtypePref = new InputMethodSubtypePreference(context, subtype, imi);
subtypePreferences.add(subtypePref);
}
}
Collections.sort(subtypePreferences, new Comparator<Preference>() {
@Override
public int compare(final Preference lhs, final Preference rhs) {
if (lhs instanceof InputMethodSubtypePreference) {
return ((InputMethodSubtypePreference) lhs).compareTo(rhs, mCollator);
}
return lhs.compareTo(rhs);
}
});
final int prefCount = subtypePreferences.size();
for (int index = 0; index < prefCount; ++index) {
final Preference pref = subtypePreferences.get(index);
activeInputMethodsCategory.addPreference(pref);
pref.setOnPreferenceChangeListener(this);
InputMethodAndSubtypeUtil.removeUnnecessaryNonPersistentPreference(pref);
}
mInputMethodAndSubtypePrefsMap.put(imiId, subtypePreferences);
if (TextUtils.isEmpty(autoSubtypeLabel)) {
autoSelectionPref.setTitle(R.string.use_system_language_to_select_input_method_subtypes);
} else {
autoSelectionPref.setTitle(autoSubtypeLabel);
}
}
use of android.support.v7.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class PixelAnimDurationSettings method refreshSettings.
public void refreshSettings() {
PreferenceScreen prefs = getPreferenceScreen();
if (prefs != null) {
prefs.removeAll();
}
addPreferencesFromResource(R.xml.pixel_anim_duration);
mContext = getActivity().getApplicationContext();
mContentRes = getActivity().getContentResolver();
final Resources res = getResources();
int defaultValue;
mPixelx = (SeekBarPreference) findPreference(PIXEL_X);
int xanim = Settings.System.getIntForUser(getContentResolver(), Settings.System.OPA_ANIM_DURATION_X, 133, UserHandle.USER_CURRENT);
mPixelx.setValue(xanim / 1);
mPixelx.setOnPreferenceChangeListener(this);
mPixely = (SeekBarPreference) findPreference(PIXEL_Y);
int yanim = Settings.System.getIntForUser(getContentResolver(), Settings.System.OPA_ANIM_DURATION_Y, 255, UserHandle.USER_CURRENT);
mPixely.setValue(yanim / 1);
mPixely.setOnPreferenceChangeListener(this);
mCollapse = (SeekBarPreference) findPreference(PIXEL_COLLAPSE);
int xcol = Settings.System.getIntForUser(getContentResolver(), Settings.System.COLLAPSE_ANIMATION_DURATION_RY, 83, UserHandle.USER_CURRENT);
mCollapse.setValue(xcol / 1);
mCollapse.setOnPreferenceChangeListener(this);
mBg = (SeekBarPreference) findPreference(PIXEL_BG);
int bg = Settings.System.getIntForUser(getContentResolver(), Settings.System.COLLAPSE_ANIMATION_DURATION_BG, 100, UserHandle.USER_CURRENT);
mBg.setValue(yanim / 1);
mBg.setOnPreferenceChangeListener(this);
mRetract = (SeekBarPreference) findPreference(PIXEL_RETRACT);
int ret = Settings.System.getIntForUser(getContentResolver(), Settings.System.RETRACT_ANIMATION_DURATION, 300, UserHandle.USER_CURRENT);
mRetract.setValue(ret / 1);
mRetract.setOnPreferenceChangeListener(this);
mDiamond = (SeekBarPreference) findPreference(PIXEL_DIAMOND);
int diam = Settings.System.getIntForUser(getContentResolver(), Settings.System.DIAMOND_ANIMATION_DURATION, 200, UserHandle.USER_CURRENT);
mDiamond.setValue(diam / 1);
mDiamond.setOnPreferenceChangeListener(this);
mDots = (SeekBarPreference) findPreference(PIXEL_DOTS);
int dots = Settings.System.getIntForUser(getContentResolver(), Settings.System.DOTS_RESIZE_DURATION, 200, UserHandle.USER_CURRENT);
mDots.setValue(dots / 1);
mDots.setOnPreferenceChangeListener(this);
mHome = (SeekBarPreference) findPreference(PIXEL_HOME);
int home = Settings.System.getIntForUser(getContentResolver(), Settings.System.HOME_RESIZE_DURATION, 255, UserHandle.USER_CURRENT);
mHome.setValue(home / 1);
mHome.setOnPreferenceChangeListener(this);
mColorCat = (PreferenceCategory) findPreference(COLOR_CAT);
mTopColor = (ColorPickerPreference) findPreference(TOP_COLOR);
mTopColor.setOnPreferenceChangeListener(this);
int top = Settings.System.getInt(mContentRes, Settings.System.DOT_TOP_COLOR, Color.RED);
String topHexColor = String.format("#%08x", (0x00ffffff & top));
mTopColor.setSummary(topHexColor);
mTopColor.setNewPreviewColor(top);
mBottomColor = (ColorPickerPreference) findPreference(BOTTOM_COLOR);
mBottomColor.setOnPreferenceChangeListener(this);
int bottom = Settings.System.getInt(mContentRes, Settings.System.DOT_BOTTOM_COLOR, Color.YELLOW);
String bottomHexColor = String.format("#%08x", (0x00ffffff & bottom));
mBottomColor.setSummary(bottomHexColor);
mBottomColor.setNewPreviewColor(bottom);
mRightColor = (ColorPickerPreference) findPreference(RIGHT_COLOR);
mRightColor.setOnPreferenceChangeListener(this);
int right = Settings.System.getInt(mContentRes, Settings.System.DOT_RIGHT_COLOR, Color.GREEN);
String rightHexColor = String.format("#%08x", (0x00ffffff & right));
mRightColor.setSummary(rightHexColor);
mRightColor.setNewPreviewColor(right);
mLeftColor = (ColorPickerPreference) findPreference(LEFT_COLOR);
mLeftColor.setOnPreferenceChangeListener(this);
int left = Settings.System.getInt(mContentRes, Settings.System.DOT_LEFT_COLOR, Color.RED);
String leftHexColor = String.format("#%08x", (0x00ffffff & left));
mLeftColor.setSummary(leftHexColor);
mLeftColor.setNewPreviewColor(left);
mColorStyle = (ListPreference) findPreference(COLOR_STYLE);
int style = Settings.System.getIntForUser(mContentRes, Settings.System.DOT_COLOR_SWITCH, 0, UserHandle.USER_CURRENT);
mColorStyle.setValue(String.valueOf(style));
mColorStyle.setSummary(mColorStyle.getEntry());
mColorStyle.setOnPreferenceChangeListener(this);
UpdateSettings(style);
}
use of android.support.v7.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class HWSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.rr_hw_keys);
final ContentResolver resolver = getContentResolver();
final PreferenceScreen prefScreen = getPreferenceScreen();
final Resources res = getResources();
final int deviceWakeKeys = getResources().getInteger(com.android.internal.R.integer.config_deviceHardwareWakeKeys);
// bits for hardware keys present on device
final int deviceKeys = getResources().getInteger(com.android.internal.R.integer.config_deviceHardwareKeys);
// read bits for present hardware keys
final boolean hasHomeKey = (deviceKeys & KEY_MASK_HOME) != 0;
final boolean hasBackKey = (deviceKeys & KEY_MASK_BACK) != 0;
final boolean hasMenuKey = (deviceKeys & KEY_MASK_MENU) != 0;
final boolean hasAssistKey = (deviceKeys & KEY_MASK_ASSIST) != 0;
final boolean hasAppSwitchKey = (deviceKeys & KEY_MASK_APP_SWITCH) != 0;
final boolean hasCameraKey = (deviceKeys & KEY_MASK_CAMERA) != 0;
final boolean showHomeWake = (deviceWakeKeys & KEY_MASK_HOME) != 0;
final boolean showBackWake = (deviceWakeKeys & KEY_MASK_BACK) != 0;
final boolean showMenuWake = (deviceWakeKeys & KEY_MASK_MENU) != 0;
final boolean showAssistWake = (deviceWakeKeys & KEY_MASK_ASSIST) != 0;
final boolean showAppSwitchWake = (deviceWakeKeys & KEY_MASK_APP_SWITCH) != 0;
final boolean needsNavbar = DUActionUtils.hasNavbarByDefault(getActivity());
final PreferenceCategory hwkeyCat = (PreferenceCategory) prefScreen.findPreference(CATEGORY_HWKEY);
int keysDisabled = 0;
if (!needsNavbar) {
mHwKeyDisable = (SwitchPreference) findPreference(HWKEY_DISABLE);
keysDisabled = Settings.Secure.getIntForUser(getContentResolver(), Settings.Secure.HARDWARE_KEYS_DISABLE, 0, UserHandle.USER_CURRENT);
mHwKeyDisable.setChecked(keysDisabled != 0);
mHwKeyDisable.setOnPreferenceChangeListener(this);
} else {
prefScreen.removePreference(hwkeyCat);
}
// load categories and init/remove preferences based on device
// configuration
final boolean hasPowerKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POWER);
final PreferenceCategory backCategory = (PreferenceCategory) prefScreen.findPreference(CATEGORY_BACK);
final PreferenceCategory homeCategory = (PreferenceCategory) prefScreen.findPreference(CATEGORY_HOME);
final PreferenceCategory menuCategory = (PreferenceCategory) prefScreen.findPreference(CATEGORY_MENU);
final PreferenceCategory assistCategory = (PreferenceCategory) prefScreen.findPreference(CATEGORY_ASSIST);
final PreferenceCategory appSwitchCategory = (PreferenceCategory) prefScreen.findPreference(CATEGORY_APPSWITCH);
// Power button ends calls.
mPowerEndCall = (SwitchPreference) findPreference(KEY_POWER_END_CALL);
// Home button answers calls.
mHomeAnswerCall = (SwitchPreference) findPreference(KEY_HOME_ANSWER_CALL);
if (hasBackKey) {
if (!showBackWake) {
backCategory.removePreference(findPreference(CMSettings.System.BACK_WAKE_SCREEN));
}
} else {
prefScreen.removePreference(backCategory);
}
if (hasHomeKey) {
if (!showHomeWake) {
homeCategory.removePreference(findPreference(CMSettings.System.HOME_WAKE_SCREEN));
}
if (!TelephonyUtils.isVoiceCapable(getActivity())) {
homeCategory.removePreference(mHomeAnswerCall);
mHomeAnswerCall = null;
}
} else {
prefScreen.removePreference(homeCategory);
}
// App switch key (recents)
if (!hasAppSwitchKey) {
prefScreen.removePreference(appSwitchCategory);
}
if (hasMenuKey) {
if (!showMenuWake) {
menuCategory.removePreference(findPreference(CMSettings.System.MENU_WAKE_SCREEN));
}
} else {
prefScreen.removePreference(menuCategory);
}
if (hasAssistKey) {
if (!showAssistWake) {
assistCategory.removePreference(findPreference(CMSettings.System.ASSIST_WAKE_SCREEN));
}
} else {
prefScreen.removePreference(assistCategory);
}
final ButtonBacklightBrightness backlight = (ButtonBacklightBrightness) findPreference(KEY_BUTTON_BACKLIGHT);
if (backlight != null) {
if (!backlight.isButtonSupported() && !backlight.isKeyboardSupported() || needsNavbar) {
prefScreen.removePreference(backlight);
}
}
// let super know we can load ActionPreferences
onPreferenceScreenLoaded(ActionConstants.getDefaults(ActionConstants.HWKEYS));
// load preferences first
setActionPreferencesEnabled(keysDisabled == 0);
}
use of android.support.v7.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ActionFragment method onPreferenceScreenLoaded.
/**
* load our button lists and ActionPreferences map button action targets from preference keys
* and defaults config maps subclass is required to set desired Defaults interface int
* ActionContants
*/
protected void onPreferenceScreenLoaded(Defaults defaults) {
mDefaults = defaults;
final PreferenceScreen prefScreen = getPreferenceScreen();
for (int i = 0; i < prefScreen.getPreferenceCount(); i++) {
Preference pref = prefScreen.getPreference(i);
if (pref instanceof PreferenceCategory) {
PreferenceCategory cat = (PreferenceCategory) pref;
for (int j = 0; j < cat.getPreferenceCount(); j++) {
Preference child = cat.getPreference(j);
if (child instanceof ActionPreference) {
mPrefHolder.add((ActionPreference) child);
}
}
} else if (pref instanceof ActionPreference) {
mPrefHolder.add((ActionPreference) pref);
}
}
loadAndSetConfigs();
}
use of android.support.v7.preference.PreferenceCategory in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class LocationSettings method createPreferenceHierarchy.
private PreferenceScreen createPreferenceHierarchy() {
final SettingsActivity activity = (SettingsActivity) getActivity();
PreferenceScreen root = getPreferenceScreen();
if (root != null) {
root.removeAll();
}
addPreferencesFromResource(R.xml.location_settings);
root = getPreferenceScreen();
setupManagedProfileCategory(root);
mLocationMode = root.findPreference(KEY_LOCATION_MODE);
mLocationMode.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
activity.startPreferencePanel(LocationMode.class.getName(), null, R.string.location_mode_screen_title, null, LocationSettings.this, 0);
return true;
}
});
mAgpsEnabled = getActivity().getResources().getBoolean(R.bool.config_agps_enabled);
mAssistedGps = (CheckBoxPreference) root.findPreference(KEY_ASSISTED_GPS);
if (!mAgpsEnabled) {
root.removePreference(mAssistedGps);
}
if (mAssistedGps != null) {
mAssistedGps.setChecked(Settings.Global.getInt(getContentResolver(), Settings.Global.ASSISTED_GPS_ENABLED, 0) == 1);
}
mCategoryRecentLocationRequests = (PreferenceCategory) root.findPreference(KEY_RECENT_LOCATION_REQUESTS);
RecentLocationApps recentApps = new RecentLocationApps(activity);
List<RecentLocationApps.Request> recentLocationRequests = recentApps.getAppList();
List<Preference> recentLocationPrefs = new ArrayList<>(recentLocationRequests.size());
for (final RecentLocationApps.Request request : recentLocationRequests) {
DimmableIconPreference pref = new DimmableIconPreference(getPrefContext(), request.contentDescription);
pref.setIcon(request.icon);
pref.setTitle(request.label);
if (request.isHighBattery) {
pref.setSummary(R.string.location_high_battery_use);
} else {
pref.setSummary(R.string.location_low_battery_use);
}
pref.setOnPreferenceClickListener(new PackageEntryClickedListener(request.packageName, request.userHandle));
recentLocationPrefs.add(pref);
}
if (recentLocationRequests.size() > 0) {
addPreferencesSorted(recentLocationPrefs, mCategoryRecentLocationRequests);
} else {
// If there's no item to display, add a "No recent apps" item.
Preference banner = new Preference(getPrefContext());
banner.setLayoutResource(R.layout.location_list_no_item);
banner.setTitle(R.string.location_no_recent_apps);
banner.setSelectable(false);
mCategoryRecentLocationRequests.addPreference(banner);
}
boolean lockdownOnLocationAccess = false;
// injected location services must not be shown.
if (mManagedProfile != null && mUm.hasUserRestriction(UserManager.DISALLOW_SHARE_LOCATION, mManagedProfile)) {
lockdownOnLocationAccess = true;
}
addLocationServices(activity, root, lockdownOnLocationAccess);
refreshLocationMode();
return root;
}
Aggregations