コード例 #1
0
    @Override
    protected void onCreate(Bundle icicle) {
      super.onCreate(icicle);
      if (DBG) log("Settings: onCreate()...");

      getPreferenceManager().setSharedPreferencesName(SHARED_PREFERENCES_NAME);

      // This preference screen is ultra-simple; it's just 4 plain
      // <EditTextPreference>s, one for each of the 4 "canned responses".
      //
      // The only nontrivial thing we do here is copy the text value of
      // each of those EditTextPreferences and use it as the preference's
      // "title" as well, so that the user will immediately see all 4
      // strings when they arrive here.
      //
      // Also, listen for change events (since we'll need to update the
      // title any time the user edits one of the strings.)

      addPreferencesFromResource(R.xml.respond_via_sms_settings);

      EditTextPreference pref;
      pref = (EditTextPreference) findPreference(KEY_CANNED_RESPONSE_PREF_1);
      pref.setTitle(pref.getText());
      pref.setOnPreferenceChangeListener(this);

      pref = (EditTextPreference) findPreference(KEY_CANNED_RESPONSE_PREF_2);
      pref.setTitle(pref.getText());
      pref.setOnPreferenceChangeListener(this);

      pref = (EditTextPreference) findPreference(KEY_CANNED_RESPONSE_PREF_3);
      pref.setTitle(pref.getText());
      pref.setOnPreferenceChangeListener(this);

      pref = (EditTextPreference) findPreference(KEY_CANNED_RESPONSE_PREF_4);
      pref.setTitle(pref.getText());
      pref.setOnPreferenceChangeListener(this);
      /* Begin: Modified by zxiaona for add_autosms 2012/07/27 */
      pref = (EditTextPreference) findPreference(KEY_CANNED_RESPONSE_PREF_5);
      pref.setTitle(pref.getText());
      pref.setOnPreferenceChangeListener(this);
      /* End: Modified by zxiaona for add_autosms 2012/07/27 */

      ActionBar actionBar = getActionBar();
      if (actionBar != null) {
        // android.R.id.home will be triggered in onOptionsItemSelected()
        actionBar.setDisplayHomeAsUpEnabled(true);
      }
    }
コード例 #2
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    PreferenceScreen ps = getPreferenceManager().createPreferenceScreen(getActivity());
    ps.setTitle(R.string.quick_response_settings_title);

    mResponses = Utils.getQuickResponses(getActivity());

    if (mResponses != null) {
      mEditTextPrefs = new EditTextPreference[mResponses.length];

      Arrays.sort(mResponses);
      int i = 0;
      for (String response : mResponses) {
        EditTextPreference et = new EditTextPreference(getActivity());
        et.setDialogTitle(R.string.quick_response_settings_edit_title);
        et.setTitle(response); // Display Text
        et.setText(response); // Value to edit
        et.setOnPreferenceChangeListener(this);
        mEditTextPrefs[i++] = et;
        ps.addPreference(et);
      }
    } else {
      Log.wtf(TAG, "No responses found");
    }
    setPreferenceScreen(ps);
    /// M:Toast to alarm @{
    mToast = Toast.makeText(getActivity(), "", Toast.LENGTH_SHORT);
    /// @}
  }
コード例 #3
0
  private PreferenceScreen createPreferenceHierarchy() {
    // Root
    PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);

    root.setPersistent(true);

    CheckBoxPreference nextScreenCheckBoxPref = new CheckBoxPreference(this);
    nextScreenCheckBoxPref.setKey(BlackBoxPrefs.KEY_ENABLED);
    nextScreenCheckBoxPref.setTitle("enabled");
    nextScreenCheckBoxPref.setSummary("is BlackBox enabled?");
    root.addPreference(nextScreenCheckBoxPref);

    EditTextPreference sgf_fname_pref = new EditTextPreference(this);
    sgf_fname_pref.setTitle("Path");
    root.addPreference(sgf_fname_pref);

    sgf_fname_pref.setDialogTitle("Enter BlackBox Path");
    sgf_fname_pref.setDialogMessage("Please enter the BlackBox Path.");
    sgf_fname_pref.setKey(BlackBoxPrefs.KEY_PATH);
    sgf_fname_pref.setText(BlackBoxPrefs.getPath());
    sgf_fname_pref.setSummary(BlackBoxPrefs.getPath());

    PreferenceScreen intentPref = getPreferenceManager().createPreferenceScreen(this);
    Intent i = new Intent(this, BlackBoxWatchActivity.class);

    intentPref.setIntent(i);
    intentPref.setTitle("Watch BlackBox");
    intentPref.setSummary("check BlackBox status");
    root.addPreference(intentPref);

    return root;
  }
コード例 #4
0
ファイル: BroadVoice.java プロジェクト: zxcpoiu/CSipSimple
  @Override
  public void fillLayout(final SipProfile account) {
    super.fillLayout(account);

    accountUsername.setTitle(R.string.w_common_phone_number);
    accountUsername.setDialogTitle(R.string.w_common_phone_number);

    accountUsername.getEditText().setInputType(InputType.TYPE_CLASS_PHONE);

    // Allow to add suffix x11
    boolean recycle = true;
    accountSuffix = (EditTextPreference) findPreference(SUFFIX_KEY);
    if (accountSuffix == null) {
      accountSuffix = new EditTextPreference(parent);
      accountSuffix.setKey(SUFFIX_KEY);
      accountSuffix.getEditText().setInputType(InputType.TYPE_CLASS_PHONE);
      accountSuffix.setTitle("Suffix for account id");
      accountSuffix.setSummary("For multipresence usage (leave blank if not want)");
      recycle = false;
    }

    if (!recycle) {
      addPreference(accountSuffix);
    }

    String uName = account.getSipUserName();
    String[] uNames = uName.split("x");

    accountUsername.setText(uNames[0]);
    if (uNames.length > 1) {
      accountSuffix.setText(uNames[1]);
    }
  }
コード例 #5
0
ファイル: SettingsActivity.java プロジェクト: aitolos/Osmand
 public EditTextPreference createEditTextPreference(
     OsmandPreference<String> b, int title, int summary) {
   EditTextPreference p = new EditTextPreference(this);
   p.setTitle(title);
   p.setKey(b.getId());
   p.setDialogTitle(title);
   p.setSummary(summary);
   p.setOnPreferenceChangeListener(this);
   screenPreferences.put(b.getId(), p);
   editTextPreferences.put(b.getId(), b);
   return p;
 }
コード例 #6
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.rcs_settings_presence_preferences);
    setTitle(R.string.rcs_settings_title_presence_settings);

    freetextEdit1 = (EditTextPreference) findPreference("edit_freetext1");
    freetextEdit1.setPersistent(false);
    freetextEdit1.setOnPreferenceChangeListener(this);
    String txt1 = RcsSettings.getInstance().getPredefinedFreetext1();
    freetextEdit1.setText(txt1);
    freetextEdit1.setTitle(txt1);

    freetextEdit2 = (EditTextPreference) findPreference("edit_freetext2");
    freetextEdit2.setPersistent(false);
    freetextEdit2.setOnPreferenceChangeListener(this);
    String txt2 = RcsSettings.getInstance().getPredefinedFreetext2();
    freetextEdit2.setText(txt2);
    freetextEdit2.setTitle(txt2);

    freetextEdit3 = (EditTextPreference) findPreference("edit_freetext3");
    freetextEdit3.setPersistent(false);
    freetextEdit3.setOnPreferenceChangeListener(this);
    String txt3 = RcsSettings.getInstance().getPredefinedFreetext3();
    freetextEdit3.setText(txt3);
    freetextEdit3.setTitle(txt3);

    freetextEdit4 = (EditTextPreference) findPreference("edit_freetext4");
    freetextEdit4.setPersistent(false);
    freetextEdit4.setOnPreferenceChangeListener(this);
    String txt4 = RcsSettings.getInstance().getPredefinedFreetext4();
    freetextEdit4.setText(txt4);
    freetextEdit4.setTitle(txt4);

    vibrateInvitation = (CheckBoxPreference) findPreference("presence_invitation_vibration");
    vibrateInvitation.setPersistent(false);
    vibrateInvitation.setOnPreferenceChangeListener(this);
    vibrateInvitation.setChecked(RcsSettings.getInstance().isPhoneVibrateForPresenceInvitation());
  }
コード例 #7
0
  public boolean onPreferenceChange(Preference preference, Object objValue) {
    if ("edit_displayname".equals(preference.getKey())) {
      String name = (String) objValue;
      try {
        getContactApi().getCommonConfiguration().setMyDisplayName(name);
        displaynameEdit.setTitle(name);

      } catch (RcsServiceException e) {
        showExceptionThenExit(e);
      }
    }
    return true;
  }
コード例 #8
0
 public boolean onPreferenceChange(Preference preference, Object objValue) {
   if (preference.getKey().equals("edit_freetext1")) {
     String txt = (String) objValue;
     RcsSettings.getInstance().setPredefinedFreetext1(txt);
     freetextEdit1.setTitle(txt);
   } else if (preference.getKey().equals("edit_freetext2")) {
     String txt = (String) objValue;
     RcsSettings.getInstance().setPredefinedFreetext2(txt);
     freetextEdit2.setTitle(txt);
   } else if (preference.getKey().equals("edit_freetext3")) {
     String txt = (String) objValue;
     RcsSettings.getInstance().setPredefinedFreetext3(txt);
     freetextEdit3.setTitle(txt);
   } else if (preference.getKey().equals("edit_freetext4")) {
     String txt = (String) objValue;
     RcsSettings.getInstance().setPredefinedFreetext4(txt);
     freetextEdit4.setTitle(txt);
   } else if (preference.getKey().equals("presence_invitation_vibration")) {
     Boolean state = (Boolean) objValue;
     RcsSettings.getInstance().setPhoneVibrateForPresenceInvitation(state.booleanValue());
   }
   return true;
 }
コード例 #9
0
    // Preference.OnPreferenceChangeListener implementation
    public boolean onPreferenceChange(Preference preference, Object newValue) {
      if (DBG) log("onPreferenceChange: key = " + preference.getKey());
      if (VDBG) log("  preference = '" + preference + "'");
      if (VDBG) log("  newValue = '" + newValue + "'");

      EditTextPreference pref = (EditTextPreference) preference;

      // Copy the new text over to the title, just like in onCreate().
      // (Watch out: onPreferenceChange() is called *before* the
      // Preference itself gets updated, so we need to use newValue here
      // rather than pref.getText().)
      pref.setTitle((String) newValue);

      return true; // means it's OK to update the state of the Preference with the new value
    }
コード例 #10
0
ファイル: Pref.java プロジェクト: 49degree/my-tel-util
 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;
 }
コード例 #11
0
  @SuppressWarnings("deprecation")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.application_preference);
    getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    mCastManager = VideoCastManager.getInstance();

    /* Volume settings */
    mVolumeListPreference =
        (ListPreference) getPreferenceScreen().findPreference(VOLUME_SELECTION_KEY);
    String volValue =
        prefs.getString(VOLUME_SELECTION_KEY, getString(R.string.prefs_volume_default));
    String volSummary = getResources().getString(R.string.prefs_volume_title_summary, volValue);
    mVolumeListPreference.setSummary(volSummary);

    EditTextPreference versionPref = (EditTextPreference) findPreference("app_version");
    versionPref.setTitle(
        getString(
            R.string.version, Utils.getAppVersionName(this), getString(R.string.ccl_version)));
  }
コード例 #12
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.rcs_settings_userprofile_preferences);

    displaynameEdit = (EditTextPreference) findPreference("edit_displayname");
    displaynameEdit.setPersistent(false);
    displaynameEdit.setOnPreferenceChangeListener(this);

    if (!isServiceConnected(RcsServiceName.FILE_TRANSFER)) {
      showMessage(R.string.label_service_not_available);
      return;
    }

    try {
      String name = getContactApi().getCommonConfiguration().getMyDisplayName();
      displaynameEdit.setText(name);
      displaynameEdit.setTitle(name);

    } catch (RcsServiceException e) {
      showExceptionThenExit(e);
    }
  }
コード例 #13
0
ファイル: SettingsActivity.java プロジェクト: aitolos/Osmand
  @Override
  public void onCreate(Bundle savedInstanceState) {
    CustomTitleBar titleBar =
        new CustomTitleBar(this, R.string.settings_activity, R.drawable.tab_settings_screen_icon);
    setTheme(R.style.CustomTitleTheme_Preference);
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.settings_pref);
    titleBar.afterSetContentView();

    String[] entries;
    String[] entrieValues;
    PreferenceScreen screen = getPreferenceScreen();
    osmandSettings = getMyApplication().getSettings();

    PreferenceCategory cat = (PreferenceCategory) screen.findPreference("global_app_settings");
    if (!Version.isBlackberry(this)) {
      CheckBoxPreference nativeCheckbox =
          createCheckBoxPreference(
              osmandSettings.SAFE_MODE, R.string.safe_mode, R.string.safe_mode_description);
      // disable the checkbox if the library cannot be used
      if ((NativeOsmandLibrary.isLoaded() && !NativeOsmandLibrary.isSupported())
          || osmandSettings.NATIVE_RENDERING_FAILED.get()) {
        nativeCheckbox.setEnabled(false);
        nativeCheckbox.setChecked(true);
      }
      cat.addPreference(nativeCheckbox);

      applicationDir = new EditTextPreference(this);
      applicationDir.setTitle(R.string.application_dir);
      applicationDir.setKey("external_storage_dir");
      applicationDir.setDialogTitle(R.string.application_dir);
      applicationDir.setOnPreferenceChangeListener(this);
      cat.addPreference(applicationDir);
    }

    //		BidForFixHelper bidForFixHelper = getMyApplication().getBidForFix();
    //		bidForFixHelper.generatePreferenceList(screen, getString(R.string.support_new_features),
    // this);
    OsmandPlugin.onSettingsActivityCreate(this, screen);

    registerBooleanPreference(osmandSettings.USE_ENGLISH_NAMES, screen);
    registerBooleanPreference(osmandSettings.AUTO_ZOOM_MAP, screen);
    registerBooleanPreference(osmandSettings.FAST_ROUTE_MODE, screen);
    registerBooleanPreference(osmandSettings.SNAP_TO_ROAD, screen);
    registerBooleanPreference(osmandSettings.USE_COMPASS_IN_NAVIGATION, screen);
    registerBooleanPreference(osmandSettings.LEFT_SIDE_NAVIGATION, screen);

    // List preferences
    //		registerListPreference(osmandSettings.ROTATE_MAP, screen,
    //				new String[]{getString(R.string.rotate_map_none_opt),
    // getString(R.string.rotate_map_bearing_opt), getString(R.string.rotate_map_compass_opt)},
    //				new Integer[]{OsmandSettings.ROTATE_MAP_NONE, OsmandSettings.ROTATE_MAP_BEARING,
    // OsmandSettings.ROTATE_MAP_COMPASS});

    registerListPreference(
        osmandSettings.MAP_SCREEN_ORIENTATION,
        screen,
        new String[] {
          getString(R.string.map_orientation_portrait),
          getString(R.string.map_orientation_landscape),
          getString(R.string.map_orientation_default)
        },
        new Integer[] {
          ActivityInfo.SCREEN_ORIENTATION_PORTRAIT,
          ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE,
          ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED
        });

    MetricsConstants[] mvls =
        new MetricsConstants[] {
          MetricsConstants.KILOMETERS_AND_METERS,
          MetricsConstants.MILES_AND_FOOTS,
          MetricsConstants.MILES_AND_YARDS
        }; // MetricsConstants.values();
    entries = new String[mvls.length];
    for (int i = 0; i < entries.length; i++) {
      entries[i] = mvls[i].toHumanString(this);
    }
    registerListPreference(osmandSettings.METRIC_SYSTEM, screen, entries, mvls);

    // getResources().getAssets().getLocales();
    entrieValues =
        new String[] {
          "", "en", "af", "hy", "eu", "bs", "bg", "ca", "cs", "nl", "fi", "fr", "ka", "de", "el",
          "he", "hi", "hu", "id", "it", "ja", "ko", "lv", "lt", "mr", "no", "pl", "pt", "ro", "ru",
          "sk", "sl", "es", "sv", "uk", "vi"
        };
    entries =
        new String[] {
          getString(R.string.system_locale),
          "English",
          "Afrikaans",
          "Armenian",
          "Basque",
          "Bosnian",
          "Bulgarian",
          "Catalan",
          "Czech",
          "Dutch",
          "Finnish",
          "French",
          "Georgian",
          "German",
          "Greek",
          "Hebrew",
          "Hindi",
          "Hungarian",
          "Indonesian",
          "Italian",
          "Japanese",
          "Korean",
          "Latvian",
          "Lithuanian",
          "Marathi",
          "Norwegian",
          "Polish",
          "Portuguese",
          "Romanian",
          "Russian",
          "Slovak",
          "Slovenian",
          "Spanish",
          "Swedish",
          "Ukrainian",
          "Vietnamese"
        };
    registerListPreference(osmandSettings.PREFERRED_LOCALE, screen, entries, entrieValues);

    Integer[] intValues = new Integer[] {0, 5, 10, 15, 20, 25, 30, 45, 60, 90};
    entries = new String[intValues.length];
    entries[0] = getString(R.string.auto_follow_route_never);
    for (int i = 1; i < intValues.length; i++) {
      entries[i] = (int) intValues[i] + " " + getString(R.string.int_seconds);
    }
    registerListPreference(osmandSettings.AUTO_FOLLOW_ROUTE, screen, entries, intValues);

    entries = new String[RouteService.values().length];
    for (int i = 0; i < entries.length; i++) {
      entries[i] = RouteService.values()[i].getName();
    }
    registerListPreference(osmandSettings.ROUTER_SERVICE, screen, entries, RouteService.values());

    //		entries = new String[ApplicationMode.values().length];
    //		for(int i=0; i<entries.length; i++){
    //			entries[i] = ApplicationMode.values()[i].toHumanString(this);
    //		}
    //		registerListPreference(osmandSettings.APPLICATION_MODE, screen, entries,
    // ApplicationMode.values());
    //
    //		applicationModePreference = (ListPreference)
    // screen.findPreference(osmandSettings.APPLICATION_MODE.getId());
    //		applicationModePreference.setOnPreferenceChangeListener(this);

    routerServicePreference =
        (ListPreference) screen.findPreference(osmandSettings.ROUTER_SERVICE.getId());
    routerServicePreference.setOnPreferenceChangeListener(this);

    Preference localIndexes = (Preference) screen.findPreference(OsmandSettings.LOCAL_INDEXES);
    localIndexes.setOnPreferenceClickListener(this);
    bidforfix = (Preference) screen.findPreference("bidforfix");
    bidforfix.setOnPreferenceClickListener(this);
    plugins = (Preference) screen.findPreference("plugins");
    plugins.setOnPreferenceClickListener(this);
    avoidRouting = (Preference) screen.findPreference("avoid_in_routing");
    avoidRouting.setOnPreferenceClickListener(this);
    showAlarms = (Preference) screen.findPreference("show_routing_alarms");
    showAlarms.setOnPreferenceClickListener(this);

    Intent intent = getIntent();
    if (intent != null && intent.getIntExtra(INTENT_KEY_SETTINGS_SCREEN, 0) != 0) {
      int s = intent.getIntExtra(INTENT_KEY_SETTINGS_SCREEN, 0);
      String pref = null;
      if (s == SCREEN_GENERAL_SETTINGS) {
        pref = SCREEN_ID_GENERAL_SETTINGS;
      } else if (s == SCREEN_NAVIGATION_SETTINGS) {
        pref = SCREEN_ID_NAVIGATION_SETTINGS;
      }
      if (pref != null) {
        Preference toOpen = screen.findPreference(pref);
        if (toOpen instanceof PreferenceScreen) {
          setPreferenceScreen((PreferenceScreen) toOpen);
        }
      }
    }
  }
コード例 #14
0
ファイル: ProxyDroid.java プロジェクト: kunal15595/proxydroid
  @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));
      }
    }
  }
コード例 #15
0
ファイル: ProxyDroid.java プロジェクト: kunal15595/proxydroid
  @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);
  }
コード例 #16
0
  @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;
          }
        });
  }