/**
     * Set the entries for the given preference. The given preference needs to be a {@link
     * ListPreference}
     */
    private void setEntries(Preference preference) {
      if (!(preference instanceof ListPreference)) {
        return;
      }

      ListPreference listPreference = (ListPreference) preference;
      if (listPreference.getKey().equals(Keys.KEY_PICTURE_SIZE_BACK)) {
        setEntriesForSelection(mPictureSizesBack, listPreference);
      } else if (listPreference.getKey().equals(Keys.KEY_PICTURE_SIZE_FRONT)) {
        setEntriesForSelection(mPictureSizesFront, listPreference);
      } else if (listPreference.getKey().equals(Keys.KEY_VIDEO_QUALITY_BACK)) {
        setEntriesForSelection(mVideoQualitiesBack, listPreference);
      } else if (listPreference.getKey().equals(Keys.KEY_VIDEO_QUALITY_FRONT)) {
        setEntriesForSelection(mVideoQualitiesFront, listPreference);
      }
    }
Exemplo n.º 2
0
  public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {

    // handle event for the Screen list preference
    if (key == mUIScreenListPreference.getKey()) {
      Log.v(TAG, "on shared preference change in conical settings");

      Log.v(TAG, mUIScreenListPreference.getEntry().toString());

      registerScreenChange(mUIScreenListPreference.getEntry().toString());
      restartLauncher2(activityManager);
    }
  }
Exemplo n.º 3
0
 @Override
 public boolean onPreferenceTreeClick(PreferenceScreen ps, Preference p) {
   ListPreference l = (ListPreference) p;
   for (Codec c : codecs)
     if (c.key().equals(l.getKey())) {
       c.init();
       if (!c.isLoaded()) {
         l.setValue("never");
         c.fail();
         l.setEnabled(false);
         l.setSummary(l.getEntry());
         if (l.getDialog() != null) l.getDialog().dismiss();
       }
     }
   return super.onPreferenceTreeClick(ps, p);
 }
Exemplo n.º 4
0
  public void findView() {
    mCheckBoxPreference = (CheckBoxPreference) findPreference("setcheckbox");
    mCheckBoxPreference.setOnPreferenceChangeListener(this);

    mListPreference = (ListPreference) findPreference("setfrequency");
    mListPreference.setOnPreferenceChangeListener(this);

    String summary =
        PreferenceManager.getDefaultSharedPreferences(this)
            .getString(mListPreference.getKey(), Utilities.readCheckFrequency(mContext) + "");
    mListPreference.setSummary(
        getResources().getString(R.string.checkfrequency_summary)
            + summary
            + getResources().getString(R.string.day));

    if (Utilities.readAutoCheck(mContext)) {
      mCheckBoxPreference.setChecked(Utilities.readAutoCheck(mContext));
    } else {
      mListPreference.setEnabled(false);
    }
  }
Exemplo n.º 5
0
  private void setSummary(Preference pref, boolean init) {
    if (pref instanceof EditTextPreference) {
      EditTextPreference editPref = (EditTextPreference) pref;
      pref.setSummary(editPref.getText());

      if (editPref.getKey().equals("serverdns") && editPref.getText().length() == 0) {
        pref.setSummary(getString(R.string.summary_serverdns_preference));
      }
      if (editPref.getKey().equals("disksize") && editPref.getText().equals("0")) {
        pref.setSummary(getString(R.string.summary_disksize_preference));
      }
      if (editPref.getKey().equals("diskimage") && !init) {
        editPref.setText(PrefStore.getTargetPath(this));
        pref.setSummary(editPref.getText());
      }
      if (editPref.getKey().equals("vncwidth") && editPref.getText().length() == 0) {
        editPref.setText(PrefStore.getScreenWidth(this).toString());
        pref.setSummary(editPref.getText());
      }
      if (editPref.getKey().equals("vncheight") && editPref.getText().length() == 0) {
        editPref.setText(PrefStore.getScreenHeight(this).toString());
        pref.setSummary(editPref.getText());
      }
    }

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

      if (listPref.getKey().equals("distribution")) {
        ListPreference suite = (ListPreference) findPreference("suite");
        ListPreference architecture = (ListPreference) findPreference("architecture");
        EditTextPreference mirror = (EditTextPreference) findPreference("mirror");
        MultiSelectListPreferenceCompat components =
            (MultiSelectListPreferenceCompat) findPreference("xcomponents");

        String distributionStr = listPref.getValue();

        // suite
        int suiteValuesId =
            PrefStore.getResourceId(this, distributionStr + "_suite_values", "array");
        if (suiteValuesId != -1) {
          suite.setEntries(suiteValuesId);
          suite.setEntryValues(suiteValuesId);
        }
        if (init) {
          int suiteId = PrefStore.getResourceId(this, distributionStr + "_suite", "string");
          if (suiteId != -1) {
            String suiteStr = getString(suiteId);
            if (suiteStr.length() > 0) suite.setValue(suiteStr);
          }
        }
        suite.setSummary(suite.getEntry());
        suite.setEnabled(true);

        // architecture
        int architectureValuesId =
            PrefStore.getResourceId(this, distributionStr + "_architecture_values", "array");
        if (suiteValuesId != -1) {
          architecture.setEntries(architectureValuesId);
          architecture.setEntryValues(architectureValuesId);
        }
        if (init || architecture.getValue().length() == 0) {
          int architectureId =
              PrefStore.getResourceId(
                  this, PrefStore.getArch() + "_" + distributionStr + "_architecture", "string");
          if (architectureId != -1) {
            String architectureStr = getString(architectureId);
            if (architectureStr.length() > 0) architecture.setValue(architectureStr);
          }
        }
        architecture.setSummary(architecture.getEntry());
        architecture.setEnabled(true);

        // mirror
        if (init || mirror.getText().length() == 0) {
          int mirrorId =
              PrefStore.getResourceId(
                  this, PrefStore.getArch() + "_" + distributionStr + "_mirror", "string");
          if (mirrorId != -1) {
            mirror.setText(getString(mirrorId));
          }
        }
        mirror.setSummary(mirror.getText());
        mirror.setEnabled(true);

        // components
        int componentsEntriesId =
            PrefStore.getResourceId(this, distributionStr + "_components_entries", "array");
        int componentsValuesId =
            PrefStore.getResourceId(this, distributionStr + "_components_values", "array");
        if (componentsEntriesId != -1 && componentsValuesId != -1) {
          components.setEntries(componentsEntriesId);
          components.setEntryValues(componentsValuesId);
        }
        if (init) {
          components.setValues(
              new HashSet<String>(
                  Arrays.asList(getResources().getStringArray(R.array.default_components))));
        }
        components.setEnabled(true);

        // RootFS
        if (distributionStr.equals("rootfs")) {
          // suite
          suite.setEnabled(false);
          // architecture
          architecture.setEnabled(false);
          // mirror
          if (init) {
            String archiveFile = PrefStore.getStorage() + "/linux-rootfs.tar.gz";
            mirror.setText(archiveFile);
          }
          mirror.setSummary(mirror.getText());
          mirror.setEnabled(true);
          // components
          components.setEnabled(false);
        }
      }
      if (listPref.getKey().equals("architecture") && init) {
        ListPreference distribution = (ListPreference) findPreference("distribution");
        EditTextPreference mirror = (EditTextPreference) findPreference("mirror");

        String architectureStr = PrefStore.getArch(listPref.getValue());
        String distributionStr = distribution.getValue();

        int mirrorId =
            PrefStore.getResourceId(
                this, architectureStr + "_" + distributionStr + "_mirror", "string");
        if (mirrorId != -1) {
          mirror.setText(getString(mirrorId));
        }

        mirror.setSummary(mirror.getText());
      }
      if (listPref.getKey().equals("deploytype")) {
        EditTextPreference diskimage = (EditTextPreference) findPreference("diskimage");
        EditTextPreference disksize = (EditTextPreference) findPreference("disksize");
        ListPreference fstype = (ListPreference) findPreference("fstype");

        switch (listPref.getValue()) {
          case "file":
            if (init) {
              diskimage.setText(PrefStore.getValues(this, R.string.targetpath_file));
            }
            disksize.setEnabled(true);
            fstype.setEnabled(true);
            break;
          case "partition":
            if (init) {
              diskimage.setText(PrefStore.getValues(this, R.string.targetpath_partition));
            }
            disksize.setEnabled(false);
            fstype.setEnabled(true);
            break;
          case "ram":
            if (init) {
              diskimage.setText(PrefStore.getValues(this, R.string.targetpath_ram));
            }
            disksize.setEnabled(true);
            fstype.setEnabled(false);
            break;
          default:
            if (init) {
              diskimage.setText(PrefStore.getValues(this, R.string.targetpath_directory));
            }
            disksize.setEnabled(false);
            fstype.setEnabled(false);
        }
      }
    }
  }