Exemplo n.º 1
0
  public boolean onPreferenceChange(Preference preference, Object newValue) {
    String fname = "";

    if (newValue != null) {
      if (preference == mGovernorPref) {
        fname = GOVERNOR;
      } else if (preference == mMinFrequencyPref) {
        fname = FREQ_MIN_FILE;
      } else if (preference == mMaxFrequencyPref) {
        fname = FREQ_MAX_FILE;
      }

      if (writeOneLine(fname, (String) newValue)) {
        if (preference == mGovernorPref) {
          mGovernorPref.setSummary(String.format(mGovernorFormat, (String) newValue));
        } else if (preference == mMinFrequencyPref) {
          mMinFrequencyPref.setSummary(
              String.format(mMinFrequencyFormat, toMHz((String) newValue)));
        } else if (preference == mMaxFrequencyPref) {
          mMaxFrequencyPref.setSummary(
              String.format(mMaxFrequencyFormat, toMHz((String) newValue)));
        }
        return true;
      } else {
        return false;
      }
    }
    return false;
  }
Exemplo n.º 2
0
 @Override
 public boolean onPreferenceChange(Preference pref, Object newValue) {
   if (KEY_AUTO_SILENCE.equals(pref.getKey())) {
     final ListPreference autoSilencePref = (ListPreference) pref;
     String delay = (String) newValue;
     updateAutoSnoozeSummary(autoSilencePref, delay);
   } else if (KEY_CLOCK_STYLE.equals(pref.getKey())) {
     final ListPreference clockStylePref = (ListPreference) pref;
     final int idx = clockStylePref.findIndexOfValue((String) newValue);
     clockStylePref.setSummary(clockStylePref.getEntries()[idx]);
   } else if (KEY_HOME_TZ.equals(pref.getKey())) {
     final ListPreference homeTimezonePref = (ListPreference) pref;
     final int idx = homeTimezonePref.findIndexOfValue((String) newValue);
     homeTimezonePref.setSummary(homeTimezonePref.getEntries()[idx]);
     notifyHomeTimeZoneChanged();
   } else if (KEY_AUTO_HOME_CLOCK.equals(pref.getKey())) {
     final boolean autoHomeClockEnabled = ((CheckBoxPreference) pref).isChecked();
     final Preference homeTimeZonePref = findPreference(KEY_HOME_TZ);
     homeTimeZonePref.setEnabled(!autoHomeClockEnabled);
     notifyHomeTimeZoneChanged();
   } else if (KEY_VOLUME_BUTTONS.equals(pref.getKey())) {
     final ListPreference volumeButtonsPref = (ListPreference) pref;
     final int index = volumeButtonsPref.findIndexOfValue((String) newValue);
     volumeButtonsPref.setSummary(volumeButtonsPref.getEntries()[index]);
   } else if (KEY_WEEK_START.equals(pref.getKey())) {
     final ListPreference weekStartPref = (ListPreference) findPreference(KEY_WEEK_START);
     final int idx = weekStartPref.findIndexOfValue((String) newValue);
     weekStartPref.setSummary(weekStartPref.getEntries()[idx]);
   }
   // Set result so DeskClock knows to refresh itself
   getActivity().setResult(RESULT_OK);
   return true;
 }
 @Override
 public void onSharedPreferenceChanged(final SharedPreferences sharedPreferences, String key) {
   if (doneLoading) {
     if (key.equals(KEY_MAX_CPU)) {
       final String value = preferences.getString(key, null);
       final String maxInMhz = (Integer.toString((Integer.parseInt(value) / 1000)) + " MHz");
       if (!sendCpu(key, value, MAX_FREQ))
         Helpers.sendMsg(getApplicationContext(), getString(R.string.toast_min_max_error01));
       else mMaxCpu.setSummary(getString(R.string.ps_set_max, maxInMhz));
     } else if (key.equals(KEY_MIN_CPU)) {
       final String value = preferences.getString(key, null);
       final String minInMhz = (Integer.toString((Integer.parseInt(value) / 1000)) + " MHz");
       if (!sendCpu(key, value, MIN_FREQ))
         Helpers.sendMsg(getApplicationContext(), getString(R.string.toast_min_max_error02));
       else mMinCpu.setSummary(getString(R.string.ps_set_min, minInMhz));
     } else if (key.equals(KEY_GOV)) {
       final String value = preferences.getString(key, null);
       if ((new CMDProcessor().su.runWaitFor("busybox echo " + value + " > " + CUR_GOV))
           .success()) mSetGov.setSummary(getString(R.string.ps_set_gov, value));
     } else if (key.equals(KEY_MINFREE)) {
       String values = preferences.getString(key, null);
       if (!values.equals(null))
         new CMDProcessor().su.runWaitFor("busybox echo " + values + " > " + MINFREE);
       mFreeMem.setSummary(getString(R.string.ps_free_memory, getMinFreeValue() + "mb"));
     }
   }
 }
Exemplo n.º 4
0
  @SuppressWarnings("deprecation")
  @Override
  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    android.preference.Preference pref = findPreference(key);

    if (key.equals(getString(R.string.key_brightness))
        || key.equals(getString(R.string.key_brightness_manual_value))) {
      ListPreference listPref = (ListPreference) findPreference(getString(R.string.key_brightness));
      if (listPref.getValue().equals(getString(R.string.value_brightness_manual))) {
        listPref.setSummary(
            listPref.getEntry()
                + " "
                + (int) (100.0f * BrightnessDialog.getBrighnessLevel(sharedPreferences, this))
                + " "
                + getString(R.string.percents));
      } else {
        listPref.setSummary(listPref.getEntry());
      }
    } else if (pref != null) {
      if (pref instanceof ListPreference) {
        ListPreference listPref = (ListPreference) pref;
        listPref.setSummary(listPref.getEntry());
      } else if (key.equals(getString(R.string.key_color))) {
        pref.setSummary(ColorDialog.getTextColorString(sharedPreferences, this));
      } else if (key.equals(getString(R.string.key_background_color))) {
        pref.setSummary(ColorDialog.getBackgroundColorString(sharedPreferences, this));
      } else if (key.equals(getString(R.string.key_city))) {
        pref.setSummary(CityDialog.getCityName(sharedPreferences, this));
      }
    }
  }
Exemplo n.º 5
0
 private void updateUIFromPreferences() {
   int var1 = System.getInt(this.mContentResolver, "psm_battery_level", 50);
   ListPreference var2 = this.mModeValueSetting;
   Context var3 = this.getApplicationContext();
   Object[] var4 = new Object[1];
   StringBuilder var5 = new StringBuilder();
   String var6 = String.valueOf(var1);
   String var7 = var5.append(var6).append("%").toString();
   var4[0] = var7;
   String var8 = var3.getString(2131232375, var4);
   var2.setSummary(var8);
   int var9 = System.getInt(this.mContentResolver, "psm_brightness_level", 10);
   ListPreference var10 = this.mBrightnessSetting;
   Context var11 = this.getApplicationContext();
   Object[] var12 = new Object[1];
   StringBuilder var13 = new StringBuilder();
   String var14 = String.valueOf(var9);
   String var15 = var13.append(var14).append("%").toString();
   var12[0] = var15;
   String var16 = var11.getString(2131232387, var12);
   var10.setSummary(var16);
   boolean var17 = this.mEnableMode.isChecked();
   this.mModeValueSetting.setEnabled(var17);
   this.mDisableWifi.setEnabled(var17);
   this.mDisableBluetooth.setEnabled(var17);
   this.mDisableGps.setEnabled(var17);
   this.mDisableSync.setEnabled(var17);
   this.mAdjustBrightness.setEnabled(var17);
   this.toggleBrightnessSetting(var17);
   this.mScreentimeout.setEnabled(var17);
 }
Exemplo n.º 6
0
  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
    if (key.equals(getString(R.string.prefSyncServerUrl_Key))) {

      mSyncServerUrlPref.setSummary(
          sharedPreferences.getString(getString(R.string.prefSyncServerUrl_Key), ""));
      mSyncServerUrlPref.setSummary(mSyncServerUrlPref.getEntry());

      ContentProviderClient client =
          getContentResolver().acquireContentProviderClient(DouiContentProvider.AUTHORITY);
      if (client != null) {
        ((DouiContentProvider) client.getLocalContentProvider()).resetDatabase();
        client.release();
        SyncAdapter.ResetUpdateDate();
        SyncAdapter.requestSync(getApplicationContext());
      }
    } else if (key.equals(getString(R.string.prefSyncRepeatTime_Key))) {
      mSyncRepeatTimePref.setSummary(
          sharedPreferences.getString(getString(R.string.prefSyncRepeatTime_Key), ""));
    } else if (key.equals(getString(R.string.prefIsSyncable_Key))) {
      loadDeviceAccounts();
      ContentResolver.setSyncAutomatically(
          new Account(mSyncAccountPref.getValue(), "com.google"),
          DouiContentProvider.AUTHORITY,
          sharedPreferences.getBoolean(key, false));
    } else if (key.equals(getString(R.string.prefSyncAccount_Key))) {
      mSyncAccountPref.setSummary(
          sharedPreferences.getString(getString(R.string.prefSyncAccount_Key), ""));
    }
  }
 @Override
 public void setSummary(CharSequence summary) {
   if (summary == null || summary.toString().isEmpty()) {
     super.setSummary("");
   } else {
     super.setSummary(summary);
   }
 }
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
      preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

      super.onCreate(savedInstanceState);
      preferences.registerOnSharedPreferenceChangeListener(this);
      addPreferencesFromResource(R.xml.performance);

      final int frequencies[] = getFrequencies();
      final String freqList[] = getMHz(frequencies);
      final String freqValues[] = getValues(frequencies);
      final String maxFreq = (Helpers.getFile(MAX_FREQ).trim());
      final String minFreq = (Helpers.getFile(MIN_FREQ).trim());
      final String maxInMhz = (Integer.toString((Integer.parseInt(maxFreq) / 1000)) + " MHz");
      final String minInMhz = (Integer.toString((Integer.parseInt(minFreq) / 1000)) + " MHz");
      final String govs[] = getAllGovs();
      final String currentGov = (Helpers.getFile(CUR_GOV).trim());

      mMaxCpu = (ListPreference) findPreference(KEY_MAX_CPU);
      mMaxCpu.setEntries(freqList);
      mMaxCpu.setEntryValues(freqValues);
      mMaxCpu.setValue(maxFreq);
      mMaxCpu.setSummary(getString(R.string.ps_set_max, maxInMhz));

      mMinCpu = (ListPreference) findPreference(KEY_MIN_CPU);
      mMinCpu.setEntries(freqList);
      mMinCpu.setEntryValues(freqValues);
      mMinCpu.setValue(minFreq);
      mMinCpu.setSummary(getString(R.string.ps_set_min, minInMhz));

      mSetGov = (ListPreference) findPreference(KEY_GOV);
      mSetGov.setEntries(govs);
      mSetGov.setEntryValues(govs);
      mSetGov.setValue(currentGov);
      mSetGov.setSummary(getString(R.string.ps_set_gov, currentGov));

      final int minFree = getMinFreeValue();
      final String values[] = getResources().getStringArray(R.array.minfree_values);
      String closestValue = preferences.getString(KEY_MINFREE, values[0]);

      if (minFree < 37) closestValue = values[0];
      else if (minFree < 62) closestValue = values[1];
      else if (minFree < 77) closestValue = values[2];
      else if (minFree < 90) closestValue = values[3];
      else closestValue = values[4];

      mFreeMem = (ListPreference) findPreference(KEY_MINFREE);
      mFreeMem.setValue(closestValue);
      mFreeMem.setSummary(getString(R.string.ps_free_memory, minFree + "mb"));

      PreferenceScreen ps = (PreferenceScreen) findPreference("volt_control");
      if (!new File(VoltageControl.MV_TABLE0).exists()) {
        ((PreferenceCategory) getPreferenceScreen().findPreference("cpu")).removePreference(ps);
      }

      doneLoading = true;
    }
 @Override
 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
   if (key.equals("pref_cameraIndex")) {
     cameraIndexPreference.setSummary(cameraIndexPreference.getEntry());
     buildResolutionListForCameraIndex();
   } else if (key.equals("pref_cameraResolution")) {
     cameraResolutionPreference.setSummary(cameraResolutionPreference.getEntry());
   }
 }
Exemplo n.º 10
0
 private void updateAutoSnoozeSummary(ListPreference listPref, String delay) {
   int i = Integer.parseInt(delay);
   if (i == -1) {
     listPref.setSummary(R.string.auto_silence_never);
   } else {
     listPref.setSummary(
         Utils.getNumberFormattedQuantityString(
             getActivity(), R.plurals.auto_silence_summary, i));
   }
 }
 public boolean onPreferenceChange(Preference preference, Object newValue) {
   if (preference == mNetTrafficState) {
     int intState = Integer.valueOf((String) newValue);
     mNetTrafficVal = setBit(mNetTrafficVal, MASK_UP, getBit(intState, MASK_UP));
     mNetTrafficVal = setBit(mNetTrafficVal, MASK_DOWN, getBit(intState, MASK_DOWN));
     Settings.System.putInt(
         getActivity().getContentResolver(),
         Settings.System.NETWORK_TRAFFIC_STATE,
         mNetTrafficVal);
     int index = mNetTrafficState.findIndexOfValue((String) newValue);
     mNetTrafficState.setSummary(mNetTrafficState.getEntries()[index]);
     updateNetworkTrafficState(index);
     return true;
   } else if (preference == mNetTrafficColor) {
     String hex = ColorPickerPreference.convertToARGB(Integer.valueOf(String.valueOf(newValue)));
     preference.setSummary(hex);
     int intHex = ColorPickerPreference.convertToColorInt(hex);
     Settings.System.putInt(getContentResolver(), Settings.System.NETWORK_TRAFFIC_COLOR, intHex);
     return true;
   } else if (preference == mNetTrafficUnit) {
     mNetTrafficVal = setBit(mNetTrafficVal, MASK_UNIT, ((String) newValue).equals("1"));
     Settings.System.putInt(
         getActivity().getContentResolver(),
         Settings.System.NETWORK_TRAFFIC_STATE,
         mNetTrafficVal);
     int index = mNetTrafficUnit.findIndexOfValue((String) newValue);
     mNetTrafficUnit.setSummary(mNetTrafficUnit.getEntries()[index]);
     return true;
   } else if (preference == mNetTrafficPeriod) {
     int intState = Integer.valueOf((String) newValue);
     mNetTrafficVal = setBit(mNetTrafficVal, MASK_PERIOD, false) + (intState << 16);
     Settings.System.putInt(
         getActivity().getContentResolver(),
         Settings.System.NETWORK_TRAFFIC_STATE,
         mNetTrafficVal);
     int index = mNetTrafficPeriod.findIndexOfValue((String) newValue);
     mNetTrafficPeriod.setSummary(mNetTrafficPeriod.getEntries()[index]);
     return true;
   } else if (preference == mNetTrafficAutohide) {
     boolean value = (Boolean) newValue;
     Settings.System.putInt(
         getActivity().getContentResolver(),
         Settings.System.NETWORK_TRAFFIC_AUTOHIDE,
         value ? 1 : 0);
     return true;
   } else if (preference == mNetTrafficAutohideThreshold) {
     int threshold = (Integer) newValue;
     Settings.System.putInt(
         getActivity().getContentResolver(),
         Settings.System.NETWORK_TRAFFIC_AUTOHIDE_THRESHOLD,
         threshold * 1);
     return true;
   }
   return false;
 }
Exemplo n.º 12
0
 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
   // Let's do something a preference values changes
   /*
   if (key.equals(KEY_CHECKBOX_PREFERENCE)) {
     mCheckBoxPreference.setSummary(sharedPreferences.getBoolean(key, false) ? "Disable this setting" : "Enable this setting");
   }
   else*/
   if (key.equals(PrefsHelper.PREF_PORTRAIT_SCALING_MODE)) {
     mPrefPortraitMode.setSummary("Current value is '" + mPrefPortraitMode.getEntry() + "'");
   } else if (key.equals(PrefsHelper.PREF_LANDSCAPE_SCALING_MODE)) {
     mPrefLandsMode.setSummary("Current value is '" + mPrefLandsMode.getEntry() + "'");
   }
   if (key.equals(PrefsHelper.PREF_PORTRAIT_FILTER_TYPE)) {
     mPrefPortraitFilterType.setSummary(
         "Current value is '" + mPrefPortraitFilterType.getEntry() + "'");
   } else if (key.equals(PrefsHelper.PREF_LANDSCAPE_FILTER_TYPE)) {
     mPrefLandsFilterType.setSummary("Current value is '" + mPrefLandsFilterType.getEntry() + "'");
   } else if (key.equals(PrefsHelper.PREF_CONTROLLER_TYPE)) {
     mPrefControllerType.setSummary("Current values is '" + mPrefControllerType.getEntry() + "'");
   } else if (key.equals(PrefsHelper.PREF_GLOBAL_VIDEO_RENDER_MODE)) {
     mPrefGlobalVideoRenderMode.setSummary(
         "Current value is '" + mPrefGlobalVideoRenderMode.getEntry() + "'");
   } else if (key.equals(PrefsHelper.PREF_INPUT_EXTERNAL)) {
     mPrefExtInput.setSummary("Current value is '" + mPrefExtInput.getEntry() + "'");
   } else if (key.equals(PrefsHelper.PREF_ANALOG_DZ)) {
     mPrefAnalogDZ.setSummary("Current value is '" + mPrefAnalogDZ.getEntry() + "'");
   } else if (key.equals(PrefsHelper.PREF_TILT_DZ)) {
     mPrefTiltDZ.setSummary("Current value is '" + mPrefTiltDZ.getEntry() + "'");
   }
 }
  @SuppressWarnings("deprecation")
  @Override
  protected void onResume() {
    super.onResume();

    cameraIndexPreference.setSummary(cameraIndexPreference.getEntry());
    cameraResolutionPreference.setSummary(cameraResolutionPreference.getEntry());

    // Register for changes.
    getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
  }
Exemplo n.º 14
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mGovernorFormat = getString(R.string.cpu_governors_summary);
    mMinFrequencyFormat = getString(R.string.cpu_min_freq_summary);
    mMaxFrequencyFormat = getString(R.string.cpu_max_freq_summary);

    String[] availableGovernors = readOneLine(GOVERNORS_LIST_FILE).split(" ");
    String[] availableFrequencies = new String[0];
    String availableFrequenciesLine = readOneLine(FREQ_LIST_FILE);
    if (availableFrequenciesLine != null)
      availableFrequencies = availableFrequenciesLine.split(" ");
    String[] frequencies;
    String temp;

    frequencies = new String[availableFrequencies.length];
    for (int i = 0; i < frequencies.length; i++) {
      frequencies[i] = toMHz(availableFrequencies[i]);
    }

    setTitle(R.string.cpu_title);
    addPreferencesFromResource(R.xml.cpu_settings);

    PreferenceScreen PrefScreen = getPreferenceScreen();

    temp = readOneLine(GOVERNOR);

    mGovernorPref = (ListPreference) PrefScreen.findPreference(GOV_PREF);
    mGovernorPref.setEntryValues(availableGovernors);
    mGovernorPref.setEntries(availableGovernors);
    mGovernorPref.setValue(temp);
    mGovernorPref.setSummary(String.format(mGovernorFormat, temp));
    mGovernorPref.setOnPreferenceChangeListener(this);

    temp = readOneLine(FREQ_MIN_FILE);

    mMinFrequencyPref = (ListPreference) PrefScreen.findPreference(MIN_FREQ_PREF);
    mMinFrequencyPref.setEntryValues(availableFrequencies);
    mMinFrequencyPref.setEntries(frequencies);
    mMinFrequencyPref.setValue(temp);
    mMinFrequencyPref.setSummary(String.format(mMinFrequencyFormat, toMHz(temp)));
    mMinFrequencyPref.setOnPreferenceChangeListener(this);

    temp = readOneLine(FREQ_MAX_FILE);

    mMaxFrequencyPref = (ListPreference) PrefScreen.findPreference(MAX_FREQ_PREF);
    mMaxFrequencyPref.setEntryValues(availableFrequencies);
    mMaxFrequencyPref.setEntries(frequencies);
    mMaxFrequencyPref.setValue(temp);
    mMaxFrequencyPref.setSummary(String.format(mMaxFrequencyFormat, toMHz(temp)));
    mMaxFrequencyPref.setOnPreferenceChangeListener(this);
  }
Exemplo n.º 15
0
  public boolean onPreferenceChange(Preference var1, Object var2) {
    ListPreference var3 = this.mModeValueSetting;
    boolean var15;
    if (var1.equals(var3)) {
      int var4 = Log.d("PowerSavingModeSettings", "set battery level is changed");
      int var5 = Integer.parseInt((String) var2);
      System.putInt(this.mContentResolver, "psm_battery_level", var5);
      ListPreference var7 = this.mModeValueSetting;
      Context var8 = this.getApplicationContext();
      Object[] var9 = new Object[1];
      StringBuilder var10 = new StringBuilder();
      String var11 = var2.toString();
      String var12 = var10.append(var11).append("%").toString();
      var9[0] = var12;
      String var13 = var8.getString(2131232375, var9);
      var7.setSummary(var13);
      Intent var14 = new Intent("android.settings.POWERSAVING_CHANGED");
      this.sendBroadcast(var14);
      var15 = true;
    } else {
      ListPreference var16 = this.mBrightnessSetting;
      if (var1.equals(var16)) {
        int var17 = Log.d("PowerSavingModeSettings", "Brightness level is changed");
        int var18 = Integer.parseInt((String) var2);
        System.putInt(this.mContentResolver, "psm_brightness_level", var18);
        ListPreference var20 = this.mBrightnessSetting;
        Context var21 = this.getApplicationContext();
        Object[] var22 = new Object[1];
        StringBuilder var23 = new StringBuilder();
        String var24 = var2.toString();
        String var25 = var23.append(var24).append("%").toString();
        var22[0] = var25;
        String var26 = var21.getString(2131232387, var22);
        var20.setSummary(var26);
        var15 = true;
      } else {
        ListPreference var27 = this.mScreentimeout;
        if (var1.equals(var27)) {
          int var28 = Log.d("PowerSavingModeSettings", "Screentimeout is changed");
          int var29 = Integer.parseInt((String) var2);
          System.putInt(this.mContentResolver, "psm_screen_timeout", var29);
          var15 = true;
        } else {
          var15 = false;
        }
      }
    }

    return var15;
  }
 @Override
 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
   if (key.equals("host")) {
     hostPref.setSummary(sharedPreferences.getString(key, ""));
   } else if (key.equals("port")) {
     portPref.setSummary(sharedPreferences.getString("port", "8001"));
   } else if (key.equals("password")) {
     String tmp = sharedPreferences.getString("password", null);
     if (tmp == null || tmp.equals("")) {
       passPref.setSummary("None Set");
     } else {
       passPref.setSummary("******");
     }
   } else if (key.equals("text_size")) {
     textSizePref.setSummary(sharedPreferences.getString("text_size", "10"));
   } else if (key.equals("timestamp_format")) {
     timestampformatPref.setSummary(sharedPreferences.getString("timestamp_format", "HH:mm:ss"));
   } else if (key.equals("stunnel_cert")) {
     stunnelCert.setSummary(
         sharedPreferences.getString("stunnel_cert", "/sdcard/weechat/client.p12"));
   } else if (key.equals("stunnel_pass")) {
     String tmp = sharedPreferences.getString("stunnel_pass", null);
     if (tmp == null || tmp.equals("")) {
       stunnelPass.setSummary("None Set");
     } else {
       stunnelPass.setSummary("******");
     }
   } else if (key.equals("ssh_host")) {
     sshHostPref.setSummary(sharedPreferences.getString(key, ""));
   } else if (key.equals("ssh_user")) {
     sshUserPref.setSummary(sharedPreferences.getString(key, ""));
   } else if (key.equals("ssh_port")) {
     sshPortPref.setSummary(sharedPreferences.getString(key, "22"));
   } else if (key.equals("ssh_pass")) {
     String tmp = sharedPreferences.getString("ssh_pass", null);
     if (tmp == null || tmp.equals("")) {
       sshPassPref.setSummary("None Set");
     } else {
       sshPassPref.setSummary("******");
     }
   } else if (key.equals("ssh_keyfile")) {
     sshKeyFilePref.setSummary(sharedPreferences.getString(key, "/sdcard/weechat/sshkey.id_rsa"));
   } else if (key.equals("prefix_align")) {
     prefixPref.setSummary(prefixPref.getEntry());
   } else if (key.equals("connection_type")) {
     connectionTypePref.setSummary(connectionTypePref.getEntry());
   }
 }
Exemplo n.º 17
0
 public void setListPreferenceSummary(ListPreference mListPreference) {
   if (mListPreference == mCameraChange) {
     if (0 == Integer.parseInt(mListPreference.getValue())) {
       mListPreference.setSummary(R.string.Hongmi_camera);
     } else {
       mListPreference.setSummary(R.string.CP_camera);
     }
   }
   if (mListPreference == mSwitchVold) {
     if (0 == Integer.parseInt(mListPreference.getValue())) {
       mListPreference.setSummary(R.string.External_sdcard);
     } else {
       mListPreference.setSummary(R.string.Internal_sdcard);
     }
   }
 }
 private void updateLcdDensityPreferenceDescription(int currentDensity) {
   final int summaryResId =
       currentDensity == getDefaultDensity()
           ? R.string.lcd_density_default_value_format
           : R.string.lcd_density_value_format;
   mLcdDensityPreference.setSummary(getString(summaryResId, currentDensity));
 }
  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));
    }
  }
  private void updateRecentsLocation(int value) {
    ContentResolver resolver = getContentResolver();
    Resources res = getResources();
    int summary = -1;

    Settings.System.putInt(resolver, Settings.System.RECENTS_CLEAR_ALL_LOCATION, value);

    if (value == 0) {
      Settings.System.putInt(resolver, Settings.System.RECENTS_CLEAR_ALL_LOCATION, 0);
      summary = R.string.recents_clear_all_location_top_right;
    } else if (value == 1) {
      Settings.System.putInt(resolver, Settings.System.RECENTS_CLEAR_ALL_LOCATION, 1);
      summary = R.string.recents_clear_all_location_top_left;
    } else if (value == 2) {
      Settings.System.putInt(resolver, Settings.System.RECENTS_CLEAR_ALL_LOCATION, 2);
      summary = R.string.recents_clear_all_location_top_center;
    } else if (value == 3) {
      Settings.System.putInt(resolver, Settings.System.RECENTS_CLEAR_ALL_LOCATION, 3);
      summary = R.string.recents_clear_all_location_bottom_right;
    } else if (value == 4) {
      Settings.System.putInt(resolver, Settings.System.RECENTS_CLEAR_ALL_LOCATION, 4);
      summary = R.string.recents_clear_all_location_bottom_left;
    } else if (value == 5) {
      Settings.System.putInt(resolver, Settings.System.RECENTS_CLEAR_ALL_LOCATION, 5);
      summary = R.string.recents_clear_all_location_bottom_center;
    }
    if (mRecentsClearAllLocation != null && summary != -1) {
      mRecentsClearAllLocation.setSummary(res.getString(summary));
    }
  }
  // updateState in fact updates the UI to reflect the system state
  private void updateState(boolean force) {
    final int ringerMode = mAudioManager.getRingerMode();

    // NB: in the UI we now simply call this "silent mode". A separate
    // setting controls whether we're in RINGER_MODE_SILENT or
    // RINGER_MODE_VIBRATE.
    final boolean silentOrVibrateMode = ringerMode != AudioManager.RINGER_MODE_NORMAL;

    if (silentOrVibrateMode != mSilent.isChecked() || force) {
      mSilent.setChecked(silentOrVibrateMode);
    }

    String phoneVibrateSetting = getPhoneVibrateSettingValue();

    if (!phoneVibrateSetting.equals(mVibrate.getValue()) || force) {
      mVibrate.setValue(phoneVibrateSetting);
    }
    mVibrate.setSummary(mVibrate.getEntry());

    int silentModeStreams =
        Settings.System.getInt(
            getContentResolver(), Settings.System.MODE_RINGER_STREAMS_AFFECTED, 0);
    boolean isAlarmInclSilentMode = (silentModeStreams & (1 << AudioManager.STREAM_ALARM)) != 0;
    mSilent.setSummary(
        isAlarmInclSilentMode
            ? R.string.silent_mode_incl_alarm_summary
            : R.string.silent_mode_summary);
  }
  public void refreshSettings() {

    int lockscreenTargets =
        Settings.System.getInt(getContentResolver(), Settings.System.LOCKSCREEN_LAYOUT, 2);

    PreferenceGroup targetGroup = (PreferenceGroup) findPreference("lockscreen_targets");
    targetGroup.removeAll();

    // quad only uses first 4, but we make the system think there's 6 for the alternate layout
    // so only show 4
    if (lockscreenTargets == 6) {
      Settings.System.putString(
          getContentResolver(), Settings.System.LOCKSCREEN_CUSTOM_APP_ACTIVITIES[4], "**null**");
      Settings.System.putString(
          getContentResolver(), Settings.System.LOCKSCREEN_CUSTOM_APP_ACTIVITIES[5], "**null**");
      lockscreenTargets = 4;
    }

    for (int i = 0; i < lockscreenTargets; i++) {
      ListPreference p = new ListPreference(getActivity());
      String dialogTitle =
          String.format(getResources().getString(R.string.custom_app_n_dialog_title), i + 1);
      ;
      p.setDialogTitle(dialogTitle);
      p.setEntries(R.array.lockscreen_choice_entries);
      p.setEntryValues(R.array.lockscreen_choice_values);
      String title = String.format(getResources().getString(R.string.custom_app_n), i + 1);
      p.setTitle(title);
      p.setKey("lockscreen_target_" + i);
      p.setSummary(getProperSummary(i));
      p.setOnPreferenceChangeListener(this);
      targetGroup.addPreference(p);
    }
  }
Exemplo n.º 23
0
  private void setUpSettingsSummary() {
    ListPreference serverConnection = getPreference(R.string.preference_key_server_connection);
    Preference applicationVersion = getPreference(R.string.preference_key_about_version);

    serverConnection.setSummary(getServerConnectionSummary());
    applicationVersion.setSummary(getApplicationVersionSummary());
  }
Exemplo n.º 24
0
  private void setLanguage(@NonNull LanguageData lang) {
    Config.setTtsEnabled(true);
    TtsPlayer.INSTANCE.setLanguage(lang);
    mPrefLanguages.setSummary(lang.name);

    update();
  }
  // updateState in fact updates the UI to reflect the system state
  private void updateState(boolean force) {
    if (getActivity() == null) return;

    mRingMode.setValue(getPhoneRingModeSettingValue());
    mRingMode.setSummary(mRingMode.getEntry());
    updateQuietHoursSummary();
  }
 @Override
 public void updateSummary(
     @NonNull Preference preference, @NonNull Config.Option option, @NonNull Object value) {
   int pos = -(int) value + 2;
   ListPreference cbp = (ListPreference) preference;
   cbp.setSummary(cbp.getEntries()[pos]);
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (getPreferenceManager() != null) {
      addPreferencesFromResource(R.xml.operator_preferences);
      PreferenceScreen prefSet = getPreferenceScreen();

      mOperatorDisplayStyle = (ListPreference) prefSet.findPreference(OPERATOR_STYLE);
      mOperatorDisplayStyle.setOnPreferenceChangeListener(this);

      mOperatorDisplayText = (EditTextPreference) prefSet.findPreference(OPERATOR_TEXT);
      mOperatorDisplayText.setOnPreferenceChangeListener(this);

      if (mOperatorDisplayText != null) {
        String operLabel = mOperatorDisplayText.getText();
        if (TextUtils.isEmpty(operLabel)) {
          mOperatorDisplayText.setSummary(getString(R.string.operator_display_summary));
        } else {
          mOperatorDisplayText.setSummary(mOperatorDisplayText.getText());
        }
      }

      int index = Settings.System.getInt(getContentResolver(), CARRIER_LABEL_TYPE, 0);
      index = index > (mOperatorDisplayStyle.getEntries().length - 1) ? 0 : index;
      mOperatorDisplayStyle.setSummary(mOperatorDisplayStyle.getEntries()[index]);

      mOperatorDisplayText.setEnabled(index == 3);
    }
  }
  private void updateGlowTimesSummary() {
    int resId;
    String combinedTime =
        Settings.System.getString(mContentRes, Settings.System.NAVIGATION_BAR_GLOW_DURATION[1])
            + "|"
            + Settings.System.getString(
                mContentRes, Settings.System.NAVIGATION_BAR_GLOW_DURATION[0]);

    String[] glowArray = getResources().getStringArray(R.array.glow_times_values);

    if (glowArray[0].equals(combinedTime)) {
      resId = R.string.glow_times_off;
      mGlowTimes.setValueIndex(0);
    } else if (glowArray[1].equals(combinedTime)) {
      resId = R.string.glow_times_superquick;
      mGlowTimes.setValueIndex(1);
    } else if (glowArray[2].equals(combinedTime)) {
      resId = R.string.glow_times_quick;
      mGlowTimes.setValueIndex(2);
    } else {
      resId = R.string.glow_times_normal;
      mGlowTimes.setValueIndex(3);
    }
    mGlowTimes.setSummary(getResources().getString(resId));
  }
  @Override
  public boolean onPreferenceChange(Preference preference, Object newValue) {
    String prefName = preference.getKey();
    if (prefName != null && prefName.equals("privacy.masterpassword.enabled")) {
      showDialog(
          (Boolean) newValue ? DIALOG_CREATE_MASTER_PASSWORD : DIALOG_REMOVE_MASTER_PASSWORD);
      return false;
    } else if (prefName != null && prefName.equals("browser.menu.showCharacterEncoding")) {
      setCharEncodingState(((String) newValue).equals("true"));
    }

    setPreference(prefName, newValue);
    if (preference instanceof ListPreference) {
      // We need to find the entry for the new value
      int newIndex = ((ListPreference) preference).findIndexOfValue((String) newValue);
      CharSequence newEntry = ((ListPreference) preference).getEntries()[newIndex];
      ((ListPreference) preference).setSummary(newEntry);
    } else if (preference instanceof LinkPreference) {
      finish();
    } else if (preference instanceof FontSizePreference) {
      final FontSizePreference fontSizePref = (FontSizePreference) preference;
      fontSizePref.setSummary(fontSizePref.getSavedFontSizeName());
    }
    return true;
  }
  @Override
  protected void onResume() {
    super.onResume();
    sharedPreferences.registerOnSharedPreferenceChangeListener(this);

    hostPref.setSummary(sharedPreferences.getString("host", ""));
    portPref.setSummary(sharedPreferences.getString("port", "8001"));
    textSizePref.setSummary(sharedPreferences.getString("text_size", "10"));
    updateBufferFontSummary();

    timestampformatPref.setSummary(sharedPreferences.getString("timestamp_format", "HH:mm:ss"));
    stunnelCert.setSummary(sharedPreferences.getString("stunnel_cert", "Not Set"));

    sshHostPref.setSummary(sharedPreferences.getString("ssh_host", ""));
    sshUserPref.setSummary(sharedPreferences.getString("ssh_user", ""));
    sshPortPref.setSummary(sharedPreferences.getString("ssh_port", "22"));
    sshKeyFilePref.setSummary(sharedPreferences.getString("ssh_keyfile", "Not Set"));

    prefixPref.setSummary(prefixPref.getEntry());
    connectionTypePref.setSummary(connectionTypePref.getEntry());

    if (pingEnabledPref.isChecked()) {
      pingPreferences.setSummary("Enabled");
    } else {
      pingPreferences.setSummary("Disabled");
    }

    String tmp;
    tmp = sharedPreferences.getString("password", null);
    if (tmp == null || tmp.equals("")) {
      passPref.setSummary("None Set");
    } else {
      passPref.setSummary("******");
    }
    tmp = sharedPreferences.getString("stunnel_pass", null);
    if (tmp == null || tmp.equals("")) {
      stunnelPass.setSummary("None Set");
    } else {
      stunnelPass.setSummary("******");
    }
    tmp = sharedPreferences.getString("ssh_pass", null);
    if (tmp == null || tmp.equals("")) {
      sshPassPref.setSummary("None Set");
    } else {
      sshPassPref.setSummary("******");
    }
  }