Example usage for android.view KeyEvent ACTION_UP

List of usage examples for android.view KeyEvent ACTION_UP

Introduction

In this page you can find the example usage for android.view KeyEvent ACTION_UP.

Prototype

int ACTION_UP

To view the source code for android.view KeyEvent ACTION_UP.

Click Source Link

Document

#getAction value: the key has been released.

Usage

From source file:net.sourceforge.servestream.fragment.AddUrlFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);

    mUrlEditText.setOnKeyListener(new OnKeyListener() {

        public boolean onKey(View v, int keyCode, KeyEvent event) {

            if (event.getAction() == KeyEvent.ACTION_UP)
                return false;

            if (keyCode != KeyEvent.KEYCODE_ENTER)
                return false;

            processUri();//from  www  . j  a v a 2 s . c  om

            return true;
        }

    });

    mCancelButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            getActivity().finish();
        }

    });

    mConfirmButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            processUri();
        }
    });

    mSavePlaylistEntriesCheckbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                mNicknameEditText.setEnabled(false);
            } else {
                mNicknameEditText.setEnabled(true);
            }
        }
    });
}

From source file:jp.gr.java_conf.ya.shiobeforandroid3.UpdateTweetDrive.java

@Override
public final boolean dispatchKeyEvent(final KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_UP) {
        if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
            //true????
            return true;
        }//w w w  . ja  va 2 s  .  c  o m
    }

    return super.dispatchKeyEvent(event);
}

From source file:com.glanznig.beepme.view.MainActivity.java

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    int action = event.getAction();
    int keyCode = event.getKeyCode();
    switch (keyCode) {
    case KeyEvent.KEYCODE_VOLUME_UP:
        if (action == KeyEvent.ACTION_UP) {
            audioManager.adjustStreamVolume(AudioManager.STREAM_ALARM, AudioManager.ADJUST_RAISE,
                    AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_PLAY_SOUND);
        }//from   w w w  .j  a v  a2s  . co  m
        return true;
    case KeyEvent.KEYCODE_VOLUME_DOWN:
        if (action == KeyEvent.ACTION_DOWN) {
            audioManager.adjustStreamVolume(AudioManager.STREAM_ALARM, AudioManager.ADJUST_LOWER,
                    AudioManager.FLAG_SHOW_UI | AudioManager.FLAG_PLAY_SOUND);
        }
        return true;
    default:
        return super.dispatchKeyEvent(event);
    }
}

From source file:org.chromium.chrome.browser.omnibox.LocationBarPhone.java

@Override
public void setMenuButtonHelper(final AppMenuButtonHelper helper) {
    super.setMenuButtonHelper(helper);
    mMenuButton.setOnTouchListener(new OnTouchListener() {
        @SuppressLint("ClickableViewAccessibility")
        @Override//from w ww .j  a  va  2  s. c  om
        public boolean onTouch(View v, MotionEvent event) {
            return helper.onTouch(v, event);
        }
    });
    mMenuButton.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View view, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_UP) {
                return helper.onEnterKeyPress(view);
            }
            return false;
        }
    });
}

From source file:com.trellmor.berrytubechat.ChatActivity.java

@SuppressLint("NewApi")
@Override/*from w w  w . j av a  2  s  .co m*/
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_chat);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        getActionBar().setDisplayHomeAsUpEnabled(false);
    }

    mEditChatMsg = (EditText) findViewById(R.id.edit_chat_msg);
    TextView.OnEditorActionListener chatMsgListener = new TextView.OnEditorActionListener() {
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_SEND) {
                sendChatMsg();
            } else if (actionId == EditorInfo.IME_NULL && event.getAction() == KeyEvent.ACTION_UP
                    && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
                sendChatMsg();
            }
            return true;
        }
    };
    mEditChatMsg.setOnEditorActionListener(chatMsgListener);

    mTextDrinks = (TextView) findViewById(R.id.text_drinks);
    registerForContextMenu(mTextDrinks);

    mCurrentVideo = (TextView) findViewById(R.id.text_video);
    mCurrentVideo.setMovementMethod(LinkMovementMethod.getInstance());

    mTextNick = (TextView) findViewById(R.id.text_nick);
    mTextNick.setText("Anonymous");

    mListChat = (ListView) findViewById(R.id.list_chat);

    Intent intent = getIntent();
    mUsername = intent.getStringExtra(MainActivity.KEY_USERNAME);
    mPassword = intent.getStringExtra(MainActivity.KEY_PASSWORD);

    if (savedInstanceState != null) {
        mDrinkCount = savedInstanceState.getInt(KEY_DRINKCOUT);
        mMyDrinkCount = savedInstanceState.getInt(KEY_MYDRINKCOUNT);
        if (mUsername == null)
            mUsername = savedInstanceState.getString(MainActivity.KEY_USERNAME);
        if (mPassword == null)
            mPassword = savedInstanceState.getString(MainActivity.KEY_PASSWORD);
    }

    startService(new Intent(this, BerryTube.class));
    bindService(new Intent(this, BerryTube.class), mService, BIND_ABOVE_CLIENT);
}

From source file:com.irccloud.android.ActionEditText.java

@Override
public boolean onKeyPreIme(int keyCode, KeyEvent event) {
    if (mDrawerLayout != null && event.getKeyCode() == KeyEvent.KEYCODE_BACK
            && event.getAction() == KeyEvent.ACTION_UP) {
        mDrawerLayout.closeDrawers();/*from   ww  w  .  j  av a2 s.  co m*/
    }
    return super.onKeyPreIme(keyCode, event);
}

From source file:ar.rulosoft.custompref.SeekBarCustomPreference.java

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
    if (isEnabled()) {
        if (event.getAction() != KeyEvent.ACTION_UP) {
            int increment = mKeyProgressIncrement;

            switch (keyCode) {
            case KeyEvent.KEYCODE_PLUS:
            case KeyEvent.KEYCODE_EQUALS:
                setProgress(getProgress() + increment);
                return true;
            case KeyEvent.KEYCODE_MINUS:
                setProgress(getProgress() - increment);
                return true;
            case KeyEvent.KEYCODE_DPAD_LEFT:
                increment = -increment;//from  w  ww  . ja  va  2 s  .c o  m
                // fallthrough
            case KeyEvent.KEYCODE_DPAD_RIGHT:
                increment = ViewCompat.getLayoutDirection(v) == ViewCompat.LAYOUT_DIRECTION_RTL ? -increment
                        : increment;
                setProgress(getProgress() + increment);
                return true;
            }
        }
    }
    return false;
}

From source file:com.lemon.lime.MainActivity.java

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

    getBatteryPercentage();//www.jav a  2  s  .  c  om
    setContentView(R.layout.activity_main);
    getSupportActionBar().setDisplayShowCustomEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    mWebView = (ObservableWebView) findViewById(R.id.activity_main_webview);
    mWebView.setScrollViewCallbacks(this);
    LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View v = inflator.inflate(R.layout.bar, null);
    getSupportActionBar().setCustomView(v);

    WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());

    swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipeToRefresh);
    swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            mWebView.reload();
        }
    });
    swipeLayout.setColorSchemeResources(R.color.lili, R.color.colorPrimary, R.color.red);

    window = getWindow();
    favicon = (ImageView) findViewById(R.id.favicon);
    editurl = (EditText) findViewById(R.id.editurl);
    mWebView.setDownloadListener(new DownloadListener() {
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype,
                long contentLength) {

            Uri uri = Uri.parse(url);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        }

    });

    favicon.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (lili == 5) {
                lilimode();
                lili = 0;
                lilimode = true;
            } else {
                lili = lili + 1;
            }
        }
    });

    editurl.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                if (event.getAction() == KeyEvent.ACTION_UP) {
                    if (editurl.getText().toString().contains("file:///")) {
                        filemgr();
                    } else if (editurl.getText().toString().contains("gaymode")) {
                        gaymode();
                    } else if (editurl.getText().toString().contains("exitapp")) {
                        finish();
                    } else if (editurl.getText().toString().contains("light")) {
                        flash();
                    }

                    if (isconnected()) {
                        if (editurl.getText().toString().contains("http://")
                                || editurl.getText().toString().contains("https://")) {
                            mWebView.loadUrl(editurl.getText().toString());

                        } else if (editurl.getText().toString().contains(".com")
                                || editurl.getText().toString().contains(".net")
                                || editurl.getText().toString().contains(".org")
                                || editurl.getText().toString().contains(".gov")
                                || editurl.getText().toString().contains(".hu")
                                || editurl.getText().toString().contains(".sk")
                                || editurl.getText().toString().contains(".co.uk")
                                || editurl.getText().toString().contains(".co.in")
                                || editurl.getText().toString().contains(".cn")
                                || editurl.getText().toString().contains(".it")
                                || editurl.getText().toString().contains(".de")
                                || editurl.getText().toString().contains(".aus")
                                || editurl.getText().toString().contains(".hr")
                                || editurl.getText().toString().contains(".cz")
                                || editurl.getText().toString().contains(".xyz")
                                || editurl.getText().toString().contains(".pl")
                                || editurl.getText().toString().contains(".io")) {
                            mWebView.loadUrl("http://" + editurl.getText().toString());

                            InputMethodManager imm = (InputMethodManager) getSystemService(
                                    Context.INPUT_METHOD_SERVICE);
                            imm.hideSoftInputFromWindow(editurl.getWindowToken(), 0);

                        } else {
                            mWebView.loadUrl("https://www.google.com/search?q=" + editurl.getText().toString());

                            InputMethodManager imm = (InputMethodManager) getSystemService(
                                    Context.INPUT_METHOD_SERVICE);
                            imm.hideSoftInputFromWindow(editurl.getWindowToken(), 0);
                        }
                    }
                    return true;
                }
                return false;
            }

            return true;
        }
    });
    // Enable Javascript
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setDisplayZoomControls(false);
    webSettings.setSupportMultipleWindows(true);

    if (isconnected()) {
        mWebView.loadUrl("http://google.com");
    } else {

        final View coordinatorLayoutView = findViewById(R.id.snackbarPosition);
        mWebView.loadUrl("file:///android_asset/nonet.html");
        Snackbar snackbar = Snackbar.make(coordinatorLayoutView, R.string.offline, Snackbar.LENGTH_LONG);
        snackbar.show();

    }

    mWebView.setWebChromeClient(new WebChromeClient() {

        @Override
        public void onReceivedIcon(WebView mWebView, Bitmap icon) {
            super.onReceivedIcon(mWebView, icon);
            favicon.setImageBitmap(icon);
        }

        public void onProgressChanged(WebView view, int progress) {
            activity.setProgress(progress * 100);
            int a = progress;
            if (lilimode) {
                editurl.setText("Liling: " + Integer.toString(a) + "?");
            } else
                editurl.setText("Liming: " + Integer.toString(a) + "%");
            if (progress == 100) {

                editurl.setHint(view.getTitle());
                activity.setTitle(view.getTitle());
                editurl.setText(view.getUrl());

                fav();

                //battery
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    if (level <= 20) {
                        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                        window.setNavigationBarColor(Color.RED);
                        window.setStatusBarColor(Color.RED);
                        getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.RED));
                    }
                }
            }
        }
    });

    mWebView.setWebViewClient(new WebViewClient() {
        public void onPageFinished(WebView mWebView, String url) {
            swipeLayout.setRefreshing(false);
        }
    });

}

From source file:io.github.prefanatic.cleantap.ui.BeerSearchActivity.java

private void searchViewEvent(TextViewEditorActionEvent event) {
    if (event.actionId() == EditorInfo.IME_ACTION_SEARCH
            || (event.keyEvent().getKeyCode() == KeyEvent.KEYCODE_ENTER
                    && event.keyEvent().getAction() == KeyEvent.ACTION_UP)) {
        recyclerView.setNestedScrollingEnabled(false);
        presenter.searchForBeer(searchView.getText().toString());

        AnimUtils.show(progress);/*from  w  w  w  .j ava 2  s . c  o  m*/
        AnimUtils.hide(helpText);
    }
}

From source file:com.bullmobi.message.services.media.MediaController2KitKat.java

/**
 * {@inheritDoc}/*from   w  w  w.j a  v  a 2 s .c  o m*/
 */
public void sendMediaAction(int action) {
    int keyCode;
    switch (action) {
    case ACTION_PLAY_PAUSE:
        keyCode = KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE;
        break;
    case ACTION_STOP:
        keyCode = KeyEvent.KEYCODE_MEDIA_STOP;
        break;
    case ACTION_SKIP_TO_NEXT:
        keyCode = KeyEvent.KEYCODE_MEDIA_NEXT;
        break;
    case ACTION_SKIP_TO_PREVIOUS:
        keyCode = KeyEvent.KEYCODE_MEDIA_PREVIOUS;
        break;
    default:
        throw new IllegalArgumentException();
    }

    // TODO We should think about sending these up/down events accurately with touch up/down
    // on the buttons, but in the near term this will interfere with the long press behavior.
    RemoteController rc = mService.getRemoteController();
    rc.sendMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, keyCode));
    rc.sendMediaKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, keyCode));
}