Skip to content

Commit

Permalink
更新依赖库,支持 Android 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Sucareto committed Mar 18, 2024
1 parent 0051f2c commit 9e51487
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 59 deletions.
26 changes: 11 additions & 15 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,35 @@ plugins {
}

android {
compileSdk 31

compileSdk 34
defaultConfig {
applicationId "org.sucareto.androidhidkeyboard"
minSdk 29
targetSdk 31
versionCode 10
versionName '1.5.1'
minSdk 26
targetSdk 34
versionCode 11
versionName '1.5.2'
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
buildFeatures {
viewBinding true
}
namespace 'org.sucareto.androidhidkeyboard'
}

dependencies {

implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.11.0'
}

dependencies {
def libsuVersion = '3.2.1'
implementation "com.github.topjohnwu.libsu:core:${libsuVersion}"
implementation "com.github.topjohnwu.libsu:io:${libsuVersion}"
implementation 'com.github.topjohnwu.libsu:io:5.2.2'
}
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.sucareto.androidhidkeyboard">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application
android:icon="@mipmap/ic_launcher"
Expand Down
54 changes: 21 additions & 33 deletions app/src/main/java/org/sucareto/androidhidkeyboard/Keyboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ public class Keyboard extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View root_view = ActivityKeyboardBinding.inflate(getLayoutInflater()).getRoot();
root_view.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
setContentView(root_view);

findViewById(R.id.BtnSpace).setOnTouchListener(new SpaceOnTouch());
Expand Down Expand Up @@ -71,18 +65,17 @@ private class SpaceOnTouch implements View.OnTouchListener {
@Override
public boolean onTouch(View v, MotionEvent e) {
switch (e.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_DOWN -> {
v.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_PRESS);
if (FnEnable) {
startActivity(new Intent(Keyboard.this, Mouse.class));
break;
}
hid.kPress((byte) Integer.parseInt(v.getTag().toString(), 16));
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
}
case MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
hid.kRelease((byte) Integer.parseInt(v.getTag().toString(), 16));
break;
}
}
return false;
}
Expand All @@ -93,24 +86,23 @@ private class EnterOnTouch implements View.OnTouchListener {
@Override
public boolean onTouch(View v, MotionEvent e) {
switch (e.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_DOWN -> {
v.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_PRESS);
if (FnEnable) {
hid.kCode = new byte[]{0x05, 0, 0x4c, 0, 0, 0, 0, 0};
hid.kSend();
} else {
hid.kPress((byte) Integer.parseInt(v.getTag().toString(), 16));
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
}
case MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
if (FnEnable) {
hid.kCode = new byte[]{0, 0, 0, 0, 0, 0, 0, 0};
hid.kSend();
} else {
hid.kRelease((byte) Integer.parseInt(v.getTag().toString(), 16));
}
break;
}
}
return false;
}
Expand All @@ -121,14 +113,13 @@ private class CtrlKeyOnTouch implements View.OnTouchListener {
@Override
public boolean onTouch(View v, MotionEvent e) {
switch (e.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_DOWN -> {
v.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_PRESS);
hid.kPress_c((byte) Integer.parseInt(v.getTag().toString(), 16));
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
}
case MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
hid.kRelease_c((byte) Integer.parseInt(v.getTag().toString(), 16));
break;
}
}
return false;
}
Expand All @@ -139,14 +130,13 @@ private class KeyOnTouch implements View.OnTouchListener {
@Override
public boolean onTouch(View v, MotionEvent e) {
switch (e.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_DOWN -> {
v.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_PRESS);
hid.kPress((byte) Integer.parseInt(v.getTag().toString(), 16));
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
}
case MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
hid.kRelease((byte) Integer.parseInt(v.getTag().toString(), 16));
break;
}
}
return false;
}
Expand All @@ -157,16 +147,14 @@ private class FnKeyOnTouch implements View.OnTouchListener {
@Override
public boolean onTouch(View v, MotionEvent e) {
switch (e.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_DOWN -> {
v.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_PRESS);
FnEnable = true;
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
FnEnable = false;
break;
default:
}
case MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> FnEnable = false;
default -> {
return false;
}
}
((Button) findViewById(R.id.Btn12)).setText(getResources().getString(FnEnable ? R.string.KeyText78 : R.string.KeyText12));//Insert
findViewById(R.id.Btn12).setTag(getResources().getString(FnEnable ? R.string.KeyCode78 : R.string.KeyCode12));
Expand Down
7 changes: 2 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.2'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:8.2.2'
}
}

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
4 changes: 1 addition & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,4 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
# AndroidX package structure to make it clearer which packages are bundled with the
# Android operating system, and which are packaged with your app"s APK
# https://developer.android.com/topic/libraries/support-library/androidx-rn
android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true
android.useAndroidX=true
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Dec 22 22:30:28 CST 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

0 comments on commit 9e51487

Please sign in to comment.