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);
    }
  }
Beispiel #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);
  }
Beispiel #3
0
 /** Create the "Key Signature" preference */
 private void createKeySignaturePrefs(PreferenceScreen root) {
   key = new ListPreference(this);
   key.setOnPreferenceChangeListener(this);
   key.setTitle(R.string.key_signature);
   key.setEntries(R.array.key_signature_entries);
   key.setEntryValues(R.array.key_signature_values);
   key.setValueIndex(options.key + 1);
   key.setSummary(key.getEntry());
   root.addPreference(key);
 }
 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);
 }
Beispiel #5
0
 /** Create the "Show Note Letters" preference */
 private void createShowLetterPrefs(PreferenceScreen root) {
   showNoteLetters = new ListPreference(this);
   showNoteLetters.setOnPreferenceChangeListener(this);
   showNoteLetters.setTitle(R.string.show_note_letters);
   showNoteLetters.setEntries(R.array.show_note_letter_entries);
   showNoteLetters.setEntryValues(R.array.show_note_letter_values);
   showNoteLetters.setValueIndex(options.showNoteLetters);
   showNoteLetters.setSummary(showNoteLetters.getEntry());
   root.addPreference(showNoteLetters);
 }
Beispiel #6
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;
 }
Beispiel #7
0
 /** Create the "Transpose Notes" preference. The values range from 12, 11, 10, .. -10, -11, -12 */
 private void createTransposePrefs(PreferenceScreen root) {
   int transposeIndex = 12 - options.transpose;
   transpose = new ListPreference(this);
   transpose.setOnPreferenceChangeListener(this);
   transpose.setTitle(R.string.transpose);
   transpose.setEntries(R.array.transpose_entries);
   transpose.setEntryValues(R.array.transpose_values);
   transpose.setValueIndex(transposeIndex);
   transpose.setSummary(transpose.getEntry());
   root.addPreference(transpose);
 }
Beispiel #8
0
 /**
  * Create the "Combine Notes Within Interval" preference. Notes within N milliseconds are combined
  * into a single chord, even though their start times may be slightly different.
  */
 private void createCombineIntervalPrefs(PreferenceScreen root) {
   int selected = options.combineInterval / 20 - 1;
   combineInterval = new ListPreference(this);
   combineInterval.setOnPreferenceChangeListener(this);
   combineInterval.setTitle(R.string.combine_interval);
   combineInterval.setEntries(R.array.combine_interval_entries);
   combineInterval.setEntryValues(R.array.combine_interval_values);
   combineInterval.setValueIndex(selected);
   combineInterval.setSummary(combineInterval.getEntry());
   root.addPreference(combineInterval);
 }
Beispiel #9
0
  public boolean onPreferenceChange(Preference preference, Object newValue) {
    if (preference.getKey().equals("selectapp")) {
      ListPreference mAppPref = (ListPreference) preference;
      CharSequence[] mEntries = mAppPref.getEntries();
      mAppPref.setTitle(mEntries[mAppPref.findIndexOfValue((String) newValue)]);

      PackageManager pm = getActivity().getPackageManager();

      try {
        mAppPref.setIcon(pm.getApplicationIcon((String) newValue));
      } catch (NameNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    if (preference.getKey().equals("selectadvancedapp")) {
      ListPreference mAdvancedAppPref = (ListPreference) preference;
      CharSequence[] mEntries = mAdvancedAppPref.getEntries();
      mAdvancedAppPref.setTitle(mEntries[mAdvancedAppPref.findIndexOfValue((String) newValue)]);

      PackageManager pm = getActivity().getPackageManager();

      try {
        mAdvancedAppPref.setIcon(pm.getApplicationIcon((String) newValue));
      } catch (NameNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }

    if (preference.getKey().equals("baud_rate")) {
      ListPreference baudRatePref = (ListPreference) preference;
      CharSequence[] mEntries = baudRatePref.getEntries();
      baudRatePref.setTitle(mEntries[baudRatePref.findIndexOfValue((String) newValue)]);
    }

    return true;
  }
Beispiel #10
0
  /**
   * Create the "Play Measures in a Loop" preference.
   *
   * <p>Note that we display the measure numbers starting at 1, but the actual
   * playMeasuresInLoopStart field starts at 0.
   */
  private void createPlayMeasuresInLoopPrefs(PreferenceScreen root) {
    String[] values = new String[options.lastMeasure + 1];
    for (int measure = 0; measure < values.length; measure++) {
      values[measure] = "" + (measure + 1);
    }

    PreferenceCategory playLoopTitle = new PreferenceCategory(this);
    playLoopTitle.setTitle(R.string.play_measures_in_loop_title);
    root.addPreference(playLoopTitle);

    showMeasures = new CheckBoxPreference(this);
    showMeasures.setTitle(R.string.show_measures);
    showMeasures.setChecked(options.showMeasures);
    root.addPreference(showMeasures);

    playMeasuresInLoop = new CheckBoxPreference(this);
    playMeasuresInLoop.setTitle(R.string.play_measures_in_loop);
    playMeasuresInLoop.setChecked(options.playMeasuresInLoop);
    root.addPreference(playMeasuresInLoop);

    loopStart = new ListPreference(this);
    loopStart.setOnPreferenceChangeListener(this);
    loopStart.setTitle(R.string.play_measures_in_loop_start);
    loopStart.setEntries(values);
    loopStart.setEntryValues(values);
    loopStart.setValueIndex(options.playMeasuresInLoopStart);
    loopStart.setSummary(loopStart.getEntry());
    root.addPreference(loopStart);

    loopEnd = new ListPreference(this);
    loopEnd.setOnPreferenceChangeListener(this);
    loopEnd.setTitle(R.string.play_measures_in_loop_end);
    loopEnd.setEntries(values);
    loopEnd.setEntryValues(values);
    loopEnd.setValueIndex(options.playMeasuresInLoopEnd);
    loopEnd.setSummary(loopEnd.getEntry());
    root.addPreference(loopEnd);
  }
Beispiel #11
0
  /** Create the "Time Signature" preference */
  private void createTimeSignaturePrefs(PreferenceScreen root) {
    String[] values = {"Default", "3/4", "4/4"};
    int selected = 0;
    if (options.time != null && options.time.getNumerator() == 3) selected = 1;
    else if (options.time != null && options.time.getNumerator() == 4) selected = 2;

    time = new ListPreference(this);
    time.setOnPreferenceChangeListener(this);
    time.setTitle(R.string.time_signature);
    time.setEntries(values);
    time.setEntryValues(values);
    time.setValueIndex(selected);
    time.setSummary(time.getEntry());
    root.addPreference(time);
  }
Beispiel #12
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);
  }
Beispiel #14
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);
  }
Beispiel #16
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;
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.repository_manager_prefs);

    repoInfo = getArguments().getParcelable(REPO_INFO);
    repoRequestDTO = getArguments().getParcelable(REQUEST_DTO);

    final EditTextPreference pref_repo_name = (EditTextPreference) findPreference("pref_repo_name");
    pref_repo_name.setTitle(repoRequestDTO.name);
    pref_repo_name.setText(repoRequestDTO.name);
    pref_repo_name.setOnPreferenceChangeListener(
        new Preference.OnPreferenceChangeListener() {
          @Override
          public boolean onPreferenceChange(Preference preference, Object newValue) {
            repoRequestDTO.name = (String) newValue;
            pref_repo_name.setTitle(repoRequestDTO.name);
            return true;
          }
        });

    Preference pref_repo_description = findPreference("pref_repo_description");
    pref_repo_description.setOnPreferenceClickListener(
        new Preference.OnPreferenceClickListener() {
          @Override
          public boolean onPreferenceClick(Preference preference) {
            Intent intent =
                ContentEditorActivity.createLauncherIntent(
                    getActivity(), repoInfo, 0, null, repoRequestDTO.description, true, true);
            startActivityForResult(intent, DESCRIPTION_EDIT);
            return false;
          }
        });

    final Preference pref_repo_url = findPreference("pref_repo_url");
    pref_repo_url.setOnPreferenceChangeListener(
        new Preference.OnPreferenceChangeListener() {
          @Override
          public boolean onPreferenceChange(Preference preference, Object newValue) {
            repoRequestDTO.homepage = (String) newValue;
            return false;
          }
        });

    CheckBoxPreference pref_repo_has_issues =
        (CheckBoxPreference) findPreference("pref_repo_has_issues");
    pref_repo_has_issues.setChecked(repoRequestDTO.has_issues);
    pref_repo_has_issues.setOnPreferenceChangeListener(
        new Preference.OnPreferenceChangeListener() {
          @Override
          public boolean onPreferenceChange(Preference preference, Object newValue) {
            repoRequestDTO.has_issues = (Boolean) newValue;
            return true;
          }
        });

    CheckBoxPreference pref_repo_has_wiki =
        (CheckBoxPreference) findPreference("pref_repo_has_wiki");
    pref_repo_has_wiki.setChecked(repoRequestDTO.has_wiki);
    pref_repo_has_wiki.setOnPreferenceChangeListener(
        new Preference.OnPreferenceChangeListener() {
          @Override
          public boolean onPreferenceChange(Preference preference, Object newValue) {
            repoRequestDTO.has_wiki = (Boolean) newValue;
            return true;
          }
        });

    CheckBoxPreference pref_repo_has_downloads =
        (CheckBoxPreference) findPreference("pref_repo_has_downloads");
    pref_repo_has_downloads.setChecked(repoRequestDTO.has_downloads);
    pref_repo_has_downloads.setOnPreferenceChangeListener(
        new Preference.OnPreferenceChangeListener() {
          @Override
          public boolean onPreferenceChange(Preference preference, Object newValue) {
            repoRequestDTO.has_downloads = (Boolean) newValue;
            return true;
          }
        });

    //        CheckBoxPreference pref_repo_is_private = (CheckBoxPreference)
    // findPreference("pref_repo_is_private");
    //        pref_repo_is_private.setChecked(repoRequestDTO.isPrivate);
    //        pref_repo_is_private.setOnPreferenceChangeListener(new
    // Preference.OnPreferenceChangeListener() {
    //            @Override
    //            public boolean onPreferenceChange(Preference preference, Object newValue) {
    //                repoRequestDTO.isPrivate = (Boolean) newValue;
    //                return true;
    //            }
    //        });

    pref_repo_default_branch = (ListPreference) findPreference("pref_repo_default_branch");
    pref_repo_default_branch.setTitle(repoRequestDTO.default_branch);
    pref_repo_default_branch.setEnabled(false);
    pref_repo_default_branch.setOnPreferenceChangeListener(
        new Preference.OnPreferenceChangeListener() {
          @Override
          public boolean onPreferenceChange(Preference preference, Object newValue) {
            repoRequestDTO.default_branch = (String) newValue;
            pref_repo_default_branch.setTitle((String) newValue);
            return true;
          }
        });

    getBranches();

    Preference pref_repo_delete = findPreference("pref_repo_delete");
    pref_repo_delete.setOnPreferenceClickListener(
        new Preference.OnPreferenceClickListener() {
          @Override
          public boolean onPreferenceClick(Preference preference) {
            checkDeleteRepository();
            return false;
          }
        });
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setTitle(R.string.title_navbar);

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

    PreferenceScreen prefs = getPreferenceScreen();

    mPicker = new ShortcutPickerHelper(this, this);
    mPackMan = getPackageManager();
    mResources = mContext.getResources();

    // Get NavBar Actions
    mActionCodes = NavBarHelpers.getNavBarActions();
    mActions = new String[mActionCodes.length];
    int actionqty = mActions.length;
    for (int i = 0; i < actionqty; i++) {
      mActions[i] = AwesomeConstants.getProperName(mContext, mActionCodes[i]);
    }

    menuDisplayLocation = (ListPreference) findPreference(PREF_MENU_UNLOCK);
    menuDisplayLocation.setOnPreferenceChangeListener(this);
    menuDisplayLocation.setValue(
        Settings.System.getInt(mContentRes, Settings.System.MENU_LOCATION, 0) + "");

    mNavBarMenuDisplay = (ListPreference) findPreference(PREF_NAVBAR_MENU_DISPLAY);
    mNavBarMenuDisplay.setOnPreferenceChangeListener(this);
    mNavBarMenuDisplay.setValue(
        Settings.System.getInt(mContentRes, Settings.System.MENU_VISIBILITY, 0) + "");

    mNavBarHideEnable = (CheckBoxPreference) findPreference(NAVBAR_HIDE_ENABLE);
    mNavBarHideEnable.setChecked(
        Settings.System.getBoolean(mContentRes, Settings.System.NAV_HIDE_ENABLE, false));

    final int defaultDragOpacity =
        Settings.System.getInt(mContentRes, Settings.System.DRAG_HANDLE_OPACITY, 50);
    mDragHandleOpacity = (SeekBarPreference) findPreference(DRAG_HANDLE_OPACITY);
    mDragHandleOpacity.setInitValue((int) (defaultDragOpacity));
    mDragHandleOpacity.setOnPreferenceChangeListener(this);

    final int defaultDragWidth =
        Settings.System.getInt(mContentRes, Settings.System.DRAG_HANDLE_WEIGHT, 5);
    mDragHandleWidth = (SeekBarPreference) findPreference(DRAG_HANDLE_WIDTH);
    mDragHandleWidth.setInitValue((int) (defaultDragWidth));
    mDragHandleWidth.setOnPreferenceChangeListener(this);

    mNavBarHideTimeout = (ListPreference) findPreference(NAVBAR_HIDE_TIMEOUT);
    mNavBarHideTimeout.setOnPreferenceChangeListener(this);
    mNavBarHideTimeout.setValue(
        Settings.System.getInt(mContentRes, Settings.System.NAV_HIDE_TIMEOUT, 3000) + "");

    boolean hasNavBarByDefault =
        mContext.getResources().getBoolean(com.android.internal.R.bool.config_showNavigationBar);
    mEnableNavigationBar = (CheckBoxPreference) findPreference(ENABLE_NAVIGATION_BAR);
    mEnableNavigationBar.setChecked(
        Settings.System.getBoolean(
            mContentRes, Settings.System.NAVIGATION_BAR_SHOW, hasNavBarByDefault));

    mNavigationColor = (ColorPickerPreference) findPreference(NAVIGATION_BAR_COLOR);
    mNavigationColor.setOnPreferenceChangeListener(this);

    mNavigationBarColor = (ColorPickerPreference) findPreference(PREF_NAV_COLOR);
    mNavigationBarColor.setOnPreferenceChangeListener(this);

    mColorizeAllIcons = (CheckBoxPreference) findPreference("navigation_bar_allcolor");
    mColorizeAllIcons.setChecked(
        Settings.System.getBoolean(mContentRes, Settings.System.NAVIGATION_BAR_ALLCOLOR, false));

    mNavigationBarGlowColor = (ColorPickerPreference) findPreference(PREF_NAV_GLOW_COLOR);
    mNavigationBarGlowColor.setOnPreferenceChangeListener(this);

    mGlowTimes = (ListPreference) findPreference(PREF_GLOW_TIMES);
    mGlowTimes.setOnPreferenceChangeListener(this);

    final float defaultButtonAlpha =
        Settings.System.getFloat(mContentRes, Settings.System.NAVIGATION_BAR_BUTTON_ALPHA, 0.6f);
    mButtonAlpha = (SeekBarPreference) findPreference("button_transparency");
    mButtonAlpha.setInitValue((int) (defaultButtonAlpha * 100));
    mButtonAlpha.setOnPreferenceChangeListener(this);

    mWidthHelp = (Preference) findPreference("width_help");

    float defaultPort =
        Settings.System.getFloat(mContentRes, Settings.System.NAVIGATION_BAR_WIDTH_PORT, 0f);
    mWidthPort = (SeekBarPreference) findPreference("width_port");
    mWidthPort.setInitValue((int) (defaultPort * 2.5f));
    mWidthPort.setOnPreferenceChangeListener(this);

    float defaultLand =
        Settings.System.getFloat(mContentRes, Settings.System.NAVIGATION_BAR_WIDTH_LAND, 0f);
    mWidthLand = (SeekBarPreference) findPreference("width_land");
    mWidthLand.setInitValue((int) (defaultLand * 2.5f));
    mWidthLand.setOnPreferenceChangeListener(this);

    mNavigationBarHeight = (ListPreference) findPreference("navigation_bar_height");
    mNavigationBarHeight.setOnPreferenceChangeListener(this);

    mNavigationBarHeightLandscape =
        (ListPreference) findPreference("navigation_bar_height_landscape");
    mNavigationBarHeightLandscape.setOnPreferenceChangeListener(this);

    mNavigationBarWidth = (ListPreference) findPreference("navigation_bar_width");
    mNavigationBarWidth.setOnPreferenceChangeListener(this);
    mConfigureWidgets = findPreference(NAVIGATION_BAR_WIDGETS);

    mMenuArrowKeysCheckBox = (CheckBoxPreference) findPreference(PREF_MENU_ARROWS);
    mMenuArrowKeysCheckBox.setChecked(
        Settings.System.getBoolean(
            mContentRes, Settings.System.NAVIGATION_BAR_MENU_ARROW_KEYS, true));

    // don't allow devices that must use a navigation bar to disable it
    if (hasNavBarByDefault) {
      prefs.removePreference(mEnableNavigationBar);
    }
    PreferenceGroup pg = (PreferenceGroup) prefs.findPreference("advanced_cat");
    if (isTablet(mContext)) {
      mNavigationBarHeight.setTitle(R.string.system_bar_height_title);
      mNavigationBarHeight.setSummary(R.string.system_bar_height_summary);
      mNavigationBarHeightLandscape.setTitle(R.string.system_bar_height_landscape_title);
      mNavigationBarHeightLandscape.setSummary(R.string.system_bar_height_landscape_summary);
      pg.removePreference(mNavigationBarWidth);
      mNavBarHideEnable.setEnabled(false);
      mDragHandleOpacity.setEnabled(false);
      mDragHandleWidth.setEnabled(false);
      mNavBarHideTimeout.setEnabled(false);
    } else { // Phones&Phablets don't have SystemBar
      pg.removePreference(mWidthPort);
      pg.removePreference(mWidthLand);
      pg.removePreference(mWidthHelp);
    }

    if (Integer.parseInt(menuDisplayLocation.getValue()) == 4) {
      mNavBarMenuDisplay.setEnabled(false);
    }

    // Only show the hardware keys config on a device that does not have a navbar
    IWindowManager windowManager =
        IWindowManager.Stub.asInterface(ServiceManager.getService(Context.WINDOW_SERVICE));

    if (hasNavBarByDefault) {
      // Let's assume they don't have hardware keys
      getPreferenceScreen().removePreference(findPreference(KEY_HARDWARE_KEYS));
    }
    refreshSettings();
    setHasOptionsMenu(true);
    updateGlowTimesSummary();
  }
Beispiel #19
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.preferences);

    PackageManager pm = getActivity().getPackageManager();
    Intent mediaIntent = new Intent(Intent.ACTION_MEDIA_BUTTON);

    List<ResolveInfo> mAppsInfo = pm.queryBroadcastReceivers(mediaIntent, 0);
    ListPreference simpleAppListPref = (ListPreference) findPreference("selectapp");
    ListPreference advancedAppListPref = (ListPreference) findPreference("selectadvancedapp");

    ListPreference baudRatePref = (ListPreference) findPreference("baud_rate");

    simpleAppListPref.setOnPreferenceChangeListener(this);
    advancedAppListPref.setOnPreferenceChangeListener(this);

    baudRatePref.setOnPreferenceChangeListener(this);
    baudRatePref.setTitle(baudRatePref.getEntry());

    CharSequence[] mEntries;
    CharSequence[] mEntryValues;

    CharSequence[] mAdvEntries;
    CharSequence[] mAdvEntryValues;

    if (mAppsInfo.size() > 0) {

      mEntries = new CharSequence[mAppsInfo.size()];
      mEntryValues = new CharSequence[mAppsInfo.size()];

      mAdvEntries = new CharSequence[mAppsInfo.size() + 1];
      mAdvEntryValues = new CharSequence[mAppsInfo.size() + 1];

      mAdvEntries[0] = "PodMode";
      mAdvEntryValues[0] = "me.spadival.podmode";

      int i = 0;
      for (ResolveInfo info : mAppsInfo) {
        mEntries[i] = info.activityInfo.applicationInfo.loadLabel(pm);
        mEntryValues[i] = (String) info.activityInfo.packageName;
        mAdvEntries[i + 1] = mEntries[i];
        mAdvEntryValues[i + 1] = mEntryValues[i];
        i++;
      }

      simpleAppListPref.setSelectable(true);
      simpleAppListPref.setEntries(mEntries);
      simpleAppListPref.setEntryValues(mEntryValues);

      advancedAppListPref.setSelectable(true);
      advancedAppListPref.setEntries(mAdvEntries);
      advancedAppListPref.setEntryValues(mAdvEntryValues);

      boolean simpleAppEntryFound = false;

      String simpleAppName = (String) simpleAppListPref.getEntry();

      if (simpleAppName != null) {
        for (i = 0; i < mEntries.length; i++) {
          if (simpleAppName.equals(mEntries[i])) {
            simpleAppEntryFound = true;
          }
        }
      }

      if (!simpleAppEntryFound) simpleAppListPref.setValue((String) mEntryValues[0]);

      simpleAppListPref.setTitle(simpleAppListPref.getEntry());
      try {
        simpleAppListPref.setIcon(pm.getApplicationIcon(simpleAppListPref.getValue()));
      } catch (NameNotFoundException e) {
        e.printStackTrace();
      }

      boolean advancedAppEntryFound = false;
      String advancedAppName = (String) advancedAppListPref.getEntry();

      if (advancedAppName != null) {
        for (i = 0; i < mAdvEntries.length; i++) {
          if (advancedAppName.equals(mAdvEntries[i])) {
            advancedAppEntryFound = true;
          }
        }
      }

      if (!advancedAppEntryFound) advancedAppListPref.setValue((String) mAdvEntryValues[0]);

      advancedAppListPref.setTitle(advancedAppListPref.getEntry());
      try {
        advancedAppListPref.setIcon(pm.getApplicationIcon(advancedAppListPref.getValue()));
      } catch (NameNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }

    } else {
      simpleAppListPref.setTitle(R.string.no_media_player);
      simpleAppListPref.setEntries(null);
      simpleAppListPref.setEntryValues(null);
      simpleAppListPref.setEnabled(false);

      mAdvEntries = new CharSequence[1];
      mAdvEntryValues = new CharSequence[1];

      mAdvEntries[0] = "PodMode";
      mAdvEntryValues[0] = "me.spadival.podmode";

      advancedAppListPref.setTitle(mAdvEntries[0]);
      advancedAppListPref.setEntries(mAdvEntries);
      advancedAppListPref.setEntryValues(mAdvEntryValues);
      advancedAppListPref.setEnabled(false);
    }
  }
    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);
        }
      }
    }
  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;
  }