Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -361,6 +362,12 @@ public void run() {
break;
}

long currentTime = System.currentTimeMillis();
if (currentTime - lastContentChangedTime < 150) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The value 150 is a magic number. It's better to define it as a named constant to improve readability and maintainability, for example: private static final int CONTENT_CHANGED_THROTTLE_INTERVAL_MS = 150; at the class level.

break;
}
lastContentChangedTime = currentTime;

if (setTargetedWidgets != null) {
if (BuildConfig.DEBUG) {
Log.d(TAG, "method by widget in CONTENT_CHANGED");
Expand Down
13 changes: 10 additions & 3 deletions app/src/main/java/com/zfdang/touchhelper/ui/home/HomeFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Comment on lines +85 to +94
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The title, message, and button texts for this AlertDialog are hardcoded. It's a best practice to extract these strings into strings.xml resources. This improves maintainability and makes it easier to support multiple languages in the future.

}
});

Expand Down
15 changes: 15 additions & 0 deletions app/src/main/res/layout/fragment_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView_app_introduction" />

<TextView
android:id="@+id/textView_privacy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:autoLink="web"
android:linksClickable="true"
android:paddingLeft="12dp"
android:paddingRight="12dp"
android:text="@string/about_privacy"
android:textSize="14sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView_weblink" />

<TextView
android:id="@+id/textView_copyright"
android:layout_width="wrap_content"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
</string>

<string name="about_weblink">https://touchhelper.zfdang.com/</string>
<string name="about_privacy">隐私政策 (Privacy Policy):\nhttps://github.com/zfdang/Android-Touch-Helper/blob/master/PrivacyPolicy.md</string>
<string name="about_copyright">Copyright © 2022 Zhengfa Dang</string>

<string name="app_version">版本: %s (%d)</string>
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ android.enableJetifier=true
# Set these in local.properties or as environment variables
KEYSTORE_PASSWORD=touchhelper
KEY_ALIAS=touchhelper
KEY_PASSWORD=touchhelper
KEY_PASSWORD=touchhelperandroid.suppressUnsupportedCompileSdk=35
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

It seems like a new property android.suppressUnsupportedCompileSdk=35 was appended to the KEY_PASSWORD line without a newline. This is incorrect and will likely cause build failures or unexpected behavior. Please add a newline before android.suppressUnsupportedCompileSdk=35.

KEY_PASSWORD=touchhelper
android.suppressUnsupportedCompileSdk=35

Loading