Example usage for android.text.method KeyListener KeyListener

List of usage examples for android.text.method KeyListener KeyListener

Introduction

In this page you can find the example usage for android.text.method KeyListener KeyListener.

Prototype

KeyListener

Source Link

Usage

From source file:net.evendanan.android.thumbremote.ui.RemoteUiActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    setRequestedOrientation(RemoteApplication.getConfig().getRequestedScreenOrientation());
    //http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_DISMISS_KEYGUARD
    //http://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_SHOW_WHEN_LOCKED
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    super.onCreate(savedInstanceState);
    mActionBarHelper.onCreate(savedInstanceState);

    mHandler = new Handler();
    mInAnimation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.boxee_dialog_in);
    mOutAnimation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.boxee_dialog_out);
    mOutAnimation.setAnimationListener(new AnimationListener() {
        @Override/*from  w  w  w. j  a va2 s  . c o m*/
        public void onAnimationStart(Animation animation) {
        }

        @Override
        public void onAnimationRepeat(Animation animation) {
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            mUserMessage.setText("");
            mUserMessage.setVisibility(View.INVISIBLE);
        }
    });

    // mRemote = new BoxeeConnector();

    setContentView(R.layout.main);

    // Setup flipper
    mFlipper = (ViewFlipper) findViewById(R.id.now_playing_flipper);
    mFlipper.setInAnimation(this, R.anim.flip_in);
    mFlipper.setOutAnimation(this, R.anim.flip_out);

    // Find other views
    // mServerTitle = (TextView) findViewById(R.id.serverTitle);

    mImageThumbnail = (ImageView) findViewById(R.id.thumbnail);
    mButtonPlayPause = (ImageView) findViewById(R.id.buttonPlayPause);
    mTextMainTitle = (TextView) findViewById(R.id.textNowPlayingMainTitle);
    mTextSubTitle = (TextView) findViewById(R.id.textNowPlayingSubTitle);
    mUserMessage = (TextView) findViewById(R.id.textMessages);
    mTextElapsed = (TextView) findViewById(R.id.textElapsed);
    mDuration = (TextView) findViewById(R.id.textDuration);
    mElapsedBar = (ProgressBar) findViewById(R.id.progressTimeBar);
    findViewById(R.id.layoutTimeBar).setOnClickListener(this);
    mMediaDetails = (TextView) findViewById(R.id.textMediaDetails);
    mImeManager = (InputMethodManager) getSystemService(Service.INPUT_METHOD_SERVICE);
    mKeyboardText = (TextView) findViewById(R.id.keyboard_text);
    mKeyboardText.setKeyListener(new KeyListener() {

        @Override
        public boolean onKeyUp(View view, Editable text, int keyCode, KeyEvent event) {
            // I'm returning false here so the activity will handle the
            // onKeyUp
            return false;
        }

        @Override
        public boolean onKeyOther(View view, Editable text, KeyEvent event) {
            // I'm returning false here so the activity will handle the
            // onKeyOther
            return false;
        }

        @Override
        public boolean onKeyDown(View view, Editable text, int keyCode, KeyEvent event) {
            // Log.d(TAG,
            // "KeyListener.onKeyDown: "+(char)event.getUnicodeChar());
            // I'm returning false here so the activity will handle the
            // onKeyDown
            return false;
        }

        @Override
        public int getInputType() {
            return 0;
        }

        @Override
        public void clearMetaKeyState(View view, Editable content, int states) {
        }
    });

    setButtonAction(R.id.back, KeyEvent.KEYCODE_BACK);
    setButtonAction(R.id.buttonPlayPause, 0);
    setButtonAction(R.id.buttonStop, 0);
    setButtonAction(R.id.buttonSmallSkipBack, 0);
    setButtonAction(R.id.buttonSmallSkipFwd, 0);
    setButtonAction(R.id.buttonPreviousMedia, 0);
    setButtonAction(R.id.buttonNextMedia, 0);

    setButtonAction(R.id.buttonOpenKeyboard, 0);
    // mShakeDetector = new ShakeListener(getApplicationContext());
    // mShakeDetector.setOnShakeListener(this);
    mServersGroup = (SubMenu) findViewById(R.id.servers_group);
    mServers = new HashMap<String, ServerAddress>();

    startHelpOnFirstRun();
}