diff --git a/.github/workflows/build_apk.yml b/.github/workflows/build_apk.yml index 72ff079..d431b8d 100644 --- a/.github/workflows/build_apk.yml +++ b/.github/workflows/build_apk.yml @@ -6,7 +6,7 @@ name: Build_TouchHelper_APK # events but only for the master branch on: push: - branches: [ master ] + branches: [ master, refactor ] paths-ignore: - .github/workflows - 'docs/**' @@ -41,27 +41,37 @@ jobs: distribution: 'temurin' java-version: '17' - - name: Assemble Release APK - run: ./gradlew assembleRelease --stacktrace + - name: Assemble Release APK and AAB + run: ./gradlew assembleRelease bundleRelease --stacktrace - name: Upload APK to artifacts uses: actions/upload-artifact@v4 with: - name: TouchHelper + name: TouchHelper-APK path: ./app/build/outputs/apk/ + - name: Upload AAB to artifacts + uses: actions/upload-artifact@v4 + with: + name: TouchHelper-AAB + path: ./app/build/outputs/bundle/release/ + - name: Create ZIPs - working-directory: ./app/build/outputs/apk/ + if: github.ref == 'refs/heads/master' + working-directory: ./app/build/outputs/ run: | - zip -r ./TouchHelper.zip ./release + zip -r ./TouchHelper-APK.zip ./apk/release + zip -r ./TouchHelper-AAB.zip ./bundle/release - name: Get git revision + if: github.ref == 'refs/heads/master' id: get_git_revision run: | echo "tag_name=$(($(git rev-list HEAD --count) + 100))" >> $GITHUB_OUTPUT echo "release_name=$(($(git rev-list HEAD --count) + 100))" >> $GITHUB_OUTPUT - name: Create Release and Upload APK + if: github.ref == 'refs/heads/master' uses: softprops/action-gh-release@v2 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -70,4 +80,6 @@ jobs: name: Release ${{ steps.get_git_revision.outputs.release_name }} draft: false prerelease: false - files: ./app/build/outputs/apk/TouchHelper.zip + files: | + ./app/build/outputs/TouchHelper-APK.zip + ./app/build/outputs/TouchHelper-AAB.zip diff --git a/app/build.gradle b/app/build.gradle index 55c4b28..ecdeabd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -74,21 +74,21 @@ android { } dependencies { - implementation fileTree(dir: "libs", include: ["*.jar"]) - implementation 'androidx.appcompat:appcompat:1.2.0' - implementation 'com.google.android.material:material:1.2.1' - implementation 'androidx.constraintlayout:constraintlayout:2.0.2' - implementation 'androidx.navigation:navigation-fragment:2.1.0' - implementation 'androidx.navigation:navigation-ui:2.1.0' - implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0' - testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + implementation 'androidx.appcompat:appcompat:1.7.0' + implementation 'com.google.android.material:material:1.12.0' + implementation 'androidx.constraintlayout:constraintlayout:2.2.1' + implementation 'androidx.navigation:navigation-fragment:2.8.5' + implementation 'androidx.navigation:navigation-ui:2.8.5' + implementation 'androidx.lifecycle:lifecycle-viewmodel:2.8.7' + implementation 'androidx.lifecycle:lifecycle-livedata:2.8.7' + testImplementation 'junit:junit:4.13.2' + androidTestImplementation 'androidx.test.ext:junit:1.2.1' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' - implementation 'com.google.code.gson:gson:2.8.5' + implementation 'com.google.code.gson:gson:2.11.0' // https://developer.android.com/jetpack/androidx/releases/preference?hl=zh-cn - implementation 'androidx.preference:preference:1.1.1' + implementation 'androidx.preference:preference:1.2.1' // https://mvnrepository.com/artifact/com.belerweb/pinyin4j implementation group: 'com.belerweb', name: 'pinyin4j', version: '2.5.1' diff --git a/app/src/main/java/com/zfdang/touchhelper/TouchHelperServiceImpl.java b/app/src/main/java/com/zfdang/touchhelper/TouchHelperServiceImpl.java index 001217f..a5e7516 100644 --- a/app/src/main/java/com/zfdang/touchhelper/TouchHelperServiceImpl.java +++ b/app/src/main/java/com/zfdang/touchhelper/TouchHelperServiceImpl.java @@ -79,6 +79,7 @@ public class TouchHelperServiceImpl { private static final int PACKAGE_POSITION_CLICK_RETRY_INTERVAL = 500; private static final int PACKAGE_POSITION_CLICK_RETRY = 6; private boolean isShow = false; + private long lastContentChangedTime = 0; public TouchHelperServiceImpl(AccessibilityService service) { this.service = service; @@ -361,6 +362,12 @@ public void run() { break; } + long currentTime = System.currentTimeMillis(); + if (currentTime - lastContentChangedTime < 150) { + break; + } + lastContentChangedTime = currentTime; + if (setTargetedWidgets != null) { if (BuildConfig.DEBUG) { Log.d(TAG, "method by widget in CONTENT_CHANGED"); diff --git a/app/src/main/java/com/zfdang/touchhelper/ui/about/AboutFragment.java b/app/src/main/java/com/zfdang/touchhelper/ui/about/AboutFragment.java index 6129bc0..3b8eeaa 100644 --- a/app/src/main/java/com/zfdang/touchhelper/ui/about/AboutFragment.java +++ b/app/src/main/java/com/zfdang/touchhelper/ui/about/AboutFragment.java @@ -12,9 +12,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; -import androidx.lifecycle.Observer; -import androidx.lifecycle.ViewModelProviders; - import com.zfdang.touchhelper.R; public class AboutFragment extends Fragment { diff --git a/app/src/main/java/com/zfdang/touchhelper/ui/home/HomeFragment.java b/app/src/main/java/com/zfdang/touchhelper/ui/home/HomeFragment.java index 7ddfc6d..9189972 100644 --- a/app/src/main/java/com/zfdang/touchhelper/ui/home/HomeFragment.java +++ b/app/src/main/java/com/zfdang/touchhelper/ui/home/HomeFragment.java @@ -31,7 +31,7 @@ import androidx.lifecycle.MediatorLiveData; import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.Observer; -import androidx.lifecycle.ViewModelProviders; +import androidx.lifecycle.ViewModelProvider; import com.zfdang.touchhelper.R; import com.zfdang.touchhelper.TouchHelperService; @@ -45,7 +45,7 @@ public class HomeFragment extends Fragment { public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { homeViewModel = - ViewModelProviders.of(this).get(HomeViewModel.class); + new ViewModelProvider(this).get(HomeViewModel.class); View root = inflater.inflate(R.layout.fragment_home, container, false); final Drawable drawableYes = ContextCompat.getDrawable(getContext(), R.drawable.ic_right); @@ -82,9 +82,16 @@ public void onChanged(Boolean aBoolean) { btAccessibilityPermission.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - Intent intent_abs = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS); - intent_abs.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent_abs); + new androidx.appcompat.app.AlertDialog.Builder(getContext()) + .setTitle("重要说明 (Prominent Disclosure)") + .setMessage("本应用需要使用无障碍服务(AccessibilityService API)来帮您在其他应用中自动查找并点击屏幕上的指定控件(例如各类重复性的按钮)。\n\n本应用属于自动化工具,所有的点击操作均基于您的配置和触发策略。\n本应用完全离线运行,不会收集、存储、传输或分享您的任何个人数据及敏感信息。\n\n请点击“同意”以继续前往系统设置中授权此服务。") + .setPositiveButton("同意", (dialog, which) -> { + Intent intent_abs = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS); + intent_abs.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent_abs); + }) + .setNegativeButton("拒绝", null) + .show(); } }); diff --git a/app/src/main/res/layout/fragment_about.xml b/app/src/main/res/layout/fragment_about.xml index 4dbf941..4588135 100644 --- a/app/src/main/res/layout/fragment_about.xml +++ b/app/src/main/res/layout/fragment_about.xml @@ -65,6 +65,21 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/textView_app_introduction" /> + + https://touchhelper.zfdang.com/ + 隐私政策 (Privacy Policy):\nhttps://touchhelper.zfdang.com/privacy.html Copyright © 2022 Zhengfa Dang 版本: %s (%d) diff --git a/build.gradle b/build.gradle index f88d0d4..7fe0aa1 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { gradlePluginPortal() } dependencies { - classpath 'com.android.tools.build:gradle:8.2.2' + classpath 'com.android.tools.build:gradle:8.7.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle.properties b/gradle.properties index ecebd1a..60a14d5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,11 +15,12 @@ org.gradle.jvmargs=-Xmx2048m # 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 +# Jetifier no longer needed - all dependencies use AndroidX natively +# android.enableJetifier=true # Keystore credentials (DO NOT commit real values to version control) # Set these in local.properties or as environment variables KEYSTORE_PASSWORD=touchhelper KEY_ALIAS=touchhelper -KEY_PASSWORD=touchhelper \ No newline at end of file +KEY_PASSWORD=touchhelper +android.suppressUnsupportedCompileSdk=35 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1cebe8b..0f34df1 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip