Beispiel #1
0
 @Override
 protected String getDomain() {
   String prefix = "login";
   if (accountState != null && !TextUtils.isEmpty(accountState.getValue())) {
     prefix = accountState.getValue();
   }
   return prefix + ".belcentrale.nl";
 }
Beispiel #2
0
 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
   Preference pref = findPreference(key);
   if (pref instanceof EditTextPreference) {
     EditTextPreference etp = (EditTextPreference) pref;
     pref.setSummary(etp.getText());
   } else if (pref instanceof ListPreference) {
     ListPreference lp = (ListPreference) pref;
     if (lp.getTitle().equals(getString(R.string.titleAutoStopAfterTime))) {
       setSummary(pref, getString(R.string.summaryAutoStopAfterTime), lp.getValue());
     } else if (lp.getTitle().equals(getString(R.string.titleRecordingRate))) {
       setSummary(pref, getString(R.string.summaryRecordingRate), lp.getValue());
     }
   }
 }
  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());
  }
 private void disableUnusableTimeouts(ListPreference screenTimeoutPreference) {
   final DevicePolicyManager dpm =
       (DevicePolicyManager) getActivity().getSystemService(Context.DEVICE_POLICY_SERVICE);
   final long maxTimeout = dpm != null ? dpm.getMaximumTimeToLock(null) : 0;
   if (maxTimeout == 0) {
     return; // policy not enforced
   }
   final CharSequence[] entries = screenTimeoutPreference.getEntries();
   final CharSequence[] values = screenTimeoutPreference.getEntryValues();
   ArrayList<CharSequence> revisedEntries = new ArrayList<CharSequence>();
   ArrayList<CharSequence> revisedValues = new ArrayList<CharSequence>();
   for (int i = 0; i < values.length; i++) {
     long timeout = Long.parseLong(values[i].toString());
     if (timeout <= maxTimeout) {
       revisedEntries.add(entries[i]);
       revisedValues.add(values[i]);
     }
   }
   if (revisedEntries.size() != entries.length || revisedValues.size() != values.length) {
     screenTimeoutPreference.setEntries(
         revisedEntries.toArray(new CharSequence[revisedEntries.size()]));
     screenTimeoutPreference.setEntryValues(
         revisedValues.toArray(new CharSequence[revisedValues.size()]));
     final int userPreference = Integer.parseInt(screenTimeoutPreference.getValue());
     if (userPreference <= maxTimeout) {
       screenTimeoutPreference.setValue(String.valueOf(userPreference));
     } else {
       // There will be no highlighted selection since nothing in the list matches
       // maxTimeout. The user can still select anything less than maxTimeout.
       // TODO: maybe append maxTimeout to the list and mark selected.
     }
   }
   screenTimeoutPreference.setEnabled(revisedEntries.size() > 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));
      }
    }
  }
Beispiel #6
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);
  }
  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), ""));
    }
  }
  // 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 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 disableUnusableTimeouts(long maxTimeout) {
   final CharSequence[] entries = mLockAfter.getEntries();
   final CharSequence[] values = mLockAfter.getEntryValues();
   ArrayList<CharSequence> revisedEntries = new ArrayList<CharSequence>();
   ArrayList<CharSequence> revisedValues = new ArrayList<CharSequence>();
   for (int i = 0; i < values.length; i++) {
     long timeout = Long.valueOf(values[i].toString());
     if (timeout <= maxTimeout) {
       revisedEntries.add(entries[i]);
       revisedValues.add(values[i]);
     }
   }
   if (revisedEntries.size() != entries.length || revisedValues.size() != values.length) {
     mLockAfter.setEntries(revisedEntries.toArray(new CharSequence[revisedEntries.size()]));
     mLockAfter.setEntryValues(revisedValues.toArray(new CharSequence[revisedValues.size()]));
     final int userPreference = Integer.valueOf(mLockAfter.getValue());
     if (userPreference <= maxTimeout) {
       mLockAfter.setValue(String.valueOf(userPreference));
     } else {
       // There will be no highlighted selection since nothing in the list matches
       // maxTimeout. The user can still select anything less than maxTimeout.
       // TODO: maybe append maxTimeout to the list and mark selected.
     }
   }
   mLockAfter.setEnabled(revisedEntries.size() > 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());
      }
    }
  }
  @SuppressWarnings("deprecation")
  @Override
  public void onPause() {
    super.onPause();

    mPrefSettings.setValue(Constants.VIBRATION_SETTINGS, mVibrationCB.isChecked());
    mPrefSettings.setValue(Constants.SOUND_SETTINGS, mSoundCB.isChecked());
    mPrefSettings.setValue(Constants.NOTIFY_ICON_SETTINGS, mNotifyCB.isChecked());
    mPrefSettings.setValue(Constants.WIDGET_THEME_SETTINGS, mThemeList.getValue());
    mPrefSettings.setValue(Constants.TEXT_COLOUR_SETTINGS, mColourList.getValue());
    mPrefSettings.setValue(Constants.TEMPERATURE_SETTINGS, mTempList.getValue());

    Intent intent = new Intent(getApplicationContext(), BatteryUpdateService.class);
    getApplicationContext().startService(intent);

    getPreferenceScreen().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
  }
Beispiel #13
0
 protected String getDomain() {
   String provider = providerListPref.getValue();
   if (provider != null) {
     String[] set = providers.get(provider);
     return set[0];
   }
   return "";
 }
Beispiel #14
0
 private static int getIntValue(ListPreference pref, int defaultValue) {
   try {
     return Integer.parseInt(pref.getValue());
   } catch (NumberFormatException e) {
     Log.e(THIS_FILE, "List item is not a number");
   }
   return defaultValue;
 }
Beispiel #15
0
  @Override
  public void fillLayout(final SipProfile account) {
    super.fillLayout(account);

    accountUsername.setTitle(R.string.w_advanced_caller_id);
    accountUsername.setDialogTitle(R.string.w_advanced_caller_id_desc);

    boolean recycle = true;
    providerListPref = (ListPreference) findPreference(PROVIDER_LIST_KEY);
    if (providerListPref == null) {
      Log.d(THIS_FILE, "Create new list pref");
      providerListPref = new ListPreference(parent);
      providerListPref.setKey(PROVIDER_LIST_KEY);
      recycle = false;
    } else {
      Log.d(THIS_FILE, "Recycle existing list pref");
    }

    CharSequence[] v = new CharSequence[providers.size()];
    int i = 0;
    for (String pv : providers.keySet()) {
      v[i] = pv;
      i++;
    }

    providerListPref.setEntries(v);
    providerListPref.setEntryValues(v);
    providerListPref.setKey(PROVIDER);
    providerListPref.setDialogTitle("Provider");
    providerListPref.setTitle("Provider");
    providerListPref.setSummary("Betamax clone provider");
    providerListPref.setDefaultValue("12VoIP");

    if (!recycle) {
      addPreference(providerListPref);
    }
    hidePreference(null, SERVER);

    String domain = account.getDefaultDomain();
    if (domain != null) {
      for (Entry<String, String[]> entry : providers.entrySet()) {
        String[] val = entry.getValue();
        if (val[0].equalsIgnoreCase(domain)) {
          Log.d(THIS_FILE, "Set provider list pref value to " + entry.getKey());
          providerListPref.setValue(entry.getKey());
          break;
        }
      }
    }
    Log.d(THIS_FILE, providerListPref.getValue());

    // Get wizard specific row
    customWizardText = (TextView) parent.findViewById(R.id.custom_wizard_text);
    customWizard = (LinearLayout) parent.findViewById(R.id.custom_wizard_row);

    updateAccountInfos(account);
  }
    /**
     * Sets the summary for the given list preference.
     *
     * @param selectedQualities The selected video qualities.
     * @param preference The preference for which to set the summary.
     */
    private void setSummaryForSelection(
        SelectedVideoQualities selectedQualities, ListPreference preference) {
      if (selectedQualities == null) {
        return;
      }

      int selectedQuality = selectedQualities.getFromSetting(preference.getValue());
      preference.setSummary(mCamcorderProfileNames[selectedQuality]);
    }
 @Override
 public boolean onPreferenceClick(Preference preference) {
   if (preference.getKey().equals("install")) {
     installDialog();
   }
   if (preference.getKey().equals("reconfigure")) {
     reconfigureDialog();
   }
   if (preference.getKey().equals("export")) {
     exportDialog();
   }
   if (preference.getKey().equals("sshproperties")) {
     Intent intent = new Intent(getApplicationContext(), PropertiesActivity.class);
     Bundle b = new Bundle();
     b.putInt("pref", 1);
     intent.putExtras(b);
     startActivity(intent);
   }
   if (preference.getKey().equals("guiproperties")) {
     ListPreference guitype = (ListPreference) findPreference("guitype");
     Intent intent = new Intent(getApplicationContext(), PropertiesActivity.class);
     Bundle b = new Bundle();
     if (guitype.getValue().equals("vnc")) {
       b.putInt("pref", 2);
     }
     if (guitype.getValue().equals("xserver")) {
       b.putInt("pref", 3);
     }
     if (guitype.getValue().equals("framebuffer")) {
       b.putInt("pref", 4);
     }
     intent.putExtras(b);
     startActivity(intent);
   }
   if (preference.getKey().equals("scriptseditor")) {
     Intent intent = new Intent(getApplicationContext(), ScriptsActivity.class);
     startActivity(intent);
   }
   if (preference.getKey().equals("mountseditor")) {
     Intent intent = new Intent(getApplicationContext(), MountsActivity.class);
     startActivity(intent);
   }
   return true;
 }
  @TargetApi(Build.VERSION_CODES.GINGERBREAD)
  private void buildResolutionListForCameraIndex() {
    int camIndex = Integer.parseInt(cameraIndexPreference.getValue());

    Camera cam = null;
    try {
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) cam = Camera.open(camIndex);
      else cam = Camera.open();

      Camera.Parameters params = cam.getParameters();
      List<Camera.Size> previewSizes = params.getSupportedPreviewSizes();
      cam.release();

      // Build list of resolutions, checking whether the current
      // resolution is in the list too.
      // String camResolution =
      // sharedPreferences.getString("pref_cameraResolution",
      // getResources().getString(R.string.pref_defaultValue_cameraResolution);
      String camResolution = cameraResolutionPreference.getValue();
      boolean foundCurrentResolution = false;
      CharSequence[] entries = new CharSequence[previewSizes.size()];
      CharSequence[] entryValues = new CharSequence[previewSizes.size()];
      for (int i = 0; i < previewSizes.size(); i++) {
        int w = previewSizes.get(i).width;
        int h = previewSizes.get(i).height;
        entries[i] = w + "x" + h + "   (" + findAspectRatioName(w, h) + ")";
        entryValues[i] = w + "x" + h;
        if (entryValues[i].equals(camResolution)) foundCurrentResolution = true;
      }
      cameraResolutionPreference.setEntries(entries);
      cameraResolutionPreference.setEntryValues(entryValues);

      if (!foundCurrentResolution) {
        cameraResolutionPreference.setValue(entryValues[0].toString());
        cameraResolutionPreference.setSummary(cameraResolutionPreference.getEntry());
      }

    } catch (RuntimeException e) {
      Log.e(TAG, "Camera failed to open: " + e.getLocalizedMessage());
    }
  }
Beispiel #19
0
  private void saveSettings() throws MessagingException {
    mFolder.setInTopGroup(mInTopGroup.isChecked());
    mFolder.setIntegrate(mIntegrate.isChecked());
    // We call getPushClass() because display class changes can affect push class when push class is
    // set to inherit
    FolderClass oldPushClass = mFolder.getPushClass();
    FolderClass oldDisplayClass = mFolder.getDisplayClass();
    mFolder.setDisplayClass(FolderClass.valueOf(mDisplayClass.getValue()));
    mFolder.setSyncClass(FolderClass.valueOf(mSyncClass.getValue()));
    mFolder.setPushClass(FolderClass.valueOf(mPushClass.getValue()));

    mFolder.save();

    FolderClass newPushClass = mFolder.getPushClass();
    FolderClass newDisplayClass = mFolder.getDisplayClass();

    if (oldPushClass != newPushClass
        || (newPushClass != FolderClass.NO_CLASS && oldDisplayClass != newDisplayClass)) {
      MailService.actionRestartPushers(getApplication(), null);
    }
  }
  protected void onCreate(Bundle savedInstanceState, int titleRes, int layout, int preferencesXml) {
    super.onCreate(savedInstanceState);

    packageName = getIntent().getStringExtra(EXTRA_PACKAGE_NAME);

    // get package title
    try {
      ApplicationInfo ai = getPackageManager().getApplicationInfo(packageName, 0);
      String appName = getPackageManager().getApplicationLabel(ai).toString();
      if (appName == null) appName = packageName;
      setTitle(appName + " - " + getString(titleRes));
    } catch (PackageManager.NameNotFoundException e) {
      setTitle(packageName + " - " + getString(titleRes));
    }

    LayoutInflater inflater = getLayoutInflater();
    View v = inflater.inflate(layout, null);
    setContentView(v);

    addPreferencesFromResource(preferencesXml);
    PreferenceScreen prefScreen = getPreferenceScreen();
    SharedPreferences sharedPrefs =
        PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

    for (int i = 0; i < prefScreen.getPreferenceCount(); i++) {
      PreferenceGroup prefGroup = (PreferenceGroup) prefScreen.getPreference(i);

      for (int j = 0; j < prefGroup.getPreferenceCount(); j++) {
        Preference pref = prefGroup.getPreference(j);
        String key = packageName + "." + pref.getKey();

        if (pref instanceof ListPreference) {
          ListPreference listPref = ((ListPreference) pref);
          String globalValue = listPref.getValue();
          String currValue = sharedPrefs.getString(key, globalValue);

          listPref.setKey(key);
          listPref.setValue(currValue);
        } else if (pref instanceof CheckBoxPreference) {
          CheckBoxPreference checkPref = (CheckBoxPreference) pref;
          boolean globalValue = checkPref.isChecked();
          boolean currValue = sharedPrefs.getBoolean(key, globalValue);
          checkPref.setKey(key);
          checkPref.setChecked(currValue);
        }
      }
    }

    // apply card layout
    CardPreferenceFragment.applyLayoutToPreferences(prefScreen);

    getActionBar().setDisplayHomeAsUpEnabled(true);
  }
Beispiel #21
0
 @Override
 public String getDefaultFieldSummary(String fieldName) {
   Integer res = SUMMARIES.get(fieldName);
   if (fieldName == PROVIDER) {
     if (providerListPref != null) {
       return providerListPref.getValue();
     }
   }
   if (res != null) {
     return parent.getString(res);
   }
   return "";
 }
  private void setParcelData() {

    try {
      pNotify.notify_active = mNotification.isChecked();
      pNotify.notify_icon = mNotifyIcon.getValue();
      pNotify.led_active = mLed.isChecked();
      pNotify.led_color = mLedColor.getValue();
      pNotify.led_pat = mLedPattern.getValue();
      pNotify.ringer_active = mRinger.isChecked();
      pNotify.ringtone = mRingtone.getRingtone();
      pNotify.ringer_vol = mRingVolume.getVolume();
      pNotify.vibrate_active = mVibrate.isChecked();
      pNotify.vibrate_pat = mVibratePattern.getValue();

      Intent retIntent = new Intent();
      retIntent.putExtra("fac.userdelroot.droidprofiles.Notify", pNotify);
      setResult(RESULT_OK, retIntent);

    } catch (NullPointerException e) {
      if (Log.LOGV) Log.e(TAG + "setParcelData null pointer " + e.getLocalizedMessage().toString());
    }
  }
    /**
     * Sets the summary for the given list preference.
     *
     * @param oldPictureSizes The old selected picture sizes for small medium and large
     * @param displayableSizes The human readable preferred sizes
     * @param preference The preference for which to set the summary.
     */
    private void setSummaryForSelection(
        SelectedPictureSizes oldPictureSizes,
        List<Size> displayableSizes,
        ListPreference preference) {
      if (oldPictureSizes == null) {
        return;
      }

      String setting = preference.getValue();
      Size selectedSize = oldPictureSizes.getFromSetting(setting, displayableSizes);

      preference.setSummary(getSizeSummaryString(selectedSize));
    }
    private void refresh() {
      final ListPreference autoSilencePref = (ListPreference) findPreference(KEY_AUTO_SILENCE);
      String delay = autoSilencePref.getValue();
      updateAutoSnoozeSummary(autoSilencePref, delay);
      autoSilencePref.setOnPreferenceChangeListener(this);

      final ListPreference clockStylePref = (ListPreference) findPreference(KEY_CLOCK_STYLE);
      clockStylePref.setSummary(clockStylePref.getEntry());
      clockStylePref.setOnPreferenceChangeListener(this);

      final Preference autoHomeClockPref = findPreference(KEY_AUTO_HOME_CLOCK);
      final boolean autoHomeClockEnabled = ((CheckBoxPreference) autoHomeClockPref).isChecked();
      autoHomeClockPref.setOnPreferenceChangeListener(this);

      final ListPreference homeTimezonePref = (ListPreference) findPreference(KEY_HOME_TZ);
      homeTimezonePref.setEnabled(autoHomeClockEnabled);
      homeTimezonePref.setSummary(homeTimezonePref.getEntry());
      homeTimezonePref.setOnPreferenceChangeListener(this);

      final ListPreference volumeButtonsPref = (ListPreference) findPreference(KEY_VOLUME_BUTTONS);
      volumeButtonsPref.setSummary(volumeButtonsPref.getEntry());
      volumeButtonsPref.setOnPreferenceChangeListener(this);

      final Preference volumePref = findPreference(KEY_ALARM_VOLUME);
      volumePref.setOnPreferenceClickListener(this);

      final SnoozeLengthDialog snoozePref = (SnoozeLengthDialog) findPreference(KEY_ALARM_SNOOZE);
      snoozePref.setSummary();

      final ListPreference weekStartPref = (ListPreference) findPreference(KEY_WEEK_START);
      // Set the default value programmatically
      final String value = weekStartPref.getValue();
      final int idx =
          weekStartPref.findIndexOfValue(
              value == null ? String.valueOf(Utils.DEFAULT_WEEK_START) : value);
      weekStartPref.setValueIndex(idx);
      weekStartPref.setSummary(weekStartPref.getEntries()[idx]);
      weekStartPref.setOnPreferenceChangeListener(this);
    }
  private ApiConnection getServerConnection() {
    ListPreference serverConnection = getPreference(R.string.preference_key_server_connection);

    if (serverConnection
        .getValue()
        .equals(getString(R.string.preference_key_server_connection_auto))) {
      return ApiConnection.AUTO;
    }

    if (serverConnection
        .getValue()
        .equals(getString(R.string.preference_key_server_connection_local))) {
      return ApiConnection.LOCAL;
    }

    if (serverConnection
        .getValue()
        .equals(getString(R.string.preference_key_server_connection_remote))) {
      return ApiConnection.REMOTE;
    }

    return ApiConnection.AUTO;
  }
Beispiel #26
0
  /** Update the MidiOptions based on the preferences selected. */
  private void updateOptions() {
    for (int i = 0; i < options.tracks.length; i++) {
      options.tracks[i] = selectTracks[i].isChecked();
    }
    for (int i = 0; i < options.mute.length; i++) {
      options.mute[i] = muteTracks[i].isChecked();
    }
    for (int i = 0; i < options.tracks.length; i++) {
      ListPreference entry = selectInstruments[i];
      options.instruments[i] = entry.findIndexOfValue(entry.getValue());
    }
    options.scrollVert = scrollVertically.isChecked();
    options.showPiano = showPiano.isChecked();
    options.showLyrics = showLyrics.isChecked();
    if (twoStaffs != null) options.twoStaffs = twoStaffs.isChecked();
    else options.twoStaffs = false;

    options.showNoteLetters = Integer.parseInt(showNoteLetters.getValue());
    options.transpose = Integer.parseInt(transpose.getValue());
    options.key = Integer.parseInt(key.getValue());
    if (time.getValue().equals("Default")) {
      options.time = null;
    } else if (time.getValue().equals("3/4")) {
      options.time =
          new TimeSignature(3, 4, options.defaultTime.getQuarter(), options.defaultTime.getTempo());
    } else if (time.getValue().equals("4/4")) {
      options.time =
          new TimeSignature(4, 4, options.defaultTime.getQuarter(), options.defaultTime.getTempo());
    }
    options.combineInterval = Integer.parseInt(combineInterval.getValue());
    options.shade1Color = shade1Color.getColor();
    options.shade2Color = shade2Color.getColor();
    options.showMeasures = showMeasures.isChecked();
    options.playMeasuresInLoop = playMeasuresInLoop.isChecked();
    options.playMeasuresInLoopStart = Integer.parseInt(loopStart.getValue()) - 1;
    options.playMeasuresInLoopEnd = Integer.parseInt(loopEnd.getValue()) - 1;
  }
 @Override
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   // Load the preferences from an XML resource
   addPreferencesFromResource(R.xml.preferences);
   final ListPreference listPreference =
       (ListPreference) findPreference(getString(R.string.progressBar_pref_key));
   if (listPreference.getValue() == null) {
     // to ensure we don't get a null value
     // set first value by default
     listPreference.setValueIndex(Integer.parseInt(getString(R.string.progressBar_pref_defValue)));
   }
   listPreference.setSummary(
       listPreference.getEntries()[Integer.parseInt(listPreference.getValue())].toString());
   listPreference.setOnPreferenceChangeListener(
       new Preference.OnPreferenceChangeListener() {
         @Override
         public boolean onPreferenceChange(Preference preference, Object newValue) {
           preference.setSummary(
               listPreference.getEntries()[Integer.parseInt(newValue.toString())]);
           return true;
         }
       });
 }
  private void setSummary(final String preferenceKey) {
    final Preference preference = findPreference(preferenceKey);

    if (preference instanceof CheckBoxPreference) {
      CheckBoxPreference cbp = (CheckBoxPreference) preference;
      preference.setSummary(getString(cbp.isChecked() ? R.string.enabled : R.string.disabled));
    } else if (preference instanceof ListPreference) {
      ListPreference lp = (ListPreference) preference;
      preference.setSummary(
          getString(R.string.countdown_preference_summary, Integer.valueOf(lp.getValue())));
    } else if (preference instanceof ColorPreference) {
      ColorPreference cp = (ColorPreference) preference;
      preference.setSummary(intToHexColor(cp));
    }
  }
 /*
  * M: get ipv6 string
  */
 public String getIPV6String(int errorIpv4, int errorIpv6) {
   String text = "";
   if (mTetherIpv6 != null && "1".equals(mTetherIpv6.getValue())) {
     Xlog.d(TAG, "[errorIpv4 =" + errorIpv4 + "];" + "[errorIpv6 =" + errorIpv6 + "];");
     if (errorIpv4 == ConnectivityManager.TETHER_ERROR_NO_ERROR
         && errorIpv6 == ConnectivityManager.TETHER_ERROR_IPV6_AVAIABLE) {
       text = getResources().getString(R.string.tethered_ipv4v6);
     } else if (errorIpv4 == ConnectivityManager.TETHER_ERROR_NO_ERROR) {
       text = getResources().getString(R.string.tethered_ipv4);
     } else if (errorIpv6 == ConnectivityManager.TETHER_ERROR_IPV6_AVAIABLE) {
       text = getResources().getString(R.string.tethered_ipv6);
     }
   }
   return text;
 }
Beispiel #30
0
  @Override
  public void setDefaultParams(PreferencesWrapper prefs) {
    super.setDefaultParams(prefs);
    // Disable ICE and turn on STUN!!!
    prefs.setPreferenceBooleanValue(SipConfigManager.ENABLE_STUN, true);
    String provider = providerListPref.getValue();
    if (provider != null) {
      String[] set = providers.get(provider);
      if (!TextUtils.isEmpty(set[1])) {
        prefs.addStunServer(set[1]);
      }
    }

    prefs.setPreferenceBooleanValue(SipConfigManager.ENABLE_ICE, false);
  }