// 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();
  }
Ejemplo n.º 2
0
        @Override
        public boolean onPreferenceChange(Preference preference, Object value) {
          String stringValue = value.toString();

          if (preference instanceof ListPreference) {
            ListPreference listPreference = (ListPreference) preference;
            int index = listPreference.findIndexOfValue(stringValue);

            preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
          } else if (preference instanceof RingtonePreference) {
            if (TextUtils.isEmpty(stringValue)) {
              preference.setSummary(R.string.pref_ringtone_silent);
            } else {
              Ringtone ringtone =
                  RingtoneManager.getRingtone(preference.getContext(), Uri.parse(stringValue));

              if (ringtone == null) {
                preference.setSummary(null);
              } else {
                String name = ringtone.getTitle(preference.getContext());
                preference.setSummary(name);
              }
            }
          } else {
            preference.setSummary(stringValue);
          }
          return true;
        }
Ejemplo n.º 3
0
  protected void onPrepareDialogBuilder(android.app.AlertDialog.Builder builder) {
    // hook into the builder to refresh the list
    BluetoothAdapter bta = BluetoothAdapter.getDefaultAdapter();
    Set<BluetoothDevice> pairedDevices = (bta != null) ? bta.getBondedDevices() : null;
    if (pairedDevices == null) {
      super.onPrepareDialogBuilder(builder);
      return;
    }

    CharSequence[] entries = new CharSequence[pairedDevices.size()];
    CharSequence[] entryValues = new CharSequence[pairedDevices.size()];
    int i = 0;
    for (BluetoothDevice dev : pairedDevices) {
      if (dev.getAddress() != null) {
        entries[i] = dev.getName();
        if (entries[i] == null) entries[i] = "(null)";
        entryValues[i] = dev.getAddress();
        i++;
      }
    }
    setEntries(entries);
    setEntryValues(entryValues);

    super.onPrepareDialogBuilder(builder);
  }
  private boolean IsFormValid() {
    CheckBoxPreference chkEnabled = (CheckBoxPreference) findPreference("opengts_enabled");
    EditTextPreference txtOpenGTSServer = (EditTextPreference) findPreference("opengts_server");
    EditTextPreference txtOpenGTSServerPort =
        (EditTextPreference) findPreference("opengts_server_port");
    ListPreference txtOpenGTSCommunicationMethod =
        (ListPreference) findPreference("opengts_server_communication_method");
    EditTextPreference txtOpenGTSServerPath =
        (EditTextPreference) findPreference("autoopengts_server_path");
    EditTextPreference txtOpenGTSDeviceId =
        (EditTextPreference) findPreference("opengts_device_id");

    return !chkEnabled.isChecked()
        || txtOpenGTSServer.getText() != null
            && txtOpenGTSServer.getText().length() > 0
            && txtOpenGTSServerPort.getText() != null
            && isNumeric(txtOpenGTSServerPort.getText())
            && txtOpenGTSCommunicationMethod.getValue() != null
            && txtOpenGTSCommunicationMethod.getValue().length() > 0
            && txtOpenGTSDeviceId.getText() != null
            && txtOpenGTSDeviceId.getText().length() > 0
            && URLUtil.isValidUrl(
                "http://"
                    + txtOpenGTSServer.getText()
                    + ":"
                    + txtOpenGTSServerPort.getText()
                    + txtOpenGTSServerPath.getText());
  }
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.recents_panel_settings);

    PreferenceScreen prefSet = getPreferenceScreen();
    ContentResolver resolver = getActivity().getContentResolver();
    PackageManager pm = getPackageManager();

    mRecentsClearAll = (SwitchPreference) prefSet.findPreference(SHOW_CLEAR_ALL_RECENTS);
    mRecentsClearAll.setChecked(
        Settings.System.getIntForUser(
                resolver, Settings.System.SHOW_CLEAR_ALL_RECENTS, 1, UserHandle.USER_CURRENT)
            == 1);
    mRecentsClearAll.setOnPreferenceChangeListener(this);

    mRecentsClearAllLocation = (ListPreference) prefSet.findPreference(RECENTS_CLEAR_ALL_LOCATION);
    int location =
        Settings.System.getIntForUser(
            resolver, Settings.System.RECENTS_CLEAR_ALL_LOCATION, 3, UserHandle.USER_CURRENT);
    mRecentsClearAllLocation.setValue(String.valueOf(location));
    mRecentsClearAllLocation.setOnPreferenceChangeListener(this);
    updateRecentsLocation(location);

    mOmniSwitch = (Preference) prefSet.findPreference(KEY_OMNISWITCH);
    if (!Helpers.isPackageInstalled(OMNISWITCH_PACKAGE_NAME, pm)) {
      prefSet.removePreference(mOmniSwitch);
    }
  }
        @Override
        public boolean onPreferenceChange(Preference preference, Object value) {
          String stringValue = value.toString();

          if (preference instanceof ListPreference) {
            // For list preferences, look up the correct display value in
            // the preference's 'entries' list.
            ListPreference listPreference = (ListPreference) preference;
            int index = listPreference.findIndexOfValue(stringValue);
            // Set the summary to reflect the new value.
            preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
          } else if (preference instanceof CheckBoxPreference) {
            // Trigger the listener immediately with the preference's
            // current value.
            if (preference.getKey().equals("prefHumidityOnTop")) {
              preference.setSummary(
                  Boolean.valueOf(stringValue)
                      ? R.string.pref_on_top_humidity_summary_yes
                      : R.string.pref_on_top_humidity_summary_no);
            }
          } else if (preference instanceof EditTextPreference) {
          } else {
            // For all other preferences, set the summary to the value's
            // simple string representation.
            preference.setSummary(stringValue);
          }
          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"));
     }
   }
 }
Ejemplo n.º 8
0
  private void enableAll() {
    hostText.setEnabled(true);

    if (!isPACCheck.isChecked()) {
      portText.setEnabled(true);
      proxyTypeList.setEnabled(true);
    }

    bypassAddrs.setEnabled(true);

    if (isAuthCheck.isChecked()) {
      userText.setEnabled(true);
      passwordText.setEnabled(true);
      isNTLMCheck.setEnabled(true);
      if (isNTLMCheck.isChecked()) domainText.setEnabled(true);
    }
    if ("https".equals(proxyTypeList.getValue())) {
      certificateText.setEnabled(true);
    }
    if (!isAutoSetProxyCheck.isChecked()) {
      proxyedApps.setEnabled(true);
      isBypassAppsCheck.setEnabled(true);
    }
    if (isAutoConnectCheck.isChecked()) ssidList.setEnabled(true);

    isDNSProxyCheck.setEnabled(true);
    profileList.setEnabled(true);
    isAutoSetProxyCheck.setEnabled(true);
    isAuthCheck.setEnabled(true);
    isAutoConnectCheck.setEnabled(true);
    isPACCheck.setEnabled(true);
  }
  @Override
  public boolean onPreferenceChange(Preference preference, Object newValue) {
    String stringValue = newValue.toString();
    String key = preference.getKey();

    if (preference instanceof ListPreference) {
      // For list preferences, look up the correct display value in
      // the preference's 'entries' list (since they have separate labels/values).
      ListPreference listPreference = (ListPreference) preference;
      int prefIndex = listPreference.findIndexOfValue(stringValue);
      if (prefIndex >= 0) {
        preference.setSummary(listPreference.getEntries()[prefIndex]);
      }
    } else if (key.equals(getString(R.string.pref_location_key))) {
      @SunshineSyncAdapter.LocationStatus int status = Utility.getLocationStatus(this);
      switch (status) {
        case SunshineSyncAdapter.LOCATION_STATUS_OK:
          preference.setSummary(stringValue);
          break;
        case SunshineSyncAdapter.LOCATION_STATUS_UNKNOWN:
          preference.setSummary(getString(R.string.pref_location_unknown_description, newValue));
          break;
        case SunshineSyncAdapter.LOCATION_STATUS_INVALID:
          preference.setSummary(getString(R.string.pref_location_error_description, newValue));
          break;
        default:
          preference.setSummary(stringValue);
      }
    } else {
      // For other preferences, set the summary to the value's simple string representation.
      preference.setSummary(stringValue);
    }
    return true;
  }
  private void loadSettings() {
    mPreferences = Preferences.getPreferences(getActivity());
    mAutoAdvance = (ListPreference) findPreference(PREFERENCE_KEY_AUTO_ADVANCE);
    mAutoAdvance.setValueIndex(mPreferences.getAutoAdvanceDirection());
    mAutoAdvance.setOnPreferenceChangeListener(this);

    mTextZoom = (ListPreference) findPreference(PREFERENCE_KEY_TEXT_ZOOM);
    if (mTextZoom != null) {
      mTextZoom.setValueIndex(mPreferences.getTextZoom());
      mTextZoom.setOnPreferenceChangeListener(this);
    }

    final CheckBoxPreference convListIcon =
        (CheckBoxPreference) findPreference(PREFERENCE_KEY_CONV_LIST_ICON);
    if (convListIcon != null) {
      final boolean showSenderImage = mMailPrefs.getShowSenderImages();
      convListIcon.setChecked(showSenderImage);
      convListIcon.setOnPreferenceChangeListener(this);
    }

    mConfirmDelete = (CheckBoxPreference) findPreference(PREFERENCE_KEY_CONFIRM_DELETE);
    mConfirmSend = (CheckBoxPreference) findPreference(PREFERENCE_KEY_CONFIRM_SEND);
    mSwipeDelete =
        (CheckBoxPreference) findPreference(MailPrefs.PreferenceKeys.CONVERSATION_LIST_SWIPE);
    mSwipeDelete.setChecked(mMailPrefs.getIsConversationListSwipeEnabled());

    final CheckBoxPreference replyAllPreference =
        (CheckBoxPreference) findPreference(MailPrefs.PreferenceKeys.DEFAULT_REPLY_ALL);
    replyAllPreference.setChecked(mMailPrefs.getDefaultReplyAll());
    replyAllPreference.setOnPreferenceChangeListener(this);

    reloadDynamicSummaries();
  }
 @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 boolean onPreferenceChange(Preference preference, Object newValue) {
          if (preference instanceof ListPreference && newValue instanceof String) {
            final ListPreference listPreference = (ListPreference) preference;
            final int index = listPreference.findIndexOfValue((String) newValue);
            final CharSequence[] entries = listPreference.getEntries();

            if (index >= 0 && index < entries.length) {
              preference.setSummary(entries[index].toString().replaceAll("%", "%%"));
            } else {
              preference.setSummary("");
            }
          }

          final String key = preference.getKey();
          if (getString(R.string.pref_resume_talkback_key).equals(key)) {
            final String oldValue =
                SharedPreferencesUtils.getStringPref(
                    mPrefs,
                    getResources(),
                    R.string.pref_resume_talkback_key,
                    R.string.pref_resume_talkback_default);
            if (!newValue.equals(oldValue)) {
              // Reset the suspend warning dialog when the resume
              // preference changes.
              SharedPreferencesUtils.putBooleanPref(
                  mPrefs, getResources(), R.string.pref_show_suspension_confirmation_dialog, true);
            }
          }

          return true;
        }
    @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);

      // Load the preferences from an XML resource
      addPreferencesFromResource(R.xml.prefs_statusbar_toggles);

      mEnabledToggles = findPreference(PREF_ENABLE_TOGGLES);

      mBrightnessLocation = (ListPreference) findPreference(PREF_BRIGHTNESS_LOC);
      mBrightnessLocation.setOnPreferenceChangeListener(this);
      mBrightnessLocation.setValue(
          Integer.toString(
              Settings.System.getInt(
                  getActivity().getContentResolver(),
                  Settings.System.STATUSBAR_TOGGLES_BRIGHTNESS_LOC,
                  1)));

      mToggleStyle = (ListPreference) findPreference(PREF_TOGGLES_STYLE);
      mToggleStyle.setOnPreferenceChangeListener(this);
      mToggleStyle.setValue(
          Integer.toString(
              Settings.System.getInt(
                  getActivity().getContentResolver(), Settings.System.STATUSBAR_TOGGLES_STYLE, 3)));

      mAlternateButtonLayout = (CheckBoxPreference) findPreference(PREF_ALT_BUTTON_LAYOUT);
      mAlternateButtonLayout.setChecked(
          Settings.System.getInt(
                  getContentResolver(), Settings.System.STATUSBAR_TOGGLES_USE_BUTTONS, 0)
              == 1);
    }
Ejemplo n.º 14
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);
 }
  @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);
    }
  }
Ejemplo n.º 16
0
 protected void updateSummaries() {
   // for all text preferences, set summary as current database value
   for (String key : mPref.mValues.keySet()) {
     Preference pref = this.findPreference(key);
     String value = null;
     if (pref == null) {
       continue;
     } else if (pref instanceof CheckBoxPreference) {
       continue;
     } else if (pref instanceof ListPreference) {
       ListPreference lp = (ListPreference) pref;
       value = lp.getEntry() != null ? lp.getEntry().toString() : "";
     } else {
       value = this.mPref.getString(key, "");
     }
     // update summary
     if (!mPref.mSummaries.containsKey(key)) {
       CharSequence s = pref.getSummary();
       mPref.mSummaries.put(key, s != null ? pref.getSummary().toString() : null);
     }
     String summ = mPref.mSummaries.get(key);
     if (summ != null && summ.contains("XXX")) {
       pref.setSummary(summ.replace("XXX", value));
     } else {
       pref.setSummary(value);
     }
   }
 }
Ejemplo n.º 17
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;
  }
  // 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);
  }
Ejemplo n.º 19
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());
  }
        @Override
        public boolean onPreferenceChange(Preference preference, Object value) {
          String stringValue = value.toString();

          if (preference instanceof ListPreference) {
            ListPreference listPreference = (ListPreference) preference;
            int index = listPreference.findIndexOfValue(stringValue);
            preference.setSummary(index >= 0 ? listPreference.getEntries()[index] : null);
          } else {
            preference.setSummary(stringValue);
          }

          // detect errors
          if (preference.getKey().equals("sos_uri")) {
            try {
              URL url = new URL(value.toString());
              if (!url.getProtocol().equals("http") && !url.getProtocol().equals("https"))
                throw new Exception("SOS URL must be HTTP or HTTPS");
            } catch (Exception e) {
              AlertDialog.Builder dlgAlert = new AlertDialog.Builder(preference.getContext());
              dlgAlert.setMessage("Invalid SOS URL");
              dlgAlert.setTitle(e.getMessage());
              dlgAlert.setPositiveButton("OK", null);
              dlgAlert.setCancelable(true);
              dlgAlert.create().show();
            }
          }

          return true;
        }
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    // Refresh testbeds list

    final ListPreference testbedslist = (ListPreference) findPreference("selecttestbed");
    SharedPreferences prefs = getSharedPreferences("prefs", MODE_PRIVATE);
    ServerDatabaseHandler serverDatabase = new ServerDatabaseHandler(this);
    Server currentServer = serverDatabase.getServer(prefs.getInt("prefServerId", 0));
    serverDatabase.close();
    DataSource tempDS = new DataSource(currentServer);
    List<Testbed> testbeds = tempDS.getTestbeds();
    ArrayList<CharSequence> testbedName = new ArrayList<CharSequence>();
    ArrayList<CharSequence> testbedValues = new ArrayList<CharSequence>();
    int i;
    for (i = 0; i < testbeds.size(); i++) {
      testbedName.add(testbeds.get(i).getName());
      testbedValues.add(Integer.toString(i));
    }
    final CharSequence[] items = testbedName.toArray(new CharSequence[testbedName.size()]);
    final CharSequence[] values = testbedValues.toArray(new CharSequence[testbedValues.size()]);

    testbedslist.setEntries(items);
    testbedslist.setEntryValues(values);
  }
Ejemplo n.º 22
0
  @Override
  public boolean onPreferenceChange(Preference preference, Object value) {
    String stringValue = value.toString();

    // are we starting the preference activity?
    if (!mBindingPreference) {
      if (preference.getKey().equals(getString(R.string.pref_location_key))) {
        FetchWeatherTask weatherTask = new FetchWeatherTask(this);
        String location = value.toString();
        weatherTask.execute(location);
      } else {
        // notify code that weather may be impacted
        getContentResolver().notifyChange(WeatherContract.WeatherEntry.CONTENT_URI, null);
      }
    }

    if (preference instanceof ListPreference) {
      // For list preferences, look up the correct display value in
      // the preference's 'entries' list (since they have separate labels/values).
      ListPreference listPreference = (ListPreference) preference;
      int prefIndex = listPreference.findIndexOfValue(stringValue);
      if (prefIndex >= 0) {
        preference.setSummary(listPreference.getEntries()[prefIndex]);
      }
    } else {
      // For other preferences, set the summary to the value's simple string representation.
      preference.setSummary(stringValue);
    }
    return true;
  }
  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));
  }
Ejemplo n.º 24
0
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.option);

    geted = PreferenceManager.getDefaultSharedPreferences(this).edit();
    geted.putBoolean("AI", false);
    geted.putString("name", Nom);
    geted.putString("surname", Prénom);
    geted.putString("nickname", Pseudonyme);

    geted.putString("IPadress", IPAdress);
    if (externe) {
      geted.putBoolean("externe", true);
      geted.putString("IPadress_ext", IPadress_ext);
      geted.putString("SSID", SSID);
    } else {
      geted.putBoolean("externe", false);
    }
    geted.putBoolean("shake", ShakeService);
    geted.putBoolean("event", EventService);
    geted.putBoolean("tts_pref", TTS);
    geted.putBoolean("update", Update_Com);
    geted.commit();

    ListPreference lp = (ListPreference) findPreference("sexe");
    lp.setEntries(Values);
    lp.setEntryValues(Values);
    if (Sexe < 3) lp.setValue(Values[Sexe]);

    finish();
  }
Ejemplo n.º 25
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), ""));
    }
  }
Ejemplo n.º 26
0
 private void initializeLanguageDialog() {
   TreeMap<String, String> items = new TreeMap<String, String>();
   for (String localeCode : mAppLanguages) {
     Locale loc;
     if (localeCode.length() > 2) {
       loc = new Locale(localeCode.substring(0, 2), localeCode.substring(3, 5));
     } else {
       loc = new Locale(localeCode);
     }
     items.put(loc.getDisplayName(), loc.toString());
   }
   mLanguageDialogLabels = new CharSequence[items.size() + 1];
   mLanguageDialogValues = new CharSequence[items.size() + 1];
   mLanguageDialogLabels[0] = getResources().getString(R.string.language_system);
   mLanguageDialogValues[0] = "";
   int i = 1;
   for (Map.Entry<String, String> e : items.entrySet()) {
     mLanguageDialogLabels[i] = e.getKey();
     mLanguageDialogValues[i] = e.getValue();
     i++;
   }
   mLanguageSelection = (ListPreference) getPreferenceScreen().findPreference("language");
   mLanguageSelection.setEntries(mLanguageDialogLabels);
   mLanguageSelection.setEntryValues(mLanguageDialogValues);
 }
Ejemplo n.º 27
0
  @Override
  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {

    // Aquí comprobamos para cuando se cambie X cosas de los ajustes.
    if ("notifications".equals(key)) {

      // Obtenemos la categoría a través del PreferenceScreen

      if (sharedPreferences.getBoolean("notifications", true)) {
        // Activamos la categoría de notificaciones
        enableNotifications();

      } else {
        // Desactivamos la categoría de notificaciones
        disableNotifications();
      }

    } else if ("general_theme".equals(key)) {
      ListPreference listPreference = (ListPreference) findPreference(key);

      if (listener != null) {
        listener.onThemeChanged(listPreference.getValue());
      }
    }
  }
Ejemplo n.º 28
0
 /**
  * For each list dialog, we display the value selected in the "summary" text. When a new value is
  * selected from the list dialog, update the summary to the selected entry.
  */
 public boolean onPreferenceChange(Preference preference, Object newValue) {
   ListPreference list = (ListPreference) preference;
   int index = list.findIndexOfValue((String) newValue);
   CharSequence entry = list.getEntries()[index];
   preference.setSummary(entry);
   return true;
 }
 public void updateRotationTimeout(int timeout) {
   if (timeout == 0) {
     timeout = KEYBOARD_ROTATION_TIMEOUT_DEFAULT;
   }
   mKeyboardRotationTimeout.setValue(Integer.toString(timeout));
   mKeyboardRotationTimeout.setSummary(
       getString(R.string.keyboard_rotation_timeout_summary, mKeyboardRotationTimeout.getEntry()));
 }
 @Override
 public void setSummary(CharSequence summary) {
   if (summary == null || summary.toString().isEmpty()) {
     super.setSummary("");
   } else {
     super.setSummary(summary);
   }
 }