Search in sources :

Example 71 with KeyEvent

use of android.view.KeyEvent in project Android-Terminal-Emulator by jackpal.

the class FSNavigator method fileView.

////////////////////////////////////////////////////////////
private LinearLayout fileView(boolean entryWindow) {
    LinearLayout ll = new LinearLayout(context);
    ll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1));
    ll.setOrientation(LinearLayout.HORIZONTAL);
    ll.setGravity(android.view.Gravity.FILL);
    final TextView tv;
    if (entryWindow) {
        tv = new EditText(context);
        tv.setHint(getString(R.string.fsnavigator_optional_enter_path));
        tv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT, 2));
        tv.setOnKeyListener(new EditText.OnKeyListener() {

            public boolean onKey(View v, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_ENTER) {
                    String path = tv.getText().toString();
                    File file = new File(getCanonicalPath(path));
                    chdir(file.getParentFile() == null ? file : file.getParentFile());
                    if (file.isFile()) {
                        setResult(RESULT_OK, getIntent().setData(Uri.fromFile(file)));
                        finish();
                    } else {
                        chdir(file);
                        makeView();
                    }
                    return (true);
                }
                return (false);
            }
        });
        ll.addView(tv);
    } else {
        tv = new TextView(context);
        tv.setClickable(true);
        tv.setLongClickable(true);
        tv.setOnClickListener(fileListener);
        tv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT, 1));
        HorizontalScrollView hv = new HorizontalScrollView(context);
        hv.setFillViewport(true);
        hv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, BUTTON_SIZE, 7));
        hv.addView(tv);
        ll.addView(hv);
    }
    tv.setFocusable(true);
    tv.setSingleLine();
    tv.setTextSize(textLg);
    tv.setTypeface(Typeface.SERIF, Typeface.BOLD);
    tv.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
    tv.setPadding(10, 5, 10, 5);
    //1);
    tv.setId(R.id.textview);
    return (ll);
}
Also used : EditText(android.widget.EditText) KeyEvent(android.view.KeyEvent) TextView(android.widget.TextView) ImageView(android.widget.ImageView) HorizontalScrollView(android.widget.HorizontalScrollView) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) View(android.view.View) File(java.io.File) HorizontalScrollView(android.widget.HorizontalScrollView) LinearLayout(android.widget.LinearLayout)

Example 72 with KeyEvent

use of android.view.KeyEvent in project Android-Terminal-Emulator by jackpal.

the class TermKeyListenerTest method keyHelperToggle.

private void keyHelperToggle(int keycode, int metastate, byte[] expectedOutPut, boolean toggle) throws UnsupportedEncodingException, IOException {
    KeyEvent event = new KeyEvent(1, 2, KeyEvent.ACTION_DOWN, keycode, 0, metastate);
    tkl_AltNotEsc.keyDown(event.getKeyCode(), event, true, toggle);
    byte[] res = mckTermSessionB.getCharSequence();
    assertNotNull(res);
    assertTrue(expectedOutPut.length <= res.length);
    for (int i = 0; i < expectedOutPut.length; i++) {
        assertEquals(expectedOutPut[i], res[i]);
    }
}
Also used : KeyEvent(android.view.KeyEvent)

Example 73 with KeyEvent

use of android.view.KeyEvent in project MaterialSearchView by MiguelCatalan.

the class MaterialSearchView method initSearchView.

private void initSearchView() {
    mSearchSrcTextView.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            onSubmitQuery();
            return true;
        }
    });
    mSearchSrcTextView.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) {
            mUserQuery = s;
            startFilter(s);
            MaterialSearchView.this.onTextChanged(s);
        }

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

        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            if (hasFocus) {
                showKeyboard(mSearchSrcTextView);
                showSuggestions();
            }
        }
    });
}
Also used : KeyEvent(android.view.KeyEvent) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Example 74 with KeyEvent

use of android.view.KeyEvent in project android-test-demo by abdyer.

the class LoginActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    DemoApplication.getInstance().getGraph().inject(this);
    // Set up the login form.
    mEmailView = (AutoCompleteTextView) findViewById(R.id.email);
    populateAutoComplete();
    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();
        }
    });
    mLoginFormView = findViewById(R.id.login_form);
    mProgressView = findViewById(R.id.login_progress);
}
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)

Example 75 with KeyEvent

use of android.view.KeyEvent in project actor-platform by actorapp.

the class SignInFragment method initView.

private void initView(View v) {
    ActorStyle style = ActorSDK.sharedActor().style;
    TextView hint = (TextView) v.findViewById(R.id.sign_in_login_hint);
    hint.setTextColor(style.getTextSecondaryColor());
    signIdEditText = (EditText) v.findViewById(R.id.tv_sign_in);
    signIdEditText.setTextColor(style.getTextPrimaryColor());
    signIdEditText.setHighlightColor(style.getMainColor());
    signIdEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView textView, int id, KeyEvent keyEvent) {
            if (id == EditorInfo.IME_ACTION_GO) {
                requestCode();
                return true;
            }
            return false;
        }
    });
    int availableAuthType = ActorSDK.sharedActor().getAuthType();
    String savedAuthId = messenger().getPreferences().getString("sign_in_auth_id");
    signIdEditText.setText(savedAuthId);
    boolean needSuggested = savedAuthId == null || savedAuthId.isEmpty();
    if (((availableAuthType & AuthActivity.AUTH_TYPE_PHONE) == AuthActivity.AUTH_TYPE_PHONE) && ((availableAuthType & AuthActivity.AUTH_TYPE_EMAIL) == AuthActivity.AUTH_TYPE_EMAIL)) {
        //both hints set phone + email by default
        if (needSuggested) {
            setSuggestedEmail(signIdEditText);
        }
    } else if ((availableAuthType & AuthActivity.AUTH_TYPE_PHONE) == AuthActivity.AUTH_TYPE_PHONE) {
        hint.setText(getString(R.string.sign_in_hint_phone_only));
        signIdEditText.setHint(getString(R.string.sign_in_edit_text_hint_phone_only));
        signIdEditText.setInputType(EditorInfo.TYPE_CLASS_PHONE);
    } else if ((availableAuthType & AuthActivity.AUTH_TYPE_EMAIL) == AuthActivity.AUTH_TYPE_EMAIL) {
        hint.setText(getString(R.string.sign_in_hint_email_only));
        signIdEditText.setHint(getString(R.string.sign_in_edit_text_hint_email_only));
        if (needSuggested) {
            setSuggestedEmail(signIdEditText);
        }
    }
    Button singUp = (Button) v.findViewById(R.id.button_sign_up);
    singUp.setTextColor(style.getTextSecondaryColor());
    onClick(singUp, new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            startSignUp();
        }
    });
    onClick(v, R.id.button_continue, new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            requestCode();
        }
    });
}
Also used : KeyEvent(android.view.KeyEvent) ActorStyle(im.actor.sdk.ActorStyle) Button(android.widget.Button) TextView(android.widget.TextView) TextView(android.widget.TextView) View(android.view.View)

Aggregations

KeyEvent (android.view.KeyEvent)513 View (android.view.View)145 TextView (android.widget.TextView)109 Intent (android.content.Intent)53 ImageView (android.widget.ImageView)38 DialogInterface (android.content.DialogInterface)36 EditText (android.widget.EditText)36 KeyCharacterMap (android.view.KeyCharacterMap)35 Editable (android.text.Editable)34 OnEditorActionListener (android.widget.TextView.OnEditorActionListener)32 Instrumentation (android.app.Instrumentation)30 OnClickListener (android.view.View.OnClickListener)30 Paint (android.graphics.Paint)27 Button (android.widget.Button)27 TextWatcher (android.text.TextWatcher)24 InputMethodManager (android.view.inputmethod.InputMethodManager)22 AlertDialog (android.app.AlertDialog)21 Message (android.os.Message)21 LayoutInflater (android.view.LayoutInflater)21 Test (org.junit.Test)20