Skip to content

Commit

Permalink
增加带启动activity 和 模拟输入法view的改进版adbkeyboard
Browse files Browse the repository at this point in the history
  • Loading branch information
hzliujq committed Jul 26, 2017
1 parent ad54ed6 commit c273859
Show file tree
Hide file tree
Showing 9 changed files with 151 additions and 11 deletions.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Mar 09 10:25:30 CET 2016
#Thu Jul 06 10:31:50 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.11-all.zip
5 changes: 3 additions & 2 deletions keyboardservice/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
compileSdkVersion 24
buildToolsVersion "23.0.2"

defaultConfig {
applicationId 'com.android.adbkeyboard'
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
versionName "1.1"
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:24.0.0'
}
8 changes: 8 additions & 0 deletions keyboardservice/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >

<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<!-- Declares the input method service -->
<service android:name="AdbIME"
Expand Down
18 changes: 14 additions & 4 deletions keyboardservice/src/main/java/com/android/adbkeyboard/AdbIME.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
import android.view.KeyEvent;
import android.view.View;
import android.view.inputmethod.InputConnection;
import android.widget.Button;

public class AdbIME extends InputMethodService {
public class AdbIME extends InputMethodService implements View.OnClickListener {
private String IME_MESSAGE = "ADB_INPUT_TEXT";
private String IME_CHARS = "ADB_INPUT_CHARS";
private String IME_KEYCODE = "ADB_INPUT_CODE";
Expand All @@ -19,7 +20,9 @@ public class AdbIME extends InputMethodService {

@Override
public View onCreateInputView() {
View mInputView = getLayoutInflater().inflate(R.layout.view, null);
// View mInputView = getLayoutInflater().inflate(R.layout.view, null);
View view = getLayoutInflater().inflate(R.layout.keyboard, null);
view.findViewById(R.id.button5).setOnClickListener(this);

if (mReceiver == null) {
IntentFilter filter = new IntentFilter(IME_MESSAGE);
Expand All @@ -30,8 +33,15 @@ public View onCreateInputView() {
registerReceiver(mReceiver, filter);
}

return mInputView;
}
return view;
}

@Override
public void onClick(View v) {
if(v.getId() == R.id.button5){
hideWindow();
}
}

public void onDestroy() {
if (mReceiver != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.android.adbkeyboard;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
49 changes: 49 additions & 0 deletions keyboardservice/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.android.adbkeyboard.MainActivity">

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button2"
android:text="启动语音监听"
android:contentDescription="启动语音监听"
android:layout_centerHorizontal="true" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="停止语音监听"
android:id="@+id/button"
android:contentDescription="停止语音监听"
android:layout_below="@+id/button2"
android:layout_alignLeft="@+id/button2"
android:layout_alignStart="@+id/button2"
android:layout_alignRight="@+id/button2"
android:layout_alignEnd="@+id/button2" />

<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="初始化连接"
android:contentDescription="初始化连接"
android:id="@+id/button3"
android:layout_below="@+id/button"
android:layout_alignLeft="@+id/button2"
android:layout_alignStart="@+id/button2"
android:layout_alignRight="@+id/button2"
android:layout_alignEnd="@+id/button2" />

<EditText
android:id="@+id/plain_text_input"
android:layout_below="@+id/button3"
android:contentDescription="输入框"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:inputType="text"
android:text="http://10.241.0.23:8090"/>

</RelativeLayout>
45 changes: 45 additions & 0 deletions keyboardservice/src/main/res/layout/keyboard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="250dp"
>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Android从入门到放弃"
android:textSize="12sp"/>

<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Java从入门到放弃" />

<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="C#从入门到怀疑人生" />

<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="OC从入门到怀疑人生" />

<Button
android:id="@+id/button5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="隐藏输入法" />

</LinearLayout>


</FrameLayout>
6 changes: 6 additions & 0 deletions keyboardservice/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
</resources>
14 changes: 11 additions & 3 deletions keyboardservice/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@
</style>

<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<!-- All customizations that are NOT specific to a particular API-level can go here. -->
</style>


<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>



</resources>

0 comments on commit c273859

Please sign in to comment.