Example usage for android.preference EditTextPreference EditTextPreference

List of usage examples for android.preference EditTextPreference EditTextPreference

Introduction

In this page you can find the example usage for android.preference EditTextPreference EditTextPreference.

Prototype

public EditTextPreference(Context context) 

Source Link

Usage

From source file:nya.miku.wishmaster.chans.nullchan.NullchanoneModule.java

private void addDomainPreference(PreferenceGroup group) {
    Context context = group.getContext();
    EditTextPreference domainPref = new EditTextPreference(context);
    domainPref.setTitle(R.string.pref_domain);
    domainPref.setDialogTitle(R.string.pref_domain);
    domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN));
    domainPref.getEditText().setHint(CHAN_DOMAIN);
    domainPref.getEditText().setSingleLine();
    domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    group.addPreference(domainPref);//ww  w.  j av a  2 s .c o  m
}

From source file:com.fututel.wizards.impl.Sipgate.java

@Override
public void fillLayout(final SipProfile account) {
    super.fillLayout(account);
    //Override titles
    accountDisplayName.setTitle(R.string.w_sipgate_display_name);
    accountDisplayName.setDialogTitle(R.string.w_sipgate_display_name);
    accountServer.setTitle(R.string.w_common_server);
    accountServer.setDialogTitle(R.string.w_common_server);
    accountUsername.setTitle(R.string.w_sipgate_username);
    accountUsername.setDialogTitle(R.string.w_sipgate_username);
    accountPassword.setTitle(R.string.w_sipgate_password);
    accountPassword.setDialogTitle(R.string.w_sipgate_password);

    // Add optional proxy
    boolean recycle = true;
    accountProxy = (EditTextPreference) findPreference(PROXY_KEY);
    if (accountProxy == null) {
        accountProxy = new EditTextPreference(parent);
        accountProxy.setKey(PROXY_KEY);/*  w ww . ja v a 2s  .c  om*/
        accountProxy.setTitle(R.string.w_advanced_proxy);
        accountProxy.setSummary(R.string.w_advanced_proxy_desc);
        accountProxy.setDialogMessage(R.string.w_advanced_proxy_desc);
        recycle = false;
    }

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

    String currentProxy = account.getProxyAddress();
    String currentServer = account.getSipDomain();
    if (!TextUtils.isEmpty(currentProxy) && !TextUtils.isEmpty(currentServer)
            && !currentProxy.equalsIgnoreCase(currentProxy)) {
        accountProxy.setText(currentProxy);
    }

    if (TextUtils.isEmpty(account.getSipDomain())) {
        accountServer.setText("sipgate.de");
    }

    //Get wizard specific row for balance
    customWizardText = (TextView) parent.findViewById(R.id.custom_wizard_text);
    customWizard = (LinearLayout) parent.findViewById(R.id.custom_wizard_row);
    updateAccountInfos(account);
}

From source file:com.csipsimple.wizards.impl.Sipgate.java

@Override
public void fillLayout(final SipProfile account) {
    super.fillLayout(account);
    //Override titles
    accountDisplayName.setTitle(R.string.w_sipgate_display_name);
    accountDisplayName.setDialogTitle(R.string.w_sipgate_display_name);
    accountServer.setTitle(R.string.w_common_server);
    accountServer.setDialogTitle(R.string.w_common_server);
    accountUsername.setTitle(R.string.w_sipgate_username);
    accountUsername.setDialogTitle(R.string.w_sipgate_username);
    accountPassword.setTitle(R.string.w_sipgate_password);
    accountPassword.setDialogTitle(R.string.w_sipgate_password);

    // Add optional proxy
    boolean recycle = true;
    accountProxy = (EditTextPreference) findPreference(PROXY_KEY);
    if (accountProxy == null) {
        accountProxy = new EditTextPreference(parent);
        accountProxy.setKey(PROXY_KEY);//from  w  w w .j  ava 2s . c  o m
        accountProxy.setTitle(R.string.w_advanced_proxy);
        accountProxy.setSummary(R.string.w_advanced_proxy_desc);
        accountProxy.setDialogMessage(R.string.w_advanced_proxy_desc);
        recycle = false;
    }

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

    String currentProxy = account.getProxyAddress();
    String currentServer = account.getSipDomain();
    if (!TextUtils.isEmpty(currentProxy) && !TextUtils.isEmpty(currentServer)) {
        String currentProxyServer = currentProxy.replace("sip:", "");
        if (!currentProxyServer.equalsIgnoreCase(currentServer)) {
            accountProxy.setText(currentProxyServer);
        }
    }

    if (TextUtils.isEmpty(account.getSipDomain())) {
        accountServer.setText("sipgate.de");
    }

    //Get wizard specific row for balance
    customWizardText = (TextView) parent.findViewById(R.id.custom_wizard_text);
    customWizard = (LinearLayout) parent.findViewById(R.id.custom_wizard_row);
    updateAccountInfos(account);
}

From source file:net.voxcorp.voxmobile.wizards.impl.Sipgate.java

@Override
public void fillLayout(final SipProfile account) {
    super.fillLayout(account);
    //Override titles
    accountDisplayName.setTitle(R.string.w_sipgate_display_name);
    accountDisplayName.setDialogTitle(R.string.w_sipgate_display_name);
    accountServer.setTitle(R.string.w_common_server);
    accountServer.setDialogTitle(R.string.w_common_server);
    accountUsername.setTitle(R.string.w_sipgate_username);
    accountUsername.setDialogTitle(R.string.w_sipgate_username);
    accountPassword.setTitle(R.string.w_sipgate_password);
    accountPassword.setDialogTitle(R.string.w_sipgate_password);

    // Add optional proxy
    boolean recycle = true;
    accountProxy = (EditTextPreference) findPreference(PROXY_KEY);
    if (accountProxy == null) {
        accountProxy = new EditTextPreference(parent);
        accountProxy.setKey(PROXY_KEY);//from  w  w  w. j a  v a 2 s .c  o m
        accountProxy.setTitle(R.string.w_advanced_proxy);
        accountProxy.setSummary(R.string.w_advanced_proxy_desc);
        accountProxy.setDialogMessage(R.string.w_advanced_proxy_desc);
        recycle = false;
    }

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

    String currentProxy = account.getProxyAddress();
    String currentServer = account.getSipDomain();
    if (!TextUtils.isEmpty(currentProxy) && !TextUtils.isEmpty(currentServer)
            && !currentProxy.equalsIgnoreCase(currentServer)) {
        accountProxy.setText(currentProxy);
    }

    if (TextUtils.isEmpty(account.getSipDomain())) {
        accountServer.setText("sipgate.de");
    }

    //Get wizard specific row for balance
    customWizardText = (TextView) parent.findViewById(R.id.custom_wizard_text);
    customWizard = (LinearLayout) parent.findViewById(R.id.custom_wizard_row);
    updateAccountInfos(account);
}

From source file:nya.miku.wishmaster.chans.endchan.EndChanModule.java

private void addDomainPreferences(PreferenceGroup group) {
    Context context = group.getContext();
    Preference.OnPreferenceChangeListener updateDomainListener = new Preference.OnPreferenceChangeListener() {
        @Override//ww w  .  j a v a2 s  .c  om
        public boolean onPreferenceChange(Preference preference, Object newValue) {
            if (preference.getKey().equals(getSharedKey(PREF_KEY_DOMAIN))) {
                updateDomain((String) newValue);
                return true;
            }
            return false;
        }
    };
    PreferenceCategory domainCat = new PreferenceCategory(context);
    domainCat.setTitle(R.string.makaba_prefs_domain_category);
    group.addPreference(domainCat);
    EditTextPreference domainPref = new EditTextPreference(context);
    domainPref.setTitle(R.string.pref_domain);
    domainPref.setDialogTitle(R.string.pref_domain);
    domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT));
    domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN));
    domainPref.getEditText().setHint(DEFAULT_DOMAIN);
    domainPref.getEditText().setSingleLine();
    domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    domainPref.setOnPreferenceChangeListener(updateDomainListener);
    domainCat.addPreference(domainPref);
}

From source file:nya.miku.wishmaster.chans.cirno.CirnoModule.java

@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
    final Context context = preferenceGroup.getContext();
    EditTextPreference passwordPref = new EditTextPreference(context);
    passwordPref.setTitle(R.string.iichan_prefs_report_thread);
    passwordPref.setDialogTitle(R.string.iichan_prefs_report_thread);
    passwordPref.setSummary(R.string.iichan_prefs_report_thread_summary);
    passwordPref.setKey(getSharedKey(PREF_KEY_REPORT_THREAD));
    passwordPref.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
    passwordPref.getEditText().setSingleLine();
    passwordPref.getEditText().setFilters(new InputFilter[] { new InputFilter.LengthFilter(255) });
    preferenceGroup.addPreference(passwordPref);

    super.addPreferencesOnScreen(preferenceGroup);
}

From source file:nya.miku.wishmaster.chans.tirech.TirechModule.java

@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
    Context context = preferenceGroup.getContext();
    EditTextPreference domainPref = new EditTextPreference(context);
    domainPref.setTitle(R.string.pref_domain);
    domainPref.setDialogTitle(R.string.pref_domain);
    domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT));
    domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN));
    domainPref.getEditText().setHint(DEFAULT_DOMAIN);
    domainPref.getEditText().setSingleLine();
    domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    preferenceGroup.addPreference(domainPref);
    addPasswordPreference(preferenceGroup);
    addCloudflareRecaptchaFallbackPreference(preferenceGroup);
    addProxyPreferences(preferenceGroup);
}

From source file:net.freifunk.android.discover.SettingsActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    addPreferencesFromResource(R.xml.pref_data_sync);

    // get data via the key
    ArrayList<NodeMap> nodeMapArrayList = new ArrayList<NodeMap>(MapMaster.getInstance().getMaps().values());
    PreferenceCategory communities = (PreferenceCategory) findPreference("communities");

    // sort by Name
    Collections.sort(nodeMapArrayList, new NodeMapComparator());

    if (nodeMapArrayList != null && communities != null) {
        for (final NodeMap nm : nodeMapArrayList) {

            PreferenceScreen communityPreferenceScreen = getPreferenceManager()
                    .createPreferenceScreen(SettingsActivity.this);

            communityPreferenceScreen.setTitle(nm.getMapName());
            communityPreferenceScreen.setKey(nm.getMapName());

            final CheckBoxPreference deactivateCommunityPreference = new CheckBoxPreference(
                    SettingsActivity.this);

            // TODO: move Strings to resources
            deactivateCommunityPreference.setTitle("Community aktiv");
            deactivateCommunityPreference
                    .setSummary("deaktivieren, falls Community nicht auf der Karte angezeigt werden soll");
            deactivateCommunityPreference.setKey("community_deactivate_" + nm.getMapName());
            deactivateCommunityPreference.setChecked(nm.isActive());
            deactivateCommunityPreference
                    .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

                        @Override
                        public boolean onPreferenceChange(Preference preference, Object newValue) {

                            Database db = Database.getInstance(null);

                            boolean newActive = newValue.toString().equals("true") ? true : false;

                            nm.setActive(newActive);
                            db.addNodeMap(nm);

                            // reload if set to active
                            if (newActive) {
                                nm.loadNodes();
                            } else {
                                nm.updateNodes();
                            }/*from  w w w .j a  v  a2 s  .  c  om*/

                            return true;
                        }
                    });

            EditTextPreference editCommunityPreference = new EditTextPreference(SettingsActivity.this);

            // TODO: move Strings to resources
            editCommunityPreference.setTitle("URL bearbeiten");
            editCommunityPreference.setSummary("aendern, falls eine andere Quelle genutzt werden soll.");
            editCommunityPreference.setKey("community_edit_" + nm.getMapName());
            editCommunityPreference.setText(nm.getMapUrl());

            editCommunityPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

                @Override
                public boolean onPreferenceChange(Preference preference, Object newValue) {

                    Database db = Database.getInstance(null);

                    // remove old nodes from map
                    nm.setActive(false);
                    EventBus.getInstance().post(new NodeResult(NodeResult.NodeResultType.UPDATE_NODES, nm));

                    // we should probably do this async as well
                    db.deleteAllNodesForMap(nm);

                    // load new nodes
                    NodeMap newMap = new NodeMap(nm.getMapName(), (String) newValue, true);
                    db.addNodeMap(newMap);

                    //HashMap<String, NodeMap> nodeResult = new HashMap<String, NodeMap>(1);
                    //nodeResult.put(nm.getMapName(), nm);

                    newMap.updateNodes();
                    //EventBus.getInstance().post(new NodeResult(NodeResult.NodeResultType.LOAD_NODES, nm));
                    //EventBus.getInstance().post(new NodeResult(NodeResult.NodeResultType.UPDATE_MAP, nodeResult));

                    return true;
                }
            });

            communityPreferenceScreen.addPreference(deactivateCommunityPreference);
            communityPreferenceScreen.addPreference(editCommunityPreference);

            communities.addPreference(communityPreferenceScreen);
        }
    }

    setupActionBar();

}

From source file:com.nttec.everychan.chans.fourchan.FourchanModule.java

private void addPasscodePreference(PreferenceGroup preferenceGroup) {
    final Context context = preferenceGroup.getContext();
    PreferenceScreen passScreen = preferenceGroup.getPreferenceManager().createPreferenceScreen(context);
    passScreen.setTitle("4chan pass");
    EditTextPreference passTokenPreference = new EditTextPreference(context);
    EditTextPreference passPINPreference = new EditTextPreference(context);
    Preference passLoginPreference = new Preference(context);
    Preference passClearPreference = new Preference(context);
    passTokenPreference.setTitle("Token");
    passTokenPreference.setDialogTitle("Token");
    passTokenPreference.setKey(getSharedKey(PREF_KEY_PASS_TOKEN));
    passTokenPreference.getEditText().setSingleLine();
    passTokenPreference.getEditText()/*from   w ww  .  j  a v a  2  s.  c om*/
            .setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
    passPINPreference.setTitle("PIN");
    passPINPreference.setDialogTitle("PIN");
    passPINPreference.setKey(getSharedKey(PREF_KEY_PASS_PIN));
    passPINPreference.getEditText().setSingleLine();
    passPINPreference.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER);
    passLoginPreference.setTitle("Log In");
    passLoginPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (!useHttps())
                Toast.makeText(context, "Using HTTPS even if HTTP is selected", Toast.LENGTH_SHORT).show();
            final String token = preferences.getString(getSharedKey(PREF_KEY_PASS_TOKEN), "");
            final String pin = preferences.getString(getSharedKey(PREF_KEY_PASS_PIN), "");
            final String authUrl = "https://sys.4chan.org/auth"; //only https
            final CancellableTask passAuthTask = new CancellableTask.BaseCancellableTask();
            final ProgressDialog passAuthProgressDialog = new ProgressDialog(context);
            passAuthProgressDialog.setMessage("Logging in");
            passAuthProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    passAuthTask.cancel();
                }
            });
            passAuthProgressDialog.setCanceledOnTouchOutside(false);
            passAuthProgressDialog.show();
            Async.runAsync(new Runnable() {
                @Override
                public void run() {
                    try {
                        if (passAuthTask.isCancelled())
                            return;
                        setPasscodeCookie(null, true);
                        List<NameValuePair> pairs = new ArrayList<NameValuePair>();
                        pairs.add(new BasicNameValuePair("act", "do_login"));
                        pairs.add(new BasicNameValuePair("id", token));
                        pairs.add(new BasicNameValuePair("pin", pin));
                        HttpRequestModel request = HttpRequestModel.builder()
                                .setPOST(new UrlEncodedFormEntity(pairs, "UTF-8")).build();
                        String response = HttpStreamer.getInstance().getStringFromUrl(authUrl, request,
                                httpClient, null, passAuthTask, false);
                        if (passAuthTask.isCancelled())
                            return;
                        if (response.contains("Your device is now authorized")) {
                            String passId = null;
                            for (Cookie cookie : httpClient.getCookieStore().getCookies()) {
                                if (cookie.getName().equals("pass_id")) {
                                    String value = cookie.getValue();
                                    if (!value.equals("0")) {
                                        passId = value;
                                        break;
                                    }
                                }
                            }
                            if (passId == null) {
                                showToast("Could not get pass id");
                            } else {
                                setPasscodeCookie(passId, true);
                                showToast("Success! Your device is now authorized.");
                            }
                        } else if (response.contains("Your Token must be exactly 10 characters")) {
                            showToast("Incorrect token");
                        } else if (response.contains("You have left one or more fields blank")) {
                            showToast("You have left one or more fields blank");
                        } else if (response.contains("Incorrect Token or PIN")) {
                            showToast("Incorrect Token or PIN");
                        } else {
                            Matcher m = Pattern
                                    .compile("<strong style=\"color: red; font-size: larger;\">(.*?)</strong>")
                                    .matcher(response);
                            if (m.find()) {
                                showToast(m.group(1));
                            } else {
                                showWebView(response);
                            }
                        }
                    } catch (Exception e) {
                        showToast(e.getMessage() == null ? resources.getString(R.string.error_unknown)
                                : e.getMessage());
                    } finally {
                        passAuthProgressDialog.dismiss();
                    }
                }

                private void showToast(final String message) {
                    if (context instanceof Activity) {
                        ((Activity) context).runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                Toast.makeText(context, message, Toast.LENGTH_LONG).show();
                            }
                        });
                    }
                }

                private void showWebView(final String html) {
                    if (context instanceof Activity) {
                        ((Activity) context).runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                WebView webView = new WebView(context);
                                webView.getSettings().setSupportZoom(true);
                                webView.loadData(html, "text/html", null);
                                new AlertDialog.Builder(context).setView(webView)
                                        .setNeutralButton(android.R.string.ok, null).show();
                            }
                        });
                    }
                }
            });
            return true;
        }
    });
    passClearPreference.setTitle("Reset pass cookie");
    passClearPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference preference) {
            setPasscodeCookie(null, true);
            Toast.makeText(context, "Cookie is reset", Toast.LENGTH_LONG).show();
            return true;
        }
    });
    passScreen.addPreference(passTokenPreference);
    passScreen.addPreference(passPINPreference);
    passScreen.addPreference(passLoginPreference);
    passScreen.addPreference(passClearPreference);
    preferenceGroup.addPreference(passScreen);
}

From source file:com.nttec.everychan.chans.dvach.DvachModule.java

@Override
public void addPreferencesOnScreen(PreferenceGroup preferenceGroup) {
    Context context = preferenceGroup.getContext();
    addPasswordPreference(preferenceGroup);
    CheckBoxPreference onionPref = new LazyPreferences.CheckBoxPreference(context);
    onionPref.setTitle(R.string.pref_use_onion);
    onionPref.setSummary(R.string.pref_use_onion_summary);
    onionPref.setKey(getSharedKey(PREF_KEY_USE_ONION));
    onionPref.setDefaultValue(false);//w ww.  j av a2 s.  c  om
    onionPref.setDisableDependentsState(true);
    preferenceGroup.addPreference(onionPref);
    EditTextPreference domainPref = new EditTextPreference(context);
    domainPref.setTitle(R.string.pref_domain);
    domainPref.setDialogTitle(R.string.pref_domain);
    domainPref.setSummary(resources.getString(R.string.pref_domain_summary, DOMAINS_HINT));
    domainPref.setKey(getSharedKey(PREF_KEY_DOMAIN));
    domainPref.getEditText().setHint(DEFAULT_DOMAIN);
    domainPref.getEditText().setSingleLine();
    domainPref.getEditText().setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    preferenceGroup.addPreference(domainPref);
    domainPref.setDependency(getSharedKey(PREF_KEY_USE_ONION));
    addProxyPreferences(preferenceGroup);
}