Example usage for android.text InputType TYPE_TEXT_VARIATION_URI

List of usage examples for android.text InputType TYPE_TEXT_VARIATION_URI

Introduction

In this page you can find the example usage for android.text InputType TYPE_TEXT_VARIATION_URI.

Prototype

int TYPE_TEXT_VARIATION_URI

To view the source code for android.text InputType TYPE_TEXT_VARIATION_URI.

Click Source Link

Document

Variation of #TYPE_CLASS_TEXT : entering a URI.

Usage

From source file:org.transdroid.core.gui.search.UrlEntryDialog.java

/**
 * Opens a dialog that allows entry of a single URL string, which (on confirmation) will be supplied to the calling
 * activity's {@link TorrentsActivity#addTorrentByUrl(String, String) method}.
 * @param activity The activity that opens (and owns) this dialog
 *//*from   w  ww.  ja v  a2 s.c  o m*/
@SuppressLint("ValidFragment")
public static void startUrlEntry(final TorrentsActivity activity) {
    new DialogFragment() {
        public android.app.Dialog onCreateDialog(android.os.Bundle savedInstanceState) {
            final EditText urlInput = new EditText(activity);
            urlInput.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
            ((InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE))
                    .toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
            return new AlertDialog.Builder(activity).setView(urlInput)
                    .setPositiveButton(android.R.string.ok, new OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            // Assume text entry box input as URL and treat the filename (after the last /) as title
                            String url = urlInput.getText().toString();
                            Uri uri = Uri.parse(url);
                            if (activity != null && !TextUtils.isEmpty(url)) {
                                String title = NavigationHelper.extractNameFromUri(uri);
                                if (uri.getScheme() != null && uri.getScheme().equals("magnet")) {
                                    activity.addTorrentByMagnetUrl(url, title);
                                } else {
                                    activity.addTorrentByUrl(url, title);
                                }
                            }
                        }
                    }).setNegativeButton(android.R.string.cancel, null).create();
        };
    }.show(activity.getSupportFragmentManager(), "urlentry");
}

From source file:de.uni.stuttgart.informatik.ToureNPlaner.UI.Dialogs.TextDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    input = new EditText(getActivity());
    String message = getArguments().getString("title");
    CharSequence content;/*from  w  ww  .jav  a 2s . c  om*/
    if (savedInstanceState == null) {
        content = getArguments().getCharSequence("content");
    } else {
        content = savedInstanceState.getCharSequence("content");
    }
    input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    input.setText(content, TextView.BufferType.SPANNABLE);
    return new AlertDialog.Builder(getActivity()).setTitle(message).setView(input)
            .setPositiveButton(getResources().getText(android.R.string.ok),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            doPositiveClick();
                        }
                    })
            .setNegativeButton(getResources().getText(android.R.string.cancel),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            doNegativeClick();
                        }
                    })
            .setOnKeyListener(new DialogInterface.OnKeyListener() {

                @Override
                public boolean onKey(DialogInterface dialogInterface, int i, KeyEvent keyEvent) {
                    if ((keyEvent.getAction() == KeyEvent.ACTION_DOWN) && (i == KeyEvent.KEYCODE_ENTER)) {
                        dialogInterface.dismiss();
                        doPositiveClick();
                        return true;
                    }
                    return false;
                }
            }).create();
}

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);//w w  w.  j a v a  2 s.com
}

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//from w w w  .java2 s .  co  m
        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:com.scigames.registration.Registration5EmailActivity.java

/** Called with the activity is first created. */
@Override//from   w ww .  ja v  a2 s .c o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG, "super.OnCreate");

    Intent i = getIntent();
    Log.d(TAG, "getIntent");
    firstNameIn = i.getStringExtra("fName");
    lastNameIn = i.getStringExtra("lName");
    studentIdIn = i.getStringExtra("studentId");
    visitIdIn = i.getStringExtra("visitId");
    Log.d(TAG, "...getStringExtra");

    // Inflate our UI from its XML layout description.
    setContentView(R.layout.registration5_email);
    Log.d(TAG, "...setContentView");

    email = (EditText) findViewById(R.id.email);
    /* to hide the keyboard on launch, then open when tap in firstname field */
    // email.setInputType(InputType.TYPE_NULL);
    email.setOnTouchListener(new View.OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            //email.setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
            email.setInputType(InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS);
            email.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
            email.onTouchEvent(event); // call native handler
            return true; // consume touch even
        }
    });

    Log.d(TAG, "...instantiateEditTexts");

    //display name in greeting sentence
    Resources res = getResources();
    TextView greets = (TextView) findViewById(R.id.greeting);
    greets.setText(String.format(res.getString(R.string.greeting), firstNameIn, lastNameIn));
    Log.d(TAG, greets.toString());
    Log.d(TAG, "...Greetings");

    // Hook up button presses to the appropriate event handler.
    //((Button) findViewById(R.id.back)).setOnClickListener(mBackListener);
    ((Button) findViewById(R.id.continue_button)).setOnClickListener(mContinueButtonListener);
    Log.d(TAG, "...instantiateButtons");

    //set listener
    task.setOnResultsListener(this);
}

From source file:org.rssin.android.NavigationDrawerManageFeedsFragment.java

/**
 * Open dialog to add new feed/*from   ww w. ja v a2s.  c o  m*/
 * For the moment, we temporarily disable rotating because we can't get it working otherwise.
 * Possible feature: make rotating possible
 */
public void openAddDialog() {
    //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
    final Context context = rootView.getContext();

    AlertDialog.Builder alert = new AlertDialog.Builder(context);

    alert.setTitle(getString(R.string.feeds_activity_add_feed));
    alert.setMessage(getString(R.string.feeds_activity_url));

    final EditText input = new EditText(context);
    input.setFocusable(true);
    input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
    input.setMaxLines(1);
    input.requestFocus();

    AlertDialog dialog = alert.setView(input).setPositiveButton(getResources().getString(R.string.button_apply),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    String value = input.getText().toString();
                    try {
                        Feed f = new Feed(value, DefaultStorageProvider.getInstance(context),
                                VolleyFetcher.getInstance(context), new FallibleListener<String, Object>() {
                                    @Override
                                    public void onError(Object error) {

                                    }

                                    @Override
                                    public void onReceive(String data) {
                                        feedAdapter.notifyDataSetChanged();
                                    }
                                });

                        f.store(DefaultStorageProvider.getInstance(context));
                        feedsList.getFeeds().add(f);
                        feedAdapter.notifyDataSetChanged();
                    } catch (Exception e) {
                        Frontend.error(context, R.string.error_save_feeds, e);
                    }
                    input.setText("");
                    //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
                }
            }).setNegativeButton(getResources().getString(R.string.button_cancel),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            input.setText("");
                            //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
                        }
                    })
            .setOnCancelListener(new DialogInterface.OnCancelListener() {
                @Override
                public void onCancel(DialogInterface dialog) {
                    input.setText("");
                    //setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
                }
            }).create();

    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    dialog.show();
}

From source file:org.developfreedom.ccdroid.app.ui.MainActivity.java

private void showAddUrlDialog() {
    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
    input.setText(preferences.getUrl());

    new AlertDialog.Builder(this).setMessage(R.string.dialog_message_add_url)
            .setTitle(R.string.dialog_title_add_url).setView(input)
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                @Override/* w ww.  ja v a  2  s  .  c  o m*/
                public void onClick(DialogInterface dialog, int id) {
                    //TODO: Check input text to be a url
                    preferences.setUrl(input.getText().toString());
                }
            }).setNegativeButton(android.R.string.cancel, null).create().show();
}

From source file:org.adaway.ui.HostsSourcesFragment.java

/**
 * Edit entry based on selection in context menu
 *
 * @param info//from   w  ww.j  a v  a2 s  .  co  m
 */
private void menuEditEntry(AdapterContextMenuInfo info) {
    mCurrentRowId = info.id; // set global RowId to row id from cursor to use inside save button
    int position = info.position;
    View v = info.targetView;

    TextView urlTextView = (TextView) v.findViewWithTag("url_" + position);

    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    builder.setCancelable(true);
    builder.setTitle(getString(R.string.checkbox_list_edit_dialog_title));

    // build view from layout
    LayoutInflater factory = LayoutInflater.from(mActivity);
    final View dialogView = factory.inflate(R.layout.lists_url_dialog, null);
    final EditText inputEditText = (EditText) dialogView.findViewById(R.id.list_dialog_url);
    // set text from list
    inputEditText.setText(urlTextView.getText());
    inputEditText.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
    // move cursor to end of EditText
    Editable inputEditContent = inputEditText.getText();
    inputEditText.setSelection(inputEditContent.length());

    builder.setView(dialogView);

    builder.setPositiveButton(getResources().getString(R.string.button_save),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();

                    String input = inputEditText.getText().toString();

                    if (RegexUtils.isValidUrl(input)) {
                        // update in db
                        ProviderHelper.updateHostsSourceUrl(mActivity, mCurrentRowId, input);
                    } else {
                        AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                        alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                        alertDialog.setTitle(R.string.no_url_title);
                        alertDialog.setMessage(getString(org.adaway.R.string.no_url));
                        alertDialog.setButton(getString(R.string.button_close),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dlg, int sum) {
                                        dlg.dismiss();
                                    }
                                });
                        alertDialog.show();
                    }
                }
            });
    builder.setNegativeButton(getResources().getString(R.string.button_cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:org.adawaycn.ui.HostsSourcesFragment.java

/**
 * Edit entry based on selection in context menu
 *
 * @param info//from  w  w  w.  jav  a 2  s  . c  o m
 */
private void menuEditEntry(AdapterContextMenuInfo info) {
    mCurrentRowId = info.id; // set global RowId to row id from cursor to use inside save button
    int position = info.position;
    View v = info.targetView;

    TextView urlTextView = (TextView) v.findViewWithTag("url_" + position);

    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    builder.setCancelable(true);
    builder.setTitle(getString(R.string.checkbox_list_edit_dialog_title));

    // build view from layout
    LayoutInflater factory = LayoutInflater.from(mActivity);
    final View dialogView = factory.inflate(R.layout.lists_url_dialog, null);
    final EditText inputEditText = (EditText) dialogView.findViewById(R.id.list_dialog_url);
    // set text from list
    inputEditText.setText(urlTextView.getText());
    inputEditText.setInputType(InputType.TYPE_TEXT_VARIATION_URI);
    // move cursor to end of EditText
    Editable inputEditContent = inputEditText.getText();
    inputEditText.setSelection(inputEditContent.length());

    builder.setView(dialogView);

    builder.setPositiveButton(getResources().getString(R.string.button_save),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();

                    String input = inputEditText.getText().toString();

                    if (RegexUtils.isValidUrl(input)) {
                        // update in db
                        ProviderHelper.updateHostsSourceUrl(mActivity, mCurrentRowId, input);
                    } else {
                        AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                        alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                        alertDialog.setTitle(R.string.no_url_title);
                        alertDialog.setMessage(getString(R.string.no_url));
                        alertDialog.setButton(getString(R.string.button_close),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dlg, int sum) {
                                        dlg.dismiss();
                                    }
                                });
                        alertDialog.show();
                    }
                }
            });
    builder.setNegativeButton(getResources().getString(R.string.button_cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.ryan.ryanreader.activities.PostSubmitActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    PrefsUtility.applyTheme(this);

    super.onCreate(savedInstanceState);

    final LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.post_submit);

    typeSpinner = (Spinner) layout.findViewById(R.id.post_submit_type);
    usernameSpinner = (Spinner) layout.findViewById(R.id.post_submit_username);
    subredditEdit = (EditText) layout.findViewById(R.id.post_submit_subreddit);
    titleEdit = (EditText) layout.findViewById(R.id.post_submit_title);
    textEdit = (EditText) layout.findViewById(R.id.post_submit_body);

    if (getIntent() != null && getIntent().hasExtra("subreddit")) {
        final String subreddit = getIntent().getStringExtra("subreddit");
        if (subreddit != null && subreddit.length() > 0 && !subreddit.equals("all")
                && subreddit.matches("\\w+")) {
            subredditEdit.setText(subreddit);
        }/*from  w ww . j a v  a 2s .c  o  m*/

    } else if (savedInstanceState != null && savedInstanceState.containsKey("post_title")) {
        titleEdit.setText(savedInstanceState.getString("post_title"));
        textEdit.setText(savedInstanceState.getString("post_body"));
        subredditEdit.setText(savedInstanceState.getString("subreddit"));
        typeSpinner.setSelection(savedInstanceState.getInt("post_type"));
    }

    final ArrayList<RedditAccount> accounts = RedditAccountManager.getInstance(this).getAccounts();
    final ArrayList<String> usernames = new ArrayList<String>();

    for (RedditAccount account : accounts) {
        if (!account.isAnonymous()) {
            usernames.add(account.username);
        }
    }

    if (usernames.size() == 0) {
        General.quickToast(this, R.string.error_toast_notloggedin);
        finish();
    }

    usernameSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, usernames));
    typeSpinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, postTypes));

    // TODO remove the duplicate code here
    if (typeSpinner.getSelectedItem().equals("Link")) {
        textEdit.setHint("URL"); // TODO string
        textEdit.setInputType(android.text.InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
        textEdit.setSingleLine(true);
    } else {
        textEdit.setHint("Self Text"); // TODO string
        textEdit.setInputType(android.text.InputType.TYPE_CLASS_TEXT
                | InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
        textEdit.setSingleLine(false);
    }

    typeSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (typeSpinner.getSelectedItem().equals("Link")) {
                textEdit.setHint("URL"); // TODO string
                textEdit.setInputType(
                        android.text.InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI);
                textEdit.setSingleLine(true);
            } else {
                textEdit.setHint("Self Text"); // TODO string
                textEdit.setInputType(android.text.InputType.TYPE_CLASS_TEXT
                        | InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
                textEdit.setSingleLine(false);
            }
        }

        public void onNothingSelected(AdapterView<?> parent) {
        }
    });

    final ScrollView sv = new ScrollView(this);
    sv.addView(layout);
    setContentView(sv);
}