private void setLatLong(double latitude, double longitude) {
   EditTextPreference latPreference = (EditTextPreference) findPreference(LATITUDE);
   EditTextPreference longPreference = (EditTextPreference) findPreference(LONGITUDE);
   latPreference.setText(Double.toString(latitude));
   longPreference.setText(Double.toString(longitude));
   String message = String.format(getString(R.string.location_place_found), latitude, longitude);
   Log.d(TAG, message);
   Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
 }
  @Override
  public void setText(final String text) {

    if (getEditText().getText().toString().length() > 0) {
      super.setText(mEncrypt.encrypt(text));
    } else {
      super.setText(text);
    }
  }
  private void addDevOptions() {
    SharedPreferences p = MultiROMMgrApplication.getPreferences();
    if (!p.getBoolean(DEV_ENABLE, false)) return;

    m_clickCounter = -1;
    addPreferencesFromResource(R.xml.dev_options);

    EditTextPreference pref = (EditTextPreference) findPreference(DEV_MANIFEST_URL);
    pref.setText(p.getString(DEV_MANIFEST_URL, Manifest.DEFAULT_URL));
    pref = (EditTextPreference) findPreference(DEV_DEVICE_NAME);
    pref.setText(p.getString(DEV_DEVICE_NAME, Build.BOARD));
  }
  /** Sets the default values for the the preferences */
  private void initPreferences() {

    // Phone name
    String phoneNum =
        ((TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE)).getLine1Number();
    Log.d(TAG, "Phone number of this phone: " + phoneNum);
    if (TextUtils.isEmpty(phoneNum)) phoneNum = Constants.DEFAULT_PHONE_NUMBER;
    EditTextPreference prefPhoneName =
        (EditTextPreference) findPreference(Constants.PREFERENCE_PHONE_NAME);
    if (TextUtils.isEmpty(prefPhoneName.getText())) {
      prefPhoneName.setText(phoneNum);
    }

    // Health worker username for OpenMRS
    EditTextPreference prefEmrUsername =
        (EditTextPreference) findPreference(Constants.PREFERENCE_EMR_USERNAME);
    if (TextUtils.isEmpty(prefEmrUsername.getText())) {
      prefEmrUsername.setText(Constants.DEFAULT_USERNAME);
    }

    // Health worker password for OpenMRS
    EditTextPreference prefEmrPassword =
        (EditTextPreference) findPreference(Constants.PREFERENCE_EMR_PASSWORD);
    prefEmrPassword.getEditText().setTransformationMethod(new PasswordTransformationMethod());
    if (TextUtils.isEmpty(prefEmrPassword.getText())) {
      prefEmrPassword.setText(Constants.DEFAULT_PASSWORD);
    }

    // Whether barcode reading is enabled on the phone
    /*
     * CheckBoxPreference barcodeEnabled = new CheckBoxPreference(this);
     * barcodeEnabled.setKey(Constants.PREFERENCE_BARCODE_ENABLED);
     * barcodeEnabled.setTitle("Enable barcode reading");
     * barcodeEnabled.setSummary
     * ("Enable barcode reading of patient and physician ids");
     * barcodeEnabled.setDefaultValue(false);
     * dialogBasedPrefCat.addPreference(barcodeEnabled);
     */

    // Launches network preferences
    PreferenceScreen prefNetwork = (PreferenceScreen) findPreference("s_network_settings");
    if (prefNetwork != null) {
      prefNetwork.setIntent(new Intent(this, NetworkSettings.class));
    }

    // Launches resource preferences
    PreferenceScreen prefResource = (PreferenceScreen) findPreference("s_resource_settings");
    if (prefResource != null) {
      prefResource.setIntent(new Intent(this, ResourceSettings.class));
    }
  }
Exemple #5
0
 private void updateApplicationDirTextAndSummary() {
   if (applicationDir != null) {
     String storageDir = osmandSettings.getExternalStorageDirectory().getAbsolutePath();
     applicationDir.setText(storageDir);
     applicationDir.setSummary(storageDir);
   }
 }
Exemple #6
0
  @Override
  public void fillLayout(final SipProfile account) {
    super.fillLayout(account);

    accountUsername.setTitle(R.string.w_common_phone_number);
    accountUsername.setDialogTitle(R.string.w_common_phone_number);

    accountUsername.getEditText().setInputType(InputType.TYPE_CLASS_PHONE);

    // Allow to add suffix x11
    boolean recycle = true;
    accountSuffix = (EditTextPreference) findPreference(SUFFIX_KEY);
    if (accountSuffix == null) {
      accountSuffix = new EditTextPreference(parent);
      accountSuffix.setKey(SUFFIX_KEY);
      accountSuffix.getEditText().setInputType(InputType.TYPE_CLASS_PHONE);
      accountSuffix.setTitle("Suffix for account id");
      accountSuffix.setSummary("For multipresence usage (leave blank if not want)");
      recycle = false;
    }

    if (!recycle) {
      addPreference(accountSuffix);
    }

    String uName = account.getSipUserName();
    String[] uNames = uName.split("x");

    accountUsername.setText(uNames[0]);
    if (uNames.length > 1) {
      accountSuffix.setText(uNames[1]);
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    PreferenceScreen ps = getPreferenceManager().createPreferenceScreen(getActivity());
    ps.setTitle(R.string.quick_response_settings_title);

    mResponses = Utils.getQuickResponses(getActivity());

    if (mResponses != null) {
      mEditTextPrefs = new EditTextPreference[mResponses.length];

      Arrays.sort(mResponses);
      int i = 0;
      for (String response : mResponses) {
        EditTextPreference et = new EditTextPreference(getActivity());
        et.setDialogTitle(R.string.quick_response_settings_edit_title);
        et.setTitle(response); // Display Text
        et.setText(response); // Value to edit
        et.setOnPreferenceChangeListener(this);
        mEditTextPrefs[i++] = et;
        ps.addPreference(et);
      }
    } else {
      Log.wtf(TAG, "No responses found");
    }
    setPreferenceScreen(ps);
    /// M:Toast to alarm @{
    mToast = Toast.makeText(getActivity(), "", Toast.LENGTH_SHORT);
    /// @}
  }
  private PreferenceScreen createPreferenceHierarchy() {
    // Root
    PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);

    root.setPersistent(true);

    CheckBoxPreference nextScreenCheckBoxPref = new CheckBoxPreference(this);
    nextScreenCheckBoxPref.setKey(BlackBoxPrefs.KEY_ENABLED);
    nextScreenCheckBoxPref.setTitle("enabled");
    nextScreenCheckBoxPref.setSummary("is BlackBox enabled?");
    root.addPreference(nextScreenCheckBoxPref);

    EditTextPreference sgf_fname_pref = new EditTextPreference(this);
    sgf_fname_pref.setTitle("Path");
    root.addPreference(sgf_fname_pref);

    sgf_fname_pref.setDialogTitle("Enter BlackBox Path");
    sgf_fname_pref.setDialogMessage("Please enter the BlackBox Path.");
    sgf_fname_pref.setKey(BlackBoxPrefs.KEY_PATH);
    sgf_fname_pref.setText(BlackBoxPrefs.getPath());
    sgf_fname_pref.setSummary(BlackBoxPrefs.getPath());

    PreferenceScreen intentPref = getPreferenceManager().createPreferenceScreen(this);
    Intent i = new Intent(this, BlackBoxWatchActivity.class);

    intentPref.setIntent(i);
    intentPref.setTitle("Watch BlackBox");
    intentPref.setSummary("check BlackBox status");
    root.addPreference(intentPref);

    return root;
  }
  protected void refresh() {
    // refresh is called from our onResume, which can happen before the owning
    // Activity tells us about an account (via our public
    // refresh(AndroidFxAccount) method).
    if (fxAccount == null) {
      throw new IllegalArgumentException("fxAccount must not be null");
    }

    updateProfileInformation();
    updateAuthServerPreference();
    updateSyncServerPreference();

    try {
      // There are error states determined by Android, not the login state
      // machine, and we have a chance to present these states here. We handle
      // them specially, since we can't surface these states as part of syncing,
      // because they generally stop syncs from happening regularly. Right now
      // there are no such states.

      // Interrogate the Firefox Account's state.
      State state = fxAccount.getState();
      switch (state.getNeededAction()) {
        case NeedsUpgrade:
          showNeedsUpgrade();
          break;
        case NeedsPassword:
          showNeedsPassword();
          break;
        case NeedsVerification:
          showNeedsVerification();
          break;
        case NeedsFinishMigrating:
          showNeedsFinishMigrating();
          break;
        case None:
          showConnected();
          break;
      }

      // We check for the master setting last, since it is not strictly
      // necessary for the user to address this error state: it's really a
      // warning state. We surface it for the user's convenience, and to prevent
      // confused folks wondering why Sync is not working at all.
      final boolean masterSyncAutomatically = ContentResolver.getMasterSyncAutomatically();
      if (!masterSyncAutomatically) {
        showNeedsMasterSyncAutomaticallyEnabled();
        return;
      }
    } finally {
      // No matter our state, we should update the checkboxes.
      updateSelectedEngines();
    }

    final String clientName = clientsDataDelegate.getClientName();
    deviceNamePreference.setSummary(clientName);
    deviceNamePreference.setText(clientName);

    updateSyncNowPreference();
  }
  @Override
  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {

    // Changing the backend url selection (internal, external, etc.)
    if (StringUtils.equals(key, getString(R.string.preference_key_key_base_url))
        || StringUtils.equals(key, getString(R.string.preference_key_value_base_url))) {
      String keyValue = sharedPreferences.getString(key, "");
      Preference keyPreference = findPreference(key);

      String[] keysTab = getResources().getStringArray(R.array.backend_url_keys);
      String[] valuesTab = getResources().getStringArray(R.array.backend_url_values);

      boolean resetBackendEndConnectors = true;

      if (StringUtils.equals(key, getString(R.string.preference_key_key_base_url))) {
        int indexKey = ArrayUtils.indexOf(keysTab, keyValue);

        // Setting the description to the right key
        keyPreference.setSummary(keyValue);

        // For custom key don't empty the field
        if (indexKey < keysTab.length - 1) {

          // If something changed
          if (!StringUtils.equals(
              valuesTab[indexKey],
              mSharedPreferences.getString(
                  getString(R.string.preference_key_value_base_url), ""))) {
            Preference prefValueBackendUrl =
                findPreference(getString(R.string.preference_key_value_base_url));
            prefValueBackendUrl.setSummary(valuesTab[indexKey]);
            ((EditTextPreference) prefValueBackendUrl).setText(valuesTab[indexKey]);

            // Saving the value on the settings
            SharedPreferences.Editor editor = mSharedPreferences.edit();
            editor.putString(
                getString(R.string.preference_key_value_base_url), valuesTab[indexKey]);
            editor.commit();
          } else {
            resetBackendEndConnectors = false;
          }
        }
      }
      // Changing the backend url value
      else {
        // Updating the description (Or custom if no value found)
        Preference prefKeyBackendUrl =
            findPreference(getString(R.string.preference_key_key_base_url));
        prefKeyBackendUrl.setSummary(keysTab[ArrayUtils.indexOf(valuesTab, keyValue)]);
        keyPreference.setSummary(keyValue);
      }

      // Update the url of the backend
      if (resetBackendEndConnectors) {
        B2BApplication.updateUrl(
            mSharedPreferences.getString(getString(R.string.preference_key_value_base_url), ""));
      }
    }
  }
    @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      addPreferencesFromResource(R.xml.pref_general);
      setHasOptionsMenu(true);

      ((PreferencesActivity) getActivity()).setBasePreferenceActivity(false);

      ((PreferencesActivity) getActivity())
          .getSupportActionBar()
          .setTitle(R.string.pref_header_general);
      ((PreferencesActivity) getActivity())
          .firebaseAnalytics.logEvent(getString(R.string.analytics_tap_general_prefs), null);

      final EditTextPreference p =
          (EditTextPreference) findPreference(getString(R.string.pref_device_name));
      bindPreferenceSummaryToValue(p);

      if (p.getTitle().toString().equals(getString(R.string.pref_default_device_name))
          || p.getTitle().toString().isEmpty()) {
        ((PreferencesActivity) getActivity())
            .firebaseAnalytics.logEvent(
                getString(R.string.analytics_event_empty_device_name), null);
        p.setText(Build.MANUFACTURER + " " + Build.MODEL);
      }

      p.setOnPreferenceChangeListener(
          new Preference.OnPreferenceChangeListener() {
            @Override
            public boolean onPreferenceChange(Preference preference, Object newValue) {
              p.setSummary(newValue.toString());

              Intent i = new Intent("com.texasgamer.zephyr.SOCKET_SERVICE");
              i.putExtra("type", "update-devices");
              getActivity().sendBroadcast(i);

              Bundle b = new Bundle();
              b.putString(getString(R.string.analytics_param_new_value), newValue.toString());
              ((PreferencesActivity) getActivity())
                  .firebaseAnalytics.logEvent(getString(R.string.analytics_tap_device_name), b);
              return true;
            }
          });

      findPreference(getString(R.string.pref_start_on_boot))
          .setOnPreferenceChangeListener(
              new Preference.OnPreferenceChangeListener() {
                @Override
                public boolean onPreferenceChange(Preference preference, Object newValue) {
                  Bundle b = new Bundle();
                  String newValueStr = newValue.toString().equals("true") ? "enabled" : "disabled";
                  b.putString(getString(R.string.analytics_param_new_value), newValueStr);
                  ((PreferencesActivity) getActivity())
                      .firebaseAnalytics.logEvent(
                          getString(R.string.analytics_tap_start_on_boot), b);
                  return true;
                }
              });
    }
  /** {@inheritDoc} */
  public void fillLayout(final SipProfile account) {
    bindFields();

    String display_name = account.display_name;
    if (TextUtils.isEmpty(display_name)) {
      display_name = getDefaultName();
    }
    accountDisplayName.setText(display_name);
    ParsedSipContactInfos parsedInfo = SipUri.parseSipContact(account.acc_id);

    accountUsername.setText(parsedInfo.userName);
    accountPassword.setText(account.data);

    if (canTcp()) {
      accountUseTcp.setChecked(account.transport == SipProfile.TRANSPORT_TCP);
    } else {
      hidePreference(null, USE_TCP);
    }
  }
 private void setServerPort(int value) {
   String v = String.valueOf(value);
   getPreferenceScreen()
       .getSharedPreferences()
       .edit()
       .putString(LICENSING_SERVER_PORT, v)
       .commit();
   mServerPort.setText(v);
   mServerPort.setSummary(v);
 }
 private void setServerAddress(String value) {
   String v = String.valueOf(value);
   getPreferenceScreen()
       .getSharedPreferences()
       .edit()
       .putString(LICENSING_SERVER_ADDRESS, v)
       .commit();
   mServerAddress.setText(v);
   mServerAddress.setSummary(value);
 }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.rcs_settings_presence_preferences);
    setTitle(R.string.rcs_settings_title_presence_settings);

    freetextEdit1 = (EditTextPreference) findPreference("edit_freetext1");
    freetextEdit1.setPersistent(false);
    freetextEdit1.setOnPreferenceChangeListener(this);
    String txt1 = RcsSettings.getInstance().getPredefinedFreetext1();
    freetextEdit1.setText(txt1);
    freetextEdit1.setTitle(txt1);

    freetextEdit2 = (EditTextPreference) findPreference("edit_freetext2");
    freetextEdit2.setPersistent(false);
    freetextEdit2.setOnPreferenceChangeListener(this);
    String txt2 = RcsSettings.getInstance().getPredefinedFreetext2();
    freetextEdit2.setText(txt2);
    freetextEdit2.setTitle(txt2);

    freetextEdit3 = (EditTextPreference) findPreference("edit_freetext3");
    freetextEdit3.setPersistent(false);
    freetextEdit3.setOnPreferenceChangeListener(this);
    String txt3 = RcsSettings.getInstance().getPredefinedFreetext3();
    freetextEdit3.setText(txt3);
    freetextEdit3.setTitle(txt3);

    freetextEdit4 = (EditTextPreference) findPreference("edit_freetext4");
    freetextEdit4.setPersistent(false);
    freetextEdit4.setOnPreferenceChangeListener(this);
    String txt4 = RcsSettings.getInstance().getPredefinedFreetext4();
    freetextEdit4.setText(txt4);
    freetextEdit4.setTitle(txt4);

    vibrateInvitation = (CheckBoxPreference) findPreference("presence_invitation_vibration");
    vibrateInvitation.setPersistent(false);
    vibrateInvitation.setOnPreferenceChangeListener(this);
    vibrateInvitation.setChecked(RcsSettings.getInstance().isPhoneVibrateForPresenceInvitation());
  }
Exemple #16
0
  @Override
  public void fillLayout(final SipProfile account) {
    bindFields();

    accountDisplayName.setText(account.display_name);

    String domain_name = "";
    String account_cfgid = account.acc_id;

    if (account_cfgid == null) {
      account_cfgid = "";
    }
    Pattern p = Pattern.compile("[^<]*<sip:([^@]*)@([^@]*)>");
    Matcher m = p.matcher(account_cfgid);
    if (m.matches()) {
      account_cfgid = m.group(1);
      domain_name = m.group(2);
    }

    String server_ip = account.reg_uri;
    if (server_ip == null) {
      server_ip = "";
    }
    p = Pattern.compile("sip:([^@]*)");
    m = p.matcher(server_ip);
    if (m.matches()) {
      server_ip = m.group(1);
    }

    if (server_ip.equalsIgnoreCase(domain_name)) {
      server_ip = "";
    }

    accountPhoneNumber.setText(account_cfgid);
    accountServerDomain.setText(domain_name);

    accountUsername.setText(account.username);
    accountPassword.setText(account.data);
  }
Exemple #17
0
  private void onProfileChange(String oldProfileName) {

    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);

    mProfile.getProfile(settings);
    Editor ed = settings.edit();
    ed.putString(oldProfileName, mProfile.toString());
    ed.commit();

    String profileString = settings.getString(profile, "");

    if (profileString.equals("")) {
      mProfile.init();
      mProfile.setName(getProfileName(profile));
    } else {
      mProfile.decodeJson(profileString);
    }

    hostText.setText(mProfile.getHost());
    userText.setText(mProfile.getUser());
    passwordText.setText(mProfile.getPassword());
    domainText.setText(mProfile.getDomain());
    proxyTypeList.setValue(mProfile.getProxyType());
    ssidList.setValue(mProfile.getSsid());

    isAuthCheck.setChecked(mProfile.isAuth());
    isNTLMCheck.setChecked(mProfile.isNTLM());
    isAutoConnectCheck.setChecked(mProfile.isAutoConnect());
    isAutoSetProxyCheck.setChecked(mProfile.isAutoSetProxy());
    isBypassAppsCheck.setChecked(mProfile.isBypassApps());
    isDNSProxyCheck.setChecked(mProfile.isDNSProxy());
    isPACCheck.setChecked(mProfile.isPAC());

    portText.setText(Integer.toString(mProfile.getPort()));

    Log.d(TAG, mProfile.toString());

    mProfile.setProfile(settings);
  }
Exemple #18
0
 private void updatePrefs(Alarm alarm) {
   mId = alarm.id;
   mEnabledPref.setChecked(alarm.enabled);
   mLabel.setText(alarm.label);
   mLabel.setSummary(alarm.label);
   mHour = alarm.hour;
   mMinutes = alarm.minutes;
   mRepeatPref.setDaysOfWeek(alarm.daysOfWeek);
   mVibratePref.setChecked(alarm.vibrate);
   // Give the alert uri to the preference.
   mAlarmPref.setAlert(alarm.alert);
   updateTime();
 }
Exemple #19
0
  private void setInitialValues() {
    ContentResolver cr = getContentResolver();
    Imps.ProviderSettings.QueryMap settings =
        new Imps.ProviderSettings.QueryMap(cr, false /* keep updated */, null /* no handler */);
    mOtrMode.setValue(settings.getOtrMode());
    mHideOfflineContacts.setChecked(settings.getHideOfflineContacts());
    mEnableNotification.setChecked(settings.getEnableNotification());
    mNotificationVibrate.setChecked(settings.getVibrate());
    mNotificationSound.setChecked(settings.getRingtoneURI() != null);
    mForegroundService.setChecked(settings.getUseForegroundPriority());
    long heartbeatInterval = settings.getHeartbeatInterval();
    if (heartbeatInterval == 0) heartbeatInterval = DEFAULT_HEARTBEAT_INTERVAL;
    mHeartbeatInterval.setText(String.valueOf(heartbeatInterval));

    settings.close();
  }
Exemple #20
0
  public void updateAllSettings() {
    for (OsmandPreference<Boolean> b : booleanPreferences.values()) {
      CheckBoxPreference pref = (CheckBoxPreference) screenPreferences.get(b.getId());
      pref.setChecked(b.get());
    }

    for (OsmandPreference<Integer> b : seekBarPreferences.values()) {
      SeekBarPreference pref = (SeekBarPreference) screenPreferences.get(b.getId());
      pref.setValue(b.get());
    }

    reloadVoiceListPreference(getPreferenceScreen());

    for (OsmandPreference<?> p : listPreferences.values()) {
      ListPreference listPref = (ListPreference) screenPreferences.get(p.getId());
      Map<String, ?> prefValues = listPrefValues.get(p.getId());
      String[] entryValues = new String[prefValues.size()];
      String[] entries = new String[prefValues.size()];
      int i = 0;
      for (Entry<String, ?> e : prefValues.entrySet()) {
        entries[i] = e.getKey();
        entryValues[i] = e.getValue() + ""; // case of null
        i++;
      }
      listPref.setEntries(entries);
      listPref.setEntryValues(entryValues);
      listPref.setValue(p.get() + "");
    }

    for (OsmandPreference<String> s : editTextPreferences.values()) {
      EditTextPreference pref = (EditTextPreference) screenPreferences.get(s.getId());
      pref.setText(s.get());
    }

    OsmandPlugin.onSettingsActivityUpdate(this);

    updateApplicationDirTextAndSummary();

    //		applicationModePreference.setTitle(getString(R.string.settings_preset) + "  ["
    //				+ osmandSettings.APPLICATION_MODE.get().toHumanString(this) + "]");
    routerServicePreference.setSummary(
        getString(R.string.router_service_descr)
            + "  ["
            + osmandSettings.ROUTER_SERVICE.get()
            + "]");
  }
Exemple #21
0
  public void fillLayout(final SipProfile account) {
    bindFields();
    if (!TextUtils.isEmpty(account.getDisplayName())) {
      accountDisplayName.setText(account.getDisplayName());
    } else {
      accountDisplayName.setText(getDefaultName());
    }

    accountUsername.setText(account.getSipUserName());
    accountServer.setText(account.getSipDomain());

    accountPassword.setText(account.data);
    accountAuthorization.setText(account.username);
    accountProxy.setText(account.getProxyAddress().replaceFirst("sip:", ""));
  }
Exemple #22
0
  public void updateAllSettings() {
    for (OsmandPreference<Boolean> b : booleanPreferences.values()) {
      CheckBoxPreference pref = (CheckBoxPreference) screenPreferences.get(b.getId());
      pref.setChecked(b.get());
    }

    for (OsmandPreference<Integer> b : seekBarPreferences.values()) {
      SeekBarPreference pref = (SeekBarPreference) screenPreferences.get(b.getId());
      pref.setValue(b.get());
    }

    reloadVoiceListPreference(getPreferenceScreen());

    for (OsmandPreference<?> p : listPreferences.values()) {
      ListPreference listPref = (ListPreference) screenPreferences.get(p.getId());
      Map<String, ?> prefValues = listPrefValues.get(p.getId());
      String[] entryValues = new String[prefValues.size()];
      String[] entries = new String[prefValues.size()];
      int i = 0;
      for (Entry<String, ?> e : prefValues.entrySet()) {
        entries[i] = e.getKey();
        entryValues[i] = e.getValue() + ""; // case of null
        i++;
      }
      listPref.setEntries(entries);
      listPref.setEntryValues(entryValues);
      listPref.setValue(p.get() + "");
    }

    for (OsmandPreference<String> s : editTextPreferences.values()) {
      EditTextPreference pref = (EditTextPreference) screenPreferences.get(s.getId());
      pref.setText(s.get());
    }

    // Specific properties
    routeServiceEnabled.setChecked(getMyApplication().getNavigationService() != null);

    updateTileSourceSummary();

    updateApplicationDirTextAndSummary();
  }
Exemple #23
0
  /**
   * Set summary for preference
   *
   * @param pref preference
   * @param init true if no recursive
   */
  private void setSummary(Preference pref, boolean init) {
    if (pref instanceof EditTextPreference) {
      EditTextPreference editPref = (EditTextPreference) pref;
      pref.setSummary(editPref.getText());

      if (editPref.getKey().equals("logfile") && !init) {
        editPref.setText(PrefStore.getLogFile(this));
        pref.setSummary(editPref.getText());
      }
    }

    if (pref instanceof ListPreference) {
      ListPreference listPref = (ListPreference) pref;
      pref.setSummary(listPref.getEntry());
    }

    if (pref instanceof CheckBoxPreference) {
      CheckBoxPreference checkPref = (CheckBoxPreference) pref;

      if (checkPref.getKey().equals("logger") && checkPref.isChecked() && init) {
        requestWritePermissions();
      }
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.rcs_settings_userprofile_preferences);

    displaynameEdit = (EditTextPreference) findPreference("edit_displayname");
    displaynameEdit.setPersistent(false);
    displaynameEdit.setOnPreferenceChangeListener(this);

    if (!isServiceConnected(RcsServiceName.FILE_TRANSFER)) {
      showMessage(R.string.label_service_not_available);
      return;
    }

    try {
      String name = getContactApi().getCommonConfiguration().getMyDisplayName();
      displaynameEdit.setText(name);
      displaynameEdit.setTitle(name);

    } catch (RcsServiceException e) {
      showExceptionThenExit(e);
    }
  }
  /** Restore all the preferences and check them */
  private void restorePreferences() {
    SharedPreferences.Editor editor = mPreferences.edit();
    editor.clear();
    editor.commit();
    mPreferencePort.setText(getResources().getString(R.string.default_port));
    mPreferenceWwwPath.setText(
        Environment.getExternalStorageDirectory()
            + getResources().getString(R.string.default_www_path));
    AccessPreferences.checkWwwPath(
        Environment.getExternalStorageDirectory()
            + getResources().getString(R.string.default_www_path));
    mPreferenceErrorPath.setText(
        Environment.getExternalStorageDirectory()
            + getResources().getString(R.string.default_error_path));
    AccessPreferences.checkErrorPath(
        Environment.getExternalStorageDirectory()
            + getResources().getString(R.string.default_error_path));
    mPreferenceLogPath.setText(
        Environment.getExternalStorageDirectory()
            + getResources().getString(R.string.default_log_path));
    AccessPreferences.checkLogPath(
        Environment.getExternalStorageDirectory()
            + getResources().getString(R.string.default_log_path));
    mPreferenceMaxClients.setText(getResources().getString(R.string.default_max_clients));
    mPreferenceExpirationCache.setText(getResources().getString(R.string.default_expiration_cache));
    mPreferenceVibrate.setChecked(false);
    mPreferenceFileIndexing.setChecked(true);
    mPreferenceLogEntries.setValue(getResources().getString(R.string.default_log_entries));
    // v0.2
    AccessPreferences.setVersion(getResources().getString(R.string.version));
    mPreferenceAutostartBoot.setChecked(false);
    mPreferenceAutostartWifi.setChecked(false);
    mPreferenceAutostopWifi.setChecked(false);
    mPreferenceAutostartBoot.setEnabled(true);
    mPreferenceAutostartWifi.setEnabled(true);
    mPreferenceShowNotification.setChecked(true);
    // mPreferenceAutostopWifi.setEnabled(false);

  }
Exemple #26
0
  public void fillLayout(final SipProfile account) {
    bindFields();

    accountDisplayName.setText(account.display_name);
    accountAccId.setText(account.acc_id);
    accountRegUri.setText(account.reg_uri);
    accountRealm.setText(account.realm);
    accountUserName.setText(account.username);
    accountData.setText(account.data);

    {
      String scheme = account.scheme;
      if (scheme != null && !scheme.equals("")) {
        accountScheme.setValue(scheme);
      } else {
        accountScheme.setValue(SipProfile.CRED_SCHEME_DIGEST);
      }
    }
    {
      int ctype = account.datatype;
      if (ctype == SipProfile.CRED_DATA_PLAIN_PASSWD) {
        accountDataType.setValueIndex(0);
      } else if (ctype == SipProfile.CRED_DATA_DIGEST) {
        accountDataType.setValueIndex(1);
      }
      // DISABLED SINCE NOT SUPPORTED YET
      /*
      else if (ctype ==SipProfile.CRED_CRED_DATA_EXT_AKA) {
      	accountDataType.setValueIndex(2);
      } */ else {
        accountDataType.setValueIndex(0);
      }
    }
    accountInitAuth.setChecked(account.initial_auth);
    accountAuthAlgo.setText(account.auth_algo);

    accountTransport.setValue(account.transport.toString());
    if (!TextUtils.isEmpty(account.default_uri_scheme)) {
      accountDefaultUriScheme.setValue(account.default_uri_scheme);
    }
    accountPublishEnabled.setChecked((account.publish_enabled == 1));
    accountRegTimeout.setText(Long.toString(account.reg_timeout));
    accountRegDelayRefresh.setText(Long.toString(account.reg_delay_before_refresh));

    accountForceContact.setText(account.force_contact);
    accountAllowContactRewrite.setChecked(account.allow_contact_rewrite);
    accountAllowViaRewrite.setChecked(account.allow_via_rewrite);
    accountContactRewriteMethod.setValue(Integer.toString(account.contact_rewrite_method));
    if (account.proxies != null) {
      accountProxy.setText(TextUtils.join(SipProfile.PROXIES_SEPARATOR, account.proxies));
    } else {
      accountProxy.setText("");
    }
    Log.d(THIS_FILE, "use srtp : " + account.use_srtp);
    accountUseSrtp.setValueIndex(account.use_srtp + 1);
    accountUseZrtp.setValueIndex(account.use_zrtp + 1);

    useRfc5626.setChecked(account.use_rfc5626);
    rfc5626_instanceId.setText(account.rfc5626_instance_id);
    rfc5626_regId.setText(account.rfc5626_reg_id);

    rtpEnableQos.setValue(Integer.toString(account.rtp_enable_qos));
    rtpQosDscp.setText(Integer.toString(account.rtp_qos_dscp));
    rtpPort.setText(Integer.toString(account.rtp_port));
    rtpBoundAddr.setText(account.rtp_bound_addr);
    rtpPublicAddr.setText(account.rtp_public_addr);

    vidInAutoShow.setValue(Integer.toString(account.vid_in_auto_show));
    vidOutAutoTransmit.setValue(Integer.toString(account.vid_out_auto_transmit));

    accountVm.setText(account.vm_nbr);
    mwiEnabled.setChecked(account.mwi_enabled);
    tryCleanRegisters.setChecked(account.try_clean_registers != 0);

    sipStunUse.setValue(Integer.toString(account.sip_stun_use));
    mediaStunUse.setValue(Integer.toString(account.media_stun_use));
    iceCfgUse.setChecked(account.ice_cfg_use == 1);
    iceCfgEnable.setChecked(account.ice_cfg_enable == 1);
    turnCfgUse.setChecked(account.turn_cfg_use == 1);
    turnCfgEnable.setChecked(account.turn_cfg_enable == 1);
    turnCfgServer.setText(account.turn_cfg_server);
    turnCfgUser.setText(account.turn_cfg_user);
    turnCfgPassword.setText(account.turn_cfg_password);

    ipv6MediaEnable.setChecked(account.ipv6_media_use == 1);
  }
 @Test
 public void setTextShouldStoreText() {
   preference.setText("some other text");
   assertThat(preference.getText()).isEqualTo("some other text");
 }
 @Test
 public void setTextShouldStoreNull() {
   preference.setText(null);
   assertNull(preference.getText());
 }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);

    mPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    mPreferencePort =
        (EditTextPreference) findPreference(getResources().getString(R.string.pref_port_key));

    mPreferenceMaxClients =
        (EditTextPreference)
            findPreference(getResources().getString(R.string.pref_max_clients_key));
    mPreferenceExpirationCache =
        (EditTextPreference)
            findPreference(getResources().getString(R.string.pref_expiration_cache_key));

    mPreferenceWwwPath =
        (EditTextPreference) findPreference(getResources().getString(R.string.pref_www_path_key));

    mPreferenceErrorPath =
        (EditTextPreference) findPreference(getResources().getString(R.string.pref_error_path_key));

    mPreferenceLogPath =
        (EditTextPreference) findPreference(getResources().getString(R.string.pref_log_path_key));

    mPreferenceResetPref =
        (Preference) findPreference(getResources().getString(R.string.pref_reset_config_key));

    mPreferenceVibrate =
        (CheckBoxPreference) findPreference(getResources().getString(R.string.pref_vibrate_key));

    mPreferenceFileIndexing =
        (CheckBoxPreference) findPreference(getResources().getString(R.string.pref_vibrate_key));

    mPreferenceAutostartBoot =
        (CheckBoxPreference)
            findPreference(getResources().getString(R.string.pref_autostart_boot_key));

    mPreferenceAutostartWifi =
        (CheckBoxPreference)
            findPreference(getResources().getString(R.string.pref_autostart_wifi_key));
    mPreferenceAutostopWifi =
        (CheckBoxPreference)
            findPreference(getResources().getString(R.string.pref_autostop_wifi_key));

    mPreferenceShowNotification =
        (CheckBoxPreference)
            findPreference(getResources().getString(R.string.pref_show_notification_key));
    mPreferenceShowAds =
        (CheckBoxPreference) findPreference(getResources().getString(R.string.pref_show_ads_key));

    mPreferenceLogEntries =
        (ListPreference) findPreference(getResources().getString(R.string.pref_log_entries_key));

    mPreferenceAbout =
        (Preference) findPreference(getResources().getString(R.string.pref_about_key));

    mPreferenceFileIndexingGetTemplate =
        (Preference)
            findPreference(
                getResources().getString(R.string.pref_directory_indexing_get_template_key));

    mPreferenceReleaseNotes =
        (Preference) findPreference(getResources().getString(R.string.pref_release_notes_key));

    mPreferenceWwwPath.setText(AccessPreferences.getWwwPath());
    mPreferenceErrorPath.setText(AccessPreferences.getErrorPath());
    mPreferenceLogPath.setText(AccessPreferences.getLogPath());

    mPreferenceAutostartWifi.setOnPreferenceChangeListener(
        new OnPreferenceChangeListener() {
          public boolean onPreferenceChange(Preference preference, Object newValue) {

            if (newValue instanceof Boolean) {
              boolean value = ((Boolean) newValue).booleanValue();
              if (value) {
                mPreferenceAutostartBoot.setEnabled(false);
                mPreferenceAutostopWifi.setEnabled(true);
              } else {
                mPreferenceAutostartBoot.setEnabled(true);
                // mPreferenceAutostopWifi.setChecked(false);
              }
            }
            return true;
          }
        });

    mPreferenceAutostartBoot.setOnPreferenceChangeListener(
        new OnPreferenceChangeListener() {
          public boolean onPreferenceChange(Preference preference, Object newValue) {

            if (newValue instanceof Boolean) {
              boolean value = ((Boolean) newValue).booleanValue();
              if (value) {
                mPreferenceAutostartWifi.setEnabled(false);
                mPreferenceAutostopWifi.setEnabled(false);
              } else {
                mPreferenceAutostartWifi.setEnabled(true);
              }
            }
            return true;
          }
        });

    // Check the port
    mPreferencePort.setOnPreferenceChangeListener(
        new OnPreferenceChangeListener() {
          public boolean onPreferenceChange(Preference preference, Object newValue) {

            try {
              int port = Integer.parseInt((String) newValue);
              if (port >= 65535 || port < 1) { // If you are not
                // root, you only
                // can until 1024
                return false;
              }
              if (port > 1 && port < 1024) { // check if it is
                // rooted
                if (ShellCommands.isIptablesExist()) {
                  if (!ShellCommands.isDeviceRooted()) {
                    Toast.makeText(
                            PreferencesActivity.this, R.string.no_su_permissions, Toast.LENGTH_LONG)
                        .show();
                    ;
                    return false;
                  }
                } else {
                  Toast.makeText(PreferencesActivity.this, R.string.no_iptables, Toast.LENGTH_LONG)
                      .show();
                  ;
                  return false;
                }
              }

            } catch (NumberFormatException e) {
              return false;
            }

            return true;
          }
        });

    // Check the max clients
    mPreferenceMaxClients.setOnPreferenceChangeListener(
        new OnPreferenceChangeListener() {

          public boolean onPreferenceChange(Preference preference, Object newValue) {

            try {
              Integer.parseInt((String) newValue);

            } catch (NumberFormatException e) {
              return false;
            }

            return true;
          }
        });

    mPreferenceExpirationCache.setOnPreferenceChangeListener(
        new OnPreferenceChangeListener() {

          public boolean onPreferenceChange(Preference preference, Object newValue) {

            try {
              Integer.parseInt((String) newValue);

            } catch (NumberFormatException e) {
              return false;
            }

            return true;
          }
        });

    // We check the path and create it if it does not exist
    mPreferenceWwwPath.setOnPreferenceChangeListener(
        new OnPreferenceChangeListener() {

          public boolean onPreferenceChange(Preference preference, Object newValue) {

            return AccessPreferences.checkWwwPath((String) newValue);
          }
        });

    // We check the path and create it if it does not exist
    mPreferenceErrorPath.setOnPreferenceChangeListener(
        new OnPreferenceChangeListener() {

          public boolean onPreferenceChange(Preference preference, Object newValue) {
            return AccessPreferences.checkErrorPath((String) newValue);
          }
        });

    // We check the path and create it if it does not exist
    mPreferenceLogPath.setOnPreferenceChangeListener(
        new OnPreferenceChangeListener() {

          public boolean onPreferenceChange(Preference preference, Object newValue) {
            return AccessPreferences.checkLogPath((String) newValue);
          }
        });

    // Reset to default preferences
    mPreferenceResetPref.setOnPreferenceClickListener(
        new OnPreferenceClickListener() {

          public boolean onPreferenceClick(Preference preference) {

            showResetDialog();

            return true;
          }
        });

    mPreferenceAbout.setOnPreferenceClickListener(
        new OnPreferenceClickListener() {

          public boolean onPreferenceClick(Preference preference) {

            showAboutDialog();

            return true;
          }
        });

    mPreferenceFileIndexingGetTemplate.setOnPreferenceClickListener(
        new OnPreferenceClickListener() {

          public boolean onPreferenceClick(Preference preference) {

            showDownloadTemplateDialog();

            return true;
          }
        });

    mPreferenceReleaseNotes.setOnPreferenceClickListener(
        new OnPreferenceClickListener() {

          public boolean onPreferenceClick(Preference preference) {

            showReleaseNotesDialog();

            return true;
          }
        });

    mPreferenceShowAds.setEnabled(false);
  }
 @Override
 protected void setUp() {
   final AccountManager accountManager = AccountManager.get(getActivity());
   final AccountMirakel accountMirakel = mItem;
   final Account account = accountMirakel.getAndroidAccount();
   // Preference Fields
   final Preference syncUsername = findPreference("syncUsername");
   final EditTextPreference syncServer = (EditTextPreference) findPreference("syncServer");
   final SwitchPreference syncUse = (SwitchPreference) findPreference("syncUse");
   final Preference syncType = findPreference("sync_type");
   final SwitchPreference defaultAccount = (SwitchPreference) findPreference("defaultAccount");
   final Preference syncInterval = findPreference("syncFrequency");
   // Set Preferences
   syncUsername.setEnabled(false);
   syncUsername.setSummary(accountMirakel.getName());
   // sync Server
   if (AccountMirakel.ACCOUNT_TYPES.TASKWARRIOR == accountMirakel.getType()) {
     syncServer.setEnabled(false);
     syncServer.setSummary(accountManager.getUserData(account, SyncAdapter.BUNDLE_SERVER_URL));
     syncServer.setText(accountManager.getUserData(account, SyncAdapter.BUNDLE_SERVER_URL));
     syncServer.setOnPreferenceChangeListener(
         new Preference.OnPreferenceChangeListener() {
           @Override
           public boolean onPreferenceChange(final Preference preference, final Object newValue) {
             accountManager.setUserData(account, SyncAdapter.BUNDLE_SERVER_URL, (String) newValue);
             syncServer.setSummary((String) newValue);
             syncServer.setText((String) newValue);
             return false;
           }
         });
   } else {
     syncServer.setEnabled(false);
     syncServer.setSummary("");
   }
   // sync use
   syncUse.setChecked(accountMirakel.isEnabled());
   syncUse.setOnPreferenceChangeListener(
       new Preference.OnPreferenceChangeListener() {
         @Override
         public boolean onPreferenceChange(final Preference preference, final Object newValue) {
           accountMirakel.setEnabled((Boolean) newValue);
           accountMirakel.save();
           return true;
         }
       });
   if (accountMirakel.getType() == AccountMirakel.ACCOUNT_TYPES.LOCAL) {
     removePreference("syncUse");
     removePreference("syncServer");
     removePreference("syncUsername");
   }
   // Sync type
   syncType.setSummary(accountMirakel.getType().typeName(getActivity()));
   // Default Account
   defaultAccount.setChecked(
       MirakelModelPreferences.getDefaultAccount().getId() == accountMirakel.getId());
   defaultAccount.setOnPreferenceChangeListener(
       new Preference.OnPreferenceChangeListener() {
         @Override
         public boolean onPreferenceChange(final Preference preference, final Object newValue) {
           if ((Boolean) newValue) {
             MirakelModelPreferences.setDefaultAccount(accountMirakel);
           } else {
             MirakelModelPreferences.setDefaultAccount(AccountMirakel.getLocal());
           }
           defaultAccount.setChecked((Boolean) newValue);
           return false;
         }
       });
   // Interval
   syncInterval.setEnabled(false);
   if (MirakelModelPreferences.getSyncFrequency(accountMirakel) == -1) {
     syncInterval.setSummary(R.string.sync_frequency_summary_man);
   } else {
     syncInterval.setSummary(
         this.getString(
             R.string.sync_frequency_summary,
             MirakelModelPreferences.getSyncFrequency(accountMirakel)));
   }
   syncInterval.setOnPreferenceClickListener(
       new Preference.OnPreferenceClickListener() {
         @Override
         public boolean onPreferenceClick(final Preference preference) {
           int hours = MirakelModelPreferences.getSyncFrequency(accountMirakel);
           if (hours == -1) {
             hours = 0;
           }
           final int minutes = hours % 60;
           hours = (int) Math.floor(hours / 60.);
           final TimePicker timePicker = new TimePicker(getActivity());
           timePicker.setIs24HourView(true);
           timePicker.setCurrentHour(hours);
           timePicker.setCurrentMinute(minutes);
           final AlertDialog.Builder dialog =
               new AlertDialog.Builder(getActivity())
                   .setTitle(R.string.sync_frequency)
                   .setView(timePicker)
                   .setPositiveButton(
                       android.R.string.ok,
                       new DialogInterface.OnClickListener() {
                         @Override
                         public void onClick(final DialogInterface dialog, final int which) {
                           int newValue =
                               timePicker.getCurrentHour() * 60 + timePicker.getCurrentMinute();
                           if (newValue == 0) {
                             newValue = -1;
                           }
                           final Bundle bundle = new Bundle();
                           if (newValue == -1) {
                             syncInterval.setSummary(R.string.sync_frequency_summary_man);
                           } else {
                             syncInterval.setSummary(
                                 getActivity()
                                     .getString(R.string.sync_frequency_summary, newValue));
                           }
                           if (accountMirakel != null) {
                             ContentResolver.removePeriodicSync(
                                 account, DefinitionsHelper.AUTHORITY_TYP, bundle);
                             if (newValue != -1) {
                               ContentResolver.setSyncAutomatically(
                                   account, DefinitionsHelper.AUTHORITY_TYP, true);
                               ContentResolver.setIsSyncable(
                                   account, DefinitionsHelper.AUTHORITY_TYP, 1);
                               ContentResolver.addPeriodicSync(
                                   account,
                                   DefinitionsHelper.AUTHORITY_TYP,
                                   bundle,
                                   newValue * 60);
                             }
                           } else {
                             Log.d(TAG, "account does not exsist");
                           }
                           MirakelModelPreferences.setSyncFrequency(accountMirakel, newValue);
                         }
                       });
           dialog.show();
           return false;
         }
       });
   if (accountMirakel.getType() != AccountMirakel.ACCOUNT_TYPES.TASKWARRIOR) {
     // we can control this only for tw
     removePreference("syncFrequency");
   } else {
     syncInterval.setEnabled(true);
   }
 }