Search in sources :

Example 21 with AutoCompleteTextView

use of android.widget.AutoCompleteTextView in project curb by irijwj.

the class RegisterActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register);
    ButterKnife.bind(this);
    // Set up the login form.
    // mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
    // populateAutoComplete();
    // mPasswordView = (EditText) findViewById(R.id.password);
    password_et.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == EditorInfo.IME_ACTION_DONE || id == EditorInfo.IME_NULL) {
                attemptLogin();
                return true;
            }
            return false;
        }
    });
    password_et.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == EditorInfo.IME_ACTION_DONE || id == EditorInfo.IME_NULL) {
                attemptLogin();
                return true;
            }
            return false;
        }
    });
    // Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);
    register_button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {
            attemptLogin();
        }
    });
    mLoginFormView = findViewById(R.id.login_form);
    mProgressView = findViewById(R.id.login_progress);
}
Also used : KeyEvent(android.view.KeyEvent) OnClickListener(android.view.View.OnClickListener) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView) BindView(butterknife.BindView) View(android.view.View) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView)

Example 22 with AutoCompleteTextView

use of android.widget.AutoCompleteTextView in project Slide by ccrama.

the class Crosspost method onCreate.

public void onCreate(Bundle savedInstanceState) {
    disableSwipeBackLayout();
    super.onCreate(savedInstanceState);
    applyColorTheme();
    setContentView(R.layout.activity_crosspost);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = this.getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    }
    setupAppBar(R.id.toolbar, R.string.title_crosspost, true, true);
    inboxReplies = (SwitchCompat) findViewById(R.id.replies);
    final AutoCompleteTextView subredditText = ((AutoCompleteTextView) findViewById(R.id.subreddittext));
    ((EditText) findViewById(R.id.crossposttext)).setText(toCrosspost.getTitle() + getString(R.string.submission_properties_seperator) + "/u/" + toCrosspost.getAuthor());
    findViewById(R.id.crossposttext).setEnabled(false);
    ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, UserSubscriptions.getAllSubreddits(this));
    subredditText.setAdapter(adapter);
    subredditText.setThreshold(2);
    subredditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (tchange != null) {
                tchange.cancel(true);
            }
            findViewById(R.id.submittext).setVisibility(View.GONE);
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    subredditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            findViewById(R.id.submittext).setVisibility(View.GONE);
            if (!hasFocus) {
                tchange = new AsyncTask<Void, Void, Subreddit>() {

                    @Override
                    protected Subreddit doInBackground(Void... params) {
                        try {
                            return Authentication.reddit.getSubreddit(subredditText.getText().toString());
                        } catch (Exception ignored) {
                        }
                        return null;
                    }

                    @Override
                    protected void onPostExecute(Subreddit s) {
                        if (s != null) {
                            String text = s.getDataNode().get("submit_text_html").asText();
                            if (text != null && !text.isEmpty() && !text.equals("null")) {
                                findViewById(R.id.submittext).setVisibility(View.VISIBLE);
                                setViews(text, subredditText.getText().toString(), (SpoilerRobotoTextView) findViewById(R.id.submittext), (CommentOverflow) findViewById(R.id.commentOverflow));
                            }
                            if (s.getSubredditType().equals("RESTRICTED")) {
                                subredditText.setText("");
                                new AlertDialogWrapper.Builder(Crosspost.this).setTitle(R.string.err_submit_restricted).setMessage(R.string.err_submit_restricted_text).setPositiveButton(R.string.btn_ok, null).show();
                            }
                        } else {
                            findViewById(R.id.submittext).setVisibility(View.GONE);
                        }
                    }
                };
                tchange.execute();
            }
        }
    });
    ((EditText) findViewById(R.id.titletext)).setText(toCrosspost.getTitle());
    findViewById(R.id.suggest).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            ((EditText) findViewById(R.id.titletext)).setText(toCrosspost.getTitle());
        }
    });
    findViewById(R.id.send).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            ((FloatingActionButton) findViewById(R.id.send)).hide();
            new AsyncDo().execute();
        }
    });
}
Also used : Window(android.view.Window) EditText(android.widget.EditText) AsyncTask(android.os.AsyncTask) SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) View(android.view.View) AutoCompleteTextView(android.widget.AutoCompleteTextView) ApiException(net.dean.jraw.ApiException) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) Subreddit(net.dean.jraw.models.Subreddit) ArrayAdapter(android.widget.ArrayAdapter) AutoCompleteTextView(android.widget.AutoCompleteTextView)

Example 23 with AutoCompleteTextView

use of android.widget.AutoCompleteTextView in project Slide by ccrama.

the class Submit method onCreate.

public void onCreate(Bundle savedInstanceState) {
    disableSwipeBackLayout();
    super.onCreate(savedInstanceState);
    applyColorTheme();
    setContentView(R.layout.activity_submit);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = this.getWindow();
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    }
    setupAppBar(R.id.toolbar, R.string.title_submit_post, true, true);
    inboxReplies = (SwitchCompat) findViewById(R.id.replies);
    Intent intent = getIntent();
    final String subreddit = intent.getStringExtra(EXTRA_SUBREDDIT);
    self = findViewById(R.id.selftext);
    final AutoCompleteTextView subredditText = ((AutoCompleteTextView) findViewById(R.id.subreddittext));
    image = findViewById(R.id.image);
    link = findViewById(R.id.url);
    image.setVisibility(View.GONE);
    link.setVisibility(View.GONE);
    if (subreddit != null && !subreddit.equals("frontpage") && !subreddit.equals("all") && !subreddit.equals("friends") && !subreddit.equals("mod") && !subreddit.contains("/m/") && !subreddit.contains("+")) {
        subredditText.setText(subreddit);
    }
    ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, UserSubscriptions.getAllSubreddits(this));
    subredditText.setAdapter(adapter);
    subredditText.setThreshold(2);
    subredditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            if (tchange != null) {
                tchange.cancel(true);
            }
            findViewById(R.id.submittext).setVisibility(View.GONE);
        }

        @Override
        public void afterTextChanged(Editable s) {
        }
    });
    subredditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            findViewById(R.id.submittext).setVisibility(View.GONE);
            if (!hasFocus) {
                tchange = new AsyncTask<Void, Void, Subreddit>() {

                    @Override
                    protected Subreddit doInBackground(Void... params) {
                        try {
                            return Authentication.reddit.getSubreddit(subredditText.getText().toString());
                        } catch (Exception ignored) {
                        }
                        return null;
                    }

                    @Override
                    protected void onPostExecute(Subreddit s) {
                        if (s != null) {
                            String text = s.getDataNode().get("submit_text_html").asText();
                            if (text != null && !text.isEmpty() && !text.equals("null")) {
                                findViewById(R.id.submittext).setVisibility(View.VISIBLE);
                                setViews(text, subredditText.getText().toString(), (SpoilerRobotoTextView) findViewById(R.id.submittext), (CommentOverflow) findViewById(R.id.commentOverflow));
                            }
                            if (s.getSubredditType().equals("RESTRICTED")) {
                                subredditText.setText("");
                                new AlertDialogWrapper.Builder(Submit.this).setTitle(R.string.err_submit_restricted).setMessage(R.string.err_submit_restricted_text).setPositiveButton(R.string.btn_ok, null).show();
                            }
                        } else {
                            findViewById(R.id.submittext).setVisibility(View.GONE);
                        }
                    }
                };
                tchange.execute();
            }
        }
    });
    findViewById(R.id.selftextradio).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            self.setVisibility(View.VISIBLE);
            image.setVisibility(View.GONE);
            link.setVisibility(View.GONE);
        }
    });
    findViewById(R.id.imageradio).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            self.setVisibility(View.GONE);
            image.setVisibility(View.VISIBLE);
            link.setVisibility(View.GONE);
        }
    });
    findViewById(R.id.linkradio).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            self.setVisibility(View.GONE);
            image.setVisibility(View.GONE);
            link.setVisibility(View.VISIBLE);
        }
    });
    findViewById(R.id.suggest).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            new AsyncTask<String, Void, String>() {

                Dialog d;

                @Override
                protected String doInBackground(String... params) {
                    try {
                        return TitleExtractor.getPageTitle(params[0]);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    return null;
                }

                @Override
                protected void onPreExecute() {
                    d = new MaterialDialog.Builder(Submit.this).progress(true, 100).title(R.string.editor_finding_title).content(R.string.misc_please_wait).show();
                }

                @Override
                protected void onPostExecute(String s) {
                    if (s != null) {
                        ((EditText) findViewById(R.id.titletext)).setText(s);
                        d.dismiss();
                    } else {
                        d.dismiss();
                        new AlertDialogWrapper.Builder(Submit.this).setTitle(R.string.title_not_found).setPositiveButton(R.string.btn_ok, null).show();
                    }
                }
            }.execute(((EditText) findViewById(R.id.urltext)).getText().toString());
        }
    });
    findViewById(R.id.selImage).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            TedBottomPicker tedBottomPicker = new TedBottomPicker.Builder(Submit.this).setOnImageSelectedListener(new TedBottomPicker.OnImageSelectedListener() {

                @Override
                public void onImageSelected(List<Uri> uri) {
                    handleImageIntent(uri);
                }
            }).setLayoutResource(R.layout.image_sheet_dialog).setTitle("Choose a photo").create();
            tedBottomPicker.show(getSupportFragmentManager());
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(findViewById(R.id.bodytext).getWindowToken(), 0);
        }
    });
    DoEditorActions.doActions(((EditText) findViewById(R.id.bodytext)), findViewById(R.id.selftext), getSupportFragmentManager(), Submit.this, null, null);
    if (intent.hasExtra(Intent.EXTRA_TEXT) && !intent.getExtras().getString(Intent.EXTRA_TEXT, "").isEmpty()) {
        String data = intent.getStringExtra(Intent.EXTRA_TEXT);
        if (data.contains("\n")) {
            ((EditText) findViewById(R.id.titletext)).setText(data.substring(0, data.indexOf("\n")));
            ((EditText) findViewById(R.id.urltext)).setText(data.substring(data.indexOf("\n"), data.length()));
        } else {
            ((EditText) findViewById(R.id.urltext)).setText(data);
        }
        self.setVisibility(View.GONE);
        image.setVisibility(View.GONE);
        link.setVisibility(View.VISIBLE);
        ((RadioButton) findViewById(R.id.linkradio)).setChecked(true);
    } else if (intent.hasExtra(Intent.EXTRA_STREAM)) {
        final Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
        if (imageUri != null) {
            handleImageIntent(new ArrayList<Uri>() {

                {
                    add(imageUri);
                }
            });
            self.setVisibility(View.GONE);
            image.setVisibility(View.VISIBLE);
            link.setVisibility(View.GONE);
            ((RadioButton) findViewById(R.id.imageradio)).setChecked(true);
        }
    }
    if (intent.hasExtra(Intent.EXTRA_SUBJECT) && !intent.getExtras().getString(Intent.EXTRA_SUBJECT, "").isEmpty()) {
        String data = intent.getStringExtra(Intent.EXTRA_SUBJECT);
        ((EditText) findViewById(R.id.titletext)).setText(data);
    }
    findViewById(R.id.send).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            ((FloatingActionButton) findViewById(R.id.send)).hide();
            new AsyncDo().execute();
        }
    });
}
Also used : ArrayList(java.util.ArrayList) InputMethodManager(android.view.inputmethod.InputMethodManager) Uri(android.net.Uri) AlertDialogWrapper(com.afollestad.materialdialogs.AlertDialogWrapper) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Dialog(android.app.Dialog) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) Window(android.view.Window) EditText(android.widget.EditText) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) AsyncTask(android.os.AsyncTask) Intent(android.content.Intent) RadioButton(android.widget.RadioButton) ImageView(android.widget.ImageView) SpoilerRobotoTextView(me.ccrama.redditslide.SpoilerRobotoTextView) View(android.view.View) AutoCompleteTextView(android.widget.AutoCompleteTextView) ApiException(net.dean.jraw.ApiException) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) Subreddit(net.dean.jraw.models.Subreddit) TedBottomPicker(gun0912.tedbottompicker.TedBottomPicker) ArrayAdapter(android.widget.ArrayAdapter) AutoCompleteTextView(android.widget.AutoCompleteTextView)

Example 24 with AutoCompleteTextView

use of android.widget.AutoCompleteTextView in project pictureapp by EyeSeeTea.

the class AutoCompleteEditTextPreference method onBindDialogView.

@Override
protected void onBindDialogView(View view) {
    // XXX Hack to avoid having a default edittext instead of our custom autocomplete
    // super.onBindDialogView(view);
    AutoCompleteTextView editText = mEditText;
    SharedPreferences preferences = view.getContext().getSharedPreferences("org.eyeseetea.surveillance_kh_preferences", view.getContext().MODE_PRIVATE);
    String key = view.getContext().getResources().getString(R.string.org_unit);
    String value = preferences.getString(key, "");
    editText.setText(value);
    ViewParent oldParent = editText.getParent();
    if (oldParent != view) {
        if (oldParent != null) {
            ((ViewGroup) oldParent).removeView(editText);
        }
        onAddEditTextToDialogView(view, editText);
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup) AutoCompleteTextView(android.widget.AutoCompleteTextView)

Example 25 with AutoCompleteTextView

use of android.widget.AutoCompleteTextView in project Api-Startup-Android by salyangoz.

the class LoginActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    // Set up the login form.
    mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
    mPasswordView = (EditText) findViewById(R.id.password);
    mPasswordView.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == R.id.login || id == EditorInfo.IME_NULL) {
                attemptLogin();
                return true;
            }
            return false;
        }
    });
    Button mEmailSignInButton = (Button) findViewById(R.id.email_sign_in_button);
    mEmailSignInButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View view) {
            attemptLogin();
        }
    });
    Button mRegisterButton = (Button) findViewById(R.id.register_button);
    mRegisterButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            RegisterActivity.start(LoginActivity.this);
        }
    });
    mLoginFormView = findViewById(R.id.login_form);
    mProgressView = findViewById(R.id.login_progress);
    if (BuildConfig.DEBUG) {
        mEmailView.setText("erkind@salyangoz.com.tr");
        mPasswordView.setText("123456");
    }
}
Also used : KeyEvent(android.view.KeyEvent) Button(android.widget.Button) OnClickListener(android.view.View.OnClickListener) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView) View(android.view.View) AutoCompleteTextView(android.widget.AutoCompleteTextView) TextView(android.widget.TextView)

Aggregations

AutoCompleteTextView (android.widget.AutoCompleteTextView)106 View (android.view.View)62 TextView (android.widget.TextView)44 ArrayAdapter (android.widget.ArrayAdapter)38 Button (android.widget.Button)27 EditText (android.widget.EditText)21 OnClickListener (android.view.View.OnClickListener)20 KeyEvent (android.view.KeyEvent)19 AdapterView (android.widget.AdapterView)17 Intent (android.content.Intent)16 ImageView (android.widget.ImageView)14 Editable (android.text.Editable)10 TextWatcher (android.text.TextWatcher)10 ArrayList (java.util.ArrayList)9 Dialog (android.app.Dialog)8 ListView (android.widget.ListView)8 Spinner (android.widget.Spinner)8 DialogInterface (android.content.DialogInterface)7 InputMethodManager (android.view.inputmethod.InputMethodManager)7 SuppressLint (android.annotation.SuppressLint)6