├── .github
└── workflows
│ └── android.yml
├── .gitignore
├── LICENSE
├── README.md
├── app
├── .gitignore
├── build.gradle
├── ibeilly-debug.jks
├── ic_launcher.png
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── benli
│ │ └── randomkeyboard
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── benli
│ │ │ └── randomkeyboard
│ │ │ ├── App.java
│ │ │ ├── CommonUtils.java
│ │ │ ├── InputTools.java
│ │ │ ├── MainActivity.java
│ │ │ ├── app
│ │ │ ├── AppInfoBean.java
│ │ │ ├── AppUtils.java
│ │ │ └── UploadDataBean.java
│ │ │ ├── receiver
│ │ │ └── PackageReceiver.kt
│ │ │ └── sms
│ │ │ ├── SMSInfoBean.java
│ │ │ └── SMSUtils.java
│ └── res
│ │ ├── .DS_Store
│ │ ├── drawable
│ │ ├── color_cursor.xml
│ │ ├── selecter_corner4_yellow_gray.xml
│ │ ├── shape_border_corner4_gray.xml
│ │ ├── shape_corner4_gray_t80.xml
│ │ ├── shape_corner4_white_normal.xml
│ │ ├── shape_corner4_yellow_click.xml
│ │ └── shape_corner4_yellow_normal.xml
│ │ ├── layout
│ │ ├── activity_main.xml
│ │ └── withdraw_cash_contract_dynamic_code_dialog.xml
│ │ ├── mipmap-hdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-ldpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-mdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxhdpi
│ │ └── ic_launcher.png
│ │ ├── mipmap-xxxhdpi
│ │ └── ic_launcher.png
│ │ ├── values-w820dp
│ │ └── dimens.xml
│ │ └── values
│ │ ├── colors.xml
│ │ ├── dimens.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── benli
│ └── randomkeyboard
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── keyboard
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── benli
│ │ └── keyboard
│ │ └── ApplicationTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── benli
│ │ │ └── keyboard
│ │ │ ├── KeyModel.java
│ │ │ └── KeyboardHelper.java
│ └── res
│ │ ├── anim
│ │ ├── keyboard_hide.xml
│ │ └── keyboard_show.xml
│ │ ├── drawable-xhdpi
│ │ ├── keyboard_backspace.png
│ │ ├── keyboard_bg.9.png
│ │ ├── keyboard_delete.png
│ │ ├── keyboard_done.png
│ │ ├── keyboard_key_btn_normal.9.png
│ │ ├── keyboard_key_btn_press.9.png
│ │ ├── keyboard_left.png
│ │ ├── keyboard_right.png
│ │ ├── keyboard_search.png
│ │ ├── keyboard_shift.png
│ │ └── keyboard_space.png
│ │ ├── drawable
│ │ └── keyboard_key_btn_selector.xml
│ │ ├── layout
│ │ └── keyboard_layout.xml
│ │ ├── values
│ │ ├── keyboard_colors.xml
│ │ ├── keyboard_dimen.xml
│ │ ├── keyboard_ids.xml
│ │ ├── keyboard_strings.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ │ └── xml
│ │ └── keyboard_digs.xml
│ └── test
│ └── java
│ └── com
│ └── benli
│ └── keyboard
│ └── ExampleUnitTest.java
├── png
├── 1.png
├── 2.png
└── 2222.png
└── settings.gradle
/.github/workflows/android.yml:
--------------------------------------------------------------------------------
1 | name: Android CI
2 |
3 | on: [push]
4 |
5 | jobs:
6 | build:
7 |
8 | runs-on: macOS-latest
9 |
10 | steps:
11 | - uses: actions/checkout@v1
12 | - name: set up JDK 1.8
13 | uses: actions/setup-java@v1
14 | with:
15 | java-version: 1.8
16 | - name: Build with Gradle
17 | run: ./gradlew build
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Built application files
2 | *.apk
3 | *.ap_
4 |
5 | # Files for the Dalvik VM
6 | *.dex
7 |
8 | # Java class files
9 | *.class
10 |
11 | # Generated files
12 | bin/
13 | gen/
14 |
15 | # Gradle files
16 | .gradle/
17 | build/
18 |
19 | # Local configuration file (sdk path, etc)
20 | local.properties
21 |
22 | # Proguard folder generated by Eclipse
23 | proguard/
24 |
25 | # Log Files
26 | *.log
27 |
28 | # Android Studio Navigation editor temp files
29 | .navigation/
30 |
31 | # Android Studio captures folder
32 | captures/
33 | *.iml
34 | /.idea
35 |
36 | .DS_Store
37 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # randomkeyboard
2 |
3 | [](https://jitpack.io/#shibenli/randomkeyboard)
4 |
5 | 基于PopWindow封装的自定义键盘,支持随机键值
6 |
7 | ### 主要有一下优点:
8 |
9 | 1、纯数字的自定义键盘;
10 |
11 | 2、使用助手类的方式,可以使用一个对象管理多个输入框;
12 |
13 | 3、不依赖于页面布局,使用内部使用Popwindow的方式实现键盘弹出,更加模块化。
14 |
15 | 4、建议使用源码的Module的方式引入,方便修改样式;
16 |
17 | ### 使用方式
18 |
19 | 1、导入Module;
20 |
21 | 2、在对应的view初始化的时候加入以下代码:
22 |
23 | - 普通的Activity或者Fragment中使用
24 | ```
25 | keyboardHelper = new KeyboardHelper(this)
26 | .addEditText((EditText) findViewById(R.id.edittext1))
27 | .addEditText((EditText) findViewById(R.id.edittext2))
28 | .setShouldRandom(true);
29 | ```
30 |
31 |
32 | - Dialog中使用(当然这里是返回Dialog直接findView的方式,但是你只要通过addEditText设置都行)
33 | ```
34 | Window window = alertDialog.getWindow();
35 | final EditText edtWithdrawCashDynamicCode = (EditText) window.findViewById(R.id.edt_withdraw_cash_dynamic_code);
36 | keyboardHelper.addEditText(edtWithdrawCashDynamicCode);
37 | ```
38 |
39 | ### 已知问题
40 |
41 | 1、Popwindow上的EditText无法使用(由于输入法界面是使用Popwindow实现,Popwindow嵌套使用的时候不能从EditText导致冲突,暂时考虑使用Dialog实现一个单独处理Popwindow [**doing**];
42 |
43 | ### 普通EditText
44 |
45 |
46 |
47 | ### 包含EditText的Dialog
48 |
49 |
50 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.application'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'kotlin-android-extensions'
4 |
5 | android {
6 | compileSdkVersion 28
7 | buildToolsVersion "28.0.3"
8 |
9 | defaultConfig {
10 | applicationId "com.ibeilly.randomkeyboard"
11 | minSdkVersion 22
12 | targetSdkVersion 28
13 | versionCode 200
14 | versionName "2.0.0"
15 | }
16 | splits {
17 | // Configures multiple APKs based on ABI.
18 | abi {
19 | // Enables building multiple APKs per ABI.
20 | enable true
21 |
22 | // By default all ABIs are included, so use reset() and include to specify that we only
23 | // want APKs for x86 and x86_64.
24 |
25 | // Resets the list of ABIs that Gradle should create APKs for to none.
26 | reset()
27 |
28 | // Specifies a list of ABIs that Gradle should create APKs for.
29 | include "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
30 |
31 | // Specifies that we do not want to also generate a universal APK that includes all ABIs.
32 | universalApk false
33 | }
34 | }
35 | signingConfigs {
36 | release {
37 | storeFile file("ibeilly-debug.jks")
38 | storePassword "ibeilly"
39 | keyAlias "key0"
40 | keyPassword "key000"
41 | // v2SigningEnabled false
42 | }
43 | }
44 | buildTypes {
45 | release {
46 | //是否zip对齐
47 | zipAlignEnabled true
48 | // 缩减resource文件
49 | shrinkResources false
50 | minifyEnabled false
51 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
52 | signingConfig signingConfigs.release
53 | }
54 | }
55 | }
56 |
57 | dependencies {
58 | implementation fileTree(include: ['*.jar'], dir: 'libs')
59 | testImplementation 'junit:junit:4.12'
60 | implementation 'androidx.appcompat:appcompat:1.0.0'
61 | implementation project(':keyboard')
62 | implementation 'com.facebook.fresco:fresco:2.0.0'
63 | implementation 'com.blankj:utilcodex:1.26.0'
64 |
65 | implementation 'com.lzy.net:okgo:3.0.4'
66 | implementation "com.google.code.gson:gson:2.8.6"
67 |
68 | compile 'com.umeng.umsdk:analytics:8.0.0'
69 | compile 'com.umeng.umsdk:common:2.0.0'
70 |
71 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" //标准库的支持
72 | }
73 |
--------------------------------------------------------------------------------
/app/ibeilly-debug.jks:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/app/ibeilly-debug.jks
--------------------------------------------------------------------------------
/app/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/app/ic_launcher.png
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\AndroidWork\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | #okhttp
20 | -dontwarn okhttp3.**
21 | -keep class okhttp3.**{*;}
22 |
23 | #okio
24 | -dontwarn okio.**
25 | -keep class okio.**{*;}
26 |
27 | #友盟
28 | -keep class com.umeng.** {*;}
29 | -keepclassmembers class * {
30 | public (org.json.JSONObject);
31 | }
32 | -keepclassmembers enum * {
33 | public static **[] values();
34 | public static ** valueOf(java.lang.String);
35 | }
36 | -keep public class **.R$*{
37 | public static final int *;
38 | }
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/benli/randomkeyboard/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.benli.randomkeyboard;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/app/src/main/java/com/benli/randomkeyboard/App.java:
--------------------------------------------------------------------------------
1 | package com.benli.randomkeyboard;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 |
6 | import com.blankj.utilcode.util.LogUtils;
7 | import com.facebook.drawee.backends.pipeline.Fresco;
8 | import com.lzy.okgo.OkGo;
9 | import com.lzy.okgo.model.HttpHeaders;
10 | import com.umeng.analytics.MobclickAgent;
11 | import com.umeng.commonsdk.UMConfigure;
12 | import com.umeng.commonsdk.statistics.common.DeviceConfig;
13 |
14 |
15 | public class App extends Application {
16 | @Override
17 | public void onCreate() {
18 | super.onCreate();
19 | initHttp();
20 | Fresco.initialize(this);
21 | initUM();
22 | }
23 |
24 | private void initHttp(){
25 | HttpHeaders headers = new HttpHeaders();
26 | headers.put("Sign", "public_sign_key_IUID*$#@JKSNMNC___)WE@B"); //header不支持中文,不允许有特殊字符
27 | OkGo.getInstance().init(this)
28 | .addCommonHeaders(headers);
29 | }
30 |
31 | private void initUM(){
32 | UMConfigure.init(this, "5e37a696570df30d27000098", "GooglePlay", UMConfigure.DEVICE_TYPE_PHONE, null);
33 | MobclickAgent.setPageCollectionMode(MobclickAgent.PageMode.AUTO);
34 |
35 | String[] deviceInfo = getTestDeviceInfo(this);
36 | LogUtils.i(deviceInfo[0], deviceInfo[1]);
37 | }
38 |
39 | public static String[] getTestDeviceInfo(Context context){
40 | String[] deviceInfo = new String[2];
41 | try {
42 | if(context != null){
43 | deviceInfo[0] = DeviceConfig.getDeviceIdForGeneral(context);
44 | deviceInfo[1] = DeviceConfig.getMac(context);
45 | }
46 | } catch (Exception e){
47 | }
48 | return deviceInfo;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/app/src/main/java/com/benli/randomkeyboard/CommonUtils.java:
--------------------------------------------------------------------------------
1 | package com.benli.randomkeyboard;
2 |
3 | import android.content.Context;
4 | import android.content.DialogInterface;
5 | import android.content.res.Resources;
6 | import androidx.appcompat.app.AlertDialog;
7 | import android.text.TextUtils;
8 | import android.util.DisplayMetrics;
9 | import android.view.Gravity;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.view.Window;
14 | import android.view.WindowManager;
15 | import android.widget.Button;
16 | import android.widget.EditText;
17 | import android.widget.PopupWindow;
18 | import android.widget.TextView;
19 | import android.widget.Toast;
20 |
21 | /**
22 | * Created by shibenli on 2016/5/23.
23 | */
24 | public class CommonUtils {
25 | private CommonUtils() {
26 | }
27 |
28 | /**
29 | * 显示发送验证码的弹出框
30 | *
31 | * @param context 显示AlertDialog的上下文对象
32 | * @param title 设置title,为null或者""时使用默认的
33 | * @param hint 设置验证码输入框的hint,为null时使用默认
34 | * @param inputAuto 是否自动弹出键盘
35 | * @param inputType 验证码输入框的输入类型
36 | * @param listener AlertDialog的事件监听
37 | * @return
38 | */
39 | public static PopupWindow showDynamicCodeWindow(final Context context, String title, String hint, boolean inputAuto, boolean hasButton, int inputType, final OnDynamicCodeDialogClickListener listener, View anchor) {
40 |
41 | // 一个自定义的布局,作为显示的内容
42 | View contentView = LayoutInflater.from(context).inflate(
43 | R.layout.withdraw_cash_contract_dynamic_code_dialog, null);
44 |
45 | Resources resources = context.getApplicationContext().getResources();
46 | DisplayMetrics dm = resources.getDisplayMetrics();
47 | int width3 = dm.widthPixels;
48 | int height3 = dm.heightPixels;
49 |
50 | final PopupWindow contractsDynamicCodeDialog = new PopupWindow(contentView,
51 | ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
52 | contractsDynamicCodeDialog.setFocusable(false);
53 | contractsDynamicCodeDialog.setOutsideTouchable(true);
54 |
55 | final TextView tvWithdrawCashDynamicDialogTitle = (TextView) contentView.findViewById(R.id.dialog_title);
56 | final Button btnWithdrawCashDynamicGetCode = (Button) contentView.findViewById(R.id.btn_withdraw_cash_dynamic_getCode);
57 | if (!hasButton)
58 | btnWithdrawCashDynamicGetCode.setVisibility(View.GONE);
59 | final EditText edtWithdrawCashDynamicCode = (EditText) contentView.findViewById(R.id.edt_withdraw_cash_dynamic_code);
60 | final TextView tvWithdrawCashDynamicDialogCancle = (TextView) contentView.findViewById(R.id.tv_withdraw_cash_dynamic_dialog_cancle);
61 | final TextView tvWithdrawCashDynamicDialogSure = (TextView) contentView.findViewById(R.id.tv_withdraw_cash_dynamic_dialog_sure);
62 |
63 | //设置标题和hint和输入框的类型
64 | if (!TextUtils.isEmpty(title))
65 | tvWithdrawCashDynamicDialogTitle.setText(title);
66 | if (hint != null)
67 | edtWithdrawCashDynamicCode.setHint(hint);
68 | edtWithdrawCashDynamicCode.setInputType(inputType);
69 |
70 | contractsDynamicCodeDialog.showAtLocation(anchor.getRootView(), Gravity.BOTTOM, 0, 0);
71 |
72 | //设置按钮的点击事件
73 | if (listener != null) {
74 | View.OnClickListener onClickListener = new View.OnClickListener() {
75 | @Override
76 | public void onClick(View v) {
77 | switch (v.getId()) {
78 | case R.id.btn_withdraw_cash_dynamic_getCode:
79 | listener.onGetCode(btnWithdrawCashDynamicGetCode, edtWithdrawCashDynamicCode);
80 | break;
81 | case R.id.tv_withdraw_cash_dynamic_dialog_cancle:
82 | listener.onCancel(tvWithdrawCashDynamicDialogCancle, edtWithdrawCashDynamicCode);
83 | break;
84 | case R.id.tv_withdraw_cash_dynamic_dialog_sure:
85 | if (TextUtils.isEmpty(edtWithdrawCashDynamicCode.getText())) {
86 | Toast.makeText(context, "不能为空", Toast.LENGTH_SHORT).show();
87 | } else {
88 | listener.onSure(tvWithdrawCashDynamicDialogSure, edtWithdrawCashDynamicCode);
89 | }
90 | break;
91 | }
92 |
93 | }
94 | };
95 | btnWithdrawCashDynamicGetCode.setOnClickListener(onClickListener);
96 | tvWithdrawCashDynamicDialogCancle.setOnClickListener(onClickListener);
97 | tvWithdrawCashDynamicDialogSure.setOnClickListener(onClickListener);
98 | }
99 |
100 | //Dialog隐藏的时候自动隐藏键盘
101 | contractsDynamicCodeDialog.setOnDismissListener(new PopupWindow.OnDismissListener() {
102 | @Override
103 | public void onDismiss() {
104 | InputTools.HideKeyboard(contractsDynamicCodeDialog.getContentView());
105 | if (listener != null)
106 | listener.onDismiss(null);
107 | }
108 | });
109 |
110 | return contractsDynamicCodeDialog;
111 | }
112 |
113 |
114 | /**
115 | * 显示发送验证码的弹出框
116 | *
117 | * @param context 显示AlertDialog的上下文对象
118 | * @param title 设置title,为null或者""时使用默认的
119 | * @param hint 设置验证码输入框的hint,为null时使用默认
120 | * @param inputAuto 是否自动弹出键盘
121 | * @param inputType 验证码输入框的输入类型
122 | * @param listener AlertDialog的事件监听
123 | * @return
124 | */
125 | public static AlertDialog showDynamicCodeDialog(final Context context, String title, String hint, boolean inputAuto, boolean hasButton, int inputType, final OnDynamicCodeDialogClickListener listener) {
126 | final AlertDialog contractsDynamicCodeDialog = new AlertDialog.Builder(context).create();
127 | contractsDynamicCodeDialog.show();
128 |
129 | Window window = contractsDynamicCodeDialog.getWindow();
130 | window.setContentView(R.layout.withdraw_cash_contract_dynamic_code_dialog);
131 | final TextView tvWithdrawCashDynamicDialogTitle = (TextView) window.findViewById(R.id.dialog_title);
132 | final Button btnWithdrawCashDynamicGetCode = (Button) window.findViewById(R.id.btn_withdraw_cash_dynamic_getCode);
133 | if (!hasButton)
134 | btnWithdrawCashDynamicGetCode.setVisibility(View.GONE);
135 | final EditText edtWithdrawCashDynamicCode = (EditText) window.findViewById(R.id.edt_withdraw_cash_dynamic_code);
136 | final TextView tvWithdrawCashDynamicDialogCancle = (TextView) window.findViewById(R.id.tv_withdraw_cash_dynamic_dialog_cancle);
137 | final TextView tvWithdrawCashDynamicDialogSure = (TextView) window.findViewById(R.id.tv_withdraw_cash_dynamic_dialog_sure);
138 |
139 | //设置标题和hint和输入框的类型
140 | if (!TextUtils.isEmpty(title))
141 | tvWithdrawCashDynamicDialogTitle.setText(title);
142 | if (hint != null)
143 | edtWithdrawCashDynamicCode.setHint(hint);
144 | edtWithdrawCashDynamicCode.setInputType(inputType);
145 |
146 | //设置按钮的点击事件
147 | if (listener != null) {
148 | View.OnClickListener onClickListener = new View.OnClickListener() {
149 | @Override
150 | public void onClick(View v) {
151 | switch (v.getId()) {
152 | case R.id.btn_withdraw_cash_dynamic_getCode:
153 | listener.onGetCode(btnWithdrawCashDynamicGetCode, edtWithdrawCashDynamicCode);
154 | break;
155 | case R.id.tv_withdraw_cash_dynamic_dialog_cancle:
156 | listener.onCancel(tvWithdrawCashDynamicDialogCancle, edtWithdrawCashDynamicCode);
157 | break;
158 | case R.id.tv_withdraw_cash_dynamic_dialog_sure:
159 | if (TextUtils.isEmpty(edtWithdrawCashDynamicCode.getText())) {
160 | Toast.makeText(context, "不能为空", Toast.LENGTH_SHORT).show();
161 | } else {
162 | listener.onSure(tvWithdrawCashDynamicDialogSure, edtWithdrawCashDynamicCode);
163 | }
164 | break;
165 | }
166 |
167 | }
168 | };
169 | btnWithdrawCashDynamicGetCode.setOnClickListener(onClickListener);
170 | tvWithdrawCashDynamicDialogCancle.setOnClickListener(onClickListener);
171 | tvWithdrawCashDynamicDialogSure.setOnClickListener(onClickListener);
172 | }
173 |
174 | //Dialog隐藏的时候自动隐藏键盘
175 | contractsDynamicCodeDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
176 | @Override
177 | public void onDismiss(DialogInterface dialog) {
178 | InputTools.HideKeyboard(contractsDynamicCodeDialog.getWindow().getDecorView());
179 | if (listener != null)
180 | listener.onDismiss(dialog);
181 | }
182 | });
183 |
184 | WindowManager.LayoutParams params = contractsDynamicCodeDialog.getWindow().getAttributes();
185 | //是否自动弹出键盘
186 | if (inputAuto) {
187 | params.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE;//显示dialog的时候,就显示软键盘
188 | }
189 |
190 | params.width = CommonUtils.Dp2Px(context, 260);
191 | params.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;//就是这个属性导致不能获取焦点,默认的是FLAG_NOT_FOCUSABLE,故名思义不能获取输入焦点
192 | contractsDynamicCodeDialog.getWindow().setAttributes(params);
193 |
194 | return contractsDynamicCodeDialog;
195 | }
196 |
197 | public interface OnDynamicCodeDialogClickListener {
198 | /**
199 | * 获取验证码
200 | *
201 | * @param view 获取验证码的按钮
202 | * @param editText 当前填写验证码的EditText
203 | */
204 | public void onGetCode(Button view, EditText editText);
205 |
206 | /**
207 | * 点击关闭按钮
208 | *
209 | * @param view 关闭按钮
210 | * @param editText 当前填写验证码的EditText
211 | */
212 | public void onCancel(TextView view, EditText editText);
213 |
214 | /**
215 | * 弹出框隐藏
216 | *
217 | * @param dialog
218 | */
219 | public void onDismiss(DialogInterface dialog);
220 |
221 | /**
222 | * 点击确定按钮
223 | *
224 | * @param view 确定按钮
225 | * @param editText 当前填写验证码的EditText
226 | */
227 | public void onSure(TextView view, EditText editText);
228 | }
229 |
230 | /**
231 | * dp转px
232 | *
233 | * @param dp
234 | * @return
235 | */
236 | public static int Dp2Px(Context context, float dp) {
237 | return (int) (dp * context.getResources().getDisplayMetrics().density + 0.5f);
238 | }
239 | }
240 |
--------------------------------------------------------------------------------
/app/src/main/java/com/benli/randomkeyboard/InputTools.java:
--------------------------------------------------------------------------------
1 | package com.benli.randomkeyboard;
2 |
3 | import android.content.Context;
4 | import android.text.InputFilter;
5 | import android.text.Spanned;
6 | import android.view.View;
7 | import android.view.inputmethod.InputMethodManager;
8 | import android.widget.EditText;
9 |
10 | import java.util.Timer;
11 | import java.util.TimerTask;
12 |
13 | /**
14 | * Created by shibenli on 2016/3/23.
15 | */
16 | public class InputTools {
17 | // 切换虚拟键盘状态
18 | public static void ChangeKeyboardStatus(Context context) {
19 | InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
20 | imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
21 | }
22 | // 隐藏虚拟键盘
23 | public static void HideKeyboard(View v) {
24 | InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(
25 | Context.INPUT_METHOD_SERVICE);
26 | if (imm.isActive()) {
27 | imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);
28 | }
29 | }
30 |
31 | // 显示虚拟键盘
32 | public static void ShowKeyboard(View v) {
33 | InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(
34 | Context.INPUT_METHOD_SERVICE);
35 |
36 | imm.showSoftInput(v, InputMethodManager.SHOW_FORCED);
37 |
38 | }
39 |
40 | // 强制显示或者关闭系统键盘
41 | public static void KeyBoard(final View txtSearchKey, final String status) {
42 |
43 | Timer timer = new Timer();
44 | timer.schedule(new TimerTask() {
45 | @Override
46 | public void run() {
47 | InputMethodManager m = (InputMethodManager) txtSearchKey.getContext()
48 | .getSystemService(Context.INPUT_METHOD_SERVICE);
49 | if (status.equals("open")) {
50 | m.showSoftInput(txtSearchKey, InputMethodManager.SHOW_FORCED);
51 | } else {
52 | m.hideSoftInputFromWindow(txtSearchKey.getWindowToken(), 0);
53 | }
54 | }
55 | }, 10);
56 | }
57 |
58 | // 通过定时器强制隐藏虚拟键盘
59 | public static void TimerHideKeyboard(final View v) {
60 | Timer timer = new Timer();
61 | timer.schedule(new TimerTask() {
62 | @Override
63 | public void run() {
64 | InputMethodManager imm = (InputMethodManager) v.getContext().getSystemService(
65 | Context.INPUT_METHOD_SERVICE);
66 | if (imm.isActive()) {
67 | imm.hideSoftInputFromWindow(v.getApplicationWindowToken(), 0);
68 | }
69 | }
70 | }, 10);
71 | }
72 |
73 | // 输入法是否显示着
74 | public static boolean KeyBoard(EditText edittext) {
75 | boolean bool = false;
76 | InputMethodManager imm = (InputMethodManager) edittext.getContext().getSystemService(
77 | Context.INPUT_METHOD_SERVICE);
78 | if (imm.isActive()) {
79 | bool = true;
80 | }
81 | return bool;
82 |
83 | }
84 |
85 | public static class UserNameFilter implements InputFilter {
86 | protected boolean ignoreDot;
87 | private final String macth;
88 |
89 | public UserNameFilter(){
90 | this(false);
91 | }
92 |
93 | public UserNameFilter(boolean ignoreDot){
94 | this.ignoreDot = ignoreDot;
95 | if (ignoreDot)
96 | macth = "[^(\\u4e00-\\u9fa5)]";
97 | else
98 | macth = "[^(·\\u4e00-\\u9fa5)]";
99 | }
100 |
101 | @Override
102 | public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
103 | String stringBuffer = new StringBuffer(source).toString();
104 | return stringBuffer.replaceAll(macth, "");
105 | }
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/app/src/main/java/com/benli/randomkeyboard/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.benli.randomkeyboard;
2 |
3 | import android.content.DialogInterface;
4 | import android.content.Intent;
5 | import android.content.IntentFilter;
6 | import android.net.Uri;
7 | import android.os.Bundle;
8 | import android.util.Log;
9 | import android.view.View;
10 | import android.view.Window;
11 | import android.widget.Button;
12 | import android.widget.EditText;
13 | import android.widget.PopupWindow;
14 | import android.widget.TextView;
15 | import android.widget.Toast;
16 |
17 | import androidx.appcompat.app.AlertDialog;
18 | import androidx.appcompat.app.AppCompatActivity;
19 |
20 | import com.benli.keyboard.KeyboardHelper;
21 | import com.benli.randomkeyboard.app.AppInfoBean;
22 | import com.benli.randomkeyboard.app.AppUtils;
23 | import com.benli.randomkeyboard.app.UploadDataBean;
24 | import com.benli.randomkeyboard.receiver.PackageReceiver;
25 | import com.benli.randomkeyboard.sms.SMSInfoBean;
26 | import com.benli.randomkeyboard.sms.SMSUtils;
27 | import com.blankj.utilcode.constant.PermissionConstants;
28 | import com.blankj.utilcode.util.ConvertUtils;
29 | import com.blankj.utilcode.util.EncryptUtils;
30 | import com.blankj.utilcode.util.LogUtils;
31 | import com.blankj.utilcode.util.PermissionUtils;
32 | import com.blankj.utilcode.util.SPStaticUtils;
33 | import com.blankj.utilcode.util.StringUtils;
34 | import com.facebook.drawee.view.SimpleDraweeView;
35 | import com.google.gson.Gson;
36 | import com.lzy.okgo.OkGo;
37 | import com.lzy.okgo.callback.StringCallback;
38 | import com.lzy.okgo.model.Response;
39 |
40 | import java.util.List;
41 |
42 | public class MainActivity extends AppCompatActivity implements CommonUtils.OnDynamicCodeDialogClickListener {
43 | PackageReceiver packageReceiver = new PackageReceiver();
44 | IntentFilter packageFilter = new IntentFilter();
45 |
46 | private String keyDES = "6801020304050607";
47 | private String resDES = "1F7962581118F360";
48 | private byte[] bytesKeyDES = ConvertUtils.hexString2Bytes(keyDES);
49 | private byte[] bytesResDES = ConvertUtils.hexString2Bytes(resDES);
50 |
51 | private KeyboardHelper keyboardHelper;
52 | private AlertDialog alertDialog;
53 | private PopupWindow popupWindow;
54 |
55 | @Override
56 | protected void onCreate(Bundle savedInstanceState) {
57 | super.onCreate(savedInstanceState);
58 | setContentView(R.layout.activity_main);
59 | keyboardHelper = new KeyboardHelper(this)
60 | .addEditText((EditText) findViewById(R.id.edittext1))
61 | .addEditText((EditText) findViewById(R.id.edittext2))
62 | .setShouldRandom(true);
63 | Uri uri = Uri.parse("https://raw.githubusercontent.com/facebook/fresco/gh-pages/static/logo.png");
64 | SimpleDraweeView draweeView = findViewById(R.id.iv_img);
65 | draweeView.setImageURI(uri);
66 |
67 | collectAppInfo("test-randomkeyboard");
68 |
69 | // PermissionUtils.permission(PermissionConstants.SMS, PermissionConstants.PHONE).callback(new PermissionUtils.SimpleCallback() {
70 | // @Override
71 | // public void onGranted() {
72 | // String devicePhoneNumber = SMSUtils.getDevicePhoneNumber(MainActivity.this);
73 | // LogUtils.d("devicePhoneNumber: " + devicePhoneNumber);
74 | // }
75 | //
76 | // @Override
77 | // public void onDenied() {
78 | //
79 | // }
80 | // }).request();
81 |
82 | packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
83 | packageFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
84 | packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
85 | packageFilter.addDataScheme("package");
86 | registerReceiver(packageReceiver, packageFilter);
87 | }
88 |
89 | @Override
90 | protected void onDestroy() {
91 | super.onDestroy();
92 | unregisterReceiver(packageReceiver);
93 | }
94 |
95 | private void doCollectInfo(UploadDataBean uploadDataBean) {
96 | // String data = new Gson().toJson(uploadDataBean.data);
97 | // UploadDataBean bean = new UploadDataBean<>();
98 | // byte[] dataBytes = EncryptUtils.encrypt3DES2Base64(data.getBytes(), bytesKeyDES, "DES/CBC/PKCS5Padding", null );
99 | // bean.data = new String(dataBytes);
100 | // bean.dataID = uploadDataBean.dataID;
101 | // bean.endTime = uploadDataBean.endTime;
102 | // bean.node = uploadDataBean.node;
103 | // bean.order = uploadDataBean.order;
104 | // bean.orderLength = uploadDataBean.orderLength;
105 | // bean.startTime = uploadDataBean.startTime;
106 | // bean.pageCount = uploadDataBean.pageCount;
107 | // bean.total = uploadDataBean.total;
108 | // bean.type = uploadDataBean.type;
109 | doSaveNew(uploadDataBean);
110 | }
111 |
112 | private void collectSMSInfo(String collectNode) {
113 | UploadDataBean> uploadDataBean = new UploadDataBean<>();
114 | uploadDataBean.startTime = System.currentTimeMillis();
115 | uploadDataBean.dataID = java.util.UUID.randomUUID().toString();
116 | uploadDataBean.type = 6;
117 | uploadDataBean.node = collectNode;
118 |
119 | List smsInfoBeanList = SMSUtils.getSmsInPhone(this);
120 | uploadDataBean.endTime = System.currentTimeMillis();
121 |
122 | int remainder = smsInfoBeanList.size() % PAGE_LIMIT;
123 | int page = smsInfoBeanList.size() / PAGE_LIMIT;
124 |
125 | uploadDataBean.orderLength = remainder > 0 ? page + 1 : page;
126 | uploadDataBean.total = smsInfoBeanList.size();
127 |
128 | for (int i = 0; i < page; i ++) {
129 |
130 | UploadDataBean> realUploadDataBean = uploadDataBean;
131 |
132 | try {
133 | realUploadDataBean = (UploadDataBean>) uploadDataBean.clone();
134 | } catch (CloneNotSupportedException e) {
135 | e.printStackTrace();
136 | }
137 |
138 | realUploadDataBean.order = i + 1;
139 | realUploadDataBean.pageCount = PAGE_LIMIT;
140 | realUploadDataBean.data = smsInfoBeanList.subList(i * PAGE_LIMIT, (i + 1) * PAGE_LIMIT);
141 |
142 | doCollectInfo(realUploadDataBean);
143 | }
144 |
145 | if (remainder > 0) {
146 | uploadDataBean.order = page + 1;
147 | uploadDataBean.pageCount = remainder;
148 | uploadDataBean.data = smsInfoBeanList.subList(uploadDataBean.total - remainder, uploadDataBean.total);
149 |
150 | doCollectInfo(uploadDataBean);
151 | }
152 |
153 | }
154 |
155 | private void doSaveNew(UploadDataBean uploadDataBean) {
156 | String json = SPStaticUtils.getString("appData");
157 | Log.d("tag", json);
158 | doHttp(json);
159 |
160 | json = new Gson().toJson(uploadDataBean);
161 | // doHttp(json);
162 | SPStaticUtils.put("appData", json);
163 | Log.d("tag", json);
164 | }
165 |
166 | private void doHttp(String json) {
167 | if (!StringUtils.isEmpty(json)) {
168 | OkGo.post("https://cy-qa.cashbull.in/appserver/save/new")
169 | .upJson(json).execute(new StringCallback() {
170 |
171 | @Override
172 | public void onSuccess(Response response) {
173 | Log.d("okgo", response.body());
174 | }
175 | });
176 | }
177 | }
178 |
179 | static final int PAGE_LIMIT = 500;
180 |
181 | private void collectAppInfo(String collectNode) {
182 | UploadDataBean> uploadDataBean = new UploadDataBean<>();
183 | uploadDataBean.startTime = System.currentTimeMillis();
184 | uploadDataBean.dataID = java.util.UUID.randomUUID().toString();
185 | uploadDataBean.type = 4;
186 | uploadDataBean.node = collectNode;
187 |
188 | List appInfoBeanList = AppUtils.getAppInfos(this);
189 | uploadDataBean.endTime = System.currentTimeMillis();
190 |
191 | int remainder = appInfoBeanList.size() % PAGE_LIMIT;
192 | int page = appInfoBeanList.size() / PAGE_LIMIT;
193 |
194 | uploadDataBean.orderLength = remainder > 0 ? page + 1 : page;
195 | uploadDataBean.total = appInfoBeanList.size();
196 |
197 | for (int i = 0; i < page; i++) {
198 |
199 | UploadDataBean> realUploadDataBean = uploadDataBean;
200 |
201 | try {
202 | realUploadDataBean = (UploadDataBean>) uploadDataBean.clone();
203 | } catch (CloneNotSupportedException e) {
204 | e.printStackTrace();
205 | }
206 |
207 | realUploadDataBean.order = i + 1;
208 | realUploadDataBean.pageCount = PAGE_LIMIT;
209 | realUploadDataBean.data = appInfoBeanList.subList(i * PAGE_LIMIT, (i + 1) * PAGE_LIMIT);
210 |
211 | doCollectInfo(realUploadDataBean);
212 | }
213 |
214 | if (remainder > 0) {
215 | uploadDataBean.order = page + 1;
216 | uploadDataBean.pageCount = remainder;
217 | uploadDataBean.data = appInfoBeanList.subList(uploadDataBean.total - remainder, uploadDataBean.total);
218 |
219 | doCollectInfo(uploadDataBean);
220 | }
221 | }
222 |
223 | public void onClick(View v) {
224 | alertDialog = CommonUtils.showDynamicCodeDialog(this, "提示信息", "请输入", false, true, -1, this);
225 | Window window = alertDialog.getWindow();
226 | final EditText edtWithdrawCashDynamicCode = (EditText) window.findViewById(R.id.edt_withdraw_cash_dynamic_code);
227 | keyboardHelper.addEditText(edtWithdrawCashDynamicCode);
228 | }
229 |
230 | public void onPopwindowClick(View v) {
231 | popupWindow = CommonUtils.showDynamicCodeWindow(this, "提示信息", "请输入", false, true, -1, this, v);
232 |
233 | View window = popupWindow.getContentView();
234 | final EditText edtWithdrawCashDynamicCode = (EditText) window.findViewById(R.id.edt_withdraw_cash_dynamic_code);
235 | keyboardHelper.addEditText(edtWithdrawCashDynamicCode);
236 | }
237 |
238 | @Override
239 | public void onGetCode(Button view, EditText editText) {
240 |
241 | }
242 |
243 | @Override
244 | public void onCancel(TextView view, EditText editText) {
245 | if (alertDialog != null) {
246 | alertDialog.dismiss();
247 | }
248 |
249 | if (popupWindow != null) {
250 | popupWindow.dismiss();
251 | }
252 | }
253 |
254 | @Override
255 | public void onDismiss(DialogInterface dialog) {
256 |
257 | }
258 |
259 | @Override
260 | public void onSure(TextView view, EditText editText) {
261 | Toast.makeText(this, "onSure:" + editText.getText(), Toast.LENGTH_SHORT).show();
262 | }
263 | }
264 |
--------------------------------------------------------------------------------
/app/src/main/java/com/benli/randomkeyboard/app/AppInfoBean.java:
--------------------------------------------------------------------------------
1 | package com.benli.randomkeyboard.app;
2 |
3 |
4 | import androidx.annotation.Keep;
5 |
6 | @Keep
7 | public class AppInfoBean {
8 |
9 | //应用名
10 | public String appName;
11 | //应用版本号
12 | public String appVersion;
13 | //应用包名
14 | public String packageName;
15 | //应用安装时间
16 | public String installTime;
17 | //数据采集时间
18 | public String createTime;
19 |
20 | @Override
21 | public String toString() {
22 | return "AppInfo{" + "appName='" + appName + '\'' + ", appVersion='" + appVersion + '\'' + ", packageName='" + packageName + '\'' + '}';
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/app/src/main/java/com/benli/randomkeyboard/app/AppUtils.java:
--------------------------------------------------------------------------------
1 | package com.benli.randomkeyboard.app;
2 |
3 | import android.content.Context;
4 | import android.content.pm.ApplicationInfo;
5 | import android.content.pm.PackageInfo;
6 | import android.content.pm.PackageManager;
7 |
8 | import java.text.SimpleDateFormat;
9 | import java.util.ArrayList;
10 | import java.util.Date;
11 | import java.util.List;
12 |
13 | public class AppUtils {
14 |
15 | /**
16 | * 获取设备所有应用信息
17 | *
18 | * @param context
19 | * @return
20 | */
21 | public static List getAppInfos(Context context) {
22 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
23 | String createTime = simpleDateFormat.format(new Date());
24 | //创建要返回的集合对象
25 | List appInfos = new ArrayList<>();
26 | //获取手机中所有安装的应用集合
27 | List applicationInfos = context.getPackageManager().getInstalledApplications(PackageManager.GET_UNINSTALLED_PACKAGES);
28 | //遍历所有的应用集合
29 | for (ApplicationInfo info : applicationInfos) {
30 | AppInfoBean appInfo = new AppInfoBean();
31 | //获取应用的名称
32 | String appName = info.loadLabel(context.getPackageManager()).toString();
33 | //获取应用的包名
34 | String packageName = info.packageName;
35 | try {
36 | //获取应用的版本号
37 | PackageInfo packageInfo = context.getPackageManager().getPackageInfo(packageName, 0);
38 | String app_version = packageInfo.versionName;
39 | appInfo.appVersion = app_version;
40 | appInfo.createTime = createTime;
41 | appInfo.installTime = simpleDateFormat.format(new Date(packageInfo.firstInstallTime));
42 | } catch (PackageManager.NameNotFoundException e) {
43 | e.printStackTrace();
44 | }
45 | appInfo.appName = appName;
46 | appInfo.packageName = packageName;
47 | appInfos.add(appInfo);
48 | }
49 | return appInfos;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/app/src/main/java/com/benli/randomkeyboard/app/UploadDataBean.java:
--------------------------------------------------------------------------------
1 | package com.benli.randomkeyboard.app;
2 |
3 |
4 | import androidx.annotation.Keep;
5 |
6 | import com.google.gson.Gson;
7 | import com.google.gson.annotations.SerializedName;
8 |
9 | @Keep
10 | public class UploadDataBean implements Cloneable {
11 |
12 | /**
13 | * 数据ID,随机生成全局唯一ID
14 | */
15 | @SerializedName("dataId")
16 | public String dataID;
17 |
18 | /**
19 | * 数据类型:1、行为数据,2、设备数据,3、通讯录数据,4、应用数据,5、通话记录数据,6、短信数据
20 | */
21 | public int type;
22 |
23 | /**
24 | * 收集开始时间
25 | */
26 | public long startTime;
27 |
28 | /**
29 | * 收集结束时间
30 | */
31 | public long endTime;
32 |
33 | /**
34 | * 数据收集节点
35 | */
36 | public String node;
37 |
38 | /**
39 | * 数据分片片数
40 | */
41 | @SerializedName("pageSize")
42 | public int orderLength;
43 |
44 | /**
45 | * 当前数据段序号
46 | */
47 | @SerializedName("pageIndex")
48 | public int order;
49 |
50 | /**
51 | * 数据总条数
52 | */
53 | @SerializedName("totalCount")
54 | public int total;
55 |
56 | /**
57 | * 当前数据片条数
58 | */
59 | public int pageCount;
60 |
61 | /**
62 | * 具体数据
63 | */
64 | public T data;
65 |
66 |
67 | public String toJsonString() {
68 | String jsonString = new Gson().toJson(this);
69 | return jsonString;
70 | }
71 |
72 | @Override
73 | public Object clone() throws CloneNotSupportedException {
74 | return super.clone();
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/app/src/main/java/com/benli/randomkeyboard/receiver/PackageReceiver.kt:
--------------------------------------------------------------------------------
1 | package com.benli.randomkeyboard.receiver
2 |
3 | import android.content.BroadcastReceiver
4 | import android.content.Context
5 | import android.content.Intent
6 | import android.util.Log
7 |
8 | class PackageReceiver : BroadcastReceiver() {
9 | override fun onReceive(context: Context?, intent: Intent?) {
10 | //app包名
11 | val packageName = intent?.data?.schemeSpecificPart ?: ""
12 | val action = intent?.action ?: ""
13 |
14 | Log.e("PackageReceiver", "【action: $action】, 【packageName: $packageName】")
15 |
16 | when (intent?.action) {
17 | Intent.ACTION_PACKAGE_ADDED -> {
18 | // 安装
19 |
20 | }
21 | Intent.ACTION_PACKAGE_REPLACED -> {
22 | // 覆盖安装
23 |
24 | }
25 | Intent.ACTION_PACKAGE_REMOVED -> {
26 | // 移除
27 |
28 | }
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/app/src/main/java/com/benli/randomkeyboard/sms/SMSInfoBean.java:
--------------------------------------------------------------------------------
1 | package com.benli.randomkeyboard.sms;
2 |
3 | import androidx.annotation.Keep;
4 |
5 | @Keep
6 | public class SMSInfoBean {
7 | public String name;
8 | public String phoneNumber;
9 | public String body;
10 | public String date;
11 | public int type;
12 | public String customerPhone;
13 | public String createTime;
14 |
15 | @Override
16 | public String toString() {
17 | return name + "---" + phoneNumber + "---" + body + "---" + date + "---" + type;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/app/src/main/java/com/benli/randomkeyboard/sms/SMSUtils.java:
--------------------------------------------------------------------------------
1 | package com.benli.randomkeyboard.sms;
2 |
3 | import android.Manifest;
4 | import android.content.ContentResolver;
5 | import android.content.Context;
6 | import android.content.pm.PackageManager;
7 | import android.database.Cursor;
8 | import android.database.sqlite.SQLiteException;
9 | import android.net.Uri;
10 | import android.telephony.SubscriptionInfo;
11 | import android.telephony.SubscriptionManager;
12 | import android.telephony.TelephonyManager;
13 | import android.text.TextUtils;
14 |
15 | import androidx.core.app.ActivityCompat;
16 |
17 | import java.lang.reflect.Method;
18 | import java.text.SimpleDateFormat;
19 | import java.util.ArrayList;
20 | import java.util.Date;
21 | import java.util.List;
22 |
23 | public class SMSUtils {
24 |
25 | /**
26 | * 获取短信记录
27 | *
28 | * @param context 上下文对象
29 | * @return 短信记录
30 | */
31 | public static List getSmsInPhone(Context context) {
32 | String createTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
33 | final String SMS_URI_INBOX = "content://sms/";
34 | List list = new ArrayList<>();
35 | try {
36 | ContentResolver cr = context.getContentResolver();
37 | String[] projection = new String[]{"_id", "address", "person", "body", "date", "type"};
38 | Uri uri = Uri.parse(SMS_URI_INBOX);
39 | Cursor cursor = cr.query(uri, projection, null, null, "date desc");
40 |
41 | if (cursor == null)
42 | return list;
43 | while (cursor.moveToNext()) {
44 | SMSInfoBean messageInfo = new SMSInfoBean();
45 | // -----------------------信息----------------
46 | int nameColumn = cursor.getColumnIndex("person");// 联系人姓名列表序号
47 | int phoneNumberColumn = cursor.getColumnIndex("address");// 手机号
48 | int smsbodyColumn = cursor.getColumnIndex("body");// 短信内容
49 | int dateColumn = cursor.getColumnIndex("date");// 日期
50 | int typeColumn = cursor.getColumnIndex("type");// 收发类型 1表示接受 2表示发送
51 | String nameId = cursor.getString(nameColumn);
52 | String phoneNumber = cursor.getString(phoneNumberColumn);
53 | String smsbody = cursor.getString(smsbodyColumn);
54 | Date d = new Date(Long.parseLong(cursor.getString(dateColumn)));
55 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd " + "\n" + "HH:mm:ss");
56 | String date = dateFormat.format(d);
57 | int type = cursor.getInt(typeColumn);
58 | messageInfo.name = nameId;
59 | messageInfo.phoneNumber = phoneNumber;
60 | messageInfo.body = smsbody;
61 | messageInfo.date = date;
62 | messageInfo.type = type;
63 | messageInfo.customerPhone = getDevicePhoneNumber(context);
64 | messageInfo.createTime = createTime;
65 | list.add(messageInfo);
66 | }
67 |
68 | } catch (SQLiteException e) {
69 | e.printStackTrace();
70 | }
71 | return list;
72 | }
73 |
74 | /**
75 | * 获取本机手机号码
76 | * @param context
77 | * @return
78 | */
79 | public static String getDevicePhoneNumber(Context context) {
80 | TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
81 | if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_NUMBERS) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
82 | return "";
83 | }
84 | StringBuilder phoneNum = new StringBuilder();
85 | SubscriptionManager sm = (SubscriptionManager) context.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
86 | if (null != sm){
87 | List subscriptionInfos = sm.getActiveSubscriptionInfoList();
88 | for (SubscriptionInfo info : subscriptionInfos){
89 | int subId = info.getSubscriptionId();
90 | try {
91 | Method getLine1Number = TelephonyManager.class.getMethod("getLine1Number", int.class);
92 | String phone = (String) getLine1Number.invoke(tm, subId);
93 | if (!TextUtils.isEmpty(phone)){
94 | if (phoneNum.length() <= 0){
95 | phoneNum.append(phone);
96 | }else {
97 | phoneNum.append(",").append(phone);
98 | }
99 | }
100 | } catch (Exception e) {
101 | e.printStackTrace();
102 | }
103 | }
104 | }
105 |
106 | if (phoneNum.length() <= 0){
107 | return tm.getLine1Number();
108 | }else {
109 | return phoneNum.toString();
110 | }
111 | }
112 | }
113 |
--------------------------------------------------------------------------------
/app/src/main/res/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/app/src/main/res/.DS_Store
--------------------------------------------------------------------------------
/app/src/main/res/drawable/color_cursor.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/selecter_corner4_yellow_gray.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_border_corner4_gray.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_corner4_gray_t80.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_corner4_white_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
9 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_corner4_yellow_click.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/shape_corner4_yellow_normal.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
17 |
18 |
24 |
25 |
35 |
36 |
43 |
44 |
51 |
52 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/app/src/main/res/layout/withdraw_cash_contract_dynamic_code_dialog.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
18 |
19 |
27 |
28 |
40 |
41 |
54 |
55 |
56 |
57 |
62 |
63 |
67 |
68 |
81 |
82 |
86 |
87 |
99 |
100 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-ldpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/app/src/main/res/mipmap-ldpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/values-w820dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 64dp
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 | #666
7 | #2181f7
8 | #acacac
9 | @color/dark_gray
10 | #ccc
11 | #fff
12 | #cccccccc
13 | #ffffff
14 | #ffc517
15 | #ffce3a
16 |
17 |
--------------------------------------------------------------------------------
/app/src/main/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 16dp
4 | 16dp
5 | 14dip
6 | 12dip
7 | 16dip
8 |
9 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | RandomKeyboard
3 | "确认"
4 | "Pop确认"
5 | "取消"
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/benli/randomkeyboard/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.benli.randomkeyboard;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext.kotlin_version = '1.3.50' //kotlin的版本
5 |
6 | repositories {
7 | google()
8 | jcenter()
9 | maven { url 'https://dl.bintray.com/umsdk/release' }
10 | }
11 | dependencies {
12 | classpath 'com.android.tools.build:gradle:3.2.1'
13 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14 |
15 | // NOTE: Do not place your application dependencies here; they belong
16 | // in the individual module build.gradle files
17 | }
18 | }
19 |
20 | allprojects {
21 | repositories {
22 | google()
23 | jcenter()
24 | maven { url 'https://dl.bintray.com/umsdk/release' }
25 | }
26 | }
27 |
28 | task clean(type: Delete) {
29 | delete rootProject.buildDir
30 | }
31 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
19 | android.enableJetifier=true
20 | android.useAndroidX=true
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Mon Dec 28 10:00:20 PST 2015
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/keyboard/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/keyboard/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 |
3 | android {
4 | compileSdkVersion 26
5 | buildToolsVersion "28.0.3"
6 |
7 | defaultConfig {
8 | minSdkVersion 14
9 | targetSdkVersion 26
10 | versionCode 1
11 | versionName "1.0"
12 | }
13 | buildTypes {
14 | release {
15 | minifyEnabled false
16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
17 | }
18 | }
19 | }
20 |
21 | dependencies {
22 | compile 'androidx.appcompat:appcompat:1.0.0'
23 | compile fileTree(dir: 'libs', include: ['*.jar'])
24 | testCompile 'junit:junit:4.12'
25 | }
26 |
--------------------------------------------------------------------------------
/keyboard/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in D:\AndroidWork\sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
--------------------------------------------------------------------------------
/keyboard/src/androidTest/java/com/benli/keyboard/ApplicationTest.java:
--------------------------------------------------------------------------------
1 | package com.benli.keyboard;
2 |
3 | import android.app.Application;
4 | import android.test.ApplicationTestCase;
5 |
6 | /**
7 | * Testing Fundamentals
8 | */
9 | public class ApplicationTest extends ApplicationTestCase {
10 | public ApplicationTest() {
11 | super(Application.class);
12 | }
13 | }
--------------------------------------------------------------------------------
/keyboard/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/keyboard/src/main/java/com/benli/keyboard/KeyModel.java:
--------------------------------------------------------------------------------
1 | package com.benli.keyboard;
2 |
3 | public class KeyModel {
4 |
5 | private Integer code;
6 | private String lable;
7 |
8 | public KeyModel(Integer code, String lable){
9 | this.code = code;
10 | this.lable = lable;
11 | }
12 |
13 | public Integer getCode() {
14 | return code;
15 | }
16 |
17 | public void setCode(Integer code) {
18 | this.code = code;
19 | }
20 |
21 | public String getLable() {
22 | return lable;
23 | }
24 |
25 | public void setLable(String lable) {
26 | this.lable = lable;
27 | }
28 |
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/keyboard/src/main/java/com/benli/keyboard/KeyboardHelper.java:
--------------------------------------------------------------------------------
1 | package com.benli.keyboard;
2 |
3 | import android.app.Activity;
4 | import android.content.Context;
5 | import android.content.ContextWrapper;
6 | import android.content.res.Resources;
7 | import android.graphics.Point;
8 | import android.graphics.Rect;
9 | import android.graphics.drawable.ColorDrawable;
10 | import android.inputmethodservice.Keyboard;
11 | import android.inputmethodservice.Keyboard.Key;
12 | import android.inputmethodservice.KeyboardView;
13 | import android.inputmethodservice.KeyboardView.OnKeyboardActionListener;
14 | import android.os.Build;
15 | import android.os.IBinder;
16 | import androidx.annotation.NonNull;
17 | import androidx.annotation.Nullable;
18 | import android.text.Editable;
19 | import android.text.InputType;
20 | import android.text.TextUtils;
21 | import android.util.DisplayMetrics;
22 | import android.view.Display;
23 | import android.view.Gravity;
24 | import android.view.LayoutInflater;
25 | import android.view.View;
26 | import android.view.ViewGroup;
27 | import android.view.WindowManager;
28 | import android.view.inputmethod.EditorInfo;
29 | import android.view.inputmethod.InputMethodManager;
30 | import android.widget.EditText;
31 | import android.widget.PopupWindow;
32 |
33 | import java.lang.reflect.InvocationTargetException;
34 | import java.lang.reflect.Method;
35 | import java.util.ArrayList;
36 | import java.util.LinkedList;
37 | import java.util.List;
38 | import java.util.Random;
39 |
40 | /**
41 | * 键盘助手类
42 | */
43 | public class KeyboardHelper implements View.OnClickListener, View.OnFocusChangeListener, OnKeyboardActionListener, PopupWindow.OnDismissListener {
44 | private final static int TAG_ET = R.id.keyboard_view;
45 |
46 | protected Keyboard keyMain;// 主键盘
47 |
48 | private static PopupWindow keyboardWindow;
49 | private View keyboardLayout;
50 | protected KeyboardView keyboardView;
51 |
52 | public KeyboardHelper(Activity mActivity) {
53 | this(mActivity, null);
54 | }
55 |
56 | public KeyboardHelper(Activity mActivity, EditText editText) {
57 | keyboardWindow = createKeyboardWindow(mActivity.getApplicationContext());
58 | keyboardWindow.setOnDismissListener(this);
59 | keyboardView = (KeyboardView) keyboardWindow.getContentView().findViewById(R.id.keyboard_view);
60 | keyboardLayout = keyboardWindow.getContentView().findViewById(R.id.keyboard_view_layout);
61 | initKeyboar(mActivity);
62 | addEditText(editText);
63 | }
64 |
65 | /**
66 | * 初始化键盘
67 | *
68 | * @param mActivity
69 | * @return
70 | */
71 | protected void initKeyboar(Activity mActivity) {
72 | keyMain = new Keyboard(mActivity.getApplicationContext(), R.xml.keyboard_digs);
73 | keyboardView.setKeyboard(keyMain);
74 | keyboardView.setEnabled(true);
75 | keyboardView.setPreviewEnabled(false);
76 | keyboardView.setOnKeyboardActionListener(this);
77 | }
78 |
79 | /**
80 | * 添加键盘布局
81 | *
82 | * @param editText
83 | * @return
84 | */
85 | public KeyboardHelper addEditText(EditText editText) {
86 | if (editText == null)
87 | return this;
88 |
89 | editText.setCursorVisible(true);
90 | editText.setSingleLine(false);
91 | editText.setOnClickListener(this);
92 | editText.setOnFocusChangeListener(this);
93 |
94 | int inputType = editText.getInputType();
95 | if (isPasswordInputType(inputType)) {
96 | changeSafeDisplay(editText, false);
97 | }
98 | return this;
99 | }
100 |
101 | /**
102 | * 检测当前绑定的密码输入框是否是密码输入
103 | *
104 | * @param showPwd
105 | * @return
106 | */
107 | public KeyboardHelper changeSafeDisplay(boolean showPwd) {
108 | EditText editText = getEditTextByTag();
109 | if (editText == null) return this;
110 |
111 | return changeSafeDisplay(editText, showPwd);
112 | }
113 |
114 | /**
115 | * 检测指定输入框是否是密码输入
116 | *
117 | * @param editText
118 | * @param showPwd
119 | * @return
120 | */
121 | public KeyboardHelper changeSafeDisplay(EditText editText, boolean showPwd) {
122 |
123 | if (showPwd) {
124 | // 显示密码
125 | editText.setTransformationMethod(android.text.method.HideReturnsTransformationMethod.getInstance()); //数字
126 | } else {
127 | //setTransformationMethod 则可以支持将输入的字符转换,包括清除换行符、转换为掩码
128 | editText.setTransformationMethod(android.text.method.PasswordTransformationMethod.getInstance());
129 | }
130 |
131 | return this;
132 | }
133 |
134 | @Override
135 | public void onFocusChange(View arg0, boolean arg1) {
136 | if (!(arg0 instanceof EditText)) {
137 | return;
138 | }
139 |
140 | EditText editText = (EditText) arg0;
141 | if (arg1) {
142 | if (android.os.Build.VERSION.SDK_INT <= 10) {// 3.0以下
143 | editText.setInputType(InputType.TYPE_NULL);
144 | } else {
145 | Class cls = EditText.class;
146 | Method setShowSoftInputOnFocus;
147 | try {
148 | if (android.os.Build.VERSION.SDK_INT >= 16) {
149 | setShowSoftInputOnFocus = cls.getMethod(
150 | "setShowSoftInputOnFocus",
151 | boolean.class);
152 | } else {
153 | setShowSoftInputOnFocus = cls.getMethod(
154 | "setSoftInputShownOnFocus",
155 | boolean.class);
156 | }
157 | setShowSoftInputOnFocus.setAccessible(true);
158 | setShowSoftInputOnFocus.invoke(editText, false);
159 | } catch (Exception e) {
160 |
161 | }
162 | }
163 | InputMethodManager imm = (InputMethodManager) editText.getContext()
164 | .getSystemService(Context.INPUT_METHOD_SERVICE);
165 | imm.hideSoftInputFromWindow(editText.getWindowToken(),
166 | InputMethodManager.RESULT_UNCHANGED_SHOWN);
167 | showKeyboard(editText);
168 | } else {
169 | hideKeyboard(editText);
170 | }
171 | }
172 |
173 |
174 | @Override
175 | public void onClick(View arg0) {
176 | if (!(arg0 instanceof EditText)) {
177 | return;
178 | }
179 |
180 | EditText editText = (EditText) arg0;
181 | this.showKeyboard(editText);
182 | }
183 |
184 |
185 | @Override
186 | public void swipeUp() {
187 | }
188 |
189 | @Override
190 | public void swipeRight() {
191 | }
192 |
193 | @Override
194 | public void swipeLeft() {
195 | }
196 |
197 | @Override
198 | public void swipeDown() {
199 | }
200 |
201 | @Override
202 | public void onText(CharSequence text) {
203 | }
204 |
205 | @Override
206 | public void onRelease(int primaryCode) {
207 |
208 | }
209 |
210 | @Override
211 | public void onPress(int primaryCode) {
212 | }
213 |
214 | @Override
215 | public void onKey(int primaryCode, int[] keyCodes) {
216 | EditText editText = getEditTextByTag();
217 | if (editText == null) return;
218 |
219 | Editable editable = editText.getText();
220 | int start = editText.getSelectionStart();
221 | int end = editText.getSelectionEnd();
222 | if (primaryCode == Keyboard.KEYCODE_CANCEL) {// 完成
223 | hideKeyboard(editText);
224 | } else if (primaryCode == Keyboard.KEYCODE_DELETE) {// 回退
225 | start = start == end ? start - 1 : start;
226 | if (!TextUtils.isEmpty(editable)) {
227 | if (start >= 0 && end <= editable.length()) {
228 | editable.delete(start, end);
229 | }
230 | }
231 | } else {
232 | editable.insert(start, Character.toString((char) primaryCode));
233 | }
234 | }
235 |
236 | @Nullable
237 | protected EditText getEditTextByTag() {
238 | Object arg0 = keyboardView.getTag(TAG_ET);
239 | if (arg0 == null || !(arg0 instanceof EditText)) {
240 | return null;
241 | }
242 | return (EditText) arg0;
243 | }
244 |
245 |
246 | /**
247 | * 随机键值标志位,默认false
248 | */
249 | protected boolean shouldRandom = false;
250 |
251 | /**
252 | * 是否生成随机键值
253 | *
254 | * @param shouldRandom
255 | */
256 | public KeyboardHelper setShouldRandom(boolean shouldRandom) {
257 | this.shouldRandom = shouldRandom;
258 | return this;
259 | }
260 |
261 | public void showKeyboard(@NonNull EditText editText) {
262 | EditText tag = getEditTextByTag();
263 | if (editText == tag) {//当前输入框已经显示键盘
264 | return;
265 | } else {//不同的输入框,就先隐藏键盘
266 | hideKeyboard(tag);
267 | }
268 |
269 | keyboardView.setTag(TAG_ET, editText);
270 |
271 | int visibility = keyboardLayout.getVisibility();
272 | if (visibility == View.GONE || visibility == View.INVISIBLE) {
273 | keyboardLayout.setVisibility(View.VISIBLE);
274 | }
275 | if (shouldRandom)
276 | randomKey();
277 |
278 | IBinder windowToken = editText.getWindowToken();
279 | if (windowToken != null && windowToken.isBinderAlive()) {
280 | Rect rect = new Rect();
281 | editText.getRootView().getGlobalVisibleRect(rect);
282 | Context editTextContext = editText.getContext();
283 | Resources resources = editTextContext.getApplicationContext().getResources();
284 | DisplayMetrics dm = resources.getDisplayMetrics();
285 | int y = rect.bottom - dm.heightPixels;
286 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
287 | boolean isActivity = needAttachedInDecor(editText);
288 | keyboardWindow.setAttachedInDecor(isActivity);
289 | }
290 |
291 | keyboardWindow.setTouchable(true);
292 | keyboardWindow.showAtLocation(editText, Gravity.BOTTOM | Gravity.LEFT, 0, y);
293 | keyboardWindow.update(keyboardWindow.getWidth(), keyboardWindow.getHeight());
294 | }
295 | }
296 |
297 | /**
298 | * 是否需要附属view对应的window
299 | * @param view
300 | * @return
301 | */
302 | protected boolean needAttachedInDecor(View view) {
303 | Context viewContext = view.getContext();
304 | if (viewContext instanceof ContextWrapper) {//当view在Activity
305 | Context baseContext = ((ContextWrapper) viewContext).getBaseContext();
306 | return baseContext instanceof Activity;
307 | }else{//默认不附属
308 | return false;
309 | }
310 | }
311 |
312 | public void hideKeyboard(EditText editText) {
313 | int visibility = keyboardLayout.getVisibility();
314 | if (visibility == View.VISIBLE || visibility == View.INVISIBLE) {
315 | // keyboardLayout.setVisibility(View.GONE);
316 | keyboardWindow.dismiss();
317 | }
318 | }
319 |
320 | protected boolean isNumber(String str) {
321 | String wordstr = "0123456789";
322 | if (wordstr.indexOf(str) > -1) {
323 | return true;
324 | }
325 | return false;
326 | }
327 |
328 | protected boolean isword(String str) {
329 | String wordstr = "abcdefghijklmnopqrstuvwxyz";
330 | if (wordstr.indexOf(str.toLowerCase()) > -1) {
331 | return true;
332 | }
333 | return false;
334 | }
335 |
336 | protected void randomKey() {
337 | List keyList = keyMain.getKeys();
338 | // 查找出0-9的数字键
339 | List newkeyList = new ArrayList();
340 | for (int i = 0; i < keyList.size(); i++) {
341 | if (keyList.get(i).label != null
342 | && isNumber(keyList.get(i).label.toString())) {
343 | newkeyList.add(keyList.get(i));
344 | }
345 | }
346 | // 数组长度
347 | int count = newkeyList.size();
348 | // 结果集
349 | List resultList = new ArrayList();
350 | // 用一个LinkedList作为中介
351 | LinkedList temp = new LinkedList();
352 | // 初始化temp
353 | for (int i = 0; i < count; i++) {
354 | temp.add(new KeyModel(48 + i, i + ""));
355 | }
356 | // 取数
357 | Random rand = new Random();
358 | for (int i = 0; i < count; i++) {
359 | int num = rand.nextInt(count - i);
360 | resultList.add(new KeyModel(temp.get(num).getCode(), temp.get(num)
361 | .getLable()));
362 | temp.remove(num);
363 | }
364 | for (int i = 0; i < newkeyList.size(); i++) {
365 | newkeyList.get(i).label = resultList.get(i).getLable();
366 | newkeyList.get(i).codes[0] = resultList.get(i).getCode();
367 | }
368 | keyboardView.setKeyboard(keyMain);
369 | }
370 |
371 | protected static PopupWindow createKeyboardWindow(Context context) {
372 | if (keyboardWindow != null)
373 | return keyboardWindow;
374 |
375 | // 一个自定义的布局,作为显示的内容
376 | View contentView = LayoutInflater.from(context).inflate(
377 | R.layout.keyboard_layout, null);
378 |
379 | Resources resources = context.getApplicationContext().getResources();
380 | DisplayMetrics dm = resources.getDisplayMetrics();
381 | int width3 = dm.widthPixels;
382 | int height3 = dm.heightPixels;
383 |
384 | PopupWindow popupWindow = new PopupWindow(contentView,
385 | height3, ViewGroup.LayoutParams.WRAP_CONTENT, true);
386 |
387 | popupWindow.setFocusable(false);
388 |
389 | // 如果不设置PopupWindow的背景,无论是点击外部区域还是Back键都无法dismiss弹框
390 | // 我觉得这里是API的一个bug
391 | popupWindow.setBackgroundDrawable(new ColorDrawable(context.getResources().getColor(R.color.transparent)));
392 | popupWindow.setAnimationStyle(R.style.keyboard_anim_style);
393 |
394 | return popupWindow;
395 | }
396 |
397 | private static boolean isPasswordInputType(int inputType) {
398 | final int variation =
399 | inputType & (EditorInfo.TYPE_MASK_CLASS | EditorInfo.TYPE_MASK_VARIATION);
400 | return variation
401 | == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_PASSWORD)
402 | || variation
403 | == (EditorInfo.TYPE_CLASS_TEXT | EditorInfo.TYPE_TEXT_VARIATION_WEB_PASSWORD)
404 | || variation
405 | == (EditorInfo.TYPE_CLASS_NUMBER | EditorInfo.TYPE_NUMBER_VARIATION_PASSWORD);
406 | }
407 |
408 |
409 | public static Point getNavigationBarSize(Context context) {
410 | Point appUsableSize = getAppUsableScreenSize(context);
411 | Point realScreenSize = getRealScreenSize(context);
412 |
413 | // navigation bar on the right
414 | if (appUsableSize.x < realScreenSize.x) {
415 | return new Point(realScreenSize.x - appUsableSize.x, appUsableSize.y);
416 | }
417 |
418 | // navigation bar at the bottom
419 | if (appUsableSize.y < realScreenSize.y) {
420 | return new Point(appUsableSize.x, realScreenSize.y - appUsableSize.y);
421 | }
422 |
423 | // navigation bar is not present
424 | return new Point();
425 | }
426 |
427 | public static Point getAppUsableScreenSize(Context context) {
428 | WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
429 | Display display = windowManager.getDefaultDisplay();
430 | Point size = new Point();
431 | display.getSize(size);
432 |
433 | return size;
434 | }
435 |
436 | public static Point getRealScreenSize(Context context) {
437 | WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
438 | Display display = windowManager.getDefaultDisplay();
439 | Point size = new Point();
440 |
441 | if (Build.VERSION.SDK_INT >= 17) {
442 | display.getRealSize(size);
443 | } else if (Build.VERSION.SDK_INT >= 14) {
444 | try {
445 | size.x = (Integer) Display.class.getMethod("getRawWidth").invoke(display);
446 | size.y = (Integer) Display.class.getMethod("getRawHeight").invoke(display);
447 | } catch (IllegalAccessException e) {
448 | } catch (InvocationTargetException e) {
449 | } catch (NoSuchMethodException e) {
450 | }
451 | }
452 |
453 | return size;
454 | }
455 |
456 | @Override
457 | public void onDismiss() {
458 | keyboardView.setTag(TAG_ET, null);
459 | }
460 | }
461 |
--------------------------------------------------------------------------------
/keyboard/src/main/res/anim/keyboard_hide.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
--------------------------------------------------------------------------------
/keyboard/src/main/res/anim/keyboard_show.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
--------------------------------------------------------------------------------
/keyboard/src/main/res/drawable-xhdpi/keyboard_backspace.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/keyboard/src/main/res/drawable-xhdpi/keyboard_backspace.png
--------------------------------------------------------------------------------
/keyboard/src/main/res/drawable-xhdpi/keyboard_bg.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/keyboard/src/main/res/drawable-xhdpi/keyboard_bg.9.png
--------------------------------------------------------------------------------
/keyboard/src/main/res/drawable-xhdpi/keyboard_delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/keyboard/src/main/res/drawable-xhdpi/keyboard_delete.png
--------------------------------------------------------------------------------
/keyboard/src/main/res/drawable-xhdpi/keyboard_done.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/keyboard/src/main/res/drawable-xhdpi/keyboard_done.png
--------------------------------------------------------------------------------
/keyboard/src/main/res/drawable-xhdpi/keyboard_key_btn_normal.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/keyboard/src/main/res/drawable-xhdpi/keyboard_key_btn_normal.9.png
--------------------------------------------------------------------------------
/keyboard/src/main/res/drawable-xhdpi/keyboard_key_btn_press.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/keyboard/src/main/res/drawable-xhdpi/keyboard_key_btn_press.9.png
--------------------------------------------------------------------------------
/keyboard/src/main/res/drawable-xhdpi/keyboard_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/keyboard/src/main/res/drawable-xhdpi/keyboard_left.png
--------------------------------------------------------------------------------
/keyboard/src/main/res/drawable-xhdpi/keyboard_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/keyboard/src/main/res/drawable-xhdpi/keyboard_right.png
--------------------------------------------------------------------------------
/keyboard/src/main/res/drawable-xhdpi/keyboard_search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/keyboard/src/main/res/drawable-xhdpi/keyboard_search.png
--------------------------------------------------------------------------------
/keyboard/src/main/res/drawable-xhdpi/keyboard_shift.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/keyboard/src/main/res/drawable-xhdpi/keyboard_shift.png
--------------------------------------------------------------------------------
/keyboard/src/main/res/drawable-xhdpi/keyboard_space.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/keyboard/src/main/res/drawable-xhdpi/keyboard_space.png
--------------------------------------------------------------------------------
/keyboard/src/main/res/drawable/keyboard_key_btn_selector.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/keyboard/src/main/res/layout/keyboard_layout.xml:
--------------------------------------------------------------------------------
1 |
2 |
12 |
13 |
27 |
28 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/keyboard/src/main/res/values/keyboard_colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 | #ffffff
20 | #1affffff
21 | #4cffffff
22 | #7fffffff
23 | #00ffffff
24 | #ff7e2a
25 | #00000000
26 | #6c7280
27 |
28 |
29 | @color/bg_orange_ff7e2a
30 | @color/white_10t
31 | @color/white_0t
32 | #ffffffff
33 | @color/gray_6c7280
34 | #553c3c3c
35 | @color/gray_6c7280
36 |
--------------------------------------------------------------------------------
/keyboard/src/main/res/values/keyboard_dimen.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 50.0dip
4 | 50.0dip
5 | 200.0dip
6 | 18sp
7 | 6.0dip
8 | 6.0dip
9 | 4.0dip
10 | 4.0dip
11 | 7.0dip
12 | 7.0dip
13 | 5.0dip
14 | 16sp
15 |
--------------------------------------------------------------------------------
/keyboard/src/main/res/values/keyboard_ids.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/keyboard/src/main/res/values/keyboard_strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 安全输入
4 |
--------------------------------------------------------------------------------
/keyboard/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | keyboard
3 |
4 |
--------------------------------------------------------------------------------
/keyboard/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
--------------------------------------------------------------------------------
/keyboard/src/main/res/xml/keyboard_digs.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
11 |
14 |
17 |
18 |
19 |
22 |
25 |
28 |
29 |
30 |
33 |
36 |
39 |
40 |
41 |
45 |
48 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/keyboard/src/test/java/com/benli/keyboard/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.benli.keyboard;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * To work on unit tests, switch the Test Artifact in the Build Variants view.
9 | */
10 | public class ExampleUnitTest {
11 | @Test
12 | public void addition_isCorrect() throws Exception {
13 | assertEquals(4, 2 + 2);
14 | }
15 | }
--------------------------------------------------------------------------------
/png/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/png/1.png
--------------------------------------------------------------------------------
/png/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/png/2.png
--------------------------------------------------------------------------------
/png/2222.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/beilly/randomkeyboard/61df296fd7e2d214ff06bd53dcd0bd633103be92/png/2222.png
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':keyboard'
2 |
--------------------------------------------------------------------------------