├── app ├── .gitignore ├── src │ └── main │ │ ├── res │ │ ├── drawable │ │ │ ├── logo.png │ │ │ ├── clear_search.png │ │ │ ├── stock_search.png │ │ │ ├── dset_keyboard_logo.9.png │ │ │ ├── shape_corner_3.xml │ │ │ └── dset_keyboard_logo_bg_small.xml │ │ ├── mipmap-hdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ │ ├── ic_launcher.png │ │ │ └── ic_launcher_round.png │ │ ├── values │ │ │ ├── colors.xml │ │ │ ├── dimens.xml │ │ │ ├── styles.xml │ │ │ └── strings.xml │ │ └── layout │ │ │ ├── layout_voice_tips.xml │ │ │ └── activity_login.xml │ │ ├── assets │ │ ├── voice │ │ │ ├── seq_0_0.png │ │ │ ├── seq_0_1.png │ │ │ ├── seq_0_10.png │ │ │ ├── seq_0_11.png │ │ │ ├── seq_0_12.png │ │ │ ├── seq_0_13.png │ │ │ ├── seq_0_14.png │ │ │ ├── seq_0_15.png │ │ │ ├── seq_0_16.png │ │ │ ├── seq_0_17.png │ │ │ ├── seq_0_18.png │ │ │ ├── seq_0_19.png │ │ │ ├── seq_0_2.png │ │ │ ├── seq_0_20.png │ │ │ ├── seq_0_21.png │ │ │ ├── seq_0_22.png │ │ │ ├── seq_0_23.png │ │ │ ├── seq_0_24.png │ │ │ ├── seq_0_25.png │ │ │ ├── seq_0_26.png │ │ │ ├── seq_0_27.png │ │ │ ├── seq_0_28.png │ │ │ ├── seq_0_29.png │ │ │ ├── seq_0_3.png │ │ │ ├── seq_0_30.png │ │ │ ├── seq_0_31.png │ │ │ ├── seq_0_32.png │ │ │ ├── seq_0_33.png │ │ │ ├── seq_0_34.png │ │ │ ├── seq_0_35.png │ │ │ ├── seq_0_36.png │ │ │ ├── seq_0_37.png │ │ │ ├── seq_0_38.png │ │ │ ├── seq_0_39.png │ │ │ ├── seq_0_4.png │ │ │ ├── seq_0_40.png │ │ │ ├── seq_0_41.png │ │ │ ├── seq_0_42.png │ │ │ ├── seq_0_43.png │ │ │ ├── seq_0_44.png │ │ │ ├── seq_0_45.png │ │ │ ├── seq_0_46.png │ │ │ ├── seq_0_47.png │ │ │ ├── seq_0_48.png │ │ │ ├── seq_0_49.png │ │ │ ├── seq_0_5.png │ │ │ ├── seq_0_6.png │ │ │ ├── seq_0_7.png │ │ │ ├── seq_0_8.png │ │ │ ├── seq_0_9.png │ │ │ └── data.json │ │ └── baidu_speech_grammar.bsg │ │ ├── jniLibs │ │ ├── armeabi │ │ │ ├── libvad.dnn.so │ │ │ ├── libbdEASRAndroid.so │ │ │ ├── libbdSpilWakeup.so │ │ │ ├── libBaiduSpeechSDK.so │ │ │ └── libbd_easr_s1_merge_normal_20151216.dat.so │ │ └── armeabi-v7a │ │ │ ├── libvad.dnn.so │ │ │ ├── libBaiduSpeechSDK.so │ │ │ ├── libbdEASRAndroid.so │ │ │ ├── libbdSpilWakeup.so │ │ │ └── libbd_easr_s1_merge_normal_20151216.dat.so │ │ ├── AndroidManifest.xml │ │ └── java │ │ └── com │ │ └── dfzq │ │ └── dset │ │ └── demo │ │ ├── BaiduRecognizer.java │ │ └── LoginActivity.java ├── libs │ └── bdasr_V3_20180801_d6f298a.jar ├── build.gradle └── proguard-rules.pro ├── jitpack.yml ├── library ├── .gitignore ├── src │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── res │ │ │ ├── drawable-xxhdpi │ │ │ │ ├── arrow_left.png │ │ │ │ ├── dset_keyboard_btn_normal.9.png │ │ │ │ ├── dset_keyboard_btn_press.9.png │ │ │ │ ├── dset_keyboard_voice_speech_off_gray.png │ │ │ │ └── dset_keyboard_voice_speech_on_white.png │ │ │ ├── drawable │ │ │ │ ├── corner_gray_bg.xml │ │ │ │ ├── corner_white_bg.xml │ │ │ │ ├── btn_selector_bg.xml │ │ │ │ ├── dset_keyboard_bolder_bg.xml │ │ │ │ ├── dset_bg_keyboardview.xml │ │ │ │ ├── dset_ic_keyboard_backspace_black_32dp.xml │ │ │ │ ├── dset_ic_keyboard_capslock_up_32dp.xml │ │ │ │ ├── dset_ic_keyboard_capslock_lower_32dp.xml │ │ │ │ ├── dset_btn_keyboard_special_bg.xml │ │ │ │ ├── dset_keyboard_special_btn_bg.xml │ │ │ │ ├── dset_btn_keyboard_special_press_bg.xml │ │ │ │ ├── dset_btn_keyboard_special_normal_bg.xml │ │ │ │ └── dset_ic_keyboard_hide_black_32dp.xml │ │ │ ├── anim │ │ │ │ ├── pop_from_button_down.xml │ │ │ │ └── pop_from_button_up.xml │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── strings.xml │ │ │ │ ├── attrs.xml │ │ │ │ ├── keys.xml │ │ │ │ └── styles.xml │ │ │ ├── layout │ │ │ │ ├── dset_keyboard.xml │ │ │ │ ├── dset_keyboard_animattion.xml │ │ │ │ ├── dset_keyboard_layout.xml │ │ │ │ └── dset_keyboard_voice.xml │ │ │ └── xml │ │ │ │ ├── dset_keyboard_num_only.xml │ │ │ │ ├── dset_keyboard_id.xml │ │ │ │ ├── dset_keyboard_num.xml │ │ │ │ ├── dset_keyboard_stock_number.xml │ │ │ │ ├── dset_keyboard_abc.xml │ │ │ │ └── dset_keyboard_stock_letter.xml │ │ └── java │ │ │ └── com │ │ │ └── dfzq │ │ │ └── dset │ │ │ ├── VoiceInputStateChangeListener.java │ │ │ ├── provider │ │ │ ├── DefaultRecognizer.java │ │ │ ├── Recognizer.java │ │ │ └── RecognizerListener.java │ │ │ ├── SecurityEditTextInterface.java │ │ │ ├── KeyboardDialog.java │ │ │ ├── ViewUtils.java │ │ │ ├── SecurityAutoCompleteEditText.java │ │ │ ├── SecurityEditText.java │ │ │ ├── SecurityEditTextDelegate.java │ │ │ ├── VoiceRecognizer.java │ │ │ ├── view │ │ │ └── SecretKeyboardView.java │ │ │ ├── KeyboardManager.java │ │ │ ├── KeyboardListener.java │ │ │ └── DsetKeyboard.java │ └── test │ │ └── java │ │ └── com │ │ └── dfzq │ │ └── dset │ │ └── ExampleUnitTest.java ├── build.gradle └── proguard-rules.pro ├── settings.gradle ├── README.md ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .gitignore ├── gradle.properties ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /jitpack.yml: -------------------------------------------------------------------------------- 1 | jdk: 2 | - openjdk11 -------------------------------------------------------------------------------- /library/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':library' 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SecurityEditText 2 | 自定义文本输入框,支持安全键盘、股票代码 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea 5 | .DS_Store 6 | /build 7 | /captures 8 | .externalNativeBuild 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/res/drawable/logo.png -------------------------------------------------------------------------------- /app/libs/bdasr_V3_20180801_d6f298a.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/libs/bdasr_V3_20180801_d6f298a.jar -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_0.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_1.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_10.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_11.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_12.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_13.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_14.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_14.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_15.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_15.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_16.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_17.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_17.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_18.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_18.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_19.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_19.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_2.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_20.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_21.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_21.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_22.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_22.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_23.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_23.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_24.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_25.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_26.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_26.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_27.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_27.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_28.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_28.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_29.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_3.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_30.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_30.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_31.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_31.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_32.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_33.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_33.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_34.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_34.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_35.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_35.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_36.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_37.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_37.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_38.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_38.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_39.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_39.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_4.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_40.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_41.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_41.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_42.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_42.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_43.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_43.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_44.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_44.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_45.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_45.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_46.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_46.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_47.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_47.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_48.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_49.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_49.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_5.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_6.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_7.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_8.png -------------------------------------------------------------------------------- /app/src/main/assets/voice/seq_0_9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/assets/voice/seq_0_9.png -------------------------------------------------------------------------------- /app/src/main/jniLibs/armeabi/libvad.dnn.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/jniLibs/armeabi/libvad.dnn.so -------------------------------------------------------------------------------- /app/src/main/res/drawable/clear_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/res/drawable/clear_search.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/stock_search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/res/drawable/stock_search.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /library/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/jniLibs/armeabi-v7a/libvad.dnn.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/jniLibs/armeabi-v7a/libvad.dnn.so -------------------------------------------------------------------------------- /app/src/main/jniLibs/armeabi/libbdEASRAndroid.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/jniLibs/armeabi/libbdEASRAndroid.so -------------------------------------------------------------------------------- /app/src/main/jniLibs/armeabi/libbdSpilWakeup.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/jniLibs/armeabi/libbdSpilWakeup.so -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/jniLibs/armeabi/libBaiduSpeechSDK.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/jniLibs/armeabi/libBaiduSpeechSDK.so -------------------------------------------------------------------------------- /app/src/main/res/drawable/dset_keyboard_logo.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/res/drawable/dset_keyboard_logo.9.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/jniLibs/armeabi-v7a/libBaiduSpeechSDK.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/jniLibs/armeabi-v7a/libBaiduSpeechSDK.so -------------------------------------------------------------------------------- /app/src/main/jniLibs/armeabi-v7a/libbdEASRAndroid.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/jniLibs/armeabi-v7a/libbdEASRAndroid.so -------------------------------------------------------------------------------- /app/src/main/jniLibs/armeabi-v7a/libbdSpilWakeup.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/jniLibs/armeabi-v7a/libbdSpilWakeup.so -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/arrow_left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/library/src/main/res/drawable-xxhdpi/arrow_left.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/dset_keyboard_btn_normal.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/library/src/main/res/drawable-xxhdpi/dset_keyboard_btn_normal.9.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/dset_keyboard_btn_press.9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/library/src/main/res/drawable-xxhdpi/dset_keyboard_btn_press.9.png -------------------------------------------------------------------------------- /app/src/main/jniLibs/armeabi/libbd_easr_s1_merge_normal_20151216.dat.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/jniLibs/armeabi/libbd_easr_s1_merge_normal_20151216.dat.so -------------------------------------------------------------------------------- /app/src/main/jniLibs/armeabi-v7a/libbd_easr_s1_merge_normal_20151216.dat.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/app/src/main/jniLibs/armeabi-v7a/libbd_easr_s1_merge_normal_20151216.dat.so -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/dset_keyboard_voice_speech_off_gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/library/src/main/res/drawable-xxhdpi/dset_keyboard_voice_speech_off_gray.png -------------------------------------------------------------------------------- /library/src/main/res/drawable-xxhdpi/dset_keyboard_voice_speech_on_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orientsec/SecurityKeyboard/HEAD/library/src/main/res/drawable-xxhdpi/dset_keyboard_voice_speech_on_white.png -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/corner_gray_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/corner_white_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/shape_corner_3.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Apr 16 10:00:42 CST 2018 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-7.5-all.zip 7 | -------------------------------------------------------------------------------- /library/src/main/res/anim/pop_from_button_down.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | -------------------------------------------------------------------------------- /library/src/main/res/anim/pop_from_button_up.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | -------------------------------------------------------------------------------- /library/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #e5e5e5 4 | #e5e5e5 5 | #1F1F1F 6 | #7F7F7F 7 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/btn_selector_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/dset_keyboard_bolder_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/dset_bg_keyboardview.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /library/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 完成 3 | 普通键盘 4 | 中文 5 | 按住说话 6 | 松手完成 7 | 手指上滑,取消搜索 8 | 9 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/dset_ic_keyboard_backspace_black_32dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/dset_ic_keyboard_capslock_up_32dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/dset_ic_keyboard_capslock_lower_32dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/dset_keyboard_logo_bg_small.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/dset_btn_keyboard_special_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /library/src/test/java/com/dfzq/dset/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.dfzq.dset; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /library/src/main/java/com/dfzq/dset/VoiceInputStateChangeListener.java: -------------------------------------------------------------------------------- 1 | package com.dfzq.dset; 2 | 3 | /** 4 | * Created by djy on 2018/1/4. 5 | */ 6 | 7 | public interface VoiceInputStateChangeListener { 8 | /** 9 | * 语音输入状态发生变化 10 | * 11 | * @param state 语音输入状态 12 | * 0. idle 13 | * 1. 输入 14 | */ 15 | void onStateChanged(int state); 16 | 17 | /** 18 | * 语音识别错误 19 | * 20 | * @param error 语音识别错误码 21 | */ 22 | void onErrorState(int error); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/dset_keyboard_special_btn_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /library/src/main/java/com/dfzq/dset/provider/DefaultRecognizer.java: -------------------------------------------------------------------------------- 1 | package com.dfzq.dset.provider; 2 | 3 | public class DefaultRecognizer implements Recognizer { 4 | 5 | @Override 6 | public void requestPermission() { 7 | 8 | } 9 | 10 | @Override 11 | public void cancel() { 12 | 13 | } 14 | 15 | @Override 16 | public void startVoice() { 17 | 18 | } 19 | 20 | @Override 21 | public void stopVoice() { 22 | 23 | } 24 | 25 | @Override 26 | public void setRecognizerListener(RecognizerListener listener) { 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /library/src/main/java/com/dfzq/dset/provider/Recognizer.java: -------------------------------------------------------------------------------- 1 | package com.dfzq.dset.provider; 2 | 3 | public interface Recognizer { 4 | /** 5 | * 请求录音权限 6 | */ 7 | void requestPermission(); 8 | 9 | /** 10 | * 取消语音识别服务 11 | */ 12 | void cancel(); 13 | 14 | /** 15 | * 开启语音识别服务 16 | */ 17 | void startVoice(); 18 | 19 | /** 20 | * 停止语音识别服务 21 | */ 22 | void stopVoice(); 23 | 24 | /** 25 | * 设置语音识别监听 26 | * @param listener listener 27 | */ 28 | void setRecognizerListener(RecognizerListener listener); 29 | } 30 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/dset_btn_keyboard_special_press_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /library/src/main/res/layout/dset_keyboard.xml: -------------------------------------------------------------------------------- 1 | 2 | 15 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/dset_btn_keyboard_special_normal_bg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /library/src/main/res/drawable/dset_ic_keyboard_hide_black_32dp.xml: -------------------------------------------------------------------------------- 1 | 6 | 9 | 10 | -------------------------------------------------------------------------------- /library/src/main/java/com/dfzq/dset/provider/RecognizerListener.java: -------------------------------------------------------------------------------- 1 | package com.dfzq.dset.provider; 2 | 3 | public interface RecognizerListener { 4 | /** 5 | * 语音识别成功 6 | * 7 | * @param result 失败结果 8 | */ 9 | void onSuccess(String result); 10 | 11 | /** 12 | * 语音识别失败 13 | * 14 | * @param errorMsg 错误 15 | * @param errorCode 错误码 16 | */ 17 | void onFailure(String errorMsg, int errorCode); 18 | 19 | /** 20 | * 语音音量变化 21 | * 22 | * @param volume 音量 23 | */ 24 | void onVolumeChange(int volume); 25 | 26 | /** 27 | * 语音识别结束 28 | */ 29 | void onExit(); 30 | 31 | /** 32 | * 无语音权限 33 | */ 34 | void onNoPermission(); 35 | } 36 | -------------------------------------------------------------------------------- /library/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | android.enableJetifier=true 10 | android.useAndroidX=true 11 | org.gradle.jvmargs=-Xmx1536m 12 | # When configured, Gradle will run in incubating parallel mode. 13 | # This option should only be used with decoupled projects. More details, visit 14 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 15 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | SecurityEditText 3 | 4 | 5 | Email 6 | Password (optional) 7 | Sign in or register 8 | Sign in 9 | This email address is invalid 10 | This password is too short 11 | This password is incorrect 12 | This field is required 13 | "Contacts permissions are needed for providing email 14 | completions." 15 | 16 | 17 | -------------------------------------------------------------------------------- /library/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 33 5 | 6 | defaultConfig { 7 | minSdkVersion 21 8 | targetSdkVersion 33 9 | versionCode 1 10 | versionName "1.3.9" 11 | 12 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 13 | 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | lintOptions { 22 | abortOnError false 23 | } 24 | } 25 | 26 | dependencies { 27 | testImplementation 'junit:junit:4.13.2' 28 | implementation 'androidx.appcompat:appcompat:1.6.1' 29 | implementation 'com.airbnb.android:lottie:6.1.0' 30 | implementation 'javax.inject:javax.inject:1' 31 | } 32 | -------------------------------------------------------------------------------- /library/src/main/res/values/keys.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 123 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 33 5 | defaultConfig { 6 | applicationId "com.dfzq.set" 7 | minSdkVersion 21 8 | targetSdkVersion 33 9 | versionCode 1 10 | versionName "1.0.0" 11 | ndk { 12 | abiFilters "armeabi-v7a", "x86" 13 | } 14 | } 15 | buildTypes { 16 | release { 17 | minifyEnabled false 18 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 19 | } 20 | } 21 | } 22 | 23 | dependencies { 24 | testImplementation 'junit:junit:4.13.2' 25 | implementation fileTree(dir: 'libs', include: ['*.jar']) 26 | implementation 'androidx.appcompat:appcompat:1.6.0' 27 | implementation 'com.google.android.material:material:1.8.0' 28 | //implementation 'com.dfzq.android.widget:securitykeyboard:1.3.2' 29 | implementation project(':library') 30 | implementation 'javax.inject:javax.inject:1' 31 | } 32 | -------------------------------------------------------------------------------- /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 H:\android-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 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /library/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 H:\android-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 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /library/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | 15 | 19 | -------------------------------------------------------------------------------- /library/src/main/res/layout/dset_keyboard_animattion.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 17 | 18 | 27 | 28 | -------------------------------------------------------------------------------- /library/src/main/res/layout/dset_keyboard_layout.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | 16 | 17 | 23 | 24 | 30 | 31 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /library/src/main/java/com/dfzq/dset/SecurityEditTextInterface.java: -------------------------------------------------------------------------------- 1 | package com.dfzq.dset; 2 | 3 | import android.content.Context; 4 | import android.graphics.Rect; 5 | import android.util.AttributeSet; 6 | import android.view.KeyEvent; 7 | 8 | /** 9 | * Created by zhanglei on 2017/5/17. 10 | */ 11 | 12 | interface SecurityEditTextInterface { 13 | void init(Context context, AttributeSet attrs); 14 | 15 | void init(Context context); 16 | 17 | int getKeyboardFrameId(); 18 | 19 | void setKeyboardFrameId(int keyboardFrameId); 20 | 21 | boolean getVoice(); 22 | 23 | void setVoice(boolean voice); 24 | 25 | int getType(); 26 | 27 | void setType(int type); 28 | 29 | void hideSystemSoftKeyboard(); 30 | 31 | void showSystemSoftKeyboard(); 32 | 33 | boolean hideSoftKeyboard(); 34 | 35 | boolean showSoftKeyboard(); 36 | 37 | boolean performClick(); 38 | 39 | void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect); 40 | 41 | void onAttachedToWindow(); 42 | 43 | void onDetachedFromWindow(); 44 | 45 | void onWindowFocusChanged(boolean hasWindowFocus); 46 | 47 | boolean onKeyPreIme(int keyCode, KeyEvent event); 48 | 49 | /** 50 | * 语音输入状态发生变化 51 | * 52 | * @param state 语音输入状态 53 | * 0. idle 54 | * 1. 输入 55 | */ 56 | void onVoiceStateChanged(int state); 57 | 58 | /** 59 | * 语音识别错误 60 | * 61 | * @param error 语音识别错误码 62 | */ 63 | void onVoiceErrorState(int error); 64 | 65 | /** 66 | * 是否支持隐藏,FrameId不为0时不支持 67 | * 68 | * @return true enable 69 | */ 70 | boolean isHideEnable(); 71 | 72 | boolean isHide(); 73 | 74 | void switchSoftKeyboardWithSystem(); 75 | 76 | /** 77 | * 是否屏蔽录屏 78 | * @param mask 79 | */ 80 | void setMask(boolean mask); 81 | 82 | boolean isMask(); 83 | } 84 | -------------------------------------------------------------------------------- /library/src/main/java/com/dfzq/dset/KeyboardDialog.java: -------------------------------------------------------------------------------- 1 | package com.dfzq.dset; 2 | 3 | import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE; 4 | 5 | import android.app.Dialog; 6 | import android.content.Context; 7 | import android.view.Gravity; 8 | import android.view.View; 9 | import android.view.Window; 10 | import android.view.WindowManager; 11 | 12 | /** 13 | * Created by xiaomao on 2016/10/16. 14 | */ 15 | 16 | class KeyboardDialog extends Dialog implements View.OnClickListener { 17 | 18 | 19 | public KeyboardDialog(Context context) { 20 | super(context); 21 | initialize(); 22 | } 23 | 24 | public KeyboardDialog(Context context, int themeResId) { 25 | super(context, themeResId); 26 | initialize(); 27 | } 28 | 29 | protected KeyboardDialog(Context context, boolean cancelable, OnCancelListener cancelListener) { 30 | super(context, cancelable, cancelListener); 31 | initialize(); 32 | } 33 | 34 | private void initialize() { 35 | Window window = getWindow(); 36 | if (window == null) return; 37 | window.getDecorView().setPadding(0, 0, 0, 0); 38 | window.setGravity(Gravity.BOTTOM); 39 | window.setWindowAnimations(R.style.dsetDialogWindowAnim); //设置窗口弹出动画 40 | WindowManager.LayoutParams lp = window.getAttributes(); 41 | lp.width = WindowManager.LayoutParams.MATCH_PARENT; 42 | lp.flags = FLAG_NOT_FOCUSABLE;// | FLAG_ALT_FOCUSABLE_IM | FLAG_WATCH_OUTSIDE_TOUCH;// | FLAG_NOT_TOUCH_MODAL; 43 | //window.setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE); 44 | setCanceledOnTouchOutside(false); 45 | setContentView(R.layout.dset_keyboard_layout); 46 | findViewById(R.id.finish).setOnClickListener(this); 47 | } 48 | 49 | @Override 50 | public void onClick(View v) { 51 | dismiss(); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /library/src/main/res/xml/dset_keyboard_num_only.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 13 | 16 | 19 | 25 | 26 | 27 | 31 | 34 | 37 | 38 | 39 | 40 | 43 | 46 | 47 | 50 | 53 | 54 | 55 | 58 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /library/src/main/res/xml/dset_keyboard_id.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 13 | 16 | 20 | 26 | 27 | 28 | 32 | 35 | 38 | 42 | 43 | 44 | 45 | 48 | 51 | 52 | 55 | 58 | 59 | 60 | 63 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 22 | 25 | 28 | 31 | 32 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /library/src/main/res/xml/dset_keyboard_num.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 13 | 16 | 19 | 25 | 26 | 27 | 31 | 34 | 37 | 41 | 42 | 43 | 44 | 47 | 50 | 51 | 54 | 57 | 58 | 59 | 62 | 65 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /library/src/main/res/layout/dset_keyboard_voice.xml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 15 | 16 | 30 | 31 | 39 | 40 | 46 | 47 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /library/src/main/res/xml/dset_keyboard_stock_number.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 12 | 15 | 18 | 21 | 25 | 26 | 27 | 30 | 33 | 36 | 39 | 42 | 43 | 44 | 47 | 50 | 53 | 56 | 59 | 60 | 61 | 64 | 67 | 70 | 73 | 76 | 77 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /app/src/main/res/layout/layout_voice_tips.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 14 | 15 | 21 | 22 | 29 | 30 | 37 | 38 | 45 | 46 | 47 | 48 | 56 | 57 | 63 | 64 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /library/src/main/java/com/dfzq/dset/ViewUtils.java: -------------------------------------------------------------------------------- 1 | package com.dfzq.dset; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.ContextWrapper; 6 | import android.os.Build; 7 | import android.provider.Settings; 8 | import android.text.TextUtils; 9 | import android.view.View; 10 | 11 | /** 12 | * Created by wangtao on 2020/9/28. 13 | */ 14 | public class ViewUtils { 15 | 16 | public static int dpToPx(Context context, float dp) { 17 | final float scale = context.getResources().getDisplayMetrics().density; 18 | return (int) (dp * scale + 0.5f); 19 | } 20 | 21 | /** 22 | * 获取虚拟按键的高度 23 | * 1. 全面屏下 24 | * 1.1 开启全面屏开关-返回0 25 | * 1.2 关闭全面屏开关-执行非全面屏下处理方式 26 | * 2. 非全面屏下 27 | * 2.1 没有虚拟键-返回0 28 | * 2.1 虚拟键隐藏-返回0 29 | * 2.2 虚拟键存在且未隐藏-返回虚拟键实际高度 30 | */ 31 | public static int getNavigationBarHeightIfRoom(Context context) { 32 | if (navigationGestureEnabled(context)) { 33 | return 0; 34 | } 35 | Activity activity = getActivity(context); 36 | if (activity == null) { 37 | return 0; 38 | } 39 | return getCurrentNavigationBarHeight(activity); 40 | } 41 | 42 | /** 43 | * 全面屏(是否开启全面屏开关 0 关闭 1 开启) 44 | */ 45 | public static boolean navigationGestureEnabled(Context context) { 46 | int val = Settings.Global.getInt(context.getContentResolver(), getDeviceInfo(), 0); 47 | return val != 0; 48 | } 49 | 50 | /** 51 | * 获取设备信息(目前支持几大主流的全面屏手机,亲测华为、小米、oppo、魅族、vivo都可以) 52 | */ 53 | public static String getDeviceInfo() { 54 | String brand = Build.BRAND; 55 | if (TextUtils.isEmpty(brand)) return "navigationbar_is_min"; 56 | 57 | if (brand.equalsIgnoreCase("HUAWEI")) { 58 | return "navigationbar_is_min"; 59 | } else if (brand.equalsIgnoreCase("XIAOMI")) { 60 | return "force_fsg_nav_bar"; 61 | } else if (brand.equalsIgnoreCase("VIVO")) { 62 | return "navigation_gesture_on"; 63 | } else if (brand.equalsIgnoreCase("OPPO")) { 64 | return "navigation_gesture_on"; 65 | } else { 66 | return "navigationbar_is_min"; 67 | } 68 | } 69 | 70 | private static Activity getActivity(Context context) { 71 | Context baseContext = context; 72 | while (baseContext instanceof ContextWrapper) { 73 | if (baseContext instanceof Activity) { 74 | return (Activity) baseContext; 75 | } 76 | baseContext = ((ContextWrapper) baseContext).getBaseContext(); 77 | } 78 | return null; 79 | } 80 | 81 | /** 82 | * 非全面屏下 虚拟键实际高度(隐藏后高度为0) 83 | */ 84 | public static int getCurrentNavigationBarHeight(Activity activity) { 85 | if (isNavigationBarShown(activity)) { 86 | return getNavigationBarHeight(activity); 87 | } else { 88 | return 0; 89 | } 90 | } 91 | 92 | /** 93 | * 非全面屏下 虚拟按键是否打开 94 | */ 95 | public static boolean isNavigationBarShown(Activity activity) { 96 | //虚拟键的view,为空或者不可见时是隐藏状态 97 | View view = activity.findViewById(android.R.id.navigationBarBackground); 98 | if (view == null) { 99 | return false; 100 | } 101 | int visible = view.getVisibility(); 102 | return visible != View.GONE && visible != View.INVISIBLE; 103 | } 104 | 105 | /** 106 | * 非全面屏下 虚拟键高度(无论是否隐藏) 107 | */ 108 | public static int getNavigationBarHeight(Context context) { 109 | int result = 0; 110 | int resourceId = context.getResources().getIdentifier("navigation_bar_height", "dimen", "android"); 111 | if (resourceId > 0) { 112 | result = context.getResources().getDimensionPixelSize(resourceId); 113 | } 114 | return result; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /library/src/main/res/xml/dset_keyboard_abc.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 13 | 16 | 19 | 22 | 25 | 28 | 31 | 34 | 37 | 41 | 42 | 43 | 48 | 51 | 54 | 57 | 60 | 63 | 66 | 69 | 73 | 74 | 75 | 82 | 86 | 89 | 92 | 95 | 98 | 101 | 104 | 111 | 112 | 113 | 117 | 120 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /library/src/main/res/xml/dset_keyboard_stock_letter.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 13 | 16 | 19 | 22 | 25 | 28 | 31 | 34 | 37 | 41 | 42 | 43 | 48 | 51 | 54 | 57 | 60 | 63 | 66 | 69 | 73 | 74 | 75 | 82 | 86 | 89 | 92 | 95 | 98 | 101 | 104 | 111 | 112 | 113 | 117 | 121 | 124 | 128 | 132 | 133 | -------------------------------------------------------------------------------- /app/src/main/java/com/dfzq/dset/demo/BaiduRecognizer.java: -------------------------------------------------------------------------------- 1 | package com.dfzq.dset.demo; 2 | 3 | import android.content.Context; 4 | 5 | import com.baidu.speech.EventListener; 6 | import com.baidu.speech.EventManager; 7 | import com.baidu.speech.EventManagerFactory; 8 | import com.baidu.speech.asr.SpeechConstant; 9 | import com.dfzq.dset.provider.Recognizer; 10 | import com.dfzq.dset.provider.RecognizerListener; 11 | 12 | import org.json.JSONArray; 13 | import org.json.JSONException; 14 | import org.json.JSONObject; 15 | 16 | import java.lang.ref.WeakReference; 17 | import java.util.LinkedHashMap; 18 | import java.util.Map; 19 | 20 | public class BaiduRecognizer implements Recognizer { 21 | private PermissionListener permissionListener; 22 | private static final class BaiduListener implements EventListener { 23 | private WeakReference listenerWeakReference; 24 | private static final BaiduListener instance = new BaiduListener(); 25 | 26 | void setRecognizerListener(RecognizerListener listener) { 27 | listenerWeakReference = new WeakReference<>(listener); 28 | } 29 | 30 | @Override 31 | public void onEvent(String name, String params, byte[] data, int offset, int length) { 32 | RecognizerListener listener = null; 33 | if (listenerWeakReference != null) { 34 | listener = listenerWeakReference.get(); 35 | } 36 | if (listener == null) return; 37 | if (params != null) { 38 | try { 39 | JSONObject obj = new JSONObject(params); 40 | JSONArray result = obj.optJSONArray("results_recognition"); 41 | int error = obj.optInt("sub_error"); 42 | if (result != null && result.length() > 0) { 43 | listener.onSuccess(result.get(0).toString()); 44 | } 45 | if (3001 == error) { 46 | listener.onNoPermission(); 47 | } 48 | if (0 != error) { 49 | listener.onFailure("", error); 50 | } 51 | } catch (JSONException e) { 52 | e.printStackTrace(); 53 | } 54 | if (name.equals(SpeechConstant.CALLBACK_EVENT_ASR_VOLUME)) { 55 | //音量变化 56 | try { 57 | JSONObject json = new JSONObject(params); 58 | int volumePercent = json.getInt("volume-percent"); 59 | listener.onVolumeChange(volumePercent); 60 | } catch (JSONException e) { 61 | e.printStackTrace(); 62 | } 63 | } 64 | } 65 | if (name.equals(SpeechConstant.CALLBACK_EVENT_ASR_EXIT)) { 66 | listener.onExit(); 67 | } 68 | 69 | } 70 | } 71 | 72 | private final EventManager asr; 73 | 74 | public BaiduRecognizer(Context context, PermissionListener permissionListener) { 75 | asr = EventManagerFactory.create(context, "asr"); 76 | asr.registerListener(BaiduListener.instance); 77 | this.permissionListener = permissionListener; 78 | loadOfflineEngine(); 79 | } 80 | 81 | private void loadOfflineEngine() { 82 | Map params = new LinkedHashMap<>(); 83 | params.put(SpeechConstant.DECODER, 2); 84 | params.put(SpeechConstant.ASR_OFFLINE_ENGINE_GRAMMER_FILE_PATH, "assets://baidu_speech_grammar.bsg"); 85 | asr.send(SpeechConstant.ASR_KWS_LOAD_ENGINE, new JSONObject(params).toString(), null, 0, 0); 86 | } 87 | 88 | @Override 89 | public void requestPermission() { 90 | permissionListener.requestPermission(); 91 | } 92 | 93 | @Override 94 | public void cancel() { 95 | if (asr != null) { 96 | asr.send(SpeechConstant.ASR_CANCEL, "{}", null, 0, 0); 97 | unloadOfflineEngine(); 98 | } 99 | } 100 | 101 | private void unloadOfflineEngine() { 102 | asr.send(SpeechConstant.ASR_KWS_UNLOAD_ENGINE, null, null, 0, 0); 103 | } 104 | 105 | @Override 106 | public void startVoice() { 107 | Map params = new LinkedHashMap<>(); 108 | String event; 109 | event = SpeechConstant.ASR_START; 110 | params.put(SpeechConstant.DECODER, 2); 111 | params.put(SpeechConstant.ACCEPT_AUDIO_VOLUME, true); 112 | String json = new JSONObject(params).toString(); 113 | asr.send(event, json, null, 0, 0); 114 | } 115 | 116 | @Override 117 | public void stopVoice() { 118 | asr.send(SpeechConstant.ASR_STOP, null, null, 0, 0); 119 | } 120 | 121 | @Override 122 | public void setRecognizerListener(RecognizerListener listener) { 123 | BaiduListener.instance.setRecognizerListener(listener); 124 | } 125 | 126 | interface PermissionListener { 127 | void requestPermission(); 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /library/src/main/java/com/dfzq/dset/SecurityAutoCompleteEditText.java: -------------------------------------------------------------------------------- 1 | package com.dfzq.dset; 2 | 3 | import android.content.Context; 4 | import android.graphics.Rect; 5 | import android.util.AttributeSet; 6 | import android.view.KeyEvent; 7 | import android.view.View; 8 | 9 | import androidx.appcompat.widget.AppCompatAutoCompleteTextView; 10 | 11 | /** 12 | * Created by zhanglei on 2017/5/17. 13 | */ 14 | 15 | public class SecurityAutoCompleteEditText extends AppCompatAutoCompleteTextView implements SecurityEditTextInterface { 16 | private SecurityEditTextDelegate delegate; 17 | private VoiceInputStateChangeListener voiceInputStateChangeListener; 18 | 19 | public SecurityAutoCompleteEditText(Context context) { 20 | super(context); 21 | } 22 | 23 | public SecurityAutoCompleteEditText(Context context, AttributeSet attrs) { 24 | super(context, attrs); 25 | init(context, attrs); 26 | } 27 | 28 | public SecurityAutoCompleteEditText(Context context, AttributeSet attrs, int defStyleAttr) { 29 | super(context, attrs, defStyleAttr); 30 | init(context, attrs); 31 | } 32 | 33 | public void setVoiceInputStateChangeListener(VoiceInputStateChangeListener voiceInputStateChangeListener) { 34 | this.voiceInputStateChangeListener = voiceInputStateChangeListener; 35 | } 36 | 37 | public int getType() { 38 | return delegate.getType(); 39 | } 40 | 41 | public void setType(int type) { 42 | delegate.setType(type); 43 | } 44 | 45 | @Override 46 | public boolean getVoice() { 47 | return delegate.getVoice(); 48 | } 49 | 50 | @Override 51 | public void setVoice(boolean voice) { 52 | delegate.setVoice(voice); 53 | } 54 | 55 | public int getKeyboardFrameId() { 56 | return delegate.getKeyboardFrameId(); 57 | } 58 | 59 | public void setKeyboardFrameId(int keyboardFrameId) { 60 | delegate.setKeyboardFrameId(keyboardFrameId); 61 | } 62 | 63 | public void init(Context context, AttributeSet attrs) { 64 | delegate = new SecurityEditTextDelegate(this); 65 | delegate.init(context, attrs); 66 | } 67 | 68 | @Override 69 | public void init(Context context) { 70 | delegate = new SecurityEditTextDelegate(this); 71 | delegate.init(context); 72 | } 73 | 74 | @Override 75 | public boolean performClick() { 76 | delegate.performClick(); 77 | return super.performClick(); 78 | } 79 | 80 | @Override 81 | public void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { 82 | super.onFocusChanged(focused, direction, previouslyFocusedRect); 83 | delegate.onFocusChanged(focused, direction, previouslyFocusedRect); 84 | } 85 | 86 | @Override 87 | public void onAttachedToWindow() { 88 | super.onAttachedToWindow(); 89 | delegate.onAttachedToWindow(); 90 | } 91 | 92 | @Override 93 | public void onDetachedFromWindow() { 94 | super.onDetachedFromWindow(); 95 | delegate.onDetachedFromWindow(); 96 | } 97 | 98 | 99 | @Override 100 | protected void onVisibilityChanged(View changedView, int visibility) { 101 | super.onVisibilityChanged(changedView, visibility); 102 | } 103 | 104 | @Override 105 | public void onWindowFocusChanged(boolean hasWindowFocus) { 106 | super.onWindowFocusChanged(hasWindowFocus); 107 | delegate.onWindowFocusChanged(hasWindowFocus); 108 | } 109 | 110 | @Override 111 | public boolean onKeyPreIme(int keyCode, KeyEvent event) { 112 | if (delegate.onKeyPreIme(keyCode, event)) { 113 | return true; 114 | } 115 | return super.onKeyPreIme(keyCode, event); 116 | } 117 | 118 | @Override 119 | public void onVoiceStateChanged(int state) { 120 | if (voiceInputStateChangeListener != null) { 121 | voiceInputStateChangeListener.onStateChanged(state); 122 | } 123 | } 124 | 125 | @Override 126 | public void onVoiceErrorState(int error) { 127 | if (voiceInputStateChangeListener != null) { 128 | voiceInputStateChangeListener.onErrorState(error); 129 | } 130 | } 131 | 132 | /** 133 | * 隐藏系统键盘 134 | */ 135 | public void hideSystemSoftKeyboard() { 136 | delegate.hideSystemSoftKeyboard(); 137 | } 138 | 139 | @Override 140 | public void showSystemSoftKeyboard() { 141 | delegate.showSystemSoftKeyboard(); 142 | } 143 | 144 | @Override 145 | public boolean hideSoftKeyboard() { 146 | return delegate.hideSoftKeyboard(); 147 | } 148 | 149 | @Override 150 | public boolean showSoftKeyboard() { 151 | return delegate.showSoftKeyboard(); 152 | } 153 | 154 | @Override 155 | public boolean isHideEnable() { 156 | return delegate.isHideEnable(); 157 | } 158 | 159 | @Override 160 | public boolean isHide() { 161 | return delegate.isHide(); 162 | } 163 | 164 | @Override 165 | public void switchSoftKeyboardWithSystem() { 166 | delegate.switchSoftKeyboardWithSystem(); 167 | } 168 | 169 | @Override 170 | public void setMask(boolean mask) { 171 | delegate.setMask(mask); 172 | } 173 | 174 | @Override 175 | public boolean isMask() { 176 | return delegate.isMask(); 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /library/src/main/java/com/dfzq/dset/SecurityEditText.java: -------------------------------------------------------------------------------- 1 | package com.dfzq.dset; 2 | 3 | import android.content.Context; 4 | import android.graphics.Rect; 5 | import android.util.AttributeSet; 6 | import android.view.KeyEvent; 7 | import android.view.View; 8 | 9 | import androidx.annotation.NonNull; 10 | import androidx.appcompat.widget.AppCompatEditText; 11 | 12 | 13 | /** 14 | * ProductName:DsetKeyboard 15 | * PackageName:com.xiaomao.keyboard_id.keyboard_id 16 | * Dage:2016/10/14 17 | * Author:Fredric 18 | * Coding is an art not science 19 | */ 20 | 21 | public class SecurityEditText extends AppCompatEditText implements SecurityEditTextInterface { 22 | private SecurityEditTextDelegate delegate; 23 | private VoiceInputStateChangeListener voiceInputStateChangeListener; 24 | 25 | public SecurityEditText(Context context) { 26 | super(context); 27 | init(context); 28 | } 29 | 30 | public SecurityEditText(Context context, AttributeSet attrs) { 31 | super(context, attrs); 32 | init(context, attrs); 33 | } 34 | 35 | public SecurityEditText(Context context, AttributeSet attrs, int defStyleAttr) { 36 | super(context, attrs, defStyleAttr); 37 | init(context, attrs); 38 | } 39 | 40 | public void setVoiceInputStateChangeListener(@NonNull VoiceInputStateChangeListener voiceInputStateChangeListener) { 41 | this.voiceInputStateChangeListener = voiceInputStateChangeListener; 42 | } 43 | 44 | public int getType() { 45 | return delegate.getType(); 46 | } 47 | 48 | public void setType(int type) { 49 | delegate.setType(type); 50 | } 51 | 52 | @Override 53 | public boolean getVoice() { 54 | return delegate.getVoice(); 55 | } 56 | 57 | @Override 58 | public void setVoice(boolean voice) { 59 | delegate.setVoice(voice); 60 | } 61 | 62 | public int getKeyboardFrameId() { 63 | return delegate.getKeyboardFrameId(); 64 | } 65 | 66 | public void setKeyboardFrameId(int keyboardFrameId) { 67 | delegate.setKeyboardFrameId(keyboardFrameId); 68 | } 69 | 70 | public void init(Context context, AttributeSet attrs) { 71 | delegate = new SecurityEditTextDelegate(this); 72 | delegate.init(context, attrs); 73 | } 74 | 75 | @Override 76 | public void init(Context context) { 77 | delegate = new SecurityEditTextDelegate(this); 78 | delegate.init(context); 79 | } 80 | 81 | @Override 82 | public boolean performClick() { 83 | delegate.performClick(); 84 | return super.performClick(); 85 | } 86 | 87 | @Override 88 | public void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { 89 | super.onFocusChanged(focused, direction, previouslyFocusedRect); 90 | delegate.onFocusChanged(focused, direction, previouslyFocusedRect); 91 | } 92 | 93 | @Override 94 | public void onAttachedToWindow() { 95 | super.onAttachedToWindow(); 96 | delegate.onAttachedToWindow(); 97 | } 98 | 99 | @Override 100 | public void onDetachedFromWindow() { 101 | super.onDetachedFromWindow(); 102 | delegate.onDetachedFromWindow(); 103 | } 104 | 105 | 106 | @Override 107 | protected void onVisibilityChanged(View changedView, int visibility) { 108 | super.onVisibilityChanged(changedView, visibility); 109 | } 110 | 111 | @Override 112 | public void onWindowFocusChanged(boolean hasWindowFocus) { 113 | super.onWindowFocusChanged(hasWindowFocus); 114 | delegate.onWindowFocusChanged(hasWindowFocus); 115 | } 116 | 117 | @Override 118 | public boolean onKeyPreIme(int keyCode, KeyEvent event) { 119 | if (delegate.onKeyPreIme(keyCode, event)) { 120 | return true; 121 | } 122 | return super.onKeyPreIme(keyCode, event); 123 | } 124 | 125 | @Override 126 | public void onVoiceStateChanged(int state) { 127 | if (voiceInputStateChangeListener != null) { 128 | voiceInputStateChangeListener.onStateChanged(state); 129 | } 130 | } 131 | 132 | @Override 133 | public void onVoiceErrorState(int error) { 134 | if (voiceInputStateChangeListener != null) { 135 | voiceInputStateChangeListener.onErrorState(error); 136 | } 137 | } 138 | 139 | @Override 140 | public boolean isHideEnable() { 141 | return delegate.isHideEnable(); 142 | } 143 | 144 | /** 145 | * 隐藏系统键盘 146 | */ 147 | public void hideSystemSoftKeyboard() { 148 | delegate.hideSystemSoftKeyboard(); 149 | } 150 | 151 | /** 152 | * 弹出系统键盘 153 | */ 154 | @Override 155 | public void showSystemSoftKeyboard() { 156 | delegate.showSystemSoftKeyboard(); 157 | } 158 | 159 | @Override 160 | public boolean hideSoftKeyboard() { 161 | return delegate.hideSoftKeyboard(); 162 | } 163 | 164 | @Override 165 | public boolean showSoftKeyboard() { 166 | return delegate.showSoftKeyboard(); 167 | } 168 | 169 | @Override 170 | public boolean isHide() { 171 | return delegate.isHide(); 172 | } 173 | 174 | @Override 175 | public void switchSoftKeyboardWithSystem() { 176 | delegate.switchSoftKeyboardWithSystem(); 177 | } 178 | 179 | @Override 180 | public void setMask(boolean mask) { 181 | delegate.setMask(mask); 182 | } 183 | 184 | @Override 185 | public boolean isMask() { 186 | return delegate.isMask(); 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /library/src/main/java/com/dfzq/dset/SecurityEditTextDelegate.java: -------------------------------------------------------------------------------- 1 | package com.dfzq.dset; 2 | 3 | import static com.dfzq.dset.view.SecretKeyboardView.KEYBOARD_NUM; 4 | 5 | import android.content.Context; 6 | import android.content.res.TypedArray; 7 | import android.graphics.Rect; 8 | import android.util.AttributeSet; 9 | import android.view.KeyEvent; 10 | import android.view.inputmethod.InputMethodManager; 11 | import android.widget.EditText; 12 | 13 | /** 14 | * Created by meihu on 2017/6/27. 15 | */ 16 | 17 | public class SecurityEditTextDelegate implements SecurityEditTextInterface { 18 | 19 | private boolean voice; 20 | 21 | private int type; 22 | 23 | private int keyboardFrameId; 24 | 25 | private final EditText editText; 26 | 27 | /** 28 | * 自定义键盘是否隐藏 29 | */ 30 | private boolean isHide; 31 | 32 | private boolean safe; 33 | 34 | public SecurityEditTextDelegate(EditText editText) { 35 | this.editText = editText; 36 | } 37 | 38 | @Override 39 | public void init(Context context) { 40 | editText.setClickable(true); 41 | editText.setShowSoftInputOnFocus(false); 42 | } 43 | 44 | @Override 45 | public void init(Context context, AttributeSet attrs) { 46 | TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SecurityEditText); 47 | voice = a.getBoolean(R.styleable.SecurityEditText_keyboardVoice, false); 48 | type = a.getInt(R.styleable.SecurityEditText_inputType, KEYBOARD_NUM); 49 | keyboardFrameId = a.getInt(R.styleable.SecurityEditText_keyboardFrameId, 0); 50 | a.recycle(); 51 | init(context); 52 | } 53 | 54 | @Override 55 | public int getKeyboardFrameId() { 56 | return keyboardFrameId; 57 | } 58 | 59 | @Override 60 | public void setKeyboardFrameId(int keyboardFrameId) { 61 | this.keyboardFrameId = keyboardFrameId; 62 | } 63 | 64 | @Override 65 | public boolean isHideEnable() { 66 | return keyboardFrameId == 0; 67 | } 68 | 69 | @Override 70 | public boolean isHide() { 71 | return isHide; 72 | } 73 | 74 | @Override 75 | public void switchSoftKeyboardWithSystem() { 76 | if (isHideEnable()) { 77 | if (isHide()) { 78 | hideSystemSoftKeyboard(); 79 | showSoftKeyboard(); 80 | } else { 81 | hideSoftKeyboard(); 82 | showSystemSoftKeyboard(); 83 | } 84 | } 85 | } 86 | 87 | @Override 88 | public void setMask(boolean mask) { 89 | this.safe = mask; 90 | } 91 | 92 | public boolean isMask() { 93 | return safe; 94 | } 95 | 96 | @Override 97 | public boolean getVoice() { 98 | return voice; 99 | } 100 | 101 | @Override 102 | public void setVoice(boolean voice) { 103 | this.voice = voice; 104 | } 105 | 106 | @Override 107 | public int getType() { 108 | return type; 109 | } 110 | 111 | @Override 112 | public void setType(int type) { 113 | this.type = type; 114 | } 115 | 116 | @Override 117 | public void hideSystemSoftKeyboard() { 118 | isHide = false; 119 | InputMethodManager imm = (InputMethodManager) editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); 120 | imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); 121 | editText.postDelayed(() -> { 122 | if (editText.isFocused() && !isHide) { 123 | imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); 124 | } 125 | }, 1000); 126 | } 127 | 128 | @Override 129 | public void showSystemSoftKeyboard() { 130 | isHide = true; 131 | InputMethodManager imm = (InputMethodManager) editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); 132 | imm.showSoftInput(editText, 1); 133 | } 134 | 135 | @Override 136 | public boolean hideSoftKeyboard() { 137 | isHide = true; 138 | return KeyboardManager.getInstance().hideSoftInput(editText); 139 | } 140 | 141 | @Override 142 | public boolean showSoftKeyboard() { 143 | isHide = false; 144 | return KeyboardManager.getInstance().showSoftInput(editText); 145 | } 146 | 147 | @Override 148 | public boolean performClick() { 149 | if (editText.isFocused()) { 150 | hideSystemSoftKeyboard(); 151 | KeyboardManager.getInstance().showSoftInput(editText); 152 | } 153 | return false; 154 | } 155 | 156 | @Override 157 | public void onFocusChanged(boolean focused, int direction, Rect previouslyFocusedRect) { 158 | if (focused) { 159 | hideSystemSoftKeyboard(); 160 | showSoftKeyboard(); 161 | // KeyboardManager.getInstance().showSoftInput(editText); 162 | } else { 163 | hideSoftKeyboard(); 164 | } 165 | } 166 | 167 | @Override 168 | public void onAttachedToWindow() { 169 | if (editText.isFocused()) { 170 | hideSystemSoftKeyboard(); 171 | KeyboardManager.getInstance().showSoftInput(editText); 172 | } 173 | } 174 | 175 | @Override 176 | public void onDetachedFromWindow() { 177 | if (editText.isFocused()) { 178 | hideSoftKeyboard(); 179 | } 180 | } 181 | 182 | @Override 183 | public void onWindowFocusChanged(boolean hasWindowFocus) { 184 | if (hasWindowFocus && editText.hasFocus()) { 185 | editText.post(() -> { 186 | hideSystemSoftKeyboard(); 187 | KeyboardManager.getInstance().showSoftInput(editText); 188 | }); 189 | } 190 | } 191 | 192 | @Override 193 | public boolean onKeyPreIme(int keyCode, KeyEvent event) { 194 | return keyCode == KeyEvent.KEYCODE_BACK && hideSoftKeyboard(); 195 | } 196 | 197 | @Override 198 | public void onVoiceStateChanged(int state) { 199 | 200 | } 201 | 202 | @Override 203 | public void onVoiceErrorState(int error) { 204 | 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /library/src/main/java/com/dfzq/dset/VoiceRecognizer.java: -------------------------------------------------------------------------------- 1 | package com.dfzq.dset; 2 | 3 | import android.Manifest; 4 | import android.annotation.SuppressLint; 5 | import android.content.pm.PackageManager; 6 | import android.text.TextUtils; 7 | import android.view.MotionEvent; 8 | import android.view.View; 9 | import android.widget.EditText; 10 | import android.widget.ImageView; 11 | import android.widget.LinearLayout; 12 | import android.widget.TextView; 13 | 14 | import androidx.core.content.ContextCompat; 15 | 16 | import com.dfzq.dset.provider.DefaultRecognizer; 17 | import com.dfzq.dset.provider.Recognizer; 18 | import com.dfzq.dset.provider.RecognizerListener; 19 | 20 | import javax.inject.Provider; 21 | 22 | /** 23 | * Created by djy on 2018/1/4. 24 | */ 25 | 26 | public class VoiceRecognizer implements View.OnTouchListener, RecognizerListener { 27 | 28 | private EditText editText; 29 | private ImageView voiceImg; 30 | private String preText = ""; 31 | private boolean stopFlag; 32 | private final Recognizer recognizer; 33 | private TextView tvTitle; 34 | private final TextView changeTv; 35 | private LinearLayout voiceBg; 36 | 37 | public VoiceRecognizer(View voiceLayout, TextView changeTv) { 38 | if (voiceLayout != null) { 39 | voiceImg = voiceLayout.findViewById(R.id.iv_voice); 40 | tvTitle = voiceLayout.findViewById(R.id.tv_title); 41 | voiceBg = voiceLayout.findViewById(R.id.btn_voice); 42 | voiceLayout.setOnTouchListener(this); 43 | } 44 | this.changeTv = changeTv; 45 | recognizer = getRecognizer(); 46 | recognizer.setRecognizerListener(this); 47 | } 48 | 49 | private Recognizer getRecognizer() { 50 | Provider provider = KeyboardManager.getInstance().getProvider(); 51 | if (provider == null) { 52 | return new DefaultRecognizer(); 53 | } 54 | return provider.get(); 55 | } 56 | 57 | public void setEditText(EditText editText) { 58 | this.editText = editText; 59 | } 60 | 61 | public void cancel() { 62 | stopSpeech(); 63 | recognizer.cancel(); 64 | } 65 | 66 | private void startVoice() { 67 | if (editText != null) { 68 | preText = editText.getText().toString(); 69 | } 70 | recognizer.startVoice(); 71 | } 72 | 73 | private void stopVoice() { 74 | recognizer.stopVoice(); 75 | } 76 | 77 | @SuppressLint("ClickableViewAccessibility") 78 | @Override 79 | public boolean onTouch(View view, MotionEvent motionEvent) { 80 | int action = motionEvent.getAction(); 81 | switch (action) { 82 | case MotionEvent.ACTION_DOWN: 83 | startSpeech(); 84 | break; 85 | case MotionEvent.ACTION_UP: 86 | stopSpeech(); 87 | break; 88 | case MotionEvent.ACTION_MOVE: 89 | if (motionEvent.getY() < -ViewUtils.dpToPx(view.getContext(), 100)) { 90 | stopSpeech(); 91 | } 92 | break; 93 | } 94 | return true; 95 | } 96 | 97 | private void startSpeech() { 98 | if (ContextCompat.checkSelfPermission(editText.getContext(), 99 | Manifest.permission.RECORD_AUDIO) != PackageManager.PERMISSION_GRANTED) { 100 | recognizer.requestPermission(); 101 | return; 102 | } 103 | if (voiceImg != null) { 104 | voiceImg.setBackgroundResource(R.drawable.dset_keyboard_voice_speech_on_white); 105 | } 106 | if (tvTitle != null) { 107 | tvTitle.setText(R.string.dset_voice_release_tips); 108 | tvTitle.setTextColor(ContextCompat.getColor(tvTitle.getContext(), R.color.dset_white)); 109 | } 110 | if (voiceBg != null) { 111 | voiceBg.setBackgroundResource(R.drawable.corner_gray_bg); 112 | } 113 | if (editText != null) { 114 | ((SecurityEditTextInterface) editText).onVoiceStateChanged(1); 115 | } 116 | if (changeTv != null) { 117 | changeTv.setVisibility(View.GONE); 118 | } 119 | stopFlag = true; 120 | KeyboardManager.getInstance().showVoiceLineView(editText, true); 121 | startVoice(); 122 | } 123 | 124 | private void stopSpeech() { 125 | if (tvTitle != null) { 126 | tvTitle.setText(R.string.dset_voice_tips); 127 | tvTitle.setTextColor(ContextCompat.getColor(tvTitle.getContext(), R.color.dset_text_black)); 128 | } 129 | if (voiceImg != null) { 130 | voiceImg.setBackgroundResource(R.drawable.dset_keyboard_voice_speech_off_gray); 131 | } 132 | if (editText != null) { 133 | ((SecurityEditTextInterface) editText).onVoiceStateChanged(0); 134 | } 135 | if (voiceBg != null) { 136 | voiceBg.setBackgroundResource(R.drawable.corner_white_bg); 137 | } 138 | if (changeTv != null) { 139 | changeTv.setVisibility(View.VISIBLE); 140 | } 141 | stopFlag = false; 142 | KeyboardManager.getInstance().showVoiceLineView(editText, false); 143 | stopVoice(); 144 | } 145 | 146 | @Override 147 | public void onSuccess(String result) { 148 | result = preText + result; 149 | if (!TextUtils.isEmpty(result) && editText != null) { 150 | editText.setText(result); 151 | editText.setSelection(editText.getText().length()); 152 | } 153 | } 154 | 155 | @Override 156 | public void onFailure(String errorMsg, int errorCode) { 157 | ((SecurityEditTextInterface) editText).onVoiceErrorState(errorCode); 158 | } 159 | 160 | @Override 161 | public void onVolumeChange(int volume) { 162 | } 163 | 164 | @Override 165 | public void onExit() { 166 | if (stopFlag) { 167 | startVoice(); 168 | } 169 | } 170 | 171 | @Override 172 | public void onNoPermission() { 173 | stopFlag = false; 174 | if (voiceImg != null) { 175 | voiceImg.setBackgroundResource(R.drawable.dset_keyboard_voice_speech_on_white); 176 | } 177 | KeyboardManager.getInstance().showVoiceLineView(editText, true); 178 | } 179 | } 180 | -------------------------------------------------------------------------------- /library/src/main/java/com/dfzq/dset/view/SecretKeyboardView.java: -------------------------------------------------------------------------------- 1 | package com.dfzq.dset.view; 2 | 3 | import android.content.Context; 4 | import android.graphics.Canvas; 5 | import android.graphics.Color; 6 | import android.graphics.Paint; 7 | import android.graphics.Rect; 8 | import android.graphics.drawable.Drawable; 9 | import android.inputmethodservice.Keyboard; 10 | import android.inputmethodservice.KeyboardView; 11 | import android.util.AttributeSet; 12 | 13 | import androidx.core.content.ContextCompat; 14 | 15 | import com.dfzq.dset.KeyboardManager; 16 | import com.dfzq.dset.R; 17 | 18 | import java.util.List; 19 | 20 | import static android.inputmethodservice.Keyboard.KEYCODE_DONE; 21 | 22 | /** 23 | * Created by wangtao on 16/8/29. 24 | */ 25 | public class SecretKeyboardView extends KeyboardView { 26 | public static final int KEYBOARD_NUM = 0x01; 27 | public static final int KEYBOARD_ID = 0x02; 28 | public static final int KEYBOARD_NUM_ONLY = 0x03; 29 | public static final int KEYBOARD_TYPICAL = 0x04; 30 | public static final int KEYBOARD_STOCK_NUM = 0x05; 31 | public static final int KEYBOARD_STOCK_LETTER = 0x06; 32 | 33 | protected boolean isHideEnable = true; 34 | 35 | private final Paint paint = new Paint(); 36 | 37 | public SecretKeyboardView(Context context, AttributeSet attrs) { 38 | super(context, attrs); 39 | init(); 40 | } 41 | 42 | public SecretKeyboardView(Context context, AttributeSet attrs, int defStyleAttr) { 43 | super(context, attrs, defStyleAttr); 44 | init(); 45 | } 46 | 47 | public void setHideEnable(boolean hideEnable) { 48 | isHideEnable = hideEnable; 49 | } 50 | 51 | protected int dip2px(int dip) { 52 | float scale = getResources().getDisplayMetrics().density; 53 | return (int) (dip * scale + 0.5f); 54 | } 55 | 56 | private void init() { 57 | paint.setTextAlign(Paint.Align.CENTER); 58 | paint.setColor(Color.parseColor("#333333")); 59 | paint.setAntiAlias(true); 60 | } 61 | 62 | @Override 63 | public void onDraw(Canvas canvas) { 64 | super.onDraw(canvas); 65 | if (getKeyboard() != null) { 66 | List keys = getKeyboard().getKeys(); 67 | for (Keyboard.Key key : keys) { 68 | draw(key, canvas); 69 | } 70 | } 71 | } 72 | 73 | protected void draw(Keyboard.Key key, Canvas canvas) { 74 | int code = key.codes[0]; 75 | if (!isHideEnable && code == KEYCODE_DONE) { 76 | key.icon = null; 77 | } 78 | // 特殊键位添加背景,同时重绘键位文字或icon 79 | if (code < 0 || code == 46) { 80 | drawKeyBackground(R.drawable.dset_btn_keyboard_special_bg, canvas, key); 81 | drawKeyText(canvas, key); 82 | drawKeyIcon(canvas, key); 83 | } 84 | // logo 85 | if (code == 32) { 86 | drawKeyBackground(KeyboardManager.logo, canvas, key); 87 | } 88 | } 89 | 90 | /** 91 | * 键位背景 92 | */ 93 | protected void drawKeyBackground(int drawableId, Canvas canvas, Keyboard.Key key) { 94 | Drawable npd = ContextCompat.getDrawable(getContext(), drawableId); 95 | if (npd == null) return; 96 | int[] drawableState = key.getCurrentDrawableState(); 97 | if (key.codes[0] != 0) { 98 | npd.setState(drawableState); 99 | } 100 | npd.setBounds(key.x, key.y, key.x + key.width, key.y 101 | + key.height); 102 | npd.draw(canvas); 103 | } 104 | 105 | /** 106 | * 键位文字 107 | */ 108 | protected void drawKeyText(Canvas canvas, Keyboard.Key key) { 109 | if (key.label == null) return; 110 | Rect bounds = new Rect(); 111 | if (key.codes[0] == -16) { 112 | paint.setTextSize(dip2px(18)); 113 | } else { 114 | paint.setTextSize(dip2px(20)); 115 | } 116 | paint.getTextBounds(key.label.toString(), 0, key.label.toString() 117 | .length(), bounds); 118 | canvas.drawText(key.label.toString(), key.x + (float) (key.width / 2), 119 | (float) (key.y + key.height / 2) + (float) bounds.height() / 2, paint); 120 | } 121 | 122 | /** 123 | * 键位icon 124 | */ 125 | protected void drawKeyIcon(Canvas canvas, Keyboard.Key key) { 126 | if (key.icon == null) return; 127 | Rect bound = new Rect(key.x + (key.width - key.icon.getIntrinsicWidth()) / 2, 128 | key.y + (key.height - key.icon.getIntrinsicHeight()) / 2, 129 | key.x + (key.width - key.icon.getIntrinsicWidth()) / 2 + key.icon.getIntrinsicWidth(), 130 | key.y + (key.height - key.icon.getIntrinsicHeight()) / 2 + key.icon.getIntrinsicHeight()); 131 | key.icon.setBounds(bound); 132 | key.icon.draw(canvas); 133 | } 134 | 135 | 136 | /** 137 | * 键盘大小写切换 138 | */ 139 | public void changeShift() { 140 | boolean upperCased = getKeyboard().isShifted(); 141 | getKeyboard().setShifted(!upperCased); 142 | Keyboard keyboard = getKeyboard(); 143 | changeKey(upperCased, getKeyboard().getKeys()); 144 | Keyboard.Key shiftedKey = keyboard.getKeys().get(keyboard.getShiftKeyIndex()); 145 | if (shiftedKey != null) { 146 | if (isShifted()) { 147 | shiftedKey.icon = ContextCompat.getDrawable(getContext(), R.drawable.dset_ic_keyboard_capslock_up_32dp); 148 | } else { 149 | shiftedKey.icon = ContextCompat.getDrawable(getContext(), R.drawable.dset_ic_keyboard_capslock_lower_32dp); 150 | } 151 | } 152 | invalidateAllKeys(); 153 | } 154 | 155 | /** 156 | * 键位code值的大小写切换 157 | */ 158 | private void changeKey(boolean isUpper, List keyList) { 159 | if (isUpper) {// 大写切小写 160 | for (android.inputmethodservice.Keyboard.Key key : keyList) { 161 | if (key.label != null && isWord(key.label.toString())) { 162 | key.codes[0] = key.codes[0] + 32; 163 | } 164 | } 165 | } else {// 小写切大写 166 | for (android.inputmethodservice.Keyboard.Key key : keyList) { 167 | if (key.label != null && isWord(key.label.toString())) { 168 | key.codes[0] = key.codes[0] - 32; 169 | } 170 | } 171 | } 172 | } 173 | 174 | /** 175 | * 判断是否为字母 176 | */ 177 | private boolean isWord(String str) { 178 | String wordStr = "abcdefghijklmnopqrstuvwxyz"; 179 | return wordStr.contains(str.toLowerCase()); 180 | } 181 | } 182 | -------------------------------------------------------------------------------- /library/src/main/java/com/dfzq/dset/KeyboardManager.java: -------------------------------------------------------------------------------- 1 | package com.dfzq.dset; 2 | 3 | import android.app.Activity; 4 | import android.content.Context; 5 | import android.content.ContextWrapper; 6 | import android.os.Looper; 7 | import android.util.SparseIntArray; 8 | import android.view.ViewGroup; 9 | import android.widget.EditText; 10 | 11 | import androidx.annotation.NonNull; 12 | import androidx.appcompat.app.AppCompatActivity; 13 | import androidx.lifecycle.DefaultLifecycleObserver; 14 | import androidx.lifecycle.LifecycleOwner; 15 | 16 | import com.dfzq.dset.provider.Recognizer; 17 | 18 | import java.lang.ref.WeakReference; 19 | import java.util.HashMap; 20 | import java.util.Map; 21 | 22 | import javax.inject.Provider; 23 | 24 | /** 25 | * ProductName:DsetKeyboard 26 | * PackageName:com.xiaomao.keyboard_id.keyboard_id 27 | * Dage:2016/10/14 28 | * Author:Fredric 29 | * Coding is an art not science 30 | */ 31 | 32 | public class KeyboardManager { 33 | // 是否随机 34 | public static boolean needRandom = false; 35 | public static int logo = R.drawable.dset_keyboard_special_btn_bg; 36 | public static String assetsFolder = ""; 37 | public static String animationName = ""; 38 | private WeakReference keyboardWeakReference; 39 | private boolean confuse; 40 | private SparseIntArray keys = new SparseIntArray(); 41 | private final Map dialogKeyboardMap = new HashMap<>(); 42 | private Provider provider; 43 | 44 | private static final class KeyboardManagerHolder { 45 | static final KeyboardManager keyboardManager = new KeyboardManager(); 46 | } 47 | 48 | public static KeyboardManager getInstance() { 49 | return KeyboardManagerHolder.keyboardManager; 50 | } 51 | 52 | public Provider getProvider() { 53 | return provider; 54 | } 55 | 56 | public void setProvider(Provider provider) { 57 | this.provider = provider; 58 | } 59 | 60 | public void clearKeys() { 61 | keys = new SparseIntArray(); 62 | } 63 | 64 | public void setKeys(SparseIntArray keys) { 65 | this.keys = keys; 66 | } 67 | 68 | public boolean isConfuse() { 69 | return confuse; 70 | } 71 | 72 | public void setConfuse(boolean confuse) { 73 | this.confuse = confuse; 74 | } 75 | 76 | /** 77 | * Validate EditText state 78 | * 79 | * @param editText 输入框 80 | * @return 输入框是否获取焦点 81 | */ 82 | private boolean validEditText(EditText editText) { 83 | if (!(editText instanceof SecurityEditTextInterface)) { 84 | return false; 85 | } 86 | return editText.isAttachedToWindow(); 87 | } 88 | 89 | public void showVoiceLineView(EditText editText, boolean flag) { 90 | if (editText != null) { 91 | DsetKeyboard keyboard = getKeyboard(editText, false); 92 | if (keyboard == null) { 93 | return; 94 | } 95 | keyboard.showVoiceView(flag); 96 | } 97 | } 98 | 99 | public boolean showSoftInput(EditText editText) { 100 | if (Thread.currentThread() != Looper.getMainLooper().getThread()) { 101 | return false; 102 | } 103 | if (!validEditText(editText)) { 104 | return false; 105 | } 106 | SecurityEditTextInterface securityEditTextInterface = (SecurityEditTextInterface) editText; 107 | DsetKeyboard keyboard = getKeyboard(editText); 108 | if (keyboard == null) { 109 | return false; 110 | } 111 | keyboard.showKeyboard(editText, securityEditTextInterface.getType(), securityEditTextInterface.getVoice(), securityEditTextInterface.isMask()); 112 | keyboardWeakReference = new WeakReference<>(keyboard); 113 | return true; 114 | 115 | } 116 | 117 | public void hideSoftInput() { 118 | DsetKeyboard keyboard = currentKeyboard(); 119 | if (keyboard != null) { 120 | keyboard.hideKeyboard(); 121 | } 122 | } 123 | 124 | boolean hideSoftInput(EditText editText) { 125 | DsetKeyboard keyboard = getKeyboard(editText, false); 126 | if (keyboard != null && keyboard.getFocus() == editText) { 127 | return keyboard.hideKeyboard(); 128 | } 129 | return false; 130 | } 131 | 132 | private DsetKeyboard currentKeyboard() { 133 | if (keyboardWeakReference != null) { 134 | return keyboardWeakReference.get(); 135 | } else { 136 | return null; 137 | } 138 | } 139 | 140 | int confuse(int code) { 141 | return keys.get(code, code); 142 | } 143 | 144 | private DsetKeyboard getKeyboard(EditText editText) { 145 | return getKeyboard(editText, true); 146 | } 147 | 148 | private DsetKeyboard getKeyboard(EditText editText, boolean autoBuild) { 149 | int frameId = ((SecurityEditTextInterface) editText).getKeyboardFrameId(); 150 | DsetKeyboard keyboard = null; 151 | if (frameId > 0) { 152 | ViewGroup parent = editText.getRootView().findViewById(frameId); 153 | Object tag = parent.getTag(R.id.dset_keyboard_id); 154 | if (tag instanceof DsetKeyboard) { 155 | keyboard = (DsetKeyboard) tag; 156 | } else if (tag == null && autoBuild) { 157 | keyboard = new DsetKeyboard(parent); 158 | parent.setTag(R.id.dset_keyboard_id, keyboard); 159 | } 160 | } else { 161 | AppCompatActivity activity = getActivity(editText.getContext()); 162 | if (activity != null) { 163 | keyboard = dialogKeyboardMap.get(activity); 164 | if (dialogKeyboardMap.get(activity) == null && autoBuild) { 165 | keyboard = new DsetKeyboard(activity); 166 | dialogKeyboardMap.put(activity, keyboard); 167 | 168 | activity.getLifecycle().addObserver(new DefaultLifecycleObserver() { 169 | @Override 170 | public void onDestroy(@NonNull LifecycleOwner owner) { 171 | DsetKeyboard keyboard = dialogKeyboardMap.remove(activity); 172 | if (keyboard != null) { 173 | keyboard.hideKeyboardImme(); 174 | } 175 | } 176 | }); 177 | } 178 | } 179 | } 180 | return keyboard; 181 | } 182 | 183 | private AppCompatActivity getActivity(Context context) { 184 | Context baseContext = context; 185 | while (baseContext instanceof ContextWrapper) { 186 | if (baseContext instanceof AppCompatActivity) { 187 | return (AppCompatActivity) baseContext; 188 | } 189 | baseContext = ((ContextWrapper) baseContext).getBaseContext(); 190 | } 191 | return null; 192 | } 193 | 194 | } 195 | -------------------------------------------------------------------------------- /library/src/main/java/com/dfzq/dset/KeyboardListener.java: -------------------------------------------------------------------------------- 1 | package com.dfzq.dset; 2 | 3 | import android.inputmethodservice.KeyboardView; 4 | import android.text.Editable; 5 | import android.widget.EditText; 6 | 7 | import com.dfzq.dset.view.SecretKeyboardView; 8 | 9 | import static android.inputmethodservice.Keyboard.KEYCODE_ALT; 10 | import static android.inputmethodservice.Keyboard.KEYCODE_DELETE; 11 | import static android.inputmethodservice.Keyboard.KEYCODE_DONE; 12 | import static android.inputmethodservice.Keyboard.KEYCODE_MODE_CHANGE; 13 | import static android.inputmethodservice.Keyboard.KEYCODE_SHIFT; 14 | import static com.dfzq.dset.view.SecretKeyboardView.KEYBOARD_NUM; 15 | import static com.dfzq.dset.view.SecretKeyboardView.KEYBOARD_NUM_ONLY; 16 | import static com.dfzq.dset.view.SecretKeyboardView.KEYBOARD_STOCK_LETTER; 17 | import static com.dfzq.dset.view.SecretKeyboardView.KEYBOARD_STOCK_NUM; 18 | import static com.dfzq.dset.view.SecretKeyboardView.KEYBOARD_TYPICAL; 19 | 20 | 21 | /** 22 | * ProductName:DsetKeyboard 23 | * PackageName:com.xiaomao.keyboard_id.keyboard_id 24 | * Dage:2016/10/14 25 | * Author:Fredric 26 | * Coding is an art not science 27 | */ 28 | 29 | class KeyboardListener implements KeyboardView.OnKeyboardActionListener { 30 | public static final int SPACE = 32; // 空格键 31 | private static final int KEYCODE_600 = -10; 32 | private static final int KEYCODE_601 = -11; 33 | private static final int KEYCODE_002 = -12; 34 | private static final int KEYCODE_300 = -13; 35 | private static final int KEYCODE_000 = -15; 36 | private static final int KEYCODE_SWITCH_SYSTEM = -16; 37 | private static final int KEYCODE_688 = -17; 38 | 39 | private SecretKeyboardView keyboardView; 40 | private final DsetKeyboard dsetKeyboard; 41 | 42 | public void setKeyboardView(SecretKeyboardView keyboardView) { 43 | this.keyboardView = keyboardView; 44 | } 45 | 46 | public KeyboardListener(SecretKeyboardView keyboardView, DsetKeyboard dsetKeyboard) { 47 | this.keyboardView = keyboardView; 48 | this.dsetKeyboard = dsetKeyboard; 49 | } 50 | 51 | @Override 52 | public void onPress(int primaryCode) { 53 | 54 | } 55 | 56 | @Override 57 | public void onRelease(int primaryCode) { 58 | 59 | } 60 | 61 | @Override 62 | public void onKey(int primaryCode, int[] keyCodes) { 63 | KeyboardManager keyboardManager = KeyboardManager.getInstance(); 64 | EditText editText = dsetKeyboard.getFocus(); 65 | if (!(editText instanceof SecurityEditTextInterface)) { 66 | return; 67 | } 68 | SecurityEditTextInterface securityEditTextInterface = (SecurityEditTextInterface) editText; 69 | Editable editable = editText.getText(); 70 | int start = editText.getSelectionStart(); 71 | int type = securityEditTextInterface.getType(); 72 | 73 | switch (primaryCode) { 74 | case SPACE: 75 | break; 76 | case KEYCODE_SWITCH_SYSTEM: 77 | ((SecurityEditTextInterface) editText).switchSoftKeyboardWithSystem(); 78 | break; 79 | case KEYCODE_600: 80 | case KEYCODE_601: 81 | case KEYCODE_300: 82 | case KEYCODE_000: 83 | case KEYCODE_002: 84 | case KEYCODE_688:// 解决多code 快速点击错误问题 85 | if (editable != null) { 86 | editable.insert(start, getKeyLabel(primaryCode)); 87 | } 88 | break; 89 | case KEYCODE_DELETE: { 90 | if (editable != null && editable.length() > 0) { 91 | if (start > 0) { 92 | editable.delete(start - 1, start); 93 | } 94 | } 95 | } 96 | break; 97 | case KEYCODE_DONE: 98 | case KEYCODE_ALT: { 99 | if (((SecurityEditTextInterface) editText).isHideEnable()) { 100 | ((SecurityEditTextInterface) editText).hideSystemSoftKeyboard(); 101 | ((SecurityEditTextInterface) editText).hideSoftKeyboard(); 102 | } 103 | } 104 | break; 105 | case KEYCODE_SHIFT: { 106 | keyboardView.changeShift(); 107 | } 108 | break; 109 | 110 | case KEYCODE_MODE_CHANGE: { 111 | if (type == KEYBOARD_STOCK_LETTER) { 112 | securityEditTextInterface.setType(KEYBOARD_STOCK_NUM); 113 | } else if (type == KEYBOARD_STOCK_NUM) { 114 | securityEditTextInterface.setType(KEYBOARD_STOCK_LETTER); 115 | } else if (type == KEYBOARD_NUM) { 116 | securityEditTextInterface.setType(KEYBOARD_TYPICAL); 117 | } else { 118 | securityEditTextInterface.setType(KEYBOARD_NUM); 119 | } 120 | KeyboardManager.getInstance().showSoftInput(editText); 121 | } 122 | break; 123 | default: 124 | if (editable != null) { 125 | StringBuilder str = new StringBuilder(); 126 | boolean confuse = keyboardManager.isConfuse() && confusable(type); 127 | for (int pChar : keyCodes) { 128 | if (pChar == -1) { 129 | break; 130 | } 131 | if (confuse) { 132 | str.append((char) keyboardManager.confuse(pChar)); 133 | } else { 134 | str.append((char) pChar); 135 | } 136 | } 137 | editable.insert(start, str.toString()); 138 | } 139 | break; 140 | } 141 | } 142 | 143 | private boolean confusable(int type) { 144 | return type == KEYBOARD_NUM || 145 | type == KEYBOARD_NUM_ONLY || 146 | type == KEYBOARD_TYPICAL; 147 | } 148 | 149 | private CharSequence getKeyLabel(int keyCode) { 150 | switch (keyCode) { 151 | case KEYCODE_600: 152 | return "600"; 153 | case KEYCODE_601: 154 | return "601"; 155 | case KEYCODE_300: 156 | return "300"; 157 | case KEYCODE_000: 158 | return "000"; 159 | case KEYCODE_002: 160 | return "002"; 161 | case KEYCODE_688: 162 | return "688"; 163 | default: 164 | return ""; 165 | } 166 | } 167 | 168 | @Override 169 | public void onText(CharSequence text) { 170 | 171 | } 172 | 173 | @Override 174 | public void swipeLeft() { 175 | 176 | } 177 | 178 | @Override 179 | public void swipeRight() { 180 | 181 | } 182 | 183 | @Override 184 | public void swipeDown() { 185 | 186 | } 187 | 188 | @Override 189 | public void swipeUp() { 190 | 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_login.xml: -------------------------------------------------------------------------------- 1 | 13 | 14 | 15 | 22 | 23 | 27 | 28 | 32 | 33 | 44 | 45 | 51 | 52 | 67 | 68 | 76 | 77 | 78 | 81 | 82 | 92 | 93 | 94 | 95 | 98 | 99 | 108 | 109 | 110 | 111 | 114 | 115 | 125 | 126 | 127 | 128 | 131 | 132 | 139 | 140 | 141 | 142 |