Android Open Source - Tip_Calculator Clean Edit Text






From Project

Back to project page Tip_Calculator.

License

The source code is released under:

Apache License

If you think the Android project Tip_Calculator listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.collinguarino.tipcalculator;
/*  w  w w  .  jav a2 s . co  m*/
import android.content.Context;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.widget.EditText;

/**
 * Created by collinux on 7/16/14.
 */
public class CleanEditText extends EditText {

    private EditTextImeBackListener mOnImeBack;

    public CleanEditText(Context context) {
        super(context);
    }

    public CleanEditText(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public CleanEditText(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    public boolean onKeyPreIme(int keyCode, KeyEvent event) {
        // detect keyboard hiding
        if ((event.getKeyCode() == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_UP)
                || event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) {
            if (mOnImeBack != null) mOnImeBack.onImeBack(this, this.getText().toString());
        }
        return super.dispatchKeyEvent(event);
    }

    public void setOnEditTextImeBackListener(EditTextImeBackListener listener) {
        mOnImeBack = listener;
    }

    public interface EditTextImeBackListener {
        public abstract void onImeBack(CleanEditText ctrl, String text);
    }

}




Java Source Code List

com.collinguarino.tipcalculator.ActivityMain.java
com.collinguarino.tipcalculator.ActivityPreferences.java
com.collinguarino.tipcalculator.ApplicationTest.java
com.collinguarino.tipcalculator.CleanEditText.java
com.collinguarino.tipcalculator.TipCalculatorDashClock.java
com.collinguarino.tipcalculator.WidgetProvider.java