コード例 #1
0
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   addPreferencesFromResource(R.xml.settings);
   PreferenceScreen preferenceScreen = getPreferenceScreen();
   listPreference = (ListPreference) preferenceScreen.findPreference(PREF_MODE);
   listPreference.setDefaultValue(getResources().getString(R.string.default_mode));
   listPreference.setOnPreferenceChangeListener(this);
 }
コード例 #2
0
ファイル: Betamax.java プロジェクト: adybkows/sip-ptt
  @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);
  }
コード例 #3
0
 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);
 }
コード例 #4
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    LinearLayout root =
        (LinearLayout) findViewById(android.R.id.list).getParent().getParent().getParent();
    View bar = LayoutInflater.from(this).inflate(R.layout.settings_toolbar, root, false);
    root.addView(bar, 0);
    Toolbar toolbar = (Toolbar) findViewById(R.id.settings_toolbar);
    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            finish();
          }
        });

    addPreferencesFromResource(R.xml.prefs);

    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
    Resources res = getResources();

    ListPreference dateFormatPref = (ListPreference) findPreference("dateFormat");
    String[] dateFormatsValues = res.getStringArray(R.array.dateFormatsValues);
    String[] dateFormatsEntries = new String[dateFormatsValues.length];

    EditTextPreference customDateFormatPref =
        (EditTextPreference) findPreference("dateFormatCustom");
    customDateFormatPref.setDefaultValue(dateFormatsValues[0]);

    SimpleDateFormat sdformat = new SimpleDateFormat();
    for (int i = 0; i < dateFormatsValues.length; i++) {
      String value = dateFormatsValues[i];
      if ("custom".equals(value)) {
        sdformat.applyPattern(sp.getString("dateFormatCustom", dateFormatsValues[0]));
        String renderedCustom;
        try {
          renderedCustom = sdformat.format(SAMPLE_DATE);
        } catch (IllegalArgumentException e) {
          renderedCustom = res.getString(R.string.error_dateFormat);
        }
        dateFormatsEntries[i] =
            String.format(
                "%s:\n%s", res.getString(R.string.setting_dateFormatCustom), renderedCustom);
      } else {
        sdformat.applyPattern(value);
        dateFormatsEntries[i] = sdformat.format(SAMPLE_DATE);
      }
    }

    dateFormatPref.setDefaultValue(dateFormatsValues[0]);
    dateFormatPref.setEntries(dateFormatsEntries);
  }
コード例 #5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    addPreferencesFromResource(R.xml.pref_general);
    showLockScreenControlsPreference =
        (TwoStatePreference) findPreference(getString(R.string.lock_screen_pref_key));
    if (showLockScreenControlsPreference != null) {

      showLockScreenControlsPreference.setEnabled(true);
    }
    showLockScreenControlsPreference.setOnPreferenceChangeListener(
        new Preference.OnPreferenceChangeListener() {
          @Override
          public boolean onPreferenceChange(
              Preference preference, Object showLockScreenControlsObj) {

            SharedPreferences.Editor sharedPrefencesEditor = sharedPreferences.edit();
            sharedPrefencesEditor.putBoolean(
                getString(R.string.lock_screen_controls),
                ((Boolean) showLockScreenControlsObj).booleanValue());
            sharedPrefencesEditor.commit();

            Intent broadcastLockScreenIntent = new Intent();
            broadcastLockScreenIntent.setAction(getString(R.string.is_lock_screen_visible));
            sendBroadcast(broadcastLockScreenIntent);

            return true;
          }
        });

    ListPreference listOfCountriesPreference =
        (ListPreference) findPreference(getString(R.string.country_code_pref_key));
    if (null != listOfCountriesPreference) {
      listOfCountriesPreference.setEntryValues(Locale.getISOCountries());
      String[] countries = new String[listOfCountriesPreference.getEntryValues().length];
      for (int i = 0; i < listOfCountriesPreference.getEntryValues().length; i++) {
        countries[i] = new Locale("", Locale.getISOCountries()[i]).getDisplayCountry();
      }
      listOfCountriesPreference.setEntries(countries);
      listOfCountriesPreference.setDefaultValue(Locale.US);
    }

    bindPreferenceSummaryToValue(findPreference(getString(R.string.country_code_pref_key)));
  }
  private void loadPreferences() {
    EnumSet<LicensingMode> modes = LicensingMode.getAvailable();
    String[] entries = new String[modes.size()];
    String[] entryValues = new String[modes.size()];
    int i = 0;
    for (LicensingMode mode : modes) {
      entries[i] = mode.getName(this);
      entryValues[i] = mode.toString();
      i++;
    }
    mLicensingMode.setEntries(entries);
    mLicensingMode.setEntryValues(entryValues);
    mLicensingMode.setDefaultValue(LicensingServiceManager.DEFAULT_LICENSING_MODE.toString());

    setLicensingMode(LicensingServiceManager.getLicensingMode(this));
    setServerAddress(LicensingServiceManager.getServerAddress(this));
    setServerPort(LicensingServiceManager.getServerPort(this));
  }
コード例 #7
0
ファイル: BelCentrale.java プロジェクト: RockHardJim/idphone
  @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);
  }
コード例 #8
0
ファイル: Pref.java プロジェクト: 49degree/my-tel-util
 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;
 }
コード例 #9
0
ファイル: ProxyDroid.java プロジェクト: kunal15595/proxydroid
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.proxydroid_preference);

    // Create the adView
    adView = new AdView(this, AdSize.SMART_BANNER, "a14db2c016cb9b6");
    // Lookup your LinearLayout assuming it’s been given
    // the attribute android:id="@+id/mainLayout"
    ViewParent parent = getListView().getParent();
    LinearLayout layout = getLayout(parent);

    // disable adds
    /*
    if (layout != null) {
      // Add the adView to it
      layout.addView(adView, 0);
      // Initiate a generic request to load it with an ad
      AdRequest aq = new AdRequest();
      adView.loadAd(aq);
    }
    */

    hostText = (EditTextPreference) findPreference("host");
    portText = (EditTextPreference) findPreference("port");
    userText = (EditTextPreference) findPreference("user");
    passwordText = (EditTextPreference) findPreference("password");
    domainText = (EditTextPreference) findPreference("domain");
    certificateText = (EditTextPreference) findPreference("certificate");
    bypassAddrs = findPreference("bypassAddrs");
    ssidList = (ListPreferenceMultiSelect) findPreference("ssid");
    proxyTypeList = (ListPreference) findPreference("proxyType");
    proxyedApps = findPreference("proxyedApps");
    profileList = (ListPreference) findPreference("profile");

    isRunningCheck = (Preference) findPreference("isRunning");
    isAutoSetProxyCheck = (CheckBoxPreference) findPreference("isAutoSetProxy");
    isAuthCheck = (CheckBoxPreference) findPreference("isAuth");
    isNTLMCheck = (CheckBoxPreference) findPreference("isNTLM");
    isDNSProxyCheck = (CheckBoxPreference) findPreference("isDNSProxy");
    isPACCheck = (CheckBoxPreference) findPreference("isPAC");
    isAutoConnectCheck = (CheckBoxPreference) findPreference("isAutoConnect");
    isBypassAppsCheck = (CheckBoxPreference) findPreference("isBypassApps");

    final SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);

    String profileValuesString = settings.getString("profileValues", "");

    if (profileValuesString.equals("")) {
      Editor ed = settings.edit();
      profile = "1";
      ed.putString("profileValues", "1|0");
      ed.putString(
          "profileEntries",
          getString(R.string.profile_default) + "|" + getString(R.string.profile_new));
      ed.putString("profile", "1");
      ed.commit();

      profileList.setDefaultValue("1");
    }

    registerReceiver(
        ssidReceiver, new IntentFilter(android.net.ConnectivityManager.CONNECTIVITY_ACTION));

    loadProfileList();

    loadNetworkList();

    new Thread() {
      @Override
      public void run() {

        try {
          // Try not to block activity
          Thread.sleep(2000);
        } catch (InterruptedException ignore) {
          // Nothing
        }

        if (!Utils.isRoot()) {
          handler.sendEmptyMessage(MSG_NO_ROOT);
        }

        String versionName;
        try {
          versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
        } catch (NameNotFoundException e) {
          versionName = "NONE";
        }

        if (!settings.getBoolean(versionName, false)) {

          String version;
          try {
            version = getPackageManager().getPackageInfo(getPackageName(), 0).versionName;
          } catch (NameNotFoundException e) {
            version = "NONE";
          }

          reset();

          Editor edit = settings.edit();
          edit.putBoolean(version, true);
          edit.commit();

          handler.sendEmptyMessage(MSG_UPDATE_FINISHED);
        }
      }
    }.start();
  }
コード例 #10
0
ファイル: settings.java プロジェクト: thomasave/Mastermind
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.settingsactivity);
    addPreferencesFromResource(R.xml.preferences);
    AnalyticsApplication application = (AnalyticsApplication) getApplication();
    tracker = application.getDefaultTracker();
    tracker.setScreenName("Settings");
    tracker.send(new HitBuilders.ScreenViewBuilder().build());
    final SharedPreferences sharedpreferences =
        getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE);
    final ListPreference columns = (ListPreference) findPreference("columns");
    final ListPreference background = (ListPreference) findPreference("backgroundpreference");
    final EditTextPreference editTextPreference = (EditTextPreference) findPreference("rows");
    editTextPreference.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
    editTextPreference.setOnPreferenceChangeListener(
        new Preference.OnPreferenceChangeListener() {
          @Override
          public boolean onPreferenceChange(Preference preference, Object o) {
            MainActivity.m_size_changed = true;
            return true;
          }
        });
    if (sharedpreferences.getString("adpreference", "Full").equals("None")) {
      Log.v("adpreference", "destroy");
      View adfragment = findViewById(R.id.ad_fragmentsettings);
      adfragment.setVisibility(View.INVISIBLE);
    } else {
      Log.v("adpreference", "Not destroy" + sharedpreferences.getString("adpreference", "Full"));
      AdView adView = (AdView) findViewById(R.id.adView);
      AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
      adView.loadAd(adRequestBuilder.build());
    }

    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);

    int maxcolumns = Math.max(Math.round(Math.min(size.x, size.y) / 154) - 2, 2);

    String[] entries = new String[maxcolumns];
    for (int i = 0; i < maxcolumns; i++) entries[i] = Integer.toString(i + 3);
    columns.setEntries(entries);
    columns.setDefaultValue(entries[0]);
    columns.setEntryValues(entries);
    columns.setOnPreferenceChangeListener(
        new Preference.OnPreferenceChangeListener() {
          @Override
          public boolean onPreferenceChange(Preference preference, Object o) {
            MainActivity.m_size_changed = true;
            return true;
          }
        });
    background.setOnPreferenceChangeListener(
        new Preference.OnPreferenceChangeListener() {
          @Override
          public boolean onPreferenceChange(Preference preference, Object o) {
            MainActivity.m_background_changed = true;
            return true;
          }
        });
    ListPreference ads = (ListPreference) findPreference("adpreference");
    defaultvalue = sharedpreferences.getString("adpreference", "Full");
    ads.setDefaultValue(defaultvalue);
    ads.setOnPreferenceChangeListener(
        new Preference.OnPreferenceChangeListener() {
          @Override
          public boolean onPreferenceChange(Preference preference, Object o) {
            MainActivity.m_ads_changed = true;
            String status = sharedpreferences.getString("adpreference", "Full");
            SharedPreferences.Editor mEdit1 = sharedpreferences.edit();
            mEdit1.putString("adpreference", (String) o);
            mEdit1.apply();
            String statusafter = sharedpreferences.getString("adpreference", "Full");
            if (statusafter.equals("None") && !(status.equals("None"))) {
              View adfragment = findViewById(R.id.ad_fragmentsettings);
              adfragment.setVisibility(View.INVISIBLE);
            }
            if (!(statusafter.equals("None")) && status.equals("None")) {
              AdView adView = (AdView) findViewById(R.id.adView);
              View adfragment = findViewById(R.id.ad_fragmentsettings);
              adfragment.setVisibility(View.VISIBLE);
              AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
              adView.loadAd(adRequestBuilder.build());
            }
            Log.v("adpreference", statusafter);
            return true;
          }
        });
  }