diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 0b842cf..19373ea 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -10,8 +10,10 @@
+
+
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 5d19981..ba7052b 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,8 +1,5 @@
-
-
-
@@ -27,17 +24,7 @@
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 1dab95f..f53e639 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,8 +2,9 @@
-
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 401bb48..94a25f7 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
index b320158..b780b88 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'
android {
- compileSdkVersion 24
- buildToolsVersion "25.0.0"
+ compileSdkVersion 26
+ buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.keybord.keyborddemo"
minSdkVersion 19
- targetSdkVersion 24
+ targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -20,6 +20,9 @@ android {
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- compile 'com.android.support:appcompat-v7:24.2.1'
+ implementation fileTree(include: ['*.jar'], dir: 'libs')
+ implementation 'com.android.support:appcompat-v7:26.1.0'
+ implementation 'com.android.support:recyclerview-v7:26.1.0'
+ implementation 'com.android.support.constraint:constraint-layout:1.0.2'
+ implementation project(':easykeyboard')
}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 95193c6..7940f80 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -1,20 +1,23 @@
+ package="com.example.keybord.keyborddemo">
-
+ android:theme="@style/AppTheme">
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/example/keybord/keyborddemo/MainActivity.java b/app/src/main/java/com/example/keybord/keyborddemo/MainActivity.java
index b48f5d3..a2abf9d 100644
--- a/app/src/main/java/com/example/keybord/keyborddemo/MainActivity.java
+++ b/app/src/main/java/com/example/keybord/keyborddemo/MainActivity.java
@@ -1,13 +1,35 @@
package com.example.keybord.keyborddemo;
-import android.support.v7.app.AppCompatActivity;
+import android.app.ListActivity;
+import android.content.Intent;
import android.os.Bundle;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
-public class MainActivity extends AppCompatActivity {
-
+public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
+ String type[] = new String[] {"SystemKeyboard","SystemKeyBoardEditText"};
+ ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, type);
+ setListAdapter(adapter);
+ }
+
+ @Override
+ protected void onListItemClick(ListView l, View v, int position, long id) {
+ super.onListItemClick(l, v, position, id);
+ switch (position){
+ case 0:
+ startActivity(SystemKeyboardActivity.class);
+ break;
+ case 1:
+ startActivity(SystemKeyboardEidtTextActivity.class);
+ break;
+ }
+ }
+
+ private void startActivity(Class c){
+ startActivity(new Intent(this,c));
}
}
diff --git a/app/src/main/java/com/example/keybord/keyborddemo/MyKeyboard.java b/app/src/main/java/com/example/keybord/keyborddemo/MyKeyboard.java
deleted file mode 100644
index 31c110d..0000000
--- a/app/src/main/java/com/example/keybord/keyborddemo/MyKeyboard.java
+++ /dev/null
@@ -1,690 +0,0 @@
-/**
- *
- */
-package com.example.keybord.keyborddemo;
-
-import android.annotation.TargetApi;
-import android.app.Activity;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Rect;
-import android.inputmethodservice.Keyboard;
-import android.inputmethodservice.Keyboard.Key;
-import android.inputmethodservice.KeyboardView;
-import android.inputmethodservice.KeyboardView.OnKeyboardActionListener;
-import android.os.Build;
-import android.os.SystemClock;
-import android.text.Editable;
-import android.text.TextWatcher;
-import android.util.AttributeSet;
-import android.util.DisplayMetrics;
-import android.view.ActionMode;
-import android.view.Display;
-import android.view.Gravity;
-import android.view.KeyEvent;
-import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.Window;
-import android.view.WindowManager;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
-import android.view.animation.TranslateAnimation;
-import android.view.inputmethod.EditorInfo;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.EditText;
-import android.widget.PopupWindow;
-import android.widget.PopupWindow.OnDismissListener;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.security.SecureRandom;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Random;
-import java.util.Timer;
-import java.util.TimerTask;
-
-/**
- * 自定义键盘,有按下效果
- * 现在只添加了身份证输入的键盘布局,想要其余的请自行添加
- */
-public class MyKeyboard extends EditText implements OnKeyboardActionListener {
-
- private KeyboardView mKeyboardView;
- private Keyboard mKeyboard;
-
- private Window mWindow;
- private View mDecorView;
- private View mContentView;
-
- private PopupWindow mKeyboardWindow;
-
- private boolean needcustomkeyboard = true; //是否启用自定义键盘
- private boolean randomkeys = false; //数字按键是否随机
-
- private int scrolldis = 0; //输入框在键盘被弹出时,要被推上去的距离
-
- public static int screenw = -1;//未知宽高
- public static int screenh = -1;
- public static int screenh_nonavbar = -1; //不包含导航栏的高度
- public static int real_scontenth = -1; //实际内容高度, 计算公式:屏幕高度-导航栏高度-电量栏高度
-
- public static float density = 1.0f;
- public static int densityDpi = 160;
- public boolean isSpace = false; //是否开启输入自动空格
-
- private boolean isHide = true;
- /**
- * 位数
- */
- private int unit = 4;
- /**
- * 标识符
- */
- private String tag = " ";
-
- /**
- * @param context
- * @param attrs
- */
- public MyKeyboard(Context context, AttributeSet attrs) {
- super(context, attrs);
- initAttributes(context);
- initKeyboard(context, attrs);
- }
-
- /**
- * @param context
- * @param attrs
- * @param defStyle
- */
- public MyKeyboard(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- initAttributes(context);
- initKeyboard(context, attrs);
- }
-
- private void initKeyboard(Context context, AttributeSet attrs) {
-
- TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.keyboard);
-
- if (a.hasValue(R.styleable.keyboard_xml)) {
- needcustomkeyboard = true;
-
- int xmlid = a.getResourceId(R.styleable.keyboard_xml, 0);
-
- mKeyboard = new Keyboard(context, xmlid);
- mKeyboardView = (KeyboardView) LayoutInflater.from(context).inflate(R.layout.mykeyboardview, null);
- if (a.hasValue(R.styleable.keyboard_randomkeys)) {
- boolean random = a.getBoolean(R.styleable.keyboard_randomkeys, false);
- randomkeys = random;
-
- if (random) {
- randomdigkey(mKeyboard);
- }
- }
-
- if (a.hasValue(R.styleable.keyboard_space)) {
- isSpace = a.getBoolean(R.styleable.keyboard_space, false);
- }
- if (isSpace) {
- addTextChangedListener(new FormatTextWatcher());
- }
-
- setOnFocusChangeListener(new OnFocusChangeListener() { //这里是解决那个点别的Edittext弹出系统键盘此键盘不消失的bug
- @Override
- public void onFocusChange(View v, boolean hasFocus) {
- if (!hasFocus){
- hideKeyboard();
- }
- }
- });
- mKeyboardView.setKeyboard(mKeyboard);
- mKeyboardView.setEnabled(true);
- mKeyboardView.setPreviewEnabled(false);
- mKeyboardView.setOnKeyboardActionListener(this);
-
- mKeyboardWindow = new PopupWindow(mKeyboardView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
- mKeyboardWindow.setAnimationStyle(R.style.AnimationFade);
- mKeyboardWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
- mKeyboardWindow.setOnDismissListener(new OnDismissListener() {
-
- @Override
- public void onDismiss() {
- // TODO Auto-generated method stub
- if (scrolldis > 0) {
- int temp = scrolldis;
- scrolldis = 0;
- if (null != mContentView) {
- mContentView.scrollBy(0, -temp);
- }
- }
- }
- });
- } else {
- needcustomkeyboard = false;
- }
-
- a.recycle();
-
- }
-
- private void showKeyboard() {
- if (null != mKeyboardWindow) {
- if (!mKeyboardWindow.isShowing()) {
- if (randomkeys) {
- randomdigkey(mKeyboard);
- }
-
- mKeyboardView.setKeyboard(mKeyboard);
-
- mKeyboardWindow.showAtLocation(this.mDecorView, Gravity.BOTTOM, 0, 0);
-// mKeyboardWindow.update();
-
-
- if (null != mDecorView && null != mContentView) {
- int[] pos = new int[2];
- getLocationOnScreen(pos);
- float height = dpToPx(getContext(), 240);
-
- Rect outRect = new Rect();
- mDecorView.getWindowVisibleDisplayFrame(outRect);
-
- int screen = real_scontenth;
- scrolldis = (int) ((pos[1] + getMeasuredHeight() - outRect.top) - (screen - height));
-
- if (scrolldis > 0) {
- mContentView.scrollBy(0, scrolldis);
- }
- }
-
- }
- }
- }
-
- private void hideKeyboard() {
- if (null != mKeyboardWindow) {
- if (mKeyboardWindow.isShowing()) {
- mKeyboardWindow.dismiss();
- }
- }
- }
-
- private void hideSysInput() {
- if (this.getWindowToken() != null) {
- InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
- imm.hideSoftInputFromWindow(this.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
- }
- }
-
-
- class FormatTextWatcher implements TextWatcher {
-
- int beforeTextLength = 0;
- int afterTextLength = 0;
- int location = 0;// 记录光标的位置
- boolean isChanging = false;// 是否更换中
-
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- beforeTextLength = s.length();
- }
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
-
- }
-
- @Override
- public void afterTextChanged(Editable s) {
- afterTextLength = s.length();
-
- if (isChanging)
- return;
-
- if (beforeTextLength < afterTextLength) {// 字符增加
- location = getSelectionEnd();
- setFormatText(s.toString());
- if (location % (unit + 1) == 0) {
- setSelection(getLocation(location + 1));
- } else {
- setSelection(getLocation(location));
- }
- } else if (beforeTextLength > afterTextLength) {// 字符减少
- location = getSelectionEnd();
- setFormatText(s.toString());
- if (location % (unit + 1) == 0) {
- setSelection(getLocation(location - 1));
- } else {
- setSelection(getLocation(location));
- }
- }
- }
-
- private int getLocation(int location) {
- if (location < 0)
- return 0;
- if (location > afterTextLength) {
- return afterTextLength;
- }
- return location;
- }
-
- private void setFormatText(String str) {
- isChanging = true;
- setText(addTag(str));
- isChanging = false;
- }
-
- /**
- * 加上标识符
- *
- * @param str
- * @return
- */
- private String addTag(String str) {
- str = replaceTag(str);
- StringBuilder sb = new StringBuilder();
- int index = 0;
- int strLength = str.length();
- while (index < strLength) {
- int increment = index + unit;
- sb.append(str.subSequence(index, index = (increment > strLength) ? strLength : increment));
- if (increment < strLength) {
- sb.append(tag);
- }
- }
- return sb.toString();
- }
- }
-
- /**
- * 清除标识符
- *
- * @param str
- * @return
- */
- public String replaceTag(String str) {
- if (str.indexOf(tag) != -1) {
- str = str.replace(tag, "");
- }
- return str;
- }
-
- @Override
- public String toString() {
- return replaceTag(getText().toString());
- }
-
-
- @Override
- public boolean onTouchEvent(MotionEvent event) {
- super.onTouchEvent(event);
- if (isHide){
- requestFocus();
- requestFocusFromTouch();
-
- if (needcustomkeyboard) {
- hideSysInput();
- showKeyboard();
- }
- }else{
- hideKeyboard();
- hideSysInput();
- }
-
- return true;
- }
-
-
- //设置是否获取焦点请用次方法,不然会有禁止获取焦点却能弹出键盘的bug
- public void setKeyBordFocuable(boolean focuable){
- setFocusable(focuable);
- setFocusableInTouchMode(focuable);
- setCursorVisible(focuable);
- isHide = focuable;
- }
-
-
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK) {
- if (null != mKeyboardWindow) {
- if (mKeyboardWindow.isShowing()) {
- mKeyboardWindow.dismiss();
- return true;
- }
- }
- }
-
- return super.onKeyDown(keyCode, event);
-
- }
-
- public void onAttachedToWindow() {
- super.onAttachedToWindow();
-
- this.mWindow = ((Activity) getContext()).getWindow();
- this.mDecorView = this.mWindow.getDecorView();
- this.mContentView = this.mWindow.findViewById(Window.ID_ANDROID_CONTENT);
-
- hideSysInput();
- }
-
- public void onDetachedFromWindow() {
- super.onDetachedFromWindow();
-
- hideKeyboard();
-
- mKeyboardWindow = null;
- mKeyboardView = null;
- mKeyboard = null;
-
- mDecorView = null;
- mContentView = null;
- mWindow = null;
- }
-
- @Override
- public void onPress(int primaryCode) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onRelease(int primaryCode) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void onKey(int primaryCode, int[] keyCodes) {
- // TODO Auto-generated method stub
- Editable editable = this.getText();
- int start = this.getSelectionStart();
- if (primaryCode == Keyboard.KEYCODE_CANCEL) {// 隐藏键盘
- hideKeyboard();
- } else if (primaryCode == Keyboard.KEYCODE_DELETE) {// 回退
- if (editable != null && editable.length() > 0) {
- if (start > 0) {
- editable.delete(start - 1, start);
- }
- }
- } else if (primaryCode == 152) {
- editable.clear();
- } else {
- editable.insert(start, Character.toString((char) primaryCode));
- }
- }
-
- //判断是否是字母
- private boolean isLetter(String str) {
- String wordStr = "abcdefghijklmnopqrstuvwxyz";
- return wordStr.contains(str.toLowerCase());
- }
-
- @Override
- public void onText(CharSequence text) {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void swipeLeft() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void swipeRight() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void swipeDown() {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void swipeUp() {
- // TODO Auto-generated method stub
-
- }
-
- private Key getKeyByKeyCode(int keyCode) {
- if (null != mKeyboard) {
- List mKeys = mKeyboard.getKeys();
- for (int i = 0, size = mKeys.size(); i < size; i++) {
- Key mKey = mKeys.get(i);
-
- int codes[] = mKey.codes;
-
- if (codes[0] == keyCode) {
- return mKey;
- }
- }
- }
-
- return null;
- }
-
- private void initAttributes(Context context) {
- initScreenParams(context);
- this.setLongClickable(false);
- this.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
- removeCopyAbility();
-
- if (this.getText() != null) {
- this.setSelection(this.getText().length());
- }
-
- this.setOnFocusChangeListener(new OnFocusChangeListener() {
-
- @Override
- public void onFocusChange(View v, boolean hasFocus) {
- // TODO Auto-generated method stub
- if (!hasFocus) {
- hideKeyboard();
- }
- }
- });
-
-
- }
-
- @TargetApi(11)
- private void removeCopyAbility() {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
- this.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
-
- @Override
- public boolean onCreateActionMode(ActionMode mode, Menu menu) {
- return false;
- }
-
- @Override
- public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
- return false;
- }
-
- @Override
- public void onDestroyActionMode(ActionMode mode) {
-
- }
-
- @Override
- public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
- return false;
- }
- });
- }
- }
-
- private boolean isNumber(String str) {
- String wordstr = "0123456789";
- if (wordstr.indexOf(str) > -1) {
- return true;
- }
- return false;
- }
-
- private void randomdigkey(Keyboard mKeyboard) {
- if (mKeyboard == null) {
- return;
- }
-
- List keyList = mKeyboard.getKeys();
-
- // 查找出0-9的数字键
- List newkeyList = new ArrayList();
- for (int i = 0, size = keyList.size(); i < size; i++) {
- Key key = keyList.get(i);
- CharSequence label = key.label;
- if (label != null && isNumber(label.toString())) {
- newkeyList.add(key);
- }
- }
-
-
- int count = newkeyList.size();
-
-
- List resultList = new ArrayList();
-
-
- LinkedList temp = new LinkedList();
-
-
- for (int i = 0; i < count; i++) {
- temp.add(new KeyModel(48 + i, i + ""));
- }
-
-
- Random rand = new SecureRandom();
- rand.setSeed(SystemClock.currentThreadTimeMillis());
-
- for (int i = 0; i < count; i++) {
- int num = rand.nextInt(count - i);
- KeyModel model = temp.get(num);
- resultList.add(new KeyModel(model.getCode(), model.getLable()));
- temp.remove(num);
- }
-
- for (int i = 0, size = newkeyList.size(); i < size; i++) {
- Key newKey = newkeyList.get(i);
- KeyModel resultmodle = resultList.get(i);
- newKey.label = resultmodle.getLable();
- newKey.codes[0] = resultmodle.getCode();
- }
-
-
- }
-
-
- class KeyModel {
-
- private Integer code;
- private String label;
-
- public KeyModel(Integer code, String lable) {
- this.code = code;
- this.label = lable;
- }
-
- public Integer getCode() {
- return code;
- }
-
- public void setCode(Integer code) {
- this.code = code;
- }
-
- public String getLable() {
- return label;
- }
-
- public void setLabel(String lable) {
- this.label = lable;
- }
-
-
- }
-
- /**
- * 密度转换为像素值
- *
- * @param dp
- * @return
- */
- public static int dpToPx(Context context, float dp) {
- final float scale = context.getResources().getDisplayMetrics().density;
- return (int) (dp * scale + 0.5f);
- }
-
-
- private void initScreenParams(Context context) {
- DisplayMetrics dMetrics = new DisplayMetrics();
- WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
- Display display = windowManager.getDefaultDisplay();
- display.getMetrics(dMetrics);
-
- screenw = dMetrics.widthPixels;
- screenh = dMetrics.heightPixels;
- density = dMetrics.density;
- densityDpi = dMetrics.densityDpi;
-
- screenh_nonavbar = screenh;
-
- int ver = Build.VERSION.SDK_INT;
-
- // 新版本的android 系统有导航栏,造成无法正确获取高度
- if (ver == 13) {
- try {
- Method mt = display.getClass().getMethod("getRealHeight");
- screenh_nonavbar = (Integer) mt.invoke(display);
- } catch (Exception e) {
- }
- } else if (ver > 13) {
- try {
- Method mt = display.getClass().getMethod("getRawHeight");
- screenh_nonavbar = (Integer) mt.invoke(display);
- } catch (Exception e) {
- }
- }
-
- real_scontenth = screenh_nonavbar - getStatusBarHeight(context);
-
-
- }
-
- /**
- * 电量栏高度
- *
- * @return
- */
- public static int getStatusBarHeight(Context context) {
- Class> c = null;
- Object obj = null;
- Field field = null;
- int x = 0,
- sbar = 0;
- try {
- c = Class.forName("com.android.internal.R$dimen");
- obj = c.newInstance();
- field = c.getField("status_bar_height");
- x = Integer.parseInt(field.get(obj).toString());
- sbar = context.getResources().getDimensionPixelSize(x);
- } catch (Exception e1) {
- e1.printStackTrace();
- }
-
- return sbar;
- }
-
-
-}
diff --git a/app/src/main/java/com/example/keybord/keyborddemo/SystemKeyboardActivity.java b/app/src/main/java/com/example/keybord/keyborddemo/SystemKeyboardActivity.java
new file mode 100644
index 0000000..0abdd58
--- /dev/null
+++ b/app/src/main/java/com/example/keybord/keyborddemo/SystemKeyboardActivity.java
@@ -0,0 +1,86 @@
+package com.example.keybord.keyborddemo;
+
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.inputmethodservice.Keyboard;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Toast;
+
+import com.jay.easykeyboard.SystemKeyboard;
+import com.jay.easykeyboard.function.SystemOnKeyboardActionListener;
+
+/**
+ * Created by huangjie on 2018/2/6.
+ * 类名:
+ * 说明:
+ */
+
+public class SystemKeyboardActivity extends AppCompatActivity implements View.OnFocusChangeListener {
+
+ private SystemKeyboard mKeyboard;
+ private SystemOnKeyboardActionListener listener;
+ private EditText edit1;
+ private EditText edit2;
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_systemkeyboard);
+ mKeyboard = findViewById(R.id.systemkeyboard);
+ Button btn_setkeyui = findViewById(R.id.btn_setkeyui);
+ edit1 = findViewById(R.id.edit);
+ edit2 = findViewById(R.id.edit2);
+ listener = new SystemOnKeyboardActionListener() {
+ @Override
+ public void onKey(int primaryCode, int[] keyCodes) {
+ //必须实现该方法,其余方法可选择实现,该方法的作用是将输入的值附到EditText上,同时进行键盘按键监听
+ super.onKey(primaryCode, keyCodes);
+ if (primaryCode == Keyboard.KEYCODE_DONE) {
+ showShortToast("点击了完成按钮");
+ }
+ }
+ };
+ listener.setEditText(edit1);
+ mKeyboard.setOnKeyboardActionListener(listener);
+
+ edit1.setOnFocusChangeListener(this);
+ edit2.setOnFocusChangeListener(this);
+
+ btn_setkeyui.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ mKeyboard.setKeyboardUI(new SystemKeyboard.KeyUI() {
+ @Override
+ public Paint paintConfig(Paint mPaint) {
+ mPaint.setColor(Color.BLUE);
+ mPaint.setTextSize(100);
+ return mPaint;
+ }
+ });
+ }
+ });
+ }
+
+ @Override
+ protected void onDestroy() {
+ super.onDestroy();
+ mKeyboard.recycle();
+ }
+
+ private void showShortToast(String str) {
+ Toast.makeText(this, str, Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void onFocusChange(View v, boolean hasFocus) {
+ if (hasFocus) {
+ if (v instanceof EditText)
+ listener.setEditText((EditText) v);
+ }
+ }
+}
diff --git a/app/src/main/java/com/example/keybord/keyborddemo/SystemKeyboardEidtTextActivity.java b/app/src/main/java/com/example/keybord/keyborddemo/SystemKeyboardEidtTextActivity.java
new file mode 100644
index 0000000..4839966
--- /dev/null
+++ b/app/src/main/java/com/example/keybord/keyborddemo/SystemKeyboardEidtTextActivity.java
@@ -0,0 +1,61 @@
+package com.example.keybord.keyborddemo;
+
+import android.inputmethodservice.Keyboard;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.view.View;
+import android.widget.EditText;
+import android.widget.Toast;
+
+import com.jay.easykeyboard.SystemKeyBoardEditText;
+import com.jay.easykeyboard.function.SystemOnKeyboardActionListener;
+
+/**
+ * Created by huangjie on 2018/2/6.
+ * 类名:
+ * 说明:
+ */
+
+public class SystemKeyboardEidtTextActivity extends AppCompatActivity implements View.OnFocusChangeListener{
+
+ private SystemKeyBoardEditText skb_top;
+ private SystemKeyBoardEditText skb_bottom;
+ private SystemOnKeyboardActionListener listener;
+
+ @Override
+ public void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_systemkeyboardedittext);
+ skb_top = findViewById(R.id.skb_top);
+ skb_bottom = findViewById(R.id.skb_bottom);
+ listener = new SystemOnKeyboardActionListener(skb_top,skb_top.getKeyboardWindow()){
+ @Override
+ public void onKey(int primaryCode, int[] keyCodes) {
+ super.onKey(primaryCode, keyCodes);
+ if (primaryCode== Keyboard.KEYCODE_DONE){
+ showShortToast("点击了完成按钮");
+ }
+ }
+ };
+ skb_top.setOnKeyboardActionListener(listener);
+ skb_bottom.setOnKeyboardActionListener(listener);
+ skb_top.setOnFocusChangeListener(this);
+ skb_bottom.setOnFocusChangeListener(this);
+ }
+
+
+ private void showShortToast(String str){
+ Toast.makeText(this, str, Toast.LENGTH_SHORT).show();
+ }
+
+ @Override
+ public void onFocusChange(View v, boolean hasFocus) {
+ if (hasFocus){
+ if (v instanceof SystemKeyBoardEditText){
+ listener.setEditText((EditText) v);
+ listener.setPopupWindow(((SystemKeyBoardEditText) v).getKeyboardWindow());
+ }
+ }
+ }
+}
diff --git a/app/src/main/res/drawable/edit_bg.xml b/app/src/main/res/drawable/edit_bg.xml
new file mode 100644
index 0000000..f0440f9
--- /dev/null
+++ b/app/src/main/res/drawable/edit_bg.xml
@@ -0,0 +1,6 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
deleted file mode 100644
index de8cbc6..0000000
--- a/app/src/main/res/layout/activity_main.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
diff --git a/app/src/main/res/layout/activity_recycle_view.xml b/app/src/main/res/layout/activity_recycle_view.xml
new file mode 100644
index 0000000..92cca80
--- /dev/null
+++ b/app/src/main/res/layout/activity_recycle_view.xml
@@ -0,0 +1,13 @@
+
+
+
+
diff --git a/app/src/main/res/layout/activity_systemkeyboard.xml b/app/src/main/res/layout/activity_systemkeyboard.xml
new file mode 100644
index 0000000..767a2f2
--- /dev/null
+++ b/app/src/main/res/layout/activity_systemkeyboard.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_systemkeyboardedittext.xml b/app/src/main/res/layout/activity_systemkeyboardedittext.xml
new file mode 100644
index 0000000..a0cbfbd
--- /dev/null
+++ b/app/src/main/res/layout/activity_systemkeyboardedittext.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
diff --git a/app/src/main/res/layout/mykeyboardview.xml b/app/src/main/res/layout/mykeyboardview.xml
deleted file mode 100644
index 70c778c..0000000
--- a/app/src/main/res/layout/mykeyboardview.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
diff --git a/app/src/main/res/layout/recycler_item.xml b/app/src/main/res/layout/recycler_item.xml
new file mode 100644
index 0000000..56a26e7
--- /dev/null
+++ b/app/src/main/res/layout/recycler_item.xml
@@ -0,0 +1,14 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml
deleted file mode 100644
index 73399ee..0000000
--- a/app/src/main/res/values/attrs.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index b5f7f6f..b44ec46 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -4,7 +4,7 @@
16dp
16dp
- 230dip
+ 240dp
60dp
1px
1px
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index e5fbf65..b5ce7cc 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -8,9 +8,4 @@
-
-
diff --git a/app/src/main/res/xml/keyboard_numbers.xml b/app/src/main/res/xml/keyboard_numbers.xml
index faec466..912c602 100644
--- a/app/src/main/res/xml/keyboard_numbers.xml
+++ b/app/src/main/res/xml/keyboard_numbers.xml
@@ -24,7 +24,7 @@
-
diff --git a/build.gradle b/build.gradle
index 03bced9..a9607a3 100644
--- a/build.gradle
+++ b/build.gradle
@@ -2,11 +2,13 @@
buildscript {
repositories {
+ google()
jcenter()
+ maven { url 'https://jitpack.io' }
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.1.0'
-
+ classpath 'com.android.tools.build:gradle:3.0.0'
+ classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0' // Add this line
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
@@ -14,7 +16,9 @@ buildscript {
allprojects {
repositories {
+ google()
jcenter()
+ maven { url 'https://jitpack.io' }
}
}
diff --git a/easykeyboard/.gitignore b/easykeyboard/.gitignore
new file mode 100644
index 0000000..796b96d
--- /dev/null
+++ b/easykeyboard/.gitignore
@@ -0,0 +1 @@
+/build
diff --git a/easykeyboard/build.gradle b/easykeyboard/build.gradle
new file mode 100644
index 0000000..455bf87
--- /dev/null
+++ b/easykeyboard/build.gradle
@@ -0,0 +1,29 @@
+apply plugin: 'com.android.library'
+apply plugin: 'com.github.dcendents.android-maven'
+group='com.github.Jay-huangjie'
+android {
+ compileSdkVersion 26
+
+ defaultConfig {
+ minSdkVersion 19
+ targetSdkVersion 26
+ versionCode 1
+ versionName "1.0"
+
+ testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ }
+ }
+
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ implementation 'com.android.support:appcompat-v7:26.1.0'
+}
diff --git a/easykeyboard/proguard-rules.pro b/easykeyboard/proguard-rules.pro
new file mode 100644
index 0000000..f1b4245
--- /dev/null
+++ b/easykeyboard/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
diff --git a/easykeyboard/src/androidTest/java/com/jay/easykeyboard/ExampleInstrumentedTest.java b/easykeyboard/src/androidTest/java/com/jay/easykeyboard/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..a4ccf12
--- /dev/null
+++ b/easykeyboard/src/androidTest/java/com/jay/easykeyboard/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package com.jay.easykeyboard;
+
+import android.content.Context;
+import android.support.test.InstrumentationRegistry;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() throws Exception {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getTargetContext();
+
+ assertEquals("com.jay.easykeyboard.test", appContext.getPackageName());
+ }
+}
diff --git a/easykeyboard/src/main/AndroidManifest.xml b/easykeyboard/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..ace191b
--- /dev/null
+++ b/easykeyboard/src/main/AndroidManifest.xml
@@ -0,0 +1,2 @@
+
diff --git a/easykeyboard/src/main/java/com/jay/easykeyboard/SystemKeyBoardEditText.java b/easykeyboard/src/main/java/com/jay/easykeyboard/SystemKeyBoardEditText.java
new file mode 100644
index 0000000..164b279
--- /dev/null
+++ b/easykeyboard/src/main/java/com/jay/easykeyboard/SystemKeyBoardEditText.java
@@ -0,0 +1,174 @@
+package com.jay.easykeyboard;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.drawable.Drawable;
+import android.util.AttributeSet;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+import android.view.View;
+
+import com.jay.easykeyboard.base.KeyBoardEditText;
+import com.jay.easykeyboard.constant.Util;
+import com.jay.easykeyboard.function.FormatTextWatcher;
+import com.jay.easykeyboard.function.SystemOnKeyboardActionListener;
+
+/**
+ * Created by huangjie on 2018/2/4.
+ * 类名:
+ * 说明:附带键盘弹出的EditText
+ */
+
+public class SystemKeyBoardEditText extends KeyBoardEditText {
+ private boolean enable = true; //是否启用自定义键盘
+ private boolean focuable = true; //默认获取焦点
+ private boolean release = true; //主动回收
+ private SystemKeyboard systemKeyboard;
+ private FormatTextWatcher textWatcher;
+ private SystemOnKeyboardActionListener listener;
+
+ public SystemKeyBoardEditText(Context context) {
+ this(context, null);
+ }
+
+ public SystemKeyBoardEditText(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public SystemKeyBoardEditText(final Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ init(context, attrs);
+ setOnTouchListener(new OnTouchListener() {
+ @Override
+ public boolean onTouch(View v, MotionEvent event) {
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
+ if (focuable) {
+ requestFocus();
+ requestFocusFromTouch();
+ if (enable) {
+ Util.closeKeyboard(context, SystemKeyBoardEditText.this);
+ showKeyboardWindow();
+ }
+ } else {
+ dismissKeyboardWindow();
+ Util.closeKeyboard(context, SystemKeyBoardEditText.this);
+ }
+ }
+ return true;
+ }
+ });
+
+ setOnFocusChangeListener(new OnFocusChangeListener() {
+ @Override
+ public void onFocusChange(View v, boolean hasFocus) {
+ if (!hasFocus){
+ dismissKeyboardWindow();
+ }
+ }
+ });
+ }
+
+
+ private void init(Context context, AttributeSet attrs) {
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SystemKeyBoardEditText);
+// boolean randomkeys = a.getBoolean(R.styleable.SystemKeyBoardEditText_randomkeys, false);
+ int xmlLayoutResId = a.getResourceId(R.styleable.SystemKeyBoardEditText_xmlLayoutResId, 0);
+ boolean isSpace = a.getBoolean(R.styleable.SystemKeyBoardEditText_space, false);
+ systemKeyboard = new SystemKeyboard(context);
+ systemKeyboard.setXmlLayoutResId(xmlLayoutResId);
+// systemKeyboard.isRandomkeys(randomkeys);
+ if (a.hasValue(R.styleable.SystemKeyBoardEditText_keyViewbg)) {
+ Drawable keyViewbg = a.getDrawable(R.styleable.SystemKeyBoardEditText_keyViewbg);
+ systemKeyboard.setKeybgDrawable(keyViewbg);
+ }
+ initPopWindow(systemKeyboard);
+ listener = new SystemOnKeyboardActionListener(this, getKeyboardWindow()) {
+ @Override
+ public void onKey(int primaryCode, int[] keyCodes) {
+ super.onKey(primaryCode, keyCodes);
+ }
+ };
+ systemKeyboard.getKeyboardView().setOnKeyboardActionListener(listener);
+ if (isSpace) {
+ textWatcher = new FormatTextWatcher(this);
+ addTextChangedListener(textWatcher);
+ }
+ setCursorVisible(true);
+ a.recycle();
+ }
+
+ @Override
+ protected void onDetachedFromWindow() {
+ super.onDetachedFromWindow();
+ if (release) recycle();
+ }
+
+ @Override
+ public boolean onKeyDown(int keyCode, KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+ if (null != getKeyboardWindow()) {
+ if (getKeyboardWindow().isShowing()) {
+ getKeyboardWindow().dismiss();
+ return true;
+ }
+ }
+ }
+ return super.onKeyDown(keyCode, event);
+ }
+
+
+ public void recycle() {
+ super.recycle();
+ systemKeyboard = null;
+ if (null != textWatcher) {
+ removeTextChangedListener(textWatcher);
+ }
+ }
+
+ public void setActiveRelease(boolean release) {
+ this.release = release;
+ }
+
+ public SystemKeyboard getSystemKeyboard() {
+ return systemKeyboard;
+ }
+
+ public void setSpaceEnable(boolean isSpace) {
+ if (isSpace) {
+ if (textWatcher == null) {
+ textWatcher = new FormatTextWatcher(this);
+ }
+ addTextChangedListener(textWatcher);
+ } else {
+ if (null != textWatcher) {
+ removeTextChangedListener(textWatcher);
+ }
+ }
+ }
+
+// public void setRandomkeysEnable(boolean randomkeys) {
+// systemKeyboard.isRandomkeys(randomkeys);
+// }
+
+ public void setOnKeyboardActionListener(SystemOnKeyboardActionListener listener) {
+ this.listener = listener;
+ systemKeyboard.getKeyboardView().setOnKeyboardActionListener(listener);
+ }
+
+ /**
+ * 设置焦点
+ *
+ * @param focuable
+ */
+ public void setFocuable(boolean focuable) {
+ this.focuable = focuable;
+ setFocusable(focuable);
+ setFocusableInTouchMode(focuable);
+ setCursorVisible(focuable);
+ }
+
+ public void setKeyViewBgDrawable(Drawable drawable) {
+ if (systemKeyboard != null) systemKeyboard.setKeybgDrawable(drawable);
+ }
+
+}
diff --git a/easykeyboard/src/main/java/com/jay/easykeyboard/SystemKeyboard.java b/easykeyboard/src/main/java/com/jay/easykeyboard/SystemKeyboard.java
new file mode 100644
index 0000000..ad87de9
--- /dev/null
+++ b/easykeyboard/src/main/java/com/jay/easykeyboard/SystemKeyboard.java
@@ -0,0 +1,179 @@
+package com.jay.easykeyboard;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Paint;
+import android.graphics.drawable.Drawable;
+import android.inputmethodservice.Keyboard;
+import android.inputmethodservice.KeyboardView;
+import android.support.annotation.Nullable;
+import android.util.AttributeSet;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.widget.EditText;
+import android.widget.FrameLayout;
+
+import com.jay.easykeyboard.constant.KeyboardConfig;
+import com.jay.easykeyboard.constant.Util;
+import com.jay.easykeyboard.function.SystemOnKeyboardActionListener;
+import com.jay.easykeyboard.keyboard.MyKeyboardView;
+
+/**
+ * Created by huangjie on 2018/2/3.
+ * 类名:
+ * 说明:使用系统API实现的键盘
+ */
+
+public class SystemKeyboard extends FrameLayout {
+ private static final String TAG = "SystemKeyboard";
+ private MyKeyboardView keyboardView;
+ private Drawable keybgDrawable;
+ private Keyboard mKeyboard;
+
+ public interface KeyUI {
+ Paint paintConfig(Paint mPaint);
+ }
+
+ public SystemKeyboard(Context context) {
+ this(context, null);
+ }
+
+ public SystemKeyboard(Context context, @Nullable AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public SystemKeyboard(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ init(context, attrs);
+ }
+
+ private void init(Context context, @Nullable AttributeSet attrs) {
+ TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SystemKeyboard);
+ if (a.hasValue(R.styleable.SystemKeyboard_xmlLayoutResId)) {
+ int xmlLayoutResId = a.getResourceId(R.styleable.SystemKeyboard_xmlLayoutResId, 0);
+ initKeyBoard(context, xmlLayoutResId);
+ }
+ if (a.hasValue(R.styleable.SystemKeyboard_keyViewbg))
+ keybgDrawable = a.getDrawable(R.styleable.SystemKeyboard_keyViewbg);
+// if (a.hasValue(R.styleable.SystemKeyboard_randomkeys)) {
+// boolean randomkeys = a.getBoolean(R.styleable.SystemKeyboard_randomkeys, false);
+// if (randomkeys) {
+// randomdigkey();
+// }
+// }
+ a.recycle();
+ }
+
+ private void initKeyBoard(Context context, int xmlLayoutResId) {
+ mKeyboard = new Keyboard(context, xmlLayoutResId);
+ keyboardView = (MyKeyboardView) LayoutInflater.from(context).inflate(R.layout.mykeyboardview, null);
+ keyboardView.setKeyboard(mKeyboard);
+ keyboardView.setEnabled(true);
+ keyboardView.setPreviewEnabled(false);
+ if (null != keybgDrawable) {
+ keyboardView.setKeybgDrawable(keybgDrawable);
+ }
+ setOnKeyboardActionListener(new SystemOnKeyboardActionListener());
+ this.addView(keyboardView);
+ }
+
+
+// private void randomdigkey() {
+// if (mKeyboard == null) {
+// Log(TAG + "==>randomdigkey方法keyboard为空");
+// return;
+// }
+// List keyList = mKeyboard.getKeys();
+// // 查找出0-9的数字键
+// List newkeyList = new ArrayList();
+// for (int i = 0, size = keyList.size(); i < size; i++) {
+// Keyboard.Key key = keyList.get(i);
+// CharSequence label = key.label;
+// if (label != null && Util.isNumeric(label.toString())) {
+// newkeyList.add(key);
+// }
+// }
+// int count = newkeyList.size();
+// List resultList = new ArrayList();
+// LinkedList temp = new LinkedList();
+// for (int i = 0; i < count; i++) {
+// temp.add(new KeyModel(48 + i, i + ""));
+// }
+// Random rand = new SecureRandom();
+// rand.setSeed(SystemClock.currentThreadTimeMillis());
+// for (int i = 0; i < count; i++) {
+// int num = rand.nextInt(count - i);
+// KeyModel model = temp.get(num);
+// resultList.add(new KeyModel(model.getCode(), model.getLable()));
+// temp.remove(num);
+// }
+// for (int i = 0, size = newkeyList.size(); i < size; i++) {
+// Keyboard.Key newKey = newkeyList.get(i);
+// KeyModel resultmodle = resultList.get(i);
+// newKey.label = resultmodle.getLable();
+// newKey.codes[0] = resultmodle.getCode();
+// }
+// }
+
+ public MyKeyboardView getKeyboardView() {
+ return keyboardView;
+ }
+
+ public Keyboard getKeyboard() {
+ return mKeyboard;
+ }
+
+ public void UserNativeKeyboard(boolean isUser) {
+ if (isUser) setVisibility(GONE);
+ else setVisibility(VISIBLE);
+ }
+
+ public void UserNativeKeyboard(boolean isUser, Activity activity, EditText editText) {
+ if (isUser) {
+ setVisibility(GONE);
+ Util.openKeyboard(activity, editText);
+ } else {
+ setVisibility(VISIBLE);
+ Util.hideKeyboard(activity);
+ }
+ }
+
+ public void setXmlLayoutResId(int xmlLayoutResId) {
+ initKeyBoard(getContext(), xmlLayoutResId);
+ }
+
+// public void isRandomkeys(boolean isRandomkeys) {
+// if (isRandomkeys) randomdigkey();
+// }
+
+ public void setKeybgDrawable(Drawable keybgDrawable) {
+ this.keybgDrawable = keybgDrawable;
+ if (null != keyboardView)
+ keyboardView.setKeybgDrawable(keybgDrawable);
+ }
+
+ public void setOnKeyboardActionListener(KeyboardView.OnKeyboardActionListener onKeyboardActionListener){
+ if (onKeyboardActionListener!=null)
+ keyboardView.setOnKeyboardActionListener(onKeyboardActionListener);
+ }
+
+ public void setKeyboardUI(KeyUI ui) {
+ if (null != ui) {
+ keyboardView.setPaint(ui.paintConfig(keyboardView.getPaint()));
+ }
+ }
+
+
+ public void recycle() {
+ keyboardView.setOnKeyboardActionListener(null);
+ keyboardView = null;
+ mKeyboard = null;
+ }
+
+ private void Log(String value) {
+ if (KeyboardConfig.openLog) {
+ Log.i(TAG, value);
+ }
+ }
+}
diff --git a/easykeyboard/src/main/java/com/jay/easykeyboard/base/KeyBoardEditText.java b/easykeyboard/src/main/java/com/jay/easykeyboard/base/KeyBoardEditText.java
new file mode 100644
index 0000000..c06ec8c
--- /dev/null
+++ b/easykeyboard/src/main/java/com/jay/easykeyboard/base/KeyBoardEditText.java
@@ -0,0 +1,170 @@
+package com.jay.easykeyboard.base;
+
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.Rect;
+import android.support.v7.widget.AppCompatEditText;
+import android.util.AttributeSet;
+import android.view.ActionMode;
+import android.view.Gravity;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.view.WindowManager;
+import android.view.inputmethod.EditorInfo;
+import android.widget.PopupWindow;
+
+import com.jay.easykeyboard.R;
+import com.jay.easykeyboard.constant.Util;
+
+/**
+ * Created by huangjie on 2018/2/5.
+ * 类名:
+ * 说明:
+ */
+
+public abstract class KeyBoardEditText extends AppCompatEditText {
+ private Activity activity;
+ private int real_scontenth;
+ private PopupWindow mKeyboardWindow;
+ private Window mWindow;
+ private View mDecorView;
+ private View mContentView;
+ private int scrolldis;
+
+
+ public KeyBoardEditText(Context context) {
+ this(context,null);
+ }
+
+ public KeyBoardEditText(Context context, AttributeSet attrs) {
+ this(context, attrs,0);
+ }
+
+ public KeyBoardEditText(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ init(context);
+ }
+
+ private void init(Context context) {
+ if (context instanceof Activity) activity = (Activity) context;
+ real_scontenth = Util.getContentHeight(context);
+ this.setImeOptions(EditorInfo.IME_FLAG_NO_EXTRACT_UI);
+ if (this.getText() != null) {
+ this.setSelection(this.getText().length());
+ }
+
+ }
+
+ protected void initPopWindow(View contentView) {
+ mKeyboardWindow = new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.WRAP_CONTENT);
+ mKeyboardWindow.setAnimationStyle(R.style.AnimationFade);
+ mKeyboardWindow.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
+ mKeyboardWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
+ @Override
+ public void onDismiss() {
+ // TODO Auto-generated method stub
+ if (scrolldis > 0) {
+ int temp = scrolldis;
+ scrolldis = 0;
+ if (null != mContentView) {
+ mContentView.scrollBy(0, -temp);
+ }
+ }
+ }
+ });
+ }
+
+
+ @Override
+ protected void onAttachedToWindow() {
+ super.onAttachedToWindow();
+ if (null != activity) {
+ mWindow = activity.getWindow();
+ mDecorView = mWindow.getDecorView();
+ mContentView = mDecorView.findViewById(Window.ID_ANDROID_CONTENT);
+ }
+ Util.closeKeyboard(getContext(), this);
+ }
+
+ public void recycle(){
+ mKeyboardWindow = null;
+ mDecorView = null;
+ mContentView = null;
+ mWindow = null;
+ activity = null;
+ }
+
+
+
+
+ protected void showKeyboardWindow() {
+ if (null != mKeyboardWindow) {
+ if (!mKeyboardWindow.isShowing()) {
+ mKeyboardWindow.showAtLocation(this.mDecorView, Gravity.BOTTOM, 0, 0);
+ if (null != mDecorView && null != mContentView) {
+ View popContentView = mKeyboardWindow.getContentView();
+ popContentView.post(new Runnable() {
+ @Override
+ public void run() {
+ int[] pos = new int[2];
+ getLocationOnScreen(pos);
+ float height = mKeyboardWindow.getContentView().getMeasuredHeight();
+ Rect outRect = new Rect();
+ mDecorView.getWindowVisibleDisplayFrame(outRect);
+ int screen = real_scontenth;
+ scrolldis = (int) ((pos[1] + getMeasuredHeight() - outRect.top) - (screen - height));
+ if (scrolldis > 0) {
+ mContentView.scrollBy(0, scrolldis);
+ }
+ }
+ });
+ }
+ }
+ }
+ }
+
+ protected void dismissKeyboardWindow() {
+ if (null != mKeyboardWindow) {
+ if (mKeyboardWindow.isShowing()) {
+ mKeyboardWindow.dismiss();
+ }
+ }
+ }
+
+ public PopupWindow getKeyboardWindow() {
+ return mKeyboardWindow;
+ }
+
+
+ /**
+ * 屏蔽EditText长按复制功能,启用后粘贴功能也会失效
+ */
+ public void removeCopyAndPaste() {
+ this.setCustomSelectionActionModeCallback(new ActionMode.Callback() {
+
+ @Override
+ public boolean onCreateActionMode(ActionMode mode, Menu menu) {
+ return false;
+ }
+
+ @Override
+ public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
+ return false;
+ }
+
+ @Override
+ public void onDestroyActionMode(ActionMode mode) {
+
+ }
+
+ @Override
+ public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
+ return false;
+ }
+ });
+ setLongClickable(false);
+ }
+}
diff --git a/easykeyboard/src/main/java/com/jay/easykeyboard/constant/KeyboardConfig.java b/easykeyboard/src/main/java/com/jay/easykeyboard/constant/KeyboardConfig.java
new file mode 100644
index 0000000..a44ead7
--- /dev/null
+++ b/easykeyboard/src/main/java/com/jay/easykeyboard/constant/KeyboardConfig.java
@@ -0,0 +1,11 @@
+package com.jay.easykeyboard.constant;
+
+/**
+ * Created by huangjie on 2018/2/3.
+ * 类名:
+ * 说明:键盘通用配置设置
+ */
+
+public final class KeyboardConfig {
+ public static boolean openLog;
+}
diff --git a/easykeyboard/src/main/java/com/jay/easykeyboard/constant/Util.java b/easykeyboard/src/main/java/com/jay/easykeyboard/constant/Util.java
new file mode 100644
index 0000000..51b31c0
--- /dev/null
+++ b/easykeyboard/src/main/java/com/jay/easykeyboard/constant/Util.java
@@ -0,0 +1,168 @@
+package com.jay.easykeyboard.constant;
+
+import android.app.Activity;
+import android.content.Context;
+import android.os.Build;
+import android.text.InputType;
+import android.util.DisplayMetrics;
+import android.view.Display;
+import android.view.View;
+import android.view.WindowManager;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Created by huangjie on 2018/2/3.
+ * 类名:
+ * 说明:
+ */
+
+public class Util {
+ /**
+ * 密度转换为像素值
+ *
+ * @param dp
+ * @return
+ */
+ public static int dpToPx(Context context, float dp) {
+ final float scale = context.getResources().getDisplayMetrics().density;
+ return (int) (dp * scale + 0.5f);
+ }
+
+ //判断是否是字母
+ public static boolean isLetter(String str) {
+ String wordStr = "abcdefghijklmnopqrstuvwxyz";
+ return wordStr.contains(str.toLowerCase());
+ }
+
+ //判断是否是数字(包含正负数校验)
+ public static boolean isNumeric(String str) {
+ Pattern pattern = Pattern.compile("-?[0-9]+.?[0-9]+");
+ Matcher isNum = pattern.matcher(str);
+ if (!isNum.matches()) {
+ return false;
+ }
+ return true;
+ }
+
+
+ /**
+ * 隐藏软键盘
+ * @param activity
+ */
+ public static void hideKeyboard(Activity activity){
+ View view = activity.getWindow().peekDecorView();
+ if (view != null) {
+ InputMethodManager inputmanger = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);
+ inputmanger.hideSoftInputFromWindow(view.getWindowToken(), 0);
+ }
+ }
+
+ /**
+ * 关闭软键盘
+ * @param context
+ * @param editText
+ */
+ public static void closeKeyboard(Context context, EditText editText) {
+ InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(editText.getWindowToken(), 0);
+ }
+
+ /**
+ * 打开软键盘
+ * @param activity
+ * @param editText
+ */
+ public static void openKeyboard(Activity activity, EditText editText) {
+ InputMethodManager imm = (InputMethodManager)activity.getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.showSoftInput(editText, InputMethodManager.RESULT_SHOWN);
+ imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
+ }
+
+ /*
+ * 关闭软键盘显示游标
+ * */
+ public static void showCursor(Activity activity, EditText editText){
+ if (android.os.Build.VERSION.SDK_INT <= 10) {
+ editText.setInputType(InputType.TYPE_NULL);
+ } else {
+ activity.getWindow().setSoftInputMode(
+ WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
+ try {
+ Class cls = EditText.class;
+ Method setShowSoftInputOnFocus;
+ setShowSoftInputOnFocus = cls.getMethod(
+ "setShowSoftInputOnFocus", boolean.class);
+ setShowSoftInputOnFocus.setAccessible(true);
+ setShowSoftInputOnFocus.invoke(editText, false);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * 获取实际内容高度
+ * @param context
+ * @return
+ */
+ public static int getContentHeight(Context context){
+ int screenh_nonavbar = 0;
+ DisplayMetrics dMetrics = new DisplayMetrics();
+ WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+ if (windowManager!=null) {
+ Display display = windowManager.getDefaultDisplay();
+ display.getMetrics(dMetrics);
+ screenh_nonavbar = dMetrics.heightPixels;
+
+ int ver = Build.VERSION.SDK_INT;
+
+ // 新版本的android 系统有导航栏,造成无法正确获取高度
+ if (ver == 13) {
+ try {
+ Method mt = display.getClass().getMethod("getRealHeight");
+ screenh_nonavbar = (Integer) mt.invoke(display);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else if (ver > 13) {
+ try {
+ Method mt = display.getClass().getMethod("getRawHeight");
+ screenh_nonavbar = (Integer) mt.invoke(display);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ return screenh_nonavbar - getStatusBarHeight(context);
+ }
+
+ /**
+ * 电量栏高度
+ *
+ * @return
+ */
+ public static int getStatusBarHeight(Context context) {
+ Class> c = null;
+ Object obj = null;
+ Field field = null;
+ int x = 0,
+ sbar = 0;
+ try {
+ c = Class.forName("com.android.internal.R$dimen");
+ obj = c.newInstance();
+ field = c.getField("status_bar_height");
+ x = Integer.parseInt(field.get(obj).toString());
+ sbar = context.getResources().getDimensionPixelSize(x);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ }
+
+ return sbar;
+ }
+}
diff --git a/easykeyboard/src/main/java/com/jay/easykeyboard/function/FormatTextWatcher.java b/easykeyboard/src/main/java/com/jay/easykeyboard/function/FormatTextWatcher.java
new file mode 100644
index 0000000..6fe2dc0
--- /dev/null
+++ b/easykeyboard/src/main/java/com/jay/easykeyboard/function/FormatTextWatcher.java
@@ -0,0 +1,113 @@
+package com.jay.easykeyboard.function;
+
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.widget.EditText;
+
+/**
+ * Created by huangjie on 2018/2/5.
+ * 类名:
+ * 说明:
+ */
+
+public class FormatTextWatcher implements TextWatcher {
+
+ private final EditText editText;
+
+ public FormatTextWatcher(EditText editText){
+ this.editText = editText;
+ }
+
+ //间隔位数
+ private int unit = 4;
+ //间隔符
+ private String tag = " ";
+ int beforeTextLength = 0;
+ int afterTextLength = 0;
+ int location = 0;//记录光标的位置
+ boolean isChanging = false;// 是否更换中
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+ beforeTextLength = s.length();
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ afterTextLength = s.length();
+ if (isChanging)
+ return;
+
+ if (beforeTextLength < afterTextLength) {// 字符增加
+ location = editText.getSelectionEnd();
+ setFormatText(s.toString());
+ if (location % (unit + 1) == 0) {
+ editText.setSelection(getLocation(location + 1));
+ } else {
+ editText.setSelection(getLocation(location));
+ }
+ } else if (beforeTextLength > afterTextLength) {// 字符减少
+ location = editText.getSelectionEnd();
+ setFormatText(s.toString());
+ if (location % (unit + 1) == 0) {
+ editText.setSelection(getLocation(location - 1));
+ } else {
+ editText.setSelection(getLocation(location));
+ }
+ }
+ }
+
+
+ private int getLocation(int location) {
+ if (location < 0)
+ return 0;
+ if (location > afterTextLength) {
+ return afterTextLength;
+ }
+ return location;
+ }
+
+ private void setFormatText(String str) {
+ isChanging = true;
+ editText.setText(addTag(str));
+ isChanging = false;
+ }
+
+ /**
+ * 加上标识符
+ *
+ * @param str
+ * @return
+ */
+ private String addTag(String str) {
+ str = replaceTag(str);
+ StringBuilder sb = new StringBuilder();
+ int index = 0;
+ int strLength = str.length();
+ while (index < strLength) {
+ int increment = index + unit;
+ sb.append(str.subSequence(index, index = (increment > strLength) ? strLength : increment));
+ if (increment < strLength) {
+ sb.append(tag);
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * 替换标识符为空格
+ *
+ * @param str
+ * @return
+ */
+ public String replaceTag(String str) {
+ if (str.contains(tag)) {
+ str = str.replace(tag, "");
+ }
+ return str;
+ }
+}
diff --git a/easykeyboard/src/main/java/com/jay/easykeyboard/function/SystemOnKeyboardActionListener.java b/easykeyboard/src/main/java/com/jay/easykeyboard/function/SystemOnKeyboardActionListener.java
new file mode 100644
index 0000000..b0f0d6c
--- /dev/null
+++ b/easykeyboard/src/main/java/com/jay/easykeyboard/function/SystemOnKeyboardActionListener.java
@@ -0,0 +1,96 @@
+package com.jay.easykeyboard.function;
+
+import android.inputmethodservice.Keyboard;
+import android.inputmethodservice.KeyboardView;
+import android.text.Editable;
+import android.widget.EditText;
+import android.widget.PopupWindow;
+
+/**
+ * Created by huangjie on 2018/2/3.
+ * 类名:
+ * 说明:实现该类可单独实现需要的方法,内部实现内容添加
+ */
+
+public class SystemOnKeyboardActionListener implements KeyboardView.OnKeyboardActionListener {
+
+ private EditText editText;
+ private PopupWindow popupWindow;
+
+ public SystemOnKeyboardActionListener(){};
+
+ public SystemOnKeyboardActionListener(EditText editText) {
+ this.editText = editText;
+ }
+
+ public SystemOnKeyboardActionListener(EditText editText, PopupWindow popupWindow) {
+ this.editText = editText;
+ this.popupWindow = popupWindow;
+ }
+
+ public void setEditText(EditText editText) {
+ this.editText = editText;
+ }
+
+ public void setPopupWindow(PopupWindow popupWindow) {
+ this.popupWindow = popupWindow;
+ }
+
+ @Override
+ public void onPress(int primaryCode) {
+
+ }
+
+ @Override
+ public void onRelease(int primaryCode) {
+
+ }
+
+ @Override
+ public void onKey(int primaryCode, int[] keyCodes) {
+ if (null != editText) {
+ Editable editable = editText.getText();
+ int start = editText.getSelectionStart();
+ if (primaryCode == Keyboard.KEYCODE_DONE) {// 隐藏键盘
+ if (null != popupWindow && popupWindow.isShowing()) {
+ popupWindow.dismiss();
+ }
+ } else if (primaryCode == Keyboard.KEYCODE_DELETE) {// 回退
+ if (editable != null && editable.length() > 0) {
+ if (start > 0) {
+ editable.delete(start - 1, start);
+ }
+ }
+ } else if (primaryCode == 152) {
+ editable.clear();
+ } else {
+ editable.insert(start, Character.toString((char) primaryCode));
+ }
+ }
+ }
+
+ @Override
+ public void onText(CharSequence text) {
+
+ }
+
+ @Override
+ public void swipeLeft() {
+
+ }
+
+ @Override
+ public void swipeRight() {
+
+ }
+
+ @Override
+ public void swipeDown() {
+
+ }
+
+ @Override
+ public void swipeUp() {
+
+ }
+}
diff --git a/easykeyboard/src/main/java/com/jay/easykeyboard/keyboard/KeyModel.java b/easykeyboard/src/main/java/com/jay/easykeyboard/keyboard/KeyModel.java
new file mode 100644
index 0000000..a37d6c9
--- /dev/null
+++ b/easykeyboard/src/main/java/com/jay/easykeyboard/keyboard/KeyModel.java
@@ -0,0 +1,33 @@
+package com.jay.easykeyboard.keyboard;
+
+/**
+ * Created by huangjie on 2018/2/3.
+ * 类名:
+ * 说明:
+ */
+
+public class KeyModel {
+ private Integer code;
+ private String label;
+
+ public KeyModel(Integer code, String lable) {
+ this.code = code;
+ this.label = lable;
+ }
+
+ public Integer getCode() {
+ return code;
+ }
+
+ public void setCode(Integer code) {
+ this.code = code;
+ }
+
+ public String getLable() {
+ return label;
+ }
+
+ public void setLabel(String lable) {
+ this.label = lable;
+ }
+}
diff --git a/app/src/main/java/com/example/keybord/keyborddemo/MyKeyboardView.java b/easykeyboard/src/main/java/com/jay/easykeyboard/keyboard/MyKeyboardView.java
similarity index 73%
rename from app/src/main/java/com/example/keybord/keyborddemo/MyKeyboardView.java
rename to easykeyboard/src/main/java/com/jay/easykeyboard/keyboard/MyKeyboardView.java
index 1df2e2f..588bf11 100644
--- a/app/src/main/java/com/example/keybord/keyborddemo/MyKeyboardView.java
+++ b/easykeyboard/src/main/java/com/jay/easykeyboard/keyboard/MyKeyboardView.java
@@ -1,4 +1,4 @@
-package com.example.keybord.keyborddemo;
+package com.jay.easykeyboard.keyboard;
import android.content.Context;
import android.content.res.Resources;
@@ -10,12 +10,16 @@
import android.inputmethodservice.KeyboardView;
import android.util.AttributeSet;
+import com.jay.easykeyboard.R;
+
import java.util.List;
+
public class MyKeyboardView extends KeyboardView {
private Drawable mKeybgDrawable;
- private Resources res;
+ private Rect rect;
+ private Paint paint;
public MyKeyboardView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -28,8 +32,28 @@ public MyKeyboardView(Context context, AttributeSet attrs, int defStyleAttr) {
}
private void initResources(Context context) {
- res = context.getResources();
+ Resources res = context.getResources();
mKeybgDrawable = res.getDrawable(R.drawable.btn_keyboard_key);
+ rect = new Rect();
+ paint = new Paint();
+ paint.setAntiAlias(true);
+ paint.setTextAlign(Paint.Align.CENTER);
+ paint.setTextSize(50);
+ paint.setColor(res.getColor(android.R.color.black));
+ }
+
+ public void setKeybgDrawable(Drawable mKeybgDrawable){
+ this.mKeybgDrawable = mKeybgDrawable;
+ invalidate();
+ }
+
+ public Paint getPaint(){
+ return paint;
+ }
+
+ public void setPaint(Paint paint){
+ this.paint = paint;
+ invalidate();
}
@Override
@@ -43,21 +67,15 @@ public void onDraw(Canvas canvas) {
offsety = 1;
}
int initdrawy = key.y + offsety;
-
- Rect rect = new Rect(key.x, initdrawy, key.x + key.width, key.y
- + key.height);
-
+ rect.left = key.x;
+ rect.top = initdrawy;
+ rect.right = key.x+key.width;
+ rect.bottom = key.y+key.height;
canvas.clipRect(rect);
int[] state = key.getCurrentDrawableState();
mKeybgDrawable.setState(state);
mKeybgDrawable.setBounds(rect);
mKeybgDrawable.draw(canvas);
- Paint paint = new Paint();
- paint.setAntiAlias(true);
- paint.setTextAlign(Paint.Align.CENTER);
- paint.setTextSize(50);
- paint.setColor(res.getColor(R.color.black));
-
if (key.label != null) {
canvas.drawText(
key.label.toString(),
diff --git a/app/src/main/res/anim/dialog_enter.xml b/easykeyboard/src/main/res/anim/dialog_enter.xml
similarity index 100%
rename from app/src/main/res/anim/dialog_enter.xml
rename to easykeyboard/src/main/res/anim/dialog_enter.xml
diff --git a/app/src/main/res/anim/dialog_exit.xml b/easykeyboard/src/main/res/anim/dialog_exit.xml
similarity index 100%
rename from app/src/main/res/anim/dialog_exit.xml
rename to easykeyboard/src/main/res/anim/dialog_exit.xml
diff --git a/app/src/main/res/drawable/bg_keyboard_selector.xml b/easykeyboard/src/main/res/drawable/bg_keyboard_selector.xml
similarity index 100%
rename from app/src/main/res/drawable/bg_keyboard_selector.xml
rename to easykeyboard/src/main/res/drawable/bg_keyboard_selector.xml
diff --git a/app/src/main/res/drawable/btn_keyboard_key.xml b/easykeyboard/src/main/res/drawable/btn_keyboard_key.xml
similarity index 100%
rename from app/src/main/res/drawable/btn_keyboard_key.xml
rename to easykeyboard/src/main/res/drawable/btn_keyboard_key.xml
diff --git a/app/src/main/res/drawable/no_pre.xml b/easykeyboard/src/main/res/drawable/no_pre.xml
similarity index 83%
rename from app/src/main/res/drawable/no_pre.xml
rename to easykeyboard/src/main/res/drawable/no_pre.xml
index 30068f0..0e4f85f 100644
--- a/app/src/main/res/drawable/no_pre.xml
+++ b/easykeyboard/src/main/res/drawable/no_pre.xml
@@ -2,6 +2,6 @@
-
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/pre.xml b/easykeyboard/src/main/res/drawable/pre.xml
similarity index 100%
rename from app/src/main/res/drawable/pre.xml
rename to easykeyboard/src/main/res/drawable/pre.xml
diff --git a/app/src/main/res/drawable/sym_keyboard_delete.png b/easykeyboard/src/main/res/drawable/sym_keyboard_delete.png
similarity index 100%
rename from app/src/main/res/drawable/sym_keyboard_delete.png
rename to easykeyboard/src/main/res/drawable/sym_keyboard_delete.png
diff --git a/easykeyboard/src/main/res/layout/mykeyboardview.xml b/easykeyboard/src/main/res/layout/mykeyboardview.xml
new file mode 100644
index 0000000..d75c9c4
--- /dev/null
+++ b/easykeyboard/src/main/res/layout/mykeyboardview.xml
@@ -0,0 +1,9 @@
+
+
diff --git a/easykeyboard/src/main/res/values/attrs.xml b/easykeyboard/src/main/res/values/attrs.xml
new file mode 100644
index 0000000..ae4aff9
--- /dev/null
+++ b/easykeyboard/src/main/res/values/attrs.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/easykeyboard/src/main/res/values/styles.xml b/easykeyboard/src/main/res/values/styles.xml
new file mode 100644
index 0000000..0aa010c
--- /dev/null
+++ b/easykeyboard/src/main/res/values/styles.xml
@@ -0,0 +1,6 @@
+
+
+
diff --git a/easykeyboard/src/test/java/com/jay/easykeyboard/ExampleUnitTest.java b/easykeyboard/src/test/java/com/jay/easykeyboard/ExampleUnitTest.java
new file mode 100644
index 0000000..5cc431e
--- /dev/null
+++ b/easykeyboard/src/test/java/com/jay/easykeyboard/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package com.jay.easykeyboard;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() throws Exception {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 122a0dc..0276e61 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
-#Mon Dec 28 10:00:20 PST 2015
+#Fri Nov 03 15:28:02 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
diff --git a/settings.gradle b/settings.gradle
index e7b4def..9f8a61d 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':app'
+include ':app', ':easykeyboard'