Exemple #1
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);
  }
  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 #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;
 }
 private void addPrefetchLinks() {
   final ListPreference pref = new ListPreference(getActivity());
   pref.setKey(KEY_PREFETCH_LINKS);
   pref.setTitle("Prefetch links"); // ES
   pref.setSummary("Fetch new link titles during background updates."); // ES
   pref.setEntries(PrefetchMode.prefEntries());
   pref.setEntryValues(PrefetchMode.prefEntryValues());
   pref.setDefaultValue(PrefetchMode.NO.getValue());
   getPreferenceScreen().addPreference(pref);
 }
  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);
  }
Exemple #6
0
  private static void addPreferences(PreferenceScreen ps) {
    Context cx = ps.getContext();
    Resources r = cx.getResources();
    ps.setOrderingAsAdded(true);

    for (Codec c : codecs) {
      ListPreference l = new ListPreference(cx);
      l.setEntries(r.getStringArray(R.array.compression_display_values));
      l.setEntryValues(r.getStringArray(R.array.compression_values));
      l.setKey(c.key());
      l.setPersistent(true);
      l.setEnabled(!c.isFailed());
      c.setListPreference(l);
      l.setSummary(l.getEntry());
      l.setTitle(c.getTitle());
      ps.addPreference(l);
    }
  }
  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 #8
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 #10
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;
  }