Skip to content

Commit 567b07b

Browse files
committed
增加adb 快速输入
1 parent 09ba16b commit 567b07b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1495
-107
lines changed

APPTest/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ android {
8686
signingConfig signingConfigs.release
8787
minifyEnabled project.minifyEnabled as boolean
8888
proguardFiles "./../proguard-rules-common.pro"
89-
proguardFiles "./../proguard-rules-mna.pro"
9089
shrinkResources false
9190
}
9291
}

APPTest/src/main/java/com/bihe0832/android/test/module/DebugRouterFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class DebugRouterFragment : com.bihe0832.android.common.debug.module.DebugRouter
1010
add(RouterItem("zixie://zabout"))
1111
add(RouterItem("zixie://m3u8"))
1212
add(RouterItem("zixie://m3u8list"))
13-
13+
add(RouterItem("zixie://guide"))
1414
}
1515
}
1616

Application/src/main/java/com/bihe0832/android/app/Application.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ public void onCreate() {
5555
super.onCreate();
5656
ZLog.d("Application", "Application onCreate start");
5757
AppFactoryInit.INSTANCE.initAll(this);
58-
ZLog.d("Application", "MnaApplication onCreate end");
58+
ZLog.d("Application", "Application onCreate end");
5959
}
6060
}

Application/src/main/java/com/bihe0832/android/app/log/AAFLoggerFile.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@ import com.bihe0832.android.framework.log.LoggerFile
1515
object AAFLoggerFile {
1616

1717
const val MODULE_UPDATE = "udpate"
18+
const val MODULE_INPUT = "input"
1819

1920
fun logUpdate(msg: String) {
2021
log(MODULE_UPDATE, msg)
2122
}
2223

24+
25+
2326
fun log(module: String, msg: String) {
2427
LoggerFile.log(LoggerFile.getZixieFileLogPathByModule(module), msg)
2528
}

Application/src/main/java/com/bihe0832/android/app/router/RouterConstants.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@ public class RouterConstants extends com.bihe0832.android.framework.router.Route
2323
public static final String MODULE_NAME_BROWSER_LIST = "weblist";
2424

2525

26+
public static final String MODULE_NAME_INPUT_GUIDE = "guide";
27+
public static final String INTENT_EXTRA_KEY_INPUT_GUIDE_TYPE = "type";
28+
public static final String INTENT_EXTRA_VALUE_INPUT_SWITCH = "1";
29+
30+
2631
}

Application/src/main/java/com/bihe0832/android/app/update/UpdateManager.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import java.net.HttpURLConnection
2727
*/
2828
object UpdateManager {
2929

30-
private val TAG = "MnaUpdateHelper-> "
30+
private val TAG = "UpdateHelper-> "
3131

3232
fun checkUpdateAndShowDialog(activity: Activity, checkUpdateByUser: Boolean) {
3333
fetchUpdate(activity, {

BaseAdbInput/build.gradle

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
4+
apply plugin: 'kotlin-kapt'
5+
6+
android {
7+
compileSdkVersion project.compileSdkVersion
8+
buildToolsVersion project.buildToolsVersion
9+
10+
11+
defaultConfig {
12+
minSdkVersion project.libMinSdkVersion
13+
targetSdkVersion project.targetSdkVersion
14+
versionName project.zixieVersionName
15+
versionCode project.zixieVersionCode
16+
}
17+
18+
lintOptions {
19+
abortOnError false
20+
}
21+
22+
buildTypes {
23+
debug {
24+
minifyEnabled false
25+
shrinkResources false
26+
}
27+
28+
release {
29+
proguardFiles "./../proguard-rules-common.pro"
30+
shrinkResources false
31+
}
32+
}
33+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
3+
package="com.bihe0832.android.base.adb.input">
4+
5+
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
6+
<!-- New Android Q permission -->
7+
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
8+
9+
10+
<application>
11+
<activity
12+
android:name=".settings.InputSettingsActivity"
13+
android:configChanges="orientation|screenSize|keyboardHidden"
14+
android:excludeFromRecents="true"
15+
android:launchMode="singleTask"
16+
android:screenOrientation="portrait"
17+
android:taskAffinity="com.bihe0832.android.input.diff"
18+
android:theme="@style/AAF.ActivityTheme">
19+
<intent-filter>
20+
<action android:name="android.intent.action.MAIN" />
21+
22+
</intent-filter>
23+
</activity>
24+
25+
26+
<!--核心 继承自InputMethodService-->
27+
<service
28+
android:name="com.bihe0832.android.base.adb.input.ZixieIME"
29+
android:label="子勰ADB快速输入"
30+
android:permission="android.permission.BIND_INPUT_METHOD">
31+
<intent-filter>
32+
<action android:name="android.view.InputMethod" />
33+
</intent-filter>
34+
<meta-data
35+
android:name="android.view.im"
36+
android:resource="@xml/method" />
37+
</service>
38+
</application>
39+
</manifest>
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
package com.bihe0832.android.base.adb.input;
2+
3+
import android.content.BroadcastReceiver;
4+
import android.content.Context;
5+
import android.content.Intent;
6+
import android.content.IntentFilter;
7+
import android.inputmethodservice.InputMethodService;
8+
import android.view.View;
9+
import android.view.inputmethod.EditorInfo;
10+
11+
import com.bihe0832.android.base.adb.input.keyboard.InputManager;
12+
import com.bihe0832.android.base.adb.input.keyboard.InputManager.InputServiceActionListener;
13+
import com.bihe0832.android.framework.log.LoggerTrace;
14+
import com.bihe0832.android.lib.log.ZLog;
15+
16+
import org.jetbrains.annotations.NotNull;
17+
18+
19+
public class ZixieIME extends InputMethodService {
20+
21+
public String IME_ADB_INPUT_ACTION = "ZIXIE_ADB_INPUT";
22+
public static final String IME_NAME = "com.bihe0832.android.app.test/com.bihe0832.android.base.adb.input.ZixieIME";
23+
24+
public static final String TAG = "InputService";
25+
private InputServiceActionListener mInputServiceActionListener = null;
26+
27+
private BroadcastReceiver mReceiver = null;
28+
29+
@Override
30+
public void onCreate() {
31+
super.onCreate();
32+
InputManager.INSTANCE.setInputMethodService(this);
33+
}
34+
35+
@Override
36+
public View onCreateInputView() {
37+
InputManager.INSTANCE.onCreateInputView(this);
38+
View mInputView = getLayoutInflater().inflate(R.layout.layout_input_keyboard_global, null);
39+
initView(mInputView);
40+
if (mReceiver == null) {
41+
IntentFilter filter = new IntentFilter(IME_ADB_INPUT_ACTION);
42+
filter.addAction(IME_ADB_INPUT_ACTION);
43+
mReceiver = new AdbReceiver();
44+
registerReceiver(mReceiver, filter);
45+
}
46+
return mInputView;
47+
}
48+
49+
@Override
50+
public void onStartInputView(EditorInfo info, boolean restarting) {
51+
ZLog.d(TAG, this + ":onStartInputView");
52+
super.onStartInputView(info, restarting);
53+
InputManager.INSTANCE.onStartInputView(info, restarting);
54+
}
55+
56+
57+
@Override
58+
public void onFinishInputView(boolean finishingInput) {
59+
super.onFinishInputView(finishingInput);
60+
ZLog.d(TAG, this.toString() + ":onFinishInputView");
61+
InputManager.INSTANCE.onFinishInputView(finishingInput);
62+
}
63+
64+
@Override
65+
public void onDestroy() {
66+
ZLog.d(TAG, this.toString() + ":onDestroy");
67+
InputManager.INSTANCE.clearInputServiceActionListener();
68+
if (mReceiver != null) {
69+
unregisterReceiver(mReceiver);
70+
}
71+
super.onDestroy();
72+
}
73+
74+
75+
@Override
76+
public View onCreateCandidatesView() {
77+
View mInputView = getLayoutInflater().inflate(R.layout.layout_input_toolbar, null);
78+
return mInputView;
79+
}
80+
81+
private final void initView(final View mInputView) {
82+
InputManager.INSTANCE.addInputServiceActionListener(new InputServiceActionListener() {
83+
@Override
84+
public void onStartInputView(@NotNull EditorInfo info, boolean restarting) {
85+
if (null != mInputServiceActionListener) {
86+
mInputServiceActionListener.onStartInputView(info, restarting);
87+
}
88+
}
89+
90+
@Override
91+
public void onFinishInputView(boolean finishingInput) {
92+
if (null != mInputServiceActionListener) {
93+
mInputServiceActionListener.onFinishInputView(finishingInput);
94+
}
95+
}
96+
97+
@Override
98+
public void onCreateInputView() {
99+
if (null != mInputServiceActionListener) {
100+
mInputServiceActionListener.onCreateInputView();
101+
}
102+
}
103+
104+
@Override
105+
public void onChangeInputType(int currentInputType) {
106+
LoggerTrace.INSTANCE.showResult(TAG);
107+
if (null != mInputServiceActionListener) {
108+
mInputServiceActionListener.onChangeInputType(currentInputType);
109+
}
110+
}
111+
});
112+
}
113+
114+
class AdbReceiver extends BroadcastReceiver {
115+
@Override
116+
public void onReceive(Context context, Intent intent) {
117+
if (intent.getAction().equals(IME_ADB_INPUT_ACTION)) {
118+
String msg = intent.getStringExtra("msg");
119+
if (msg != null) {
120+
InputManager.INSTANCE.commitResultText(msg);
121+
}
122+
}
123+
}
124+
}
125+
126+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.bihe0832.android.base.adb.input.config
2+
3+
import com.bihe0832.android.lib.config.Config
4+
5+
/**
6+
* @author zixie code@bihe0832.com Created on 4/9/21.
7+
*/
8+
object InputSwitchConfig {
9+
10+
private val KEY_NOTIFY = "com.bihe0832.input.config.notify"
11+
private val KEY_RECORD = "com.bihe0832.input.config.record"
12+
13+
fun canNotify(): Boolean {
14+
return Config.isSwitchEnabled(KEY_NOTIFY, true)
15+
}
16+
17+
fun setNotify(notify: Boolean) {
18+
Config.writeConfig(KEY_NOTIFY, notify)
19+
}
20+
21+
fun canRecord(): Boolean {
22+
return Config.isSwitchEnabled(KEY_RECORD, true)
23+
}
24+
25+
fun setRecord(record: Boolean) {
26+
Config.writeConfig(KEY_RECORD, record)
27+
}
28+
29+
}

0 commit comments

Comments
 (0)