public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference == mPieMode) { int pieMode = Integer.valueOf((String) newValue); Settings.System.putInt(getActivity().getContentResolver(), Settings.System.PIE_MODE, pieMode); return true; } else if (preference == mPieSize) { float pieSize = Float.valueOf((String) newValue); Settings.System.putFloat( getActivity().getContentResolver(), Settings.System.PIE_SIZE, pieSize); return true; } else if (preference == mPieGravity) { int pieGravity = Integer.valueOf((String) newValue); Settings.System.putInt( getActivity().getContentResolver(), Settings.System.PIE_GRAVITY, pieGravity); return true; } else if (preference == mPieAngle) { int pieAngle = Integer.valueOf((String) newValue); Settings.System.putInt( getActivity().getContentResolver(), Settings.System.PIE_ANGLE, pieAngle); return true; } else if (preference == mPieGap) { int pieGap = Integer.valueOf((String) newValue); Settings.System.putInt(getActivity().getContentResolver(), Settings.System.PIE_GAP, pieGap); return true; } else if (preference == mPieTrigger) { float pieTrigger = Float.valueOf((String) newValue); Settings.System.putFloat( getActivity().getContentResolver(), Settings.System.PIE_TRIGGER, pieTrigger); return true; } return false; }
@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (preference == mShowPowerSaver) { Settings.System.putInt( getActivity().getContentResolver(), Settings.System.POWER_DIALOG_SHOW_POWER_SAVER, ((CheckBoxPreference) preference).isChecked() ? 1 : 0); return true; } else if (preference == mShowScreenShot) { Settings.System.putInt( getActivity().getContentResolver(), Settings.System.POWER_DIALOG_SHOW_SCREENSHOT, ((CheckBoxPreference) preference).isChecked() ? 1 : 0); return true; } else if (preference == mShowTorchToggle) { Settings.System.putInt( getActivity().getContentResolver(), Settings.System.POWER_DIALOG_SHOW_TORCH_TOGGLE, ((CheckBoxPreference) preference).isChecked() ? 1 : 0); return true; } else if (preference == mShowAirplaneToggle) { Settings.System.putInt( getActivity().getContentResolver(), Settings.System.POWER_DIALOG_SHOW_AIRPLANE_TOGGLE, ((CheckBoxPreference) preference).isChecked() ? 1 : 0); return true; } return super.onPreferenceTreeClick(preferenceScreen, preference); }
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.reset: Settings.System.putInt(mContentRes, Settings.System.NAVIGATION_BAR_COLOR, -1); Settings.System.putInt(mContentRes, Settings.System.NAVIGATION_BAR_TINT, -1); Settings.System.putInt(mContentRes, Settings.System.NAVIGATION_BAR_GLOW_TINT, -1); Settings.System.putInt(mContentRes, Settings.System.NAVIGATION_BAR_BUTTONS_QTY, 3); Settings.System.putString( mContentRes, Settings.System.NAVIGATION_CUSTOM_ACTIVITIES[0], "**back**"); Settings.System.putString( mContentRes, Settings.System.NAVIGATION_CUSTOM_ACTIVITIES[1], "**home**"); Settings.System.putString( mContentRes, Settings.System.NAVIGATION_CUSTOM_ACTIVITIES[2], "**recents**"); Settings.System.putString( mContentRes, Settings.System.NAVIGATION_LONGPRESS_ACTIVITIES[0], "**null**"); Settings.System.putString( mContentRes, Settings.System.NAVIGATION_LONGPRESS_ACTIVITIES[1], "**null**"); Settings.System.putString( mContentRes, Settings.System.NAVIGATION_LONGPRESS_ACTIVITIES[2], "**null**"); Settings.System.putString(mContentRes, Settings.System.NAVIGATION_CUSTOM_APP_ICONS[0], ""); Settings.System.putString(mContentRes, Settings.System.NAVIGATION_CUSTOM_APP_ICONS[1], ""); Settings.System.putString(mContentRes, Settings.System.NAVIGATION_CUSTOM_APP_ICONS[2], ""); loadButtons(); refreshSettings(); return true; default: return super.onContextItemSelected(item); } }
private void updateExpandedDesktop(int value) { Resources res = getResources(); int summary = -1; Settings.System.putInt(getContentResolver(), Settings.System.EXPANDED_DESKTOP_STYLE, value); if (value == 0) { // Expanded desktop deactivated Settings.System.putInt( getContentResolver(), Settings.System.POWER_MENU_EXPANDED_DESKTOP_ENABLED, 0); summary = R.string.expanded_desktop_disabled; // Disable expanded desktop if enabled Settings.System.putInt(getContentResolver(), Settings.System.EXPANDED_DESKTOP_STATE, 0); } else if (value == 1) { Settings.System.putInt( getContentResolver(), Settings.System.POWER_MENU_EXPANDED_DESKTOP_ENABLED, 1); summary = R.string.expanded_desktop_status_bar; } else if (value == 2) { Settings.System.putInt( getContentResolver(), Settings.System.POWER_MENU_EXPANDED_DESKTOP_ENABLED, 1); summary = R.string.expanded_desktop_no_status_bar; } if (mExpandedDesktopPref != null && summary != -1) { mExpandedDesktopPref.setSummary(res.getString(summary)); } }
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (preference == mFlashRecovery) { // 警告弹框 new AlertDialog.Builder(StockSettings.this) .setTitle(R.string.confirm) .setMessage("您确定刷入并重启进入刷机模式?") .setNegativeButton( R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { RootCmd.RunRootCmd("dd if=/sdcard/recovery.img of=/dev/recovery"); RootCmd.RunRootCmd("reboot recovery"); } }) .setPositiveButton(R.string.no, null) .show(); } if (preference == mCrtLockscreen) { if (mCrtLockscreen.isChecked()) { Settings.System.putInt(getContentResolver(), "allow_crt_lockscreen", 1); } else { Settings.System.putInt(getContentResolver(), "allow_crt_lockscreen", 0); } } return super.onPreferenceTreeClick(preferenceScreen, preference); }
public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference == mPositionPref) { int position = Integer.valueOf((String) newValue); updatePositionSummary(position); return true; } else if (preference == mEnabledPref) { Settings.System.putInt( getContentResolver(), Settings.System.GESTURE_ANYWHERE_ENABLED, ((Boolean) newValue).booleanValue() ? 1 : 0); return true; } else if (preference == mGestureAnywhereFloatingWindow) { Settings.System.putInt( getContentResolver(), Settings.System.GESTURE_ANYWHERE_FLOATING, (Boolean) newValue ? 1 : 0); return true; } else if (preference == mTriggerWidthPref) { int width = ((Integer) newValue).intValue(); Settings.System.putInt( getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_WIDTH, width); return true; } else if (preference == mTriggerTopPref) { int top = ((Integer) newValue).intValue(); Settings.System.putInt( getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_TOP, top); return true; } else if (preference == mTriggerBottomPref) { int bottom = ((Integer) newValue).intValue(); Settings.System.putInt( getContentResolver(), Settings.System.GESTURE_ANYWHERE_TRIGGER_HEIGHT, bottom); return true; } return false; }
@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (preference == mEnableWeather) { // _stop_ alarm or start service boolean check = ((CheckBoxPreference) preference).isChecked(); Intent i = new Intent(getActivity().getApplicationContext(), WeatherRefreshService.class); i.setAction(WeatherService.INTENT_REQUEST_WEATHER); PendingIntent weatherRefreshIntent = PendingIntent.getService(getActivity(), 0, i, 0); if (!check) { AlarmManager alarms = (AlarmManager) getActivity().getSystemService(Context.ALARM_SERVICE); alarms.cancel(weatherRefreshIntent); } else { getActivity().startService(i); } Settings.System.putInt( getActivity().getContentResolver(), Settings.System.USE_WEATHER, check ? 1 : 0); return true; } else if (preference == mUseCustomLoc) { return WeatherPrefs.setUseCustomLocation( mContext, ((CheckBoxPreference) preference).isChecked()); } else if (preference == mShowLoc) { Settings.System.putInt( getActivity().getContentResolver(), Settings.System.WEATHER_SHOW_LOCATION, ((CheckBoxPreference) preference).isChecked() ? 1 : 0); return true; } else if (preference == mUseCelcius) { return WeatherPrefs.setUseCelcius(mContext, ((CheckBoxPreference) preference).isChecked()); } return super.onPreferenceTreeClick(preferenceScreen, preference); }
@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (preference == mPieMenu) { Settings.System.putInt( getActivity().getApplicationContext().getContentResolver(), Settings.System.PIE_MENU, mPieMenu.isChecked() ? 1 : 0); } else if (preference == mPieSearch) { Settings.System.putInt( getActivity().getApplicationContext().getContentResolver(), Settings.System.PIE_SEARCH, mPieSearch.isChecked() ? 1 : 0); } else if (preference == mPieCenter) { Settings.System.putInt( getActivity().getApplicationContext().getContentResolver(), Settings.System.PIE_CENTER, mPieCenter.isChecked() ? 1 : 0); } else if (preference == mPieStick) { Settings.System.putInt( getActivity().getApplicationContext().getContentResolver(), Settings.System.PIE_STICK, mPieStick.isChecked() ? 1 : 0); } return super.onPreferenceTreeClick(preferenceScreen, preference); }
/** 发射FM */ public static void launchFM(int fm, Context context) { Settings.System.putInt(context.getContentResolver(), "fm_freg", fm); Settings.System.putInt(context.getContentResolver(), "fm_switch", 0); Intent intent = new Intent("action.colink.startFM"); intent.putExtra("fm_fq", (fm * 1.0f / 1000)); context.sendBroadcast(intent); }
public void setPhoneRotationState(boolean canRotate) { if (canRotate) { Settings.System.putInt( this.mContext.getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 1); } else { Settings.System.putInt( this.mContext.getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 0); } }
@Override public void toggleState(Context context) { if (getOrientationState(context) == 0) { Settings.System.putInt( context.getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 1); } else { Settings.System.putInt( context.getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 0); } }
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (preference == mPieButtonColor) { ColorPickerDialog cp = new ColorPickerDialog(this, mPieButtonColorListener, getPieButtonColor()); cp.show(); return true; } else if (preference == mPieBackgroundButtonColor) { ColorPickerDialog cp = new ColorPickerDialog(this, mPieBackgroundButtonColorListener, getPieBgColor()); cp.show(); return true; } else if (preference == mPieChoiceButtonColor) { ColorPickerDialog cp = new ColorPickerDialog(this, mPieChoiceButtonColorListener, getPieChoiceColor()); cp.show(); return true; } else if (preference == mPieBatteryColor) { ColorPickerDialog cp = new ColorPickerDialog(this, mPieBatteryColorListener, getPieBatteryColor()); cp.show(); return true; } else if (preference == mPieChevronColor) { ColorPickerDialog cp = new ColorPickerDialog(this, mPieChevronColorListener, getPieChevronColor()); cp.show(); return true; } else if (preference == mPieClockColor) { ColorPickerDialog cp = new ColorPickerDialog(this, mPieClockColorListener, getPieClockColor()); cp.show(); return true; } else if (preference == mPieOutlineColor) { ColorPickerDialog cp = new ColorPickerDialog(this, mPieOutlineColorListener, getPieOutlineColor()); cp.show(); return true; } else if (preference == mPieEnableColor) { Settings.System.putInt( getContentResolver(), Settings.System.PIE_ENABLE_COLOR, mPieEnableColor.isChecked() ? 1 : 0); return true; } else if (preference == mPieEnableControl) { Settings.System.putInt( getContentResolver(), Settings.System.PIE_CONTROL_ENABLE, mPieEnableControl.isChecked() ? 1 : 0); return true; } else if (preference == mPieCenter) { Settings.System.putInt( getContentResolver(), Settings.System.PIE_CENTER, mPieCenter.isChecked() ? 1 : 0); return true; } return false; }
/** * Updates the default or application specific notification settings. * * @param key of the specific setting to update * @param color */ protected void updateValues(String key, Integer color) { ContentResolver resolver = getContentResolver(); if (key.equals(LOW_COLOR_PREF)) { Settings.System.putInt(resolver, Settings.System.BATTERY_LIGHT_LOW_COLOR, color); } else if (key.equals(MEDIUM_COLOR_PREF)) { Settings.System.putInt(resolver, Settings.System.BATTERY_LIGHT_MEDIUM_COLOR, color); } else if (key.equals(FULL_COLOR_PREF)) { Settings.System.putInt(resolver, Settings.System.BATTERY_LIGHT_FULL_COLOR, color); } }
@Override protected void toggleState() { Context context = mView.getContext(); if (getOrientationState(context) == 0) { Settings.System.putInt( context.getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 1); } else { Settings.System.putInt( context.getContentResolver(), Settings.System.ACCELEROMETER_ROTATION, 0); } }
protected void toggleInsomnia(boolean state) { if (state) { saveUserTimeout(); Settings.System.putInt( mContext.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, neverSleep); } else { Settings.System.putInt( mContext.getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, storedUserTimeout); saveUserTimeout(); // save here incase of manual change } }
public void onClick(View v) { int id = v.getId(); if (id == R.id.ToggleButtonBoldText) { if ((tb_bold).isChecked()) { textView1.setTypeface(typefaceBold); textView2.setTypeface(typefaceBold); brtn1.setTypeface(typefaceBold); btn_textSize.setTypeface(typefaceBold); btn_textBold.setTypeface(typefaceBold); Button01.setTypeface(typefaceBold); Editor editor = mSettings.edit(); editor.putBoolean(APP_PREFERENCES_bold_text, true); editor.apply(); } else { textView1.setTypeface(typefaceRoman); textView2.setTypeface(typefaceRoman); brtn1.setTypeface(typefaceRoman); btn_textSize.setTypeface(typefaceRoman); btn_textBold.setTypeface(typefaceRoman); Button01.setTypeface(typefaceRoman); Editor editor = mSettings.edit(); editor.putBoolean(APP_PREFERENCES_bold_text, false); editor.apply(); } } else if (id == R.id.brtntoggle) { if ((tb_brtns).isChecked()) { Settings.System.putInt( getContentResolver(), SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_AUTOMATIC); refreshBrightness(-1); } else { Settings.System.putInt( getContentResolver(), SCREEN_BRIGHTNESS_MODE, SCREEN_BRIGHTNESS_MODE_MANUAL); refreshBrightness(-1); } } else if (id == R.id.Button04) { Intent settingsIntent = new Intent(android.provider.Settings.ACTION_DISPLAY_SETTINGS); startActivity(settingsIntent); overridePendingTransition(center_to_left, center_to_left2); } else if (id == R.id.ButtonTextSize) { Intent intent18 = new Intent(this, ActivityTextSize.class); startActivity(intent18); overridePendingTransition(center_to_right, center_to_right2); } else if (id == R.id.Button01) { speed_anim(); } }
/** * Increases or decreases the brightness. * * @param context */ private void toggleBrightness(Context context) { try { IPowerManager power = IPowerManager.Stub.asInterface(ServiceManager.getService("power")); if (power != null) { ContentResolver cr = context.getContentResolver(); int brightness = Settings.System.getInt(cr, Settings.System.SCREEN_BRIGHTNESS); int brightnessMode = Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL; // Only get brightness setting if available if (context .getResources() .getBoolean(com.android.internal.R.bool.config_automatic_brightness_available)) { brightnessMode = Settings.System.getInt(cr, Settings.System.SCREEN_BRIGHTNESS_MODE); } // Rotate AUTO -> MINIMUM -> DEFAULT -> MAXIMUM // Technically, not a toggle... if (brightnessMode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) { brightness = MINIMUM_BACKLIGHT; brightnessMode = Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL; } else if (brightness < DEFAULT_BACKLIGHT) { brightness = DEFAULT_BACKLIGHT; } else if (brightness < MAXIMUM_BACKLIGHT) { brightness = MAXIMUM_BACKLIGHT; } else { brightnessMode = Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC; brightness = MINIMUM_BACKLIGHT; } if (context .getResources() .getBoolean(com.android.internal.R.bool.config_automatic_brightness_available)) { // Set screen brightness mode (automatic or manual) Settings.System.putInt( context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, brightnessMode); } else { // Make sure we set the brightness if automatic mode isn't available brightnessMode = Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL; } if (brightnessMode == Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL) { power.setBacklightBrightness(brightness); Settings.System.putInt(cr, Settings.System.SCREEN_BRIGHTNESS, brightness); } } } catch (RemoteException e) { Xlog.d(TAG, "toggleBrightness: " + e); } catch (Settings.SettingNotFoundException e) { Xlog.d(TAG, "toggleBrightness: " + e); } }
@Override public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, Preference preference) { if (preference == menuButtonLocation) { Settings.System.putInt( getActivity().getContentResolver(), Settings.System.LOCKSCREEN_ENABLE_MENU_KEY, ((CheckBoxPreference) preference).isChecked() ? 1 : 0); return true; } else if (preference == mLockScreenTimeoutUserOverride) { Settings.Secure.putInt( getActivity().getContentResolver(), Settings.Secure.LOCK_SCREEN_LOCK_USER_OVERRIDE, ((CheckBoxPreference) preference).isChecked() ? 1 : 0); return true; } else if (preference == mLockscreenBattery) { Settings.System.putInt( getActivity().getContentResolver(), Settings.System.LOCKSCREEN_BATTERY, ((CheckBoxPreference) preference).isChecked() ? 1 : 0); return true; } else if (preference == mVolumeWake) { Settings.System.putInt( getActivity().getContentResolver(), Settings.System.VOLUME_WAKE_SCREEN, ((CheckBoxPreference) preference).isChecked() ? 1 : 0); return true; } else if (preference == mVolumeMusic) { Settings.System.putInt( getActivity().getContentResolver(), Settings.System.VOLUME_MUSIC_CONTROLS, ((CheckBoxPreference) preference).isChecked() ? 1 : 0); return true; } else if (keys.contains(preference.getKey())) { Log.e("RC_Lockscreens", "key: " + preference.getKey()); return Settings.System.putInt( getActivity().getContentResolver(), preference.getKey(), ((CheckBoxPreference) preference).isChecked() ? 1 : 0); } return super.onPreferenceTreeClick(preferenceScreen, preference); }
// change screen lock time out public static void setScreenTimeOut(int value) { if (Log.LOGV) { Log.v(t + ".setScreenTimeOut(): value = " + value); } Settings.System.putInt( OBS.getInstance().getContentResolver(), Settings.System.SCREEN_OFF_TIMEOUT, value); }
// change screen brightness public static void switchBrightness(int value) { if (Log.LOGV) { Log.v(t + ".switchBrightness(): value = " + value); } Settings.System.putInt( OBS.getInstance().getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, value); }
public boolean onPreferenceChange(Preference preference, Object objValue) { final String key = preference.getKey(); if (KEY_EMERGENCY_TONE.equals(key)) { try { int value = Integer.parseInt((String) objValue); Settings.System.putInt(getContentResolver(), Settings.System.EMERGENCY_TONE, value); } catch (NumberFormatException e) { Log.e(TAG, "could not persist emergency tone setting", e); } } else if (preference == mVibrateOnRing) { setPhoneVibrateSettingValue((Boolean) objValue); } else if (preference == mSilentMode) { setPhoneSilentSettingValue(objValue.toString()); } /*Begin: mzikun add for settings menu*/ else if (preference == mReverseCallMute) { handleReversalMute(preference, objValue); } else if (preference == mReverseMP3Mute) { // handleReversalMute(preference, objValue); } else if (preference == mReverseMP4Mute) { // handleReversalMute(preference, objValue); } /*End: mzikun add for settings menu*/ return true; }
/*Begin: mzikun add for settings menu*/ private void handleReversalMute(Preference preference, Object objValue) { boolean isMute = Boolean.parseBoolean(objValue.toString()); // log("handleReversalMute() display is mute " + (isMute? "true" : "false")); android.provider.Settings.System.putInt(getContentResolver(), "reversal_mute", isMute ? 1 : 0); mReverseCallMute.setSummary( isMute ? R.string.reversal_call_off_summary : R.string.reversal_call_on_summary); }
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (preference == mLockscreenOption) { int val = Integer.parseInt((String) newValue); Settings.System.putInt( getActivity().getContentResolver(), Settings.System.LOCKSCREEN_LAYOUT, val); refreshSettings(); return true; } else if (preference.getKey().startsWith("lockscreen_target")) { int index = Integer.parseInt(preference.getKey().substring(preference.getKey().lastIndexOf("_") + 1)); Log.e("ROMAN", "lockscreen target, index: " + index); if (newValue.equals("**app**")) { mCurrentCustomActivityPreference = preference; mCurrentCustomActivityString = Settings.System.LOCKSCREEN_CUSTOM_APP_ACTIVITIES[index]; mPicker.pickShortcut(); } else { Settings.System.putString( getContentResolver(), Settings.System.LOCKSCREEN_CUSTOM_APP_ACTIVITIES[index], (String) newValue); refreshSettings(); } return true; } return false; }
@Override public boolean onPreferenceChange(Preference preference, Object newValue) { String key = preference.getKey(); if (KEY_FREQUENCY_BAND.equals(key)) { try { mWifiManager.setFrequencyBand(Integer.parseInt((String) newValue), true); } catch (NumberFormatException e) { Toast.makeText( getActivity(), R.string.wifi_setting_frequency_band_error, Toast.LENGTH_SHORT) .show(); return false; } } if (KEY_SLEEP_POLICY.equals(key)) { try { String stringValue = (String) newValue; Settings.System.putInt( getContentResolver(), Settings.System.WIFI_SLEEP_POLICY, Integer.parseInt(stringValue)); updateSleepPolicySummary(preference, stringValue); } catch (NumberFormatException e) { Toast.makeText(getActivity(), R.string.wifi_setting_sleep_policy_error, Toast.LENGTH_SHORT) .show(); return false; } } return true; }
@Kroll.setProperty @Kroll.method protected void setScreenBrightness(int val) { ContentResolver contentResolver = getActivity().getContentResolver(); Settings.System.putInt( contentResolver, android.provider.Settings.System.SCREEN_BRIGHTNESS, val); }
private void setPhoneVibrateSettingValue(String value) { boolean vibeInSilent; int callsVibrateSetting; if (value.equals(VALUE_VIBRATE_UNLESS_SILENT)) { callsVibrateSetting = AudioManager.VIBRATE_SETTING_ON; vibeInSilent = false; } else if (value.equals(VALUE_VIBRATE_NEVER)) { callsVibrateSetting = AudioManager.VIBRATE_SETTING_OFF; vibeInSilent = false; } else if (value.equals(VALUE_VIBRATE_ONLY_SILENT)) { callsVibrateSetting = AudioManager.VIBRATE_SETTING_ONLY_SILENT; vibeInSilent = true; } else { // VALUE_VIBRATE_ALWAYS callsVibrateSetting = AudioManager.VIBRATE_SETTING_ON; vibeInSilent = true; } Settings.System.putInt( getContentResolver(), Settings.System.VIBRATE_IN_SILENT, vibeInSilent ? 1 : 0); // might need to switch the ringer mode from one kind of "silent" to // another if (mSilent.isChecked()) { mAudioManager.setRingerMode( vibeInSilent ? AudioManager.RINGER_MODE_VIBRATE : AudioManager.RINGER_MODE_SILENT); } mAudioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, callsVibrateSetting); }
public static void startAutoBrightness(Context context) { Settings.System.putInt( context.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS_MODE, Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC); }
void updateSleep() { ContentResolver cr = getContentResolver(); int get = android.provider.Settings.System.getInt( cr, android.provider.Settings.System.WIFI_SLEEP_POLICY, -1); int set = get; boolean wlan = settings.getBoolean(PREF_WLAN, DEFAULT_WLAN); boolean g3 = settings.getBoolean(PREF_3G, DEFAULT_3G) || settings.getBoolean(PREF_EDGE, DEFAULT_EDGE); boolean ownwifi = settings.getBoolean(PREF_OWNWIFI, DEFAULT_OWNWIFI); if (g3 && !ownwifi) { set = android.provider.Settings.System.WIFI_SLEEP_POLICY_DEFAULT; if (set != get) { Toast.makeText(this, R.string.settings_policy_default, Toast.LENGTH_LONG).show(); } } else if (wlan || ownwifi) { set = android.provider.Settings.System.WIFI_SLEEP_POLICY_NEVER; if (set != get) { Toast.makeText(this, R.string.settings_policy_never, Toast.LENGTH_LONG).show(); } } if (set != get) { android.provider.Settings.System.putInt( cr, android.provider.Settings.System.WIFI_SLEEP_POLICY, set); } }
/** 设置当前屏幕亮度值 0--255 */ public static void saveScreenBrightness(int paramInt) { try { Settings.System.putInt( App.CONTEXT.getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, paramInt); } catch (Exception localException) { localException.printStackTrace(); } }
@Override public boolean onPreferenceChange(HtcPreference preference, Object object) { Integer value = 0; if (object.toString() == "true") value = 1; Settings.System.putInt(preference.getContext().getContentResolver(), mKey, value); return true; }