Skip to content

Commit c273859

Browse files
author
hzliujq
committed
增加带启动activity 和 模拟输入法view的改进版adbkeyboard
1 parent ad54ed6 commit c273859

File tree

9 files changed

+151
-11
lines changed

9 files changed

+151
-11
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#Wed Mar 09 10:25:30 CET 2016
1+
#Thu Jul 06 10:31:50 CST 2017
22
distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-bin.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-all.zip

keyboardservice/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
apply plugin: 'com.android.application'
22

33
android {
4-
compileSdkVersion 23
4+
compileSdkVersion 24
55
buildToolsVersion "23.0.2"
66

77
defaultConfig {
88
applicationId 'com.android.adbkeyboard'
99
minSdkVersion 15
1010
targetSdkVersion 22
1111
versionCode 1
12-
versionName "1.0"
12+
versionName "1.1"
1313
}
1414
}
1515

1616
dependencies {
1717
compile fileTree(include: ['*.jar'], dir: 'libs')
18+
compile 'com.android.support:appcompat-v7:24.0.0'
1819
}

keyboardservice/src/main/AndroidManifest.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@
1212
android:icon="@drawable/ic_launcher"
1313
android:label="@string/app_name"
1414
android:theme="@style/AppTheme" >
15+
16+
<activity android:name=".MainActivity">
17+
<intent-filter>
18+
<action android:name="android.intent.action.MAIN" />
19+
20+
<category android:name="android.intent.category.LAUNCHER" />
21+
</intent-filter>
22+
</activity>
1523

1624
<!-- Declares the input method service -->
1725
<service android:name="AdbIME"

keyboardservice/src/main/java/com/android/adbkeyboard/AdbIME.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
import android.view.KeyEvent;
1010
import android.view.View;
1111
import android.view.inputmethod.InputConnection;
12+
import android.widget.Button;
1213

13-
public class AdbIME extends InputMethodService {
14+
public class AdbIME extends InputMethodService implements View.OnClickListener {
1415
private String IME_MESSAGE = "ADB_INPUT_TEXT";
1516
private String IME_CHARS = "ADB_INPUT_CHARS";
1617
private String IME_KEYCODE = "ADB_INPUT_CODE";
@@ -19,7 +20,9 @@ public class AdbIME extends InputMethodService {
1920

2021
@Override
2122
public View onCreateInputView() {
22-
View mInputView = getLayoutInflater().inflate(R.layout.view, null);
23+
// View mInputView = getLayoutInflater().inflate(R.layout.view, null);
24+
View view = getLayoutInflater().inflate(R.layout.keyboard, null);
25+
view.findViewById(R.id.button5).setOnClickListener(this);
2326

2427
if (mReceiver == null) {
2528
IntentFilter filter = new IntentFilter(IME_MESSAGE);
@@ -30,8 +33,15 @@ public View onCreateInputView() {
3033
registerReceiver(mReceiver, filter);
3134
}
3235

33-
return mInputView;
34-
}
36+
return view;
37+
}
38+
39+
@Override
40+
public void onClick(View v) {
41+
if(v.getId() == R.id.button5){
42+
hideWindow();
43+
}
44+
}
3545

3646
public void onDestroy() {
3747
if (mReceiver != null)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.android.adbkeyboard;
2+
3+
import android.support.v7.app.AppCompatActivity;
4+
import android.os.Bundle;
5+
6+
public class MainActivity extends AppCompatActivity {
7+
8+
@Override
9+
protected void onCreate(Bundle savedInstanceState) {
10+
super.onCreate(savedInstanceState);
11+
setContentView(R.layout.activity_main);
12+
}
13+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:tools="http://schemas.android.com/tools"
4+
android:layout_width="match_parent"
5+
android:layout_height="match_parent"
6+
tools:context="com.android.adbkeyboard.MainActivity">
7+
8+
<Button
9+
android:layout_width="wrap_content"
10+
android:layout_height="wrap_content"
11+
android:id="@+id/button2"
12+
android:text="启动语音监听"
13+
android:contentDescription="启动语音监听"
14+
android:layout_centerHorizontal="true" />
15+
16+
<Button
17+
android:layout_width="wrap_content"
18+
android:layout_height="wrap_content"
19+
android:text="停止语音监听"
20+
android:id="@+id/button"
21+
android:contentDescription="停止语音监听"
22+
android:layout_below="@+id/button2"
23+
android:layout_alignLeft="@+id/button2"
24+
android:layout_alignStart="@+id/button2"
25+
android:layout_alignRight="@+id/button2"
26+
android:layout_alignEnd="@+id/button2" />
27+
28+
<Button
29+
android:layout_width="wrap_content"
30+
android:layout_height="wrap_content"
31+
android:text="初始化连接"
32+
android:contentDescription="初始化连接"
33+
android:id="@+id/button3"
34+
android:layout_below="@+id/button"
35+
android:layout_alignLeft="@+id/button2"
36+
android:layout_alignStart="@+id/button2"
37+
android:layout_alignRight="@+id/button2"
38+
android:layout_alignEnd="@+id/button2" />
39+
40+
<EditText
41+
android:id="@+id/plain_text_input"
42+
android:layout_below="@+id/button3"
43+
android:contentDescription="输入框"
44+
android:layout_height="wrap_content"
45+
android:layout_width="match_parent"
46+
android:inputType="text"
47+
android:text="http://10.241.0.23:8090"/>
48+
49+
</RelativeLayout>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
android:layout_width="match_parent"
4+
android:layout_height="250dp"
5+
>
6+
7+
<LinearLayout
8+
android:layout_width="match_parent"
9+
android:layout_height="match_parent"
10+
android:orientation="vertical">
11+
<Button
12+
android:id="@+id/button1"
13+
android:layout_width="match_parent"
14+
android:layout_height="wrap_content"
15+
android:text="Android从入门到放弃"
16+
android:textSize="12sp"/>
17+
18+
<Button
19+
android:id="@+id/button2"
20+
android:layout_width="match_parent"
21+
android:layout_height="wrap_content"
22+
android:text="Java从入门到放弃" />
23+
24+
<Button
25+
android:id="@+id/button3"
26+
android:layout_width="match_parent"
27+
android:layout_height="wrap_content"
28+
android:text="C#从入门到怀疑人生" />
29+
30+
<Button
31+
android:id="@+id/button4"
32+
android:layout_width="match_parent"
33+
android:layout_height="wrap_content"
34+
android:text="OC从入门到怀疑人生" />
35+
36+
<Button
37+
android:id="@+id/button5"
38+
android:layout_width="wrap_content"
39+
android:layout_height="wrap_content"
40+
android:text="隐藏输入法" />
41+
42+
</LinearLayout>
43+
44+
45+
</FrameLayout>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<resources>
3+
<color name="colorPrimary">#3F51B5</color>
4+
<color name="colorPrimaryDark">#303F9F</color>
5+
<color name="colorAccent">#FF4081</color>
6+
</resources>

keyboardservice/src/main/res/values/styles.xml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,16 @@
1313
</style>
1414

1515
<!-- Application theme. -->
16-
<style name="AppTheme" parent="AppBaseTheme">
17-
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
18-
</style>
16+
17+
18+
<!-- Base application theme. -->
19+
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
20+
<!-- Customize your theme here. -->
21+
<item name="colorPrimary">@color/colorPrimary</item>
22+
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
23+
<item name="colorAccent">@color/colorAccent</item>
24+
</style>
25+
26+
1927

2028
</resources>

0 commit comments

Comments
 (0)