Search in sources :

Example 66 with KeyEvent

use of android.view.KeyEvent in project materialistic by hidroh.

the class BaseListActivityLandTest method testBackPressed.

@Test
public void testBackPressed() {
    activity.onItemSelected(new TestHnItem(1L) {

        @NonNull
        @Override
        public String getType() {
            return STORY_TYPE;
        }
    });
    activity.onKeyDown(KeyEvent.KEYCODE_BACK, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK));
    verify(keyDelegate).setBackInterceptor(any(KeyDelegate.BackInterceptor.class));
    verify(keyDelegate).onKeyDown(anyInt(), any(KeyEvent.class));
}
Also used : KeyEvent(android.view.KeyEvent) NonNull(android.support.annotation.NonNull) TestHnItem(io.github.hidroh.materialistic.data.TestHnItem) Test(org.junit.Test) SlowTest(io.github.hidroh.materialistic.test.suite.SlowTest)

Example 67 with KeyEvent

use of android.view.KeyEvent in project materialistic by hidroh.

the class ThreadPreviewActivityTest method testVolumeNavigation.

@Test
public void testVolumeNavigation() {
    activity.onKeyDown(KeyEvent.KEYCODE_VOLUME_UP, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_VOLUME_UP));
    verify(keyDelegate).setScrollable(any(Scrollable.class), any());
    verify(keyDelegate).onKeyDown(anyInt(), any(KeyEvent.class));
    activity.onKeyUp(KeyEvent.KEYCODE_VOLUME_UP, new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_VOLUME_UP));
    verify(keyDelegate).onKeyUp(anyInt(), any(KeyEvent.class));
    activity.onKeyLongPress(KeyEvent.KEYCODE_VOLUME_UP, new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_VOLUME_UP));
    verify(keyDelegate).onKeyLongPress(anyInt(), any(KeyEvent.class));
}
Also used : KeyEvent(android.view.KeyEvent) Test(org.junit.Test)

Example 68 with KeyEvent

use of android.view.KeyEvent in project ToolBarLib by jjhesk.

the class MaterialSearchView method initSearchView.

protected 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 69 with KeyEvent

use of android.view.KeyEvent in project KJFrameForAndroid by kymjs.

the class CurtainViewController method prepareSlidingLayout.

/**
     * 为控件做一些属性设置
     */
protected void prepareSlidingLayout() {
    curtainLayoutParams = (FrameLayout.LayoutParams) curtainParent.getLayoutParams();
    ViewTreeObserver vto = curtainParent.getViewTreeObserver();
    vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {

        @Override
        @SuppressLint("NewApi")
        public void onGlobalLayout() {
            hideCurtainLayout();
            ViewTreeObserver obs = curtainParent.getViewTreeObserver();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                obs.removeOnGlobalLayoutListener(this);
            } else {
                obs.removeGlobalOnLayoutListener(this);
            }
        }
    });
    curtainParent.setOnTouchListener(new OnContentTouchListener());
    curtainParent.setOnKeyListener(new OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK && getSlidingStatus() == SlidingStatus.EXPANDED) {
                collapse();
                return true;
            } else {
                return false;
            }
        }
    });
}
Also used : KeyEvent(android.view.KeyEvent) FrameLayout(android.widget.FrameLayout) OnGlobalLayoutListener(android.view.ViewTreeObserver.OnGlobalLayoutListener) SuppressLint(android.annotation.SuppressLint) OnKeyListener(android.view.View.OnKeyListener) ViewTreeObserver(android.view.ViewTreeObserver) View(android.view.View) SuppressLint(android.annotation.SuppressLint)

Example 70 with KeyEvent

use of android.view.KeyEvent in project KJFrameForAndroid by kymjs.

the class InputHelper method backspace.

public static void backspace(EditText editText) {
    if (editText == null) {
        return;
    }
    KeyEvent event = new KeyEvent(0, 0, 0, KeyEvent.KEYCODE_DEL, 0, 0, 0, 0, KeyEvent.KEYCODE_ENDCALL);
    editText.dispatchKeyEvent(event);
}
Also used : KeyEvent(android.view.KeyEvent)

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