use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_DU-Tweaks by DirtyUnicorns.
the class FlingSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.fling_settings);
mFooterPreferenceMixin.createFooterPreference().setTitle(R.string.fling_back_home_policy);
mContext = (Context) getActivity();
mIconPickHelper = new IconPickHelper(getActivity(), this);
mShowLogo = (SwitchPreference) findPreference("eos_fling_show_logo");
mShowLogo.setChecked(Settings.Secure.getInt(getContentResolver(), Settings.Secure.FLING_LOGO_VISIBLE, 1) == 1);
mShowLogo.setOnPreferenceChangeListener(this);
mAnimateLogo = (SwitchPreference) findPreference("eos_fling_animate_logo");
mAnimateLogo.setChecked(Settings.Secure.getInt(getContentResolver(), Settings.Secure.FLING_LOGO_ANIMATES, 1) == 1);
mAnimateLogo.setOnPreferenceChangeListener(this);
mShowRipple = (SwitchPreference) findPreference("eos_fling_show_ripple");
mShowRipple.setChecked(Settings.Secure.getInt(getContentResolver(), Settings.Secure.FLING_RIPPLE_ENABLED, 1) == 1);
mShowRipple.setOnPreferenceChangeListener(this);
int rippleColor = Settings.Secure.getIntForUser(getContentResolver(), Settings.Secure.FLING_RIPPLE_COLOR, Color.WHITE, UserHandle.USER_CURRENT);
mRippleColor = (ColorPickerPreference) findPreference("eos_fling_ripple_color");
mRippleColor.setNewPreviewColor(rippleColor);
mRippleColor.setOnPreferenceChangeListener(this);
mTrailsEnabled = (SwitchPreference) findPreference("eos_fling_trails_enable");
mTrailsEnabled.setChecked(Settings.Secure.getInt(getContentResolver(), Settings.Secure.FLING_TRAILS_ENABLED, 1) == 1);
mTrailsEnabled.setOnPreferenceChangeListener(this);
int trailsColor = Settings.Secure.getIntForUser(getContentResolver(), Settings.Secure.FLING_TRAILS_COLOR, Color.WHITE, UserHandle.USER_CURRENT);
mTrailsColor = (ColorPickerPreference) findPreference("eos_fling_trails_color");
mTrailsColor.setNewPreviewColor(trailsColor);
mTrailsColor.setOnPreferenceChangeListener(this);
mTrailsWidth = (CustomSeekBarPreference) findPreference("du_fling_trails_width");
int width = Settings.Secure.getIntForUser(getContentResolver(), Settings.Secure.FLING_TRAILS_WIDTH, 15, UserHandle.USER_CURRENT);
mTrailsWidth.setValue(width);
mTrailsWidth.setOnPreferenceChangeListener(this);
// NOTE: we display to the user actual timeouts starting from touch event
// but framework wants the value less tap timeout, which is 100ms
// so we always write 100ms less but display 100ms more
mLongPressTimeout = (CustomSeekBarPreference) findPreference("du_fling_longpress_pref");
int val = Settings.Secure.getIntForUser(getContentResolver(), Settings.Secure.FLING_LONGPRESS_TIMEOUT, 250, UserHandle.USER_CURRENT);
val += 100;
mLongPressTimeout.setValue(val);
mLongPressTimeout.setOnPreferenceChangeListener(this);
final boolean isTablet = !DUActionUtils.navigationBarCanMove();
mSwipePortRight = (CustomSeekBarPreference) findPreference("du_fling_longswipe_port_right");
val = Settings.Secure.getIntForUser(getContentResolver(), Settings.Secure.FLING_LONGSWIPE_THRESHOLD_RIGHT_PORT, isTablet ? 30 : 40, UserHandle.USER_CURRENT);
mSwipePortRight.setValue(val);
mSwipePortRight.setOnPreferenceChangeListener(this);
mSwipePortLeft = (CustomSeekBarPreference) findPreference("du_fling_longswipe_port_left");
val = Settings.Secure.getIntForUser(getContentResolver(), Settings.Secure.FLING_LONGSWIPE_THRESHOLD_LEFT_PORT, isTablet ? 30 : 40, UserHandle.USER_CURRENT);
mSwipePortLeft.setValue(val);
mSwipePortLeft.setOnPreferenceChangeListener(this);
mSwipeLandRight = (CustomSeekBarPreference) findPreference("du_fling_longswipe_land_right");
mSwipeLandLeft = (CustomSeekBarPreference) findPreference("du_fling_longswipe_land_left");
mSwipeVertUp = (CustomSeekBarPreference) findPreference("du_fling_longswipe_vert_up");
mSwipeVertDown = (CustomSeekBarPreference) findPreference("du_fling_longswipe_vert_down");
PreferenceCategory longSwipeCategory = (PreferenceCategory) getPreferenceScreen().findPreference("eos_long_swipe_category");
if (isTablet) {
longSwipeCategory.removePreference(mSwipeVertUp);
longSwipeCategory.removePreference(mSwipeVertDown);
val = Settings.Secure.getIntForUser(getContentResolver(), Settings.Secure.FLING_LONGSWIPE_THRESHOLD_RIGHT_LAND, 25, UserHandle.USER_CURRENT);
mSwipeLandRight.setValue(val);
mSwipeLandRight.setOnPreferenceChangeListener(this);
val = Settings.Secure.getIntForUser(getContentResolver(), Settings.Secure.FLING_LONGSWIPE_THRESHOLD_LEFT_LAND, 25, UserHandle.USER_CURRENT);
mSwipeLandLeft.setValue(val);
mSwipeLandLeft.setOnPreferenceChangeListener(this);
} else {
longSwipeCategory.removePreference(mSwipeLandRight);
longSwipeCategory.removePreference(mSwipeLandLeft);
val = Settings.Secure.getIntForUser(getContentResolver(), Settings.Secure.FLING_LONGSWIPE_THRESHOLD_UP_LAND, 40, UserHandle.USER_CURRENT);
mSwipeVertUp.setValue(val);
mSwipeVertUp.setOnPreferenceChangeListener(this);
val = Settings.Secure.getIntForUser(getContentResolver(), Settings.Secure.FLING_LONGSWIPE_THRESHOLD_DOWN_LAND, 40, UserHandle.USER_CURRENT);
mSwipeVertDown.setValue(val);
mSwipeVertDown.setOnPreferenceChangeListener(this);
}
mKbCursors = (SwitchPreference) findPreference("fling_keyboard_cursors");
mKbCursors.setChecked(Settings.Secure.getIntForUser(getContentResolver(), Settings.Secure.FLING_KEYBOARD_CURSORS, 1, UserHandle.USER_CURRENT) == 1);
mKbCursors.setOnPreferenceChangeListener(this);
mLogoOpacity = (CustomSeekBarPreference) findPreference("fling_logo_opacity");
int alpha = Settings.Secure.getIntForUser(getContentResolver(), Settings.Secure.FLING_LOGO_OPACITY, 255, UserHandle.USER_CURRENT);
mLogoOpacity.setValue(alpha);
mLogoOpacity.setOnPreferenceChangeListener(this);
onPreferenceScreenLoaded(ActionConstants.getDefaults(ActionConstants.FLING));
}
use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_DU-Tweaks by DirtyUnicorns.
the class PulseSettings method onPreferenceChange.
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (preference.equals(mRenderMode)) {
int mode = Integer.valueOf((String) newValue);
Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_RENDER_STYLE_URI, mode, UserHandle.USER_CURRENT);
PreferenceCategory fadingBarsCat = (PreferenceCategory) findPreference("pulse_fading_bars_category");
fadingBarsCat.setEnabled(mode == RENDER_STYLE_FADING_BARS);
PreferenceCategory solidBarsCat = (PreferenceCategory) findPreference("pulse_2");
solidBarsCat.setEnabled(mode == RENDER_STYLE_SOLID_LINES);
return true;
} else if (preference.equals(mShowPulse)) {
boolean enabled = ((Boolean) newValue).booleanValue();
Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.FLING_PULSE_ENABLED, enabled ? 1 : 0, UserHandle.USER_CURRENT);
return true;
} else if (preference.equals(mAutoColor)) {
boolean enabled = ((Boolean) newValue).booleanValue();
Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_AUTO_COLOR, enabled ? 1 : 0, UserHandle.USER_CURRENT);
return true;
} else if (preference.equals(mPulseColor)) {
int color = ((Integer) newValue).intValue();
Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.FLING_PULSE_COLOR, color, UserHandle.USER_CURRENT);
return true;
} else if (preference.equals(mLavaLampEnabled)) {
boolean enabled = ((Boolean) newValue).booleanValue();
Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.FLING_PULSE_LAVALAMP_ENABLED, enabled ? 1 : 0, UserHandle.USER_CURRENT);
return true;
} else if (preference == mCustomDimen) {
int val = (Integer) newValue;
Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_CUSTOM_DIMEN, val, UserHandle.USER_CURRENT);
return true;
} else if (preference == mCustomDiv) {
int val = (Integer) newValue;
Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_CUSTOM_DIV, val, UserHandle.USER_CURRENT);
return true;
} else if (preference == mFilled) {
int val = (Integer) newValue;
Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_FILLED_BLOCK_SIZE, val, UserHandle.USER_CURRENT);
return true;
} else if (preference == mEmpty) {
int val = (Integer) newValue;
Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_EMPTY_BLOCK_SIZE, val, UserHandle.USER_CURRENT);
return true;
} else if (preference == mFudge) {
int val = (Integer) newValue;
Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_CUSTOM_FUDGE_FACTOR, val, UserHandle.USER_CURRENT);
return true;
} else if (preference == mSolidFudge) {
int val = (Integer) newValue;
Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_SOLID_FUDGE_FACTOR, val, UserHandle.USER_CURRENT);
return true;
} else if (preference == mSolidSpeed) {
int val = (Integer) newValue;
Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_LAVALAMP_SOLID_SPEED, val, UserHandle.USER_CURRENT);
return true;
} else if (preference == mFadingSpeed) {
int val = (Integer) newValue;
Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.FLING_PULSE_LAVALAMP_SPEED, val, UserHandle.USER_CURRENT);
return true;
} else if (preference == mSolidCount) {
int val = (Integer) newValue;
Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_SOLID_UNITS_COUNT, val, UserHandle.USER_CURRENT);
return true;
} else if (preference == mSolidOpacity) {
int val = (Integer) newValue;
Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_SOLID_UNITS_OPACITY, val, UserHandle.USER_CURRENT);
return true;
} else if (preference == mNavButtonsOpacity) {
int val = (Integer) newValue;
Settings.Secure.putIntForUser(getContentResolver(), Settings.Secure.PULSE_CUSTOM_BUTTONS_OPACITY, val, UserHandle.USER_CURRENT);
return true;
}
return false;
}
use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by DirtyUnicorns.
the class PhysicalKeyboardFragment method onCreatePreferences.
@Override
public void onCreatePreferences(Bundle bundle, String s) {
Activity activity = Preconditions.checkNotNull(getActivity());
addPreferencesFromResource(R.xml.physical_keyboard_settings);
mIm = Preconditions.checkNotNull(activity.getSystemService(InputManager.class));
mSettings = new InputMethodUtils.InputMethodSettings(activity.getResources(), getContentResolver(), new HashMap<>(), new ArrayList<>(), UserHandle.myUserId(), false);
mKeyboardAssistanceCategory = Preconditions.checkNotNull((PreferenceCategory) findPreference(KEYBOARD_ASSISTANCE_CATEGORY));
mShowVirtualKeyboardSwitch = Preconditions.checkNotNull((SwitchPreference) mKeyboardAssistanceCategory.findPreference(SHOW_VIRTUAL_KEYBOARD_SWITCH));
findPreference(KEYBOARD_SHORTCUTS_HELPER).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
toggleKeyboardShortcutsMenu();
return true;
}
});
}
use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by DirtyUnicorns.
the class LocationSettings method addLocationServices.
/**
* Add the settings injected by external apps into the "App Settings" category. Hides the
* category if there are no injected settings.
*
* Reloads the settings whenever receives
* {@link SettingInjectorService#ACTION_INJECTED_SETTING_CHANGED}.
*/
private void addLocationServices(Context context, PreferenceScreen root, boolean lockdownOnLocationAccess) {
PreferenceCategory categoryLocationServices = (PreferenceCategory) root.findPreference(KEY_LOCATION_SERVICES);
injector = new SettingsInjector(context);
// If location access is locked down by device policy then we only show injected settings
// for the primary profile.
final Context prefContext = categoryLocationServices.getContext();
final List<Preference> locationServices = injector.getInjectedSettings(prefContext, lockdownOnLocationAccess ? UserHandle.myUserId() : UserHandle.USER_CURRENT);
mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Received settings change intent: " + intent);
}
injector.reloadStatusMessages();
}
};
IntentFilter filter = new IntentFilter();
filter.addAction(SettingInjectorService.ACTION_INJECTED_SETTING_CHANGED);
context.registerReceiver(mReceiver, filter);
if (locationServices.size() > 0) {
addPreferencesSorted(locationServices, categoryLocationServices);
} else {
// If there's no item to display, remove the whole category.
root.removePreference(categoryLocationServices);
}
}
use of android.support.v7.preference.PreferenceCategory in project android_packages_apps_Settings by DirtyUnicorns.
the class PowerUsageAnomalyDetailsTest method setUp.
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
mContext = RuntimeEnvironment.application;
mAbnormalListGroup = spy(new PreferenceCategory(mContext));
mAnomalyList = new ArrayList<>();
Anomaly anomaly1 = new Anomaly.Builder().setType(Anomaly.AnomalyType.WAKE_LOCK).setPackageName(PACKAGE_NAME_1).setDisplayName(NAME_APP_1).build();
mAnomalyList.add(anomaly1);
Anomaly anomaly2 = new Anomaly.Builder().setType(Anomaly.AnomalyType.WAKEUP_ALARM).setPackageName(PACKAGE_NAME_2).setDisplayName(NAME_APP_2).build();
mAnomalyList.add(anomaly2);
Anomaly anomaly3 = new Anomaly.Builder().setType(Anomaly.AnomalyType.BLUETOOTH_SCAN).setPackageName(PACKAGE_NAME_3).setDisplayName(NAME_APP_3).build();
mAnomalyList.add(anomaly3);
mFragment = spy(new PowerUsageAnomalyDetails());
mFragment.mAbnormalListGroup = mAbnormalListGroup;
mFragment.mAnomalies = mAnomalyList;
mFragment.mBatteryUtils = new BatteryUtils(mContext);
mFragment.mPackageManager = mPackageManager;
mFragment.mIconDrawableFactory = mIconDrawableFactory;
doReturn(mPreferenceManager).when(mFragment).getPreferenceManager();
doReturn(mContext).when(mPreferenceManager).getContext();
}
Aggregations