예제 #1
0
  private void enableAll() {
    hostText.setEnabled(true);

    if (!isPACCheck.isChecked()) {
      portText.setEnabled(true);
      proxyTypeList.setEnabled(true);
    }

    bypassAddrs.setEnabled(true);

    if (isAuthCheck.isChecked()) {
      userText.setEnabled(true);
      passwordText.setEnabled(true);
      isNTLMCheck.setEnabled(true);
      if (isNTLMCheck.isChecked()) domainText.setEnabled(true);
    }
    if (!isAutoSetProxyCheck.isChecked()) {
      proxyedApps.setEnabled(true);
      isBypassAppsCheck.setEnabled(true);
    }
    if (isAutoConnectCheck.isChecked()) ssidList.setEnabled(true);

    isDNSProxyCheck.setEnabled(true);
    profileList.setEnabled(true);
    isAutoSetProxyCheck.setEnabled(true);
    isAuthCheck.setEnabled(true);
    isAutoConnectCheck.setEnabled(true);
    isPACCheck.setEnabled(true);
  }
  private void setLicensingMode(LicensingMode mode) {
    getPreferenceScreen()
        .getSharedPreferences()
        .edit()
        .putString(LICENSING_MODE, mode.toString())
        .commit();
    mLicensingMode.setValue(mode.toString());
    mLicensingMode.setSummary(mode.getName(this));

    boolean value = mode.isServerConfigurable();
    mServerAddress.setEnabled(value);
    mServerAddress.setSelectable(value);
    mServerPort.setEnabled(value);
    mServerPort.setSelectable(value);
  }
  private void updateSummaries() {
    int t = PREFS_DEFAULT_LOCATION_TIMEOUT;
    try {
      t =
          Integer.parseInt(
              prefs.getString(PREFS_KEY_LOCATION_TIMEOUT, "" + PREFS_DEFAULT_LOCATION_TIMEOUT));
      if (t < 1) {
        t = PREFS_DEFAULT_LOCATION_TIMEOUT;
        final SharedPreferences.Editor edit = prefs.edit();
        edit.putString(PREFS_KEY_LOCATION_TIMEOUT, "" + t);
        edit.commit();
      }
    } catch (final Exception e) {
      t = PREFS_DEFAULT_LOCATION_TIMEOUT;
      final SharedPreferences.Editor edit = prefs.edit();
      edit.putString(PREFS_KEY_LOCATION_TIMEOUT, "" + t);
      edit.commit();
    }
    final EditTextPreference timeout =
        (EditTextPreference) prefFrag.findPreference(PREFS_KEY_LOCATION_TIMEOUT);
    String summary = getResources().getString(R.string.pref_geolocation_timeout_summary);
    summary += "\nTimeout: '" + t + "'";
    timeout.setSummary(summary);

    final Preference povider = prefFrag.findPreference(PREFS_KEY_OPENCELLID_PROVIDER);
    final Preference gps = prefFrag.findPreference(PREFS_KEY_GPS);
    final boolean en = prefs.getBoolean(PREFS_KEY_LOCATE, PREFS_DEFAULT_LOCATE);
    povider.setEnabled(en);
    timeout.setEnabled(en);
    gps.setEnabled(en);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (getPreferenceManager() != null) {
      addPreferencesFromResource(R.xml.operator_preferences);
      PreferenceScreen prefSet = getPreferenceScreen();

      mOperatorDisplayStyle = (ListPreference) prefSet.findPreference(OPERATOR_STYLE);
      mOperatorDisplayStyle.setOnPreferenceChangeListener(this);

      mOperatorDisplayText = (EditTextPreference) prefSet.findPreference(OPERATOR_TEXT);
      mOperatorDisplayText.setOnPreferenceChangeListener(this);

      if (mOperatorDisplayText != null) {
        String operLabel = mOperatorDisplayText.getText();
        if (TextUtils.isEmpty(operLabel)) {
          mOperatorDisplayText.setSummary(getString(R.string.operator_display_summary));
        } else {
          mOperatorDisplayText.setSummary(mOperatorDisplayText.getText());
        }
      }

      int index = Settings.System.getInt(getContentResolver(), CARRIER_LABEL_TYPE, 0);
      index = index > (mOperatorDisplayStyle.getEntries().length - 1) ? 0 : index;
      mOperatorDisplayStyle.setSummary(mOperatorDisplayStyle.getEntries()[index]);

      mOperatorDisplayText.setEnabled(index == 3);
    }
  }
 protected void setCheckboxesEnabled(boolean enabled) {
   bookmarksPreference.setEnabled(enabled);
   historyPreference.setEnabled(enabled);
   tabsPreference.setEnabled(enabled);
   passwordsPreference.setEnabled(enabled);
   // Since we can't sync, we can't update our remote client record.
   deviceNamePreference.setEnabled(enabled);
   syncNowPreference.setEnabled(enabled);
 }
예제 #6
0
  private void disableAll() {
    hostText.setEnabled(false);
    portText.setEnabled(false);
    userText.setEnabled(false);
    passwordText.setEnabled(false);
    domainText.setEnabled(false);
    ssidList.setEnabled(false);
    proxyTypeList.setEnabled(false);
    proxyedApps.setEnabled(false);
    profileList.setEnabled(false);
    bypassAddrs.setEnabled(false);

    isAuthCheck.setEnabled(false);
    isNTLMCheck.setEnabled(false);
    isDNSProxyCheck.setEnabled(false);
    isAutoSetProxyCheck.setEnabled(false);
    isAutoConnectCheck.setEnabled(false);
    isPACCheck.setEnabled(false);
    isBypassAppsCheck.setEnabled(false);
  }
  @Override
  public boolean onPreferenceChange(Preference preference, Object newValue) {
    // TODO Auto-generated method stub
    if (preference == mOperatorDisplayStyle) {
      int value = Integer.valueOf((String) newValue);
      int index = mOperatorDisplayStyle.findIndexOfValue((String) newValue);

      mOperatorDisplayStyle.setSummary(mOperatorDisplayStyle.getEntries()[index]);
      Settings.System.putInt(getContentResolver(), CARRIER_LABEL_TYPE, value);

      mOperatorDisplayText.setEnabled(index == 3);

      return true;
    } else if (preference == mOperatorDisplayText) {
      String operLabel = newValue.toString();
      mOperatorDisplayText.setSummary(newValue.toString());
      Settings.System.putString(getContentResolver(), CARRIER_LABEL_CUSTOM_STRING, operLabel);
      return true;
    }
    return false;
  }
예제 #8
0
 public static EditTextPreference Edit(
     Context paramContext,
     PreferenceCategory paramPreferenceCategory,
     String paramString1,
     String paramString2,
     String paramString3,
     String paramString4,
     Object paramObject,
     boolean paramBoolean,
     Integer paramInteger) {
   EditTextPreference localEditTextPreference = new EditTextPreference(paramContext);
   localEditTextPreference.setTitle(paramString1);
   localEditTextPreference.setSummary(paramString2);
   localEditTextPreference.setEnabled(paramBoolean);
   localEditTextPreference.setKey(paramString4);
   localEditTextPreference.setDefaultValue(paramObject);
   localEditTextPreference.setDialogTitle(paramString3);
   if (paramInteger != null)
     localEditTextPreference.getEditText().setInputType(paramInteger.intValue());
   paramPreferenceCategory.addPreference(localEditTextPreference);
   return localEditTextPreference;
 }
 @Override
 protected void setUp() {
   final AccountManager accountManager = AccountManager.get(getActivity());
   final AccountMirakel accountMirakel = mItem;
   final Account account = accountMirakel.getAndroidAccount();
   // Preference Fields
   final Preference syncUsername = findPreference("syncUsername");
   final EditTextPreference syncServer = (EditTextPreference) findPreference("syncServer");
   final SwitchPreference syncUse = (SwitchPreference) findPreference("syncUse");
   final Preference syncType = findPreference("sync_type");
   final SwitchPreference defaultAccount = (SwitchPreference) findPreference("defaultAccount");
   final Preference syncInterval = findPreference("syncFrequency");
   // Set Preferences
   syncUsername.setEnabled(false);
   syncUsername.setSummary(accountMirakel.getName());
   // sync Server
   if (AccountMirakel.ACCOUNT_TYPES.TASKWARRIOR == accountMirakel.getType()) {
     syncServer.setEnabled(false);
     syncServer.setSummary(accountManager.getUserData(account, SyncAdapter.BUNDLE_SERVER_URL));
     syncServer.setText(accountManager.getUserData(account, SyncAdapter.BUNDLE_SERVER_URL));
     syncServer.setOnPreferenceChangeListener(
         new Preference.OnPreferenceChangeListener() {
           @Override
           public boolean onPreferenceChange(final Preference preference, final Object newValue) {
             accountManager.setUserData(account, SyncAdapter.BUNDLE_SERVER_URL, (String) newValue);
             syncServer.setSummary((String) newValue);
             syncServer.setText((String) newValue);
             return false;
           }
         });
   } else {
     syncServer.setEnabled(false);
     syncServer.setSummary("");
   }
   // sync use
   syncUse.setChecked(accountMirakel.isEnabled());
   syncUse.setOnPreferenceChangeListener(
       new Preference.OnPreferenceChangeListener() {
         @Override
         public boolean onPreferenceChange(final Preference preference, final Object newValue) {
           accountMirakel.setEnabled((Boolean) newValue);
           accountMirakel.save();
           return true;
         }
       });
   if (accountMirakel.getType() == AccountMirakel.ACCOUNT_TYPES.LOCAL) {
     removePreference("syncUse");
     removePreference("syncServer");
     removePreference("syncUsername");
   }
   // Sync type
   syncType.setSummary(accountMirakel.getType().typeName(getActivity()));
   // Default Account
   defaultAccount.setChecked(
       MirakelModelPreferences.getDefaultAccount().getId() == accountMirakel.getId());
   defaultAccount.setOnPreferenceChangeListener(
       new Preference.OnPreferenceChangeListener() {
         @Override
         public boolean onPreferenceChange(final Preference preference, final Object newValue) {
           if ((Boolean) newValue) {
             MirakelModelPreferences.setDefaultAccount(accountMirakel);
           } else {
             MirakelModelPreferences.setDefaultAccount(AccountMirakel.getLocal());
           }
           defaultAccount.setChecked((Boolean) newValue);
           return false;
         }
       });
   // Interval
   syncInterval.setEnabled(false);
   if (MirakelModelPreferences.getSyncFrequency(accountMirakel) == -1) {
     syncInterval.setSummary(R.string.sync_frequency_summary_man);
   } else {
     syncInterval.setSummary(
         this.getString(
             R.string.sync_frequency_summary,
             MirakelModelPreferences.getSyncFrequency(accountMirakel)));
   }
   syncInterval.setOnPreferenceClickListener(
       new Preference.OnPreferenceClickListener() {
         @Override
         public boolean onPreferenceClick(final Preference preference) {
           int hours = MirakelModelPreferences.getSyncFrequency(accountMirakel);
           if (hours == -1) {
             hours = 0;
           }
           final int minutes = hours % 60;
           hours = (int) Math.floor(hours / 60.);
           final TimePicker timePicker = new TimePicker(getActivity());
           timePicker.setIs24HourView(true);
           timePicker.setCurrentHour(hours);
           timePicker.setCurrentMinute(minutes);
           final AlertDialog.Builder dialog =
               new AlertDialog.Builder(getActivity())
                   .setTitle(R.string.sync_frequency)
                   .setView(timePicker)
                   .setPositiveButton(
                       android.R.string.ok,
                       new DialogInterface.OnClickListener() {
                         @Override
                         public void onClick(final DialogInterface dialog, final int which) {
                           int newValue =
                               timePicker.getCurrentHour() * 60 + timePicker.getCurrentMinute();
                           if (newValue == 0) {
                             newValue = -1;
                           }
                           final Bundle bundle = new Bundle();
                           if (newValue == -1) {
                             syncInterval.setSummary(R.string.sync_frequency_summary_man);
                           } else {
                             syncInterval.setSummary(
                                 getActivity()
                                     .getString(R.string.sync_frequency_summary, newValue));
                           }
                           if (accountMirakel != null) {
                             ContentResolver.removePeriodicSync(
                                 account, DefinitionsHelper.AUTHORITY_TYP, bundle);
                             if (newValue != -1) {
                               ContentResolver.setSyncAutomatically(
                                   account, DefinitionsHelper.AUTHORITY_TYP, true);
                               ContentResolver.setIsSyncable(
                                   account, DefinitionsHelper.AUTHORITY_TYP, 1);
                               ContentResolver.addPeriodicSync(
                                   account,
                                   DefinitionsHelper.AUTHORITY_TYP,
                                   bundle,
                                   newValue * 60);
                             }
                           } else {
                             Log.d(TAG, "account does not exsist");
                           }
                           MirakelModelPreferences.setSyncFrequency(accountMirakel, newValue);
                         }
                       });
           dialog.show();
           return false;
         }
       });
   if (accountMirakel.getType() != AccountMirakel.ACCOUNT_TYPES.TASKWARRIOR) {
     // we can control this only for tw
     removePreference("syncFrequency");
   } else {
     syncInterval.setEnabled(true);
   }
 }
예제 #10
0
  @Override
  public void onSharedPreferenceChanged(SharedPreferences settings, String key) {
    // Let's do something a preference value changes

    if (key.equals("profile")) {
      String profileString = settings.getString("profile", "");
      if (profileString.equals("0")) {
        String[] profileEntries = settings.getString("profileEntries", "").split("\\|");
        String[] profileValues = settings.getString("profileValues", "").split("\\|");
        int newProfileValue = Integer.valueOf(profileValues[profileValues.length - 2]) + 1;

        StringBuilder profileEntriesBuffer = new StringBuilder();
        StringBuilder profileValuesBuffer = new StringBuilder();

        for (int i = 0; i < profileValues.length - 1; i++) {
          profileEntriesBuffer.append(profileEntries[i]).append("|");
          profileValuesBuffer.append(profileValues[i]).append("|");
        }
        profileEntriesBuffer.append(getProfileName(Integer.toString(newProfileValue))).append("|");
        profileValuesBuffer.append(newProfileValue).append("|");
        profileEntriesBuffer.append(getString(R.string.profile_new));
        profileValuesBuffer.append("0");

        Editor ed = settings.edit();
        ed.putString("profileEntries", profileEntriesBuffer.toString());
        ed.putString("profileValues", profileValuesBuffer.toString());
        ed.putString("profile", Integer.toString(newProfileValue));
        ed.commit();

        loadProfileList();
      } else {
        String oldProfile = profile;
        profile = profileString;
        profileList.setValue(profile);
        onProfileChange(oldProfile);
        profileList.setSummary(getProfileName(profileString));
      }
    }

    if (key.equals("isConnecting")) {
      if (settings.getBoolean("isConnecting", false)) {
        Log.d(TAG, "Connecting start");
        isRunningCheck.setEnabled(false);
        pd = ProgressDialog.show(this, "", getString(R.string.connecting), true, true);
      } else {
        Log.d(TAG, "Connecting finish");
        if (pd != null) {
          pd.dismiss();
          pd = null;
        }
        isRunningCheck.setEnabled(true);
      }
    }

    if (key.equals("isPAC")) {
      if (settings.getBoolean("isPAC", false)) {
        portText.setEnabled(false);
        proxyTypeList.setEnabled(false);
        hostText.setTitle(R.string.host_pac);
      } else {
        portText.setEnabled(true);
        proxyTypeList.setEnabled(true);
        hostText.setTitle(R.string.host);
      }
      if (settings.getString("host", "").equals("")) {
        hostText.setSummary(
            settings.getBoolean("isPAC", false)
                ? R.string.host_pac_summary
                : R.string.host_summary);
      } else {
        hostText.setSummary(settings.getString("host", ""));
      }
    }

    if (key.equals("isAuth")) {
      if (!settings.getBoolean("isAuth", false)) {
        userText.setEnabled(false);
        passwordText.setEnabled(false);
        isNTLMCheck.setEnabled(false);
        domainText.setEnabled(false);
      } else {
        userText.setEnabled(true);
        passwordText.setEnabled(true);
        isNTLMCheck.setEnabled(true);
        if (isNTLMCheck.isChecked()) {
          domainText.setEnabled(true);
        } else {
          domainText.setEnabled(false);
        }
      }
    }

    if (key.equals("isNTLM")) {
      if (!settings.getBoolean("isAuth", false) || !settings.getBoolean("isNTLM", false)) {
        domainText.setEnabled(false);
      } else {
        domainText.setEnabled(true);
      }
    }

    if (key.equals("proxyType")) {
      if (!"https".equals(settings.getString("proxyType", ""))) {
        certificateText.setEnabled(false);
      } else {
        certificateText.setEnabled(true);
      }
    }

    if (key.equals("isAutoConnect")) {
      if (settings.getBoolean("isAutoConnect", false)) {
        loadNetworkList();
        ssidList.setEnabled(true);
      } else {
        ssidList.setEnabled(false);
      }
    }

    if (key.equals("isAutoSetProxy")) {
      if (settings.getBoolean("isAutoSetProxy", false)) {
        proxyedApps.setEnabled(false);
        isBypassAppsCheck.setEnabled(false);
      } else {
        proxyedApps.setEnabled(true);
        isBypassAppsCheck.setEnabled(true);
      }
    }

    if (key.equals("isRunning")) {
      if (settings.getBoolean("isRunning", false)) {
        disableAll();
        if (Build.VERSION.SDK_INT >= 14) {
          ((SwitchPreference) isRunningCheck).setChecked(true);
        } else {
          ((CheckBoxPreference) isRunningCheck).setChecked(true);
        }
        if (!Utils.isConnecting()) serviceStart();
      } else {
        enableAll();
        if (Build.VERSION.SDK_INT >= 14) {
          ((SwitchPreference) isRunningCheck).setChecked(false);
        } else {
          ((CheckBoxPreference) isRunningCheck).setChecked(false);
        }
        if (!Utils.isConnecting()) serviceStop();
      }
    }

    if (key.equals("ssid")) {
      if (settings.getString("ssid", "").equals("")) {
        ssidList.setSummary(getString(R.string.ssid_summary));
      } else {
        ssidList.setSummary(settings.getString("ssid", ""));
      }
    } else if (key.equals("user")) {
      if (settings.getString("user", "").equals("")) {
        userText.setSummary(getString(R.string.user_summary));
      } else {
        userText.setSummary(settings.getString("user", ""));
      }
    } else if (key.equals("domain")) {
      if (settings.getString("domain", "").equals("")) {
        domainText.setSummary(getString(R.string.domain_summary));
      } else {
        domainText.setSummary(settings.getString("domain", ""));
      }
    } else if (key.equals("proxyType")) {
      if (settings.getString("proxyType", "").equals("")) {
        certificateText.setSummary(getString(R.string.certificate_summary));
      } else {
        certificateText.setSummary(settings.getString("certificate", ""));
      }
    } else if (key.equals("bypassAddrs")) {
      if (settings.getString("bypassAddrs", "").equals("")) {
        bypassAddrs.setSummary(getString(R.string.set_bypass_summary));
      } else {
        bypassAddrs.setSummary(settings.getString("bypassAddrs", "").replace("|", ", "));
      }
    } else if (key.equals("port")) {
      if (settings.getString("port", "-1").equals("-1")
          || settings.getString("port", "-1").equals("")) {
        portText.setSummary(getString(R.string.port_summary));
      } else {
        portText.setSummary(settings.getString("port", ""));
      }
    } else if (key.equals("host")) {
      if (settings.getString("host", "").equals("")) {
        hostText.setSummary(
            settings.getBoolean("isPAC", false)
                ? R.string.host_pac_summary
                : R.string.host_summary);
      } else {
        hostText.setSummary(settings.getString("host", ""));
      }
    } else if (key.equals("proxyType")) {
      if (settings.getString("proxyType", "").equals("")) {
        proxyTypeList.setSummary(getString(R.string.proxy_type_summary));
      } else {
        proxyTypeList.setSummary(settings.getString("proxyType", "").toUpperCase());
      }
    } else if (key.equals("password")) {
      if (!settings.getString("password", "").equals("")) {
        passwordText.setSummary("*********");
      } else {
        passwordText.setSummary(getString(R.string.password_summary));
      }
    }
  }
예제 #11
0
  @Override
  protected void onResume() {
    super.onResume();
    SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);

    if (settings.getBoolean("isAutoSetProxy", false)) {
      proxyedApps.setEnabled(false);
      isBypassAppsCheck.setEnabled(false);
    } else {
      proxyedApps.setEnabled(true);
      isBypassAppsCheck.setEnabled(true);
    }

    if (settings.getBoolean("isAutoConnect", false)) {
      ssidList.setEnabled(true);
    } else {
      ssidList.setEnabled(false);
    }

    if (settings.getBoolean("isPAC", false)) {
      portText.setEnabled(false);
      proxyTypeList.setEnabled(false);
      hostText.setTitle(R.string.host_pac);
      hostText.setSummary(R.string.host_pac_summary);
    }

    if (!settings.getBoolean("isAuth", false)) {
      userText.setEnabled(false);
      passwordText.setEnabled(false);
      isNTLMCheck.setEnabled(false);
    }

    if (!settings.getBoolean("isAuth", false) || !settings.getBoolean("isNTLM", false)) {
      domainText.setEnabled(false);
    }

    if (!"https".equals(settings.getString("proxyType", ""))) {
      certificateText.setEnabled(false);
    }

    Editor edit = settings.edit();

    if (Utils.isWorking()) {
      if (settings.getBoolean("isConnecting", false)) isRunningCheck.setEnabled(false);
      edit.putBoolean("isRunning", true);
    } else {
      if (settings.getBoolean("isRunning", false)) {
        new Thread() {
          @Override
          public void run() {
            reset();
          }
        }.start();
      }
      edit.putBoolean("isRunning", false);
    }

    edit.commit();

    if (settings.getBoolean("isRunning", false)) {
      if (Build.VERSION.SDK_INT >= 14) {
        ((SwitchPreference) isRunningCheck).setChecked(true);
      } else {
        ((CheckBoxPreference) isRunningCheck).setChecked(true);
      }
      disableAll();
    } else {
      if (Build.VERSION.SDK_INT >= 14) {
        ((SwitchPreference) isRunningCheck).setChecked(false);
      } else {
        ((CheckBoxPreference) isRunningCheck).setChecked(false);
      }
      enableAll();
    }

    // Setup the initial values
    profile = settings.getString("profile", "1");
    profileList.setValue(profile);

    profileList.setSummary(getProfileName(profile));

    if (!settings.getString("ssid", "").equals("")) {
      ssidList.setSummary(settings.getString("ssid", ""));
    }
    if (!settings.getString("user", "").equals("")) {
      userText.setSummary(settings.getString("user", getString(R.string.user_summary)));
    }
    if (!settings.getString("certificate", "").equals("")) {
      certificateText.setSummary(
          settings.getString("certificate", getString(R.string.certificate_summary)));
    }
    if (!settings.getString("bypassAddrs", "").equals("")) {
      bypassAddrs.setSummary(
          settings
              .getString("bypassAddrs", getString(R.string.set_bypass_summary))
              .replace("|", ", "));
    } else {
      bypassAddrs.setSummary(R.string.set_bypass_summary);
    }
    if (!settings.getString("port", "-1").equals("-1")
        && !settings.getString("port", "-1").equals("")) {
      portText.setSummary(settings.getString("port", getString(R.string.port_summary)));
    }
    if (!settings.getString("host", "").equals("")) {
      hostText.setSummary(
          settings.getString(
              "host",
              getString(
                  settings.getBoolean("isPAC", false)
                      ? R.string.host_pac_summary
                      : R.string.host_summary)));
    }
    if (!settings.getString("password", "").equals("")) passwordText.setSummary("*********");
    if (!settings.getString("proxyType", "").equals("")) {
      proxyTypeList.setSummary(settings.getString("proxyType", "").toUpperCase());
    }
    if (!settings.getString("domain", "").equals("")) {
      domainText.setSummary(settings.getString("domain", ""));
    }

    // Set up a listener whenever a key changes
    getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
  }
예제 #12
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);
        }
      }
    }
  }