From 9e51487e234dc352f8d7d5fe4b239bb38323de82 Mon Sep 17 00:00:00 2001 From: Sucareto <28331534+Sucareto@users.noreply.github.com> Date: Tue, 19 Mar 2024 05:32:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BE=9D=E8=B5=96=E5=BA=93?= =?UTF-8?q?=EF=BC=8C=E6=94=AF=E6=8C=81=20Android=208.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 26 ++++----- app/src/main/AndroidManifest.xml | 3 +- .../sucareto/androidhidkeyboard/Keyboard.java | 54 ++++++++----------- build.gradle | 7 +-- gradle.properties | 4 +- gradle/wrapper/gradle-wrapper.properties | 2 +- 6 files changed, 37 insertions(+), 59 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 72fef42..4c8531f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -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' } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2b9d4ea..a2f46aa 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,5 @@ - + { 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; } @@ -93,7 +86,7 @@ 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}; @@ -101,16 +94,15 @@ public boolean onTouch(View v, MotionEvent e) { } 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; } @@ -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; } @@ -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; } @@ -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)); diff --git a/build.gradle b/build.gradle index 7b2734d..57e94aa 100644 --- a/build.gradle +++ b/build.gradle @@ -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 } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 52f5917..6826e61 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 \ No newline at end of file +android.useAndroidX=true \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 69f188e..bee36e6 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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