@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.applications_settings, menu); MenuItem actionSwitch = menu.findItem(R.id.switch_button); mSwitch = (Switch) actionSwitch.getActionView().findViewById(R.id.color_switch); if (mSwitch != null) { mSwitch.setChecked(mSettingsHelper.isEnabled(mPackageName, mActivityName)); // Toggle the visibility of the lower panel when changed mSwitch.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { mDirty = true; Editor editor = mSettingsHelper.getSharedPreferences().edit(); String keyName = SettingsHelper.getKeyName(mPackageName, mActivityName, SettingsKeys.IS_ACTIVE); editor.putBoolean(keyName, isChecked); editor.commit(); } }); } updateMenuEntries(getApplicationContext(), menu, mPackageName); return true; }
private void onStatusBarIconTintColorButtonClicked() { Intent colorIntent = new Intent(this, ColorPickerActivity.class); Bundle bundle = new Bundle(); bundle.putString("title", getString(R.string.status_bar_icon_tint_text)); bundle.putString("key", SettingsKeys.STATUS_BAR_ICON_TINT); String mOldColor = mSettingsHelper.getIconColors(mPackageName, mActivityName, false); if (mOldColor == null) mOldColor = mSettingsHelper.getDefaultTint(Tint.STATUS_BAR, false); boolean isEnabled = mSettingsHelper.isEnabled(mPackageName, mActivityName); bundle.putString("color", mOldColor); bundle.putBoolean("enabled", isEnabled); colorIntent.putExtras(bundle); startActivityForResult(colorIntent, STATUS_BAR_ICON_TINT_COLOR_REQUEST); }