public void refreshSettings() {

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

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

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

    for (int i = 0; i < lockscreenTargets; i++) {
      ListPreference p = new ListPreference(getActivity());
      String dialogTitle =
          String.format(getResources().getString(R.string.custom_app_n_dialog_title), i + 1);
      ;
      p.setDialogTitle(dialogTitle);
      p.setEntries(R.array.lockscreen_choice_entries);
      p.setEntryValues(R.array.lockscreen_choice_values);
      String title = String.format(getResources().getString(R.string.custom_app_n), i + 1);
      p.setTitle(title);
      p.setKey("lockscreen_target_" + i);
      p.setSummary(getProperSummary(i));
      p.setOnPreferenceChangeListener(this);
      targetGroup.addPreference(p);
    }
  }
Exemple #2
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);
  }
Exemple #3
0
 public <T> ListPreference createListPreference(
     OsmandPreference<T> b, String[] names, T[] values, int title, int summary) {
   ListPreference p = new ListPreference(this);
   p.setTitle(title);
   p.setKey(b.getId());
   p.setDialogTitle(title);
   p.setSummary(summary);
   prepareListPreference(b, names, values, p);
   return p;
 }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.addPreferencesFromResource(R.layout.layout_text_settings_activity);

    PreferenceScreen screen = this.getPreferenceScreen();

    ListPreference idList = new ListPreference(this);
    idList.setTitle(R.string.config_identifiers_title);
    idList.setDialogTitle(R.string.config_identifiers_title);
    idList.setKey("config_text_identifier");

    String[] identifiers = IdentifiersManager.fetchIdentifiers(this);

    idList.setEntries(identifiers);
    idList.setEntryValues(identifiers);

    screen.addPreference(idList);
  }
Exemple #5
0
  @Override
  public void fillLayout(SipProfile account) {
    super.fillLayout(account);

    CharSequence[] states =
        new CharSequence[] {
          "login", "pbx2", "pbx3", "pbx4", "pbx6", "pbx7", "pbx8", "pbx9", "pbx10", "pbx11",
          "pbx12", "pbx13", "pbx15"
        };

    boolean recycle = true;
    accountState = (ListPreference) parent.findPreference(STATE_KEY);
    if (accountState == null) {
      accountState = new ListPreference(parent);
      accountState.setKey(STATE_KEY);
      recycle = false;
    }

    accountState.setEntries(states);
    accountState.setEntryValues(states);
    accountState.setDialogTitle(R.string.w_common_server);
    accountState.setTitle(R.string.w_common_server);
    accountState.setSummary(R.string.w_common_server_desc);
    accountState.setDefaultValue("login");

    if (!recycle) {
      parent.getPreferenceScreen().addPreference(accountState);
    }

    String domain = account.reg_uri;
    if (domain != null) {
      for (CharSequence state : states) {
        String currentComp = "sip:" + state + ".belcentrale.nl";
        if (domain.startsWith(currentComp)) {
          accountState.setValue((String) state);
          break;
        }
      }
    }

    accountUsername.getEditText().setInputType(InputType.TYPE_CLASS_PHONE);
  }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.addPreferencesFromResource(R.layout.layout_five_settings_activity);

    PreferenceScreen screen = this.getPreferenceScreen();

    ListPreference idList = new ListPreference(this);
    idList.setTitle(R.string.config_identifiers_title);
    idList.setDialogTitle(R.string.config_identifiers_title);
    idList.setKey("config_five_identifier");

    String[] identifiers = IdentifiersManager.fetchIdentifiers(this);

    idList.setEntries(identifiers);
    idList.setEntryValues(identifiers);

    screen.addPreference(idList);

    EditTextPreference editPreference =
        (EditTextPreference) screen.findPreference("config_five_one");
    EditText field = editPreference.getEditText();
    field.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);

    editPreference = (EditTextPreference) screen.findPreference("config_five_two");
    field = editPreference.getEditText();
    field.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);

    editPreference = (EditTextPreference) screen.findPreference("config_five_three");
    field = editPreference.getEditText();
    field.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);

    editPreference = (EditTextPreference) screen.findPreference("config_five_four");
    field = editPreference.getEditText();
    field.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);

    editPreference = (EditTextPreference) screen.findPreference("config_five_five");
    field = editPreference.getEditText();
    field.setRawInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
  }
Exemple #7
0
 public static ListPreference List(
     Context paramContext,
     PreferenceCategory paramPreferenceCategory,
     String paramString1,
     String paramString2,
     String paramString3,
     String paramString4,
     Object paramObject,
     CharSequence[] paramArrayOfCharSequence1,
     CharSequence[] paramArrayOfCharSequence2,
     boolean paramBoolean) {
   ListPreference localListPreference = new ListPreference(paramContext);
   localListPreference.setTitle(paramString1);
   localListPreference.setSummary(paramString2);
   localListPreference.setEnabled(paramBoolean);
   localListPreference.setKey(paramString4);
   localListPreference.setDefaultValue(paramObject);
   localListPreference.setDialogTitle(paramString3);
   localListPreference.setEntries(paramArrayOfCharSequence1);
   localListPreference.setEntryValues(paramArrayOfCharSequence2);
   paramPreferenceCategory.addPreference(localListPreference);
   return localListPreference;
 }
  private PreferenceScreen createPreferenceHierarchy() {
    int index = 0;
    if (mPrefs == null) {
      return null;
    }
    // Root
    PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);

    // Band/Country
    String[] summaryBandItems = getResources().getStringArray(R.array.regional_band_summary);
    mBandPreference = new ListPreference(this);
    mBandPreference.setEntries(R.array.regional_band_entries);
    mBandPreference.setEntryValues(R.array.regional_band_values);
    mBandPreference.setDialogTitle(R.string.sel_band_menu);
    mBandPreference.setKey(REGIONAL_BAND_KEY);
    mBandPreference.setTitle(R.string.regional_band);
    index = FmSharedPreferences.getCountry();
    Log.d(LOGTAG, "createPreferenceHierarchy: Country: " + index);
    // Get the preference and list the value.
    if ((index < 0) || (index >= summaryBandItems.length)) {
      index = 0;
    }
    Log.d(LOGTAG, "createPreferenceHierarchy: CountrySummary: " + summaryBandItems[index]);
    mBandPreference.setSummary(summaryBandItems[index]);
    mBandPreference.setValueIndex(index);
    root.addPreference(mBandPreference);

    if (mRxMode) {
      // Audio Output (Stereo or Mono)
      String[] summaryAudioModeItems = getResources().getStringArray(R.array.ster_mon_entries);
      mAudioPreference = new ListPreference(this);
      mAudioPreference.setEntries(R.array.ster_mon_entries);
      mAudioPreference.setEntryValues(R.array.ster_mon_values);
      mAudioPreference.setDialogTitle(R.string.sel_audio_output);
      mAudioPreference.setKey(AUDIO_OUTPUT_KEY);
      mAudioPreference.setTitle(R.string.aud_output_mode);
      boolean audiomode = FmSharedPreferences.getAudioOutputMode();
      if (audiomode) {
        index = 0;
      } else {
        index = 1;
      }
      Log.d(LOGTAG, "createPreferenceHierarchy: audiomode: " + audiomode);
      mAudioPreference.setSummary(summaryAudioModeItems[index]);
      mAudioPreference.setValueIndex(index);
      root.addPreference(mAudioPreference);

      // AF Auto Enable (Checkbox)
      mAfPref = new CheckBoxPreference(this);
      mAfPref.setKey(AUTO_AF);
      mAfPref.setTitle(R.string.auto_select_af);
      mAfPref.setSummaryOn(R.string.auto_select_af_enabled);
      mAfPref.setSummaryOff(R.string.auto_select_af_disabled);
      boolean bAFAutoSwitch = FmSharedPreferences.getAutoAFSwitch();
      Log.d(LOGTAG, "createPreferenceHierarchy: bAFAutoSwitch: " + bAFAutoSwitch);
      mAfPref.setChecked(bAFAutoSwitch);
      root.addPreference(mAfPref);

      if (FMRadio.RECORDING_ENABLE) {
        String[] summaryRecordItems =
            getResources().getStringArray(R.array.record_durations_entries);
        mRecordDurPreference = new ListPreference(this);
        mRecordDurPreference.setEntries(R.array.record_durations_entries);
        mRecordDurPreference.setEntryValues(R.array.record_duration_values);
        mRecordDurPreference.setDialogTitle(R.string.sel_rec_dur);
        mRecordDurPreference.setKey(RECORD_DURATION_KEY);
        mRecordDurPreference.setTitle(R.string.record_dur);
        index = FmSharedPreferences.getRecordDuration();
        Log.d(LOGTAG, "createPreferenceHierarchy: recordDuration: " + index);
        // Get the preference and list the value.
        if ((index < 0) || (index >= summaryRecordItems.length)) {
          index = 0;
        }
        Log.d(
            LOGTAG,
            "createPreferenceHierarchy: recordDurationSummary: " + summaryRecordItems[index]);
        mRecordDurPreference.setSummary(summaryRecordItems[index]);
        mRecordDurPreference.setValueIndex(index);
        root.addPreference(mRecordDurPreference);
      }
    }

    mBluetoothBehaviour = new ListPreference(this);
    mBluetoothBehaviour.setEntries(R.array.bt_exit_behaviour_entries);
    mBluetoothBehaviour.setEntryValues(R.array.bt_exit_behaviour_values);
    mBluetoothBehaviour.setDialogTitle(R.string.pref_bt_behaviour_on_exit_dialog_title);
    mBluetoothBehaviour.setKey(BT_EXIT_BEHAVIOUR);
    mBluetoothBehaviour.setTitle(R.string.pref_bt_behaviour_on_exit_title);
    mBluetoothBehaviour.setSummary(R.string.pref_bt_behaviour_on_exit_summary);
    root.addPreference(mBluetoothBehaviour);

    mRemoveHeadset = new CheckBoxPreference(this);
    mRemoveHeadset.setKey(HEADSET_DC_BEHAVIOUR);
    mRemoveHeadset.setTitle(R.string.pref_headset_behaviour_title);
    mRemoveHeadset.setSummary(R.string.pref_headset_behaviour_summary);
    mRemoveHeadset.setChecked(FmSharedPreferences.getHeadsetDcBehaviour());
    root.addPreference(mRemoveHeadset);

    mRestoreDefaultPreference = new Preference(this);
    mRestoreDefaultPreference.setTitle(R.string.settings_revert_defaults_title);
    mRestoreDefaultPreference.setKey(RESTORE_FACTORY_DEFAULT);
    mRestoreDefaultPreference.setSummary(R.string.settings_revert_defaults_summary);
    mRestoreDefaultPreference.setOnPreferenceClickListener(this);
    root.addPreference(mRestoreDefaultPreference);

    // Add a new category
    PreferenceCategory prefCat = new PreferenceCategory(this);
    prefCat.setTitle(R.string.about_title);
    root.addPreference(prefCat);

    mAboutPreference = new Preference(this);
    mAboutPreference.setTitle(R.string.about_title);
    mAboutPreference.setKey(ABOUT_KEY);
    mAboutPreference.setSummary(R.string.about_summary);
    mAboutPreference.setOnPreferenceClickListener(this);
    root.addPreference(mAboutPreference);

    return root;
  }
    protected void onPostExecute(Boolean result) {
      if (D) Log.d(TAG, "onPostExecute - " + result);

      if (result) {

        boolean enabled = mHelper.loadBooleanPref(context, "enabled", mHelper.SYNC);

        CheckBoxPreference cbp_enabled = new CheckBoxPreference(context);
        cbp_enabled.setTitle(res.getString(R.string.enabled_title));
        cbp_enabled.setChecked(enabled);
        cbp_enabled.setOnPreferenceChangeListener(
            new Preference.OnPreferenceChangeListener() {
              public boolean onPreferenceChange(Preference p, Object o) {
                boolean newvalue = Boolean.parseBoolean(o.toString());
                mHelper.saveBooleanPref(context, "enabled", newvalue);

                //

                pc_cell.setEnabled(newvalue);
                pc_wifi.setEnabled(newvalue);
                lp_notifications.setEnabled(newvalue);

                return true;
              }
            });

        int notifications = mHelper.loadIntPref(context, "notifications", mHelper.NOTIFICATIONS);

        final String[] notifications_entries = res.getStringArray(R.array.notifications);
        String[] notifications_values = new String[] {"0", "1", "2"};

        lp_notifications = new ListPreference(AccountsActivity.this);
        lp_notifications.setEnabled(enabled);
        lp_notifications.setTitle(res.getString(R.string.notifications));
        lp_notifications.setEntries(notifications_entries);
        lp_notifications.setEntryValues(notifications_values);
        lp_notifications.setDialogTitle(res.getString(R.string.pleasechoose));
        lp_notifications.setSummary(notifications_entries[notifications]);
        lp_notifications.setValue(String.valueOf(notifications));
        lp_notifications.setOnPreferenceChangeListener(
            new Preference.OnPreferenceChangeListener() {
              public boolean onPreferenceChange(Preference preference, Object newValue) {
                final String summary = newValue.toString();
                ListPreference lp = (ListPreference) preference;
                int newvalue = lp.findIndexOfValue(summary);
                lp.setSummary(notifications_entries[newvalue]);
                mHelper.saveIntPref(context, "notifications", newvalue);

                return true;
              }
            });

        //

        pc_cell = new PreferenceCategory(context);
        pc_cell.setTitle(
            res.getString(R.string.mobiledata) + " - " + res.getString(R.string.accounts));
        pc_cell.setEnabled(enabled);

        pc_wifi = new PreferenceCategory(context);
        pc_wifi.setEnabled(false);
        pc_wifi.setTitle(res.getString(R.string.wifi) + " - " + res.getString(R.string.accounts));
        pc_wifi.setEnabled(enabled);

        int length = Helper.accounts.size();
        if (length > 0) {
          root.addPreference(cbp_enabled);
          root.addPreference(lp_notifications);

          // MobileData Accounts
          root.addPreference(pc_cell);

          for (int i = 0; i < length; i++) {

            final Ac ac = (Ac) Helper.accounts.get(i);

            @SuppressWarnings("deprecation")
            PreferenceScreen ps =
                getPreferenceManager().createPreferenceScreen(AccountsActivity.this);
            ps.setTitle(ac.getAccount().name + " - " + res.getString(R.string.mobiledata));
            ps.setSummary(ac.getAccount().type);
            pc_cell.addPreference(ps);

            final ArrayList<At> ats = ac.getAuthorities();
            for (int j = 0; j < ats.size(); j++) {

              final At at = (At) ats.get(j);

              final CheckBoxPreference cbp = new CheckBoxPreference(context);
              cbp.setTitle(at.getAuthorityName());
              cbp.setSummary(at.getAuthorityValue());

              final String whichone =
                  mHelper.CELL
                      + "_"
                      + ac.getAccount().name
                      + "_"
                      + ac.getAccount().type
                      + "_"
                      + at.getAuthorityValue();
              boolean sync = mHelper.loadBooleanPref(context, whichone, mHelper.SYNC);
              cbp.setChecked(sync);

              cbp.setOnPreferenceChangeListener(
                  new Preference.OnPreferenceChangeListener() {
                    public boolean onPreferenceChange(Preference p, Object o) {

                      boolean newvalue = Boolean.parseBoolean(o.toString());
                      mHelper.saveBooleanPref(context, whichone, newvalue);

                      //

                      mHelper.setAccounts(context, mHelper.CELL, false);

                      return true;
                    }
                  });

              ps.addPreference(cbp);
            }
          }

          //

          int ps_cell = mHelper.loadIntPref(context, "ps_cell", mHelper.PERIODIC_SYNC);

          final String[] times = res.getStringArray(R.array.times);
          final String[] times_values = res.getStringArray(R.array.times_values);

          ListPreference lp_cell = new ListPreference(AccountsActivity.this);
          lp_cell.setTitle(
              res.getString(R.string.periodicsync) + " - " + res.getString(R.string.mobiledata));
          lp_cell.setEntries(times);
          lp_cell.setEntryValues(times_values);
          lp_cell.setDialogTitle(res.getString(R.string.pleasechoose));
          lp_cell.setSummary(times[ps_cell]);
          lp_cell.setValue(String.valueOf(ps_cell));
          lp_cell.setOnPreferenceChangeListener(
              new Preference.OnPreferenceChangeListener() {
                public boolean onPreferenceChange(Preference preference, Object newValue) {
                  final String summary = newValue.toString();
                  ListPreference lp = (ListPreference) preference;
                  int newvalue = lp.findIndexOfValue(summary);
                  lp.setSummary(times[newvalue]);
                  mHelper.saveIntPref(context, "ps_cell", Integer.parseInt(times_values[newvalue]));
                  if (mHelper.isConnected(context, mHelper.CELL))
                    mHelper.setAccounts(context, mHelper.CELL, false);

                  return true;
                }
              });
          // pc_cell.addPreference(lp_cell);

          // Wifi-Accounts
          root.addPreference(pc_wifi);

          for (int i = 0; i < length; i++) {

            final Ac ac = (Ac) Helper.accounts.get(i);

            @SuppressWarnings("deprecation")
            PreferenceScreen ps =
                getPreferenceManager().createPreferenceScreen(AccountsActivity.this);
            ps.setTitle(ac.getAccount().name + " - " + res.getString(R.string.wifi));
            ps.setSummary(ac.getAccount().type);
            pc_wifi.addPreference(ps);

            final ArrayList<At> ats = ac.getAuthorities();
            for (int j = 0; j < ats.size(); j++) {

              final At at = (At) ats.get(j);

              final CheckBoxPreference cbp = new CheckBoxPreference(context);
              cbp.setTitle(at.getAuthorityName());
              cbp.setSummary(at.getAuthorityValue());

              final String whichone =
                  mHelper.WIFI
                      + "_"
                      + ac.getAccount().name
                      + "_"
                      + ac.getAccount().type
                      + "_"
                      + at.getAuthorityValue();
              boolean sync = mHelper.loadBooleanPref(context, whichone, mHelper.SYNC);
              cbp.setChecked(sync);

              cbp.setOnPreferenceChangeListener(
                  new Preference.OnPreferenceChangeListener() {
                    public boolean onPreferenceChange(Preference p, Object o) {

                      boolean newvalue = Boolean.parseBoolean(o.toString());
                      mHelper.saveBooleanPref(context, whichone, newvalue);

                      //

                      mHelper.setAccounts(context, mHelper.WIFI, false);

                      return true;
                    }
                  });

              ps.addPreference(cbp);
            }
          }

          //

          int ps_wifi = mHelper.loadIntPref(context, "ps_wifi", mHelper.PERIODIC_SYNC);

          ListPreference lp_wifi = new ListPreference(AccountsActivity.this);
          lp_wifi.setTitle(
              res.getString(R.string.periodicsync) + " - " + res.getString(R.string.wifi));
          lp_wifi.setEntries(times);
          lp_wifi.setEntryValues(times_values);
          lp_wifi.setDialogTitle(res.getString(R.string.pleasechoose));
          lp_wifi.setSummary(times[ps_wifi]);
          lp_wifi.setValue(String.valueOf(ps_wifi));
          lp_wifi.setOnPreferenceChangeListener(
              new Preference.OnPreferenceChangeListener() {
                public boolean onPreferenceChange(Preference preference, Object newValue) {
                  final String summary = newValue.toString();
                  ListPreference lp = (ListPreference) preference;
                  int newvalue = lp.findIndexOfValue(summary);
                  lp.setSummary(times[newvalue]);
                  mHelper.saveIntPref(context, "ps_wifi", Integer.parseInt(times_values[newvalue]));
                  if (mHelper.isConnected(context, mHelper.WIFI))
                    mHelper.setAccounts(context, mHelper.WIFI, false);

                  return true;
                }
              });
          // pc_wifi.addPreference(lp_wifi);

        } else {

          Preference p_noaccountsfound = new Preference(context);
          p_noaccountsfound.setTitle(res.getString(R.string.noaccounts_title));
          p_noaccountsfound.setSummary(res.getString(R.string.noaccounts_summary));
          p_noaccountsfound.setEnabled(false);
          root.addPreference(p_noaccountsfound);
        }
      }
    }