From 474f01b83c90760f92e335347c50be3da77d33fe Mon Sep 17 00:00:00 2001 From: lihongwei Date: Mon, 30 Jun 2025 17:13:45 +0800 Subject: [PATCH] =?UTF-8?q?V1.0.0=EF=BC=881=EF=BC=89=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/AutoClicker.jks | Bin 0 -> 2554 bytes app/build.gradle.kts | 10 +- app/proguard-rules.pro | 17 +- .../autoclicker/service/AutoClickService.java | 4 + .../ui/activity/main/MainActivity.java | 17 +- .../menu/BatteryLimitFreeActivity.java | 16 ++ .../ui/activity/menu/MenuActivity.java | 14 ++ .../menu/TroubleshootingActivity.java | 14 ++ .../ui/activity/welcome/LauncherActivity.java | 5 +- .../ui/activity/welcome/SplashActivity.java | 2 +- .../view/FloatingSettingDialogManager.java | 195 +++++++++--------- .../autoclicker/view/FloatingViewManager.java | 20 +- .../layout/activity_battery_limit_free.xml | 1 + .../main/res/layout/activity_how_to_use.xml | 1 + app/src/main/res/layout/activity_menu.xml | 13 +- app/src/main/res/layout/activity_setting.xml | 1 + .../res/layout/activity_troubleshooting.xml | 1 + .../res/layout/floating_setting_dialog.xml | 30 ++- keystore.properties | 6 + 19 files changed, 242 insertions(+), 125 deletions(-) create mode 100644 app/AutoClicker.jks create mode 100644 keystore.properties diff --git a/app/AutoClicker.jks b/app/AutoClicker.jks new file mode 100644 index 0000000000000000000000000000000000000000..7b1926659d0a250662c0b198e1793fc8137b1c93 GIT binary patch literal 2554 zcma)8XH=7k5={j{2SdqXD2jpv8maMLYFu7mT39t@JkJz~diS6aU91=-NDz;-nCtk<+%q&SKt3+u0> zRD6C6N{ejObDMGdeoVPy7VDo7UeCEywVdm-kQPx>M(2+q(}|Bpx;;lmIw+tP;fXhd z#)cwfnZ%7Yi_P(cYA0U2Hl&UtJ9IwOQM#?^*a&)&!R9{Hb$y6-k#Xg-cK&YH%J~c$ zRe78KtOqZN*`4Dsu(=%vnLeZPlDRWQmOFcU*52*g{Ni@=xIVbF|K)LRw$%n=Av?CE z;_F|Lc1n3N-UE5^Ev;@CQv_GFkMPKAk9H^&vcr5T<4m=Nj^xSN`=TL#xcz+#B-` zMBP0N7QQ~$bCT`!-Oqx1gsW+*rwGkO#8m?;+{11P*tF4*hE)Dp>BT;*IqS|;j&v4F zL^W|kmy5k7Vc%|~1Z8X0WvRv)p5hibvUzYfp$6S-eK=f_{dxZJftrlqZZB$4wrDXl zhtR8B=NCUkcSBx_jE2p>7lBa`lBK8WrzgQ~MYLv=L|CJN<(H9Dy!S&)p8CsueZKM> zVT3{%TiwN!G|<8+hwE1x7RebxW6$_GWH}$Mv8}z*)w%V3NyJz;nn>? zE@SMIxV7nc(S;D!(xgH~-0!_oaug-pE0{Pj?!{p1pf$@LU4p;Ovp0EIpu@u*!ARqF zNeMO5=@IkRiT6F2SR695(@0pKA8b$f^k-9FS$pKdJ*7EFVaA#qumYczv-M3f^Gvyb zJutRdhmKDeYaQ~UHI{R@?5$4sf+q`u+<7Of1rvMEwt4!6!YkOzPQ)Z_G53c$Bp}b6Wk1Id6DR-8z^H1A*mJsl3!+bI+dhm@d>=VHl!(y>Ws+UEEP@s-StN#aggg}1qWBF^H-P%^qv@Xf zu&Qs&1Z$lqLf)A2>O?P{7d~0Gs9-n#Tc*bz_w#>=GtbX{0E|hmUi!hUp>U7A-eaJR zJYJ^^0vtL_G38UI26}yqzU1+Z@*R;AdRV_{7UWID4)g|tJ!B+@)@opH(PQ@f$Bb%z zaTQxP^4Q6F9dNa_bc@L1hL*C!wY)pZs`YIp3mfv1?avkPNh$KK+8(iwhv0XVgyaNj z`+o?AHqa5}cS>#+6L`GG$-#m4ii%Gt^wl~JT1O>o0D1;7EPppy4fS#gGs2hhQvPF_ zoCzTF(=HK6IZI5c_+aPYwy=HFLk~A}WVf zl9R_O$YTKjD-V#MjX#H&nKDSw@)N2U0tTI=yuUl(|7F~_^u}xd@H^m&$*EPn9c$G6 z23#BZ{}^{cr^vWz1hV&y#~qwSYZB}c2?{9AUNB8I>O6B@vW|XQ@HOrCJL6}|4@$hr zihX|Tu@>(|X)Tv^!AkYqQWdXrRl1rw3{`ImQeU1G@%sa>AT{|p)gxMpc&cS3Owv$= z*ryIv+tdBnJa~Wf{=B}aj;a(8IA@>^-K}Bj4f9U4u5VB6jFSBbd3H@@Jz$o6dT8_I zhHeFvShu6o7>5+d%lGN(&m z`ui~vOf~c>h0aw+=iHzeHVaPGhdJ9`M^Q$M8A`=uY7IlUq^ietMr$pK_r1K&LHOJk z;;uxhOVmnVavtABhpJMtu@Lu>RqzT;-wq)jYOadoy-1L{%#`vzj_?&PZ8MFK=q_^^ zZAICmpO3;&)*@%#)-c#?@1tBR!7#fO6mi89uUV<+Dt63@wz-1Ki#kqLnH6>aYc2 zaF4D6Qisdwo(Y^%==iqmUZzvC;}f{&%}GrIk&sdt}pTK@;`tHtuD zcUz^hJG@GL4HntAD!-=A))D54(?y1J`RL`3^Ah+9n3Jz8=tcD%I_@-Cg+$`YDQu0+&x_mM@?Pn_HrtOS zT+Wk?d$W;*8`sNFu#re&#!-(my>|?XlM^a@%!9VbLJl@EZ^v)56WwPd9+F^aKQVA1 ztBNu7SK4n~z9oPGAO~>#{D&Z5I0z;xwv9zGR-or>@DU|v2tJEq7wV~cNpcLnyMb`b g>Ny$=d4KaJEh$o)8&`<2gk16~PH^55_~*&~1?p3b!2kdN literal 0 HcmV?d00001 diff --git a/app/build.gradle.kts b/app/build.gradle.kts index bc74911..faf2ee4 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,7 +1,10 @@ +import java.text.SimpleDateFormat +import java.util.Date + plugins { alias(libs.plugins.android.application) } - +val timestamp: String = SimpleDateFormat("MM_dd_HH_mm").format(Date()) android { namespace = "com.auto.clicker.autoclicker" compileSdk = 35 @@ -12,7 +15,10 @@ android { targetSdk = 35 versionCode = 1 versionName = "1.0.0" - + setProperty( + "archivesBaseName", + "Auto Clicker_V" + versionName + "(${versionCode})_$timestamp" + ) testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 481bb43..64a1c8f 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -18,4 +18,19 @@ # If you keep the line number information, uncomment this to # hide the original source file name. -#-renamesourcefileattribute SourceFile \ No newline at end of file +#-renamesourcefileattribute SourceFile + +-keepclassmembers class com.auto.clicker.autoclicker.MyApplication { + public static final java.lang.String DB_NAME; + public static final int DB_VERSION; +} + +-keepclassmembers class * { + @androidx.room.Query ; +} + +-keep class com.auto.clicker.autoclicker.room.AppDatabase { *; } +-keep class com.auto.clicker.autoclicker.room.entity.TouchPoint { *; } +-keep class com.auto.clicker.autoclicker.room.entity.EventEntity { *; } +-keep class com.auto.clicker.autoclicker.room.entity.Solution { *; } +-keep class com.auto.clicker.autoclicker.room.SolutionWithEventsAndPoints { *; } \ No newline at end of file diff --git a/app/src/main/java/com/auto/clicker/autoclicker/service/AutoClickService.java b/app/src/main/java/com/auto/clicker/autoclicker/service/AutoClickService.java index 35dfcaf..faff802 100644 --- a/app/src/main/java/com/auto/clicker/autoclicker/service/AutoClickService.java +++ b/app/src/main/java/com/auto/clicker/autoclicker/service/AutoClickService.java @@ -184,6 +184,10 @@ public class AutoClickService extends AccessibilityService { startTimeMillis = 0; logDebug("停止执行事件"); + + Intent stopIntent = new Intent("com.auto.clicker.autoclicker.FLASH_TOUCH_POINT"); + stopIntent.putExtra("isStopEvent", true); + LocalBroadcastManager.getInstance(this).sendBroadcast(stopIntent); } } diff --git a/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/main/MainActivity.java b/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/main/MainActivity.java index ac72f1a..5c088be 100644 --- a/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/main/MainActivity.java +++ b/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/main/MainActivity.java @@ -15,7 +15,6 @@ import android.provider.Settings; import android.util.Log; import android.view.accessibility.AccessibilityManager; import android.widget.Toast; -import android.widget.VideoView; import androidx.activity.EdgeToEdge; import androidx.activity.result.ActivityResultLauncher; @@ -185,7 +184,7 @@ public class MainActivity extends AppCompatActivity { if (!accessibilityGranted) { logDebug("无障碍服务未启用,请求权限"); - showPermissionRequest(Settings.ACTION_ACCESSIBILITY_SETTINGS, "Please enable accessibility services to ensure the application works properly", "Accessibility Settings cannot be enabled"); + showPermissionRequest(); setStartButtonEnabled(false); return false; } @@ -243,7 +242,7 @@ public class MainActivity extends AppCompatActivity { if (!accessibilityGranted) { logDebug("无障碍服务未启用,请求权限"); - showPermissionRequest(Settings.ACTION_ACCESSIBILITY_SETTINGS, "Please enable accessibility services to ensure the application works properly", "Accessibility Settings cannot be enabled"); + showPermissionRequest(); setStartButtonEnabled(false); return; @@ -273,15 +272,15 @@ public class MainActivity extends AppCompatActivity { } - private void showPermissionRequest(String action, String toastMessage, String errorMessage) { + private void showPermissionRequest() { try { - Intent intent = new Intent(action); + Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS); permissionLauncher.launch(intent); - Toast.makeText(this, toastMessage, Toast.LENGTH_LONG).show(); - logDebug("尝试启动权限设置页面: " + action); + Toast.makeText(this, "Please enable accessibility services to ensure the application works properly", Toast.LENGTH_LONG).show(); + logDebug("尝试启动权限设置页面: " + Settings.ACTION_ACCESSIBILITY_SETTINGS); } catch (Exception e) { - Toast.makeText(this, errorMessage, Toast.LENGTH_LONG).show(); - logDebug("打开设置页面失败: " + errorMessage + ", 异常: " + e.getMessage()); + Toast.makeText(this, "Accessibility Settings cannot be enabled", Toast.LENGTH_LONG).show(); + logDebug("打开设置页面失败: " + "Accessibility Settings cannot be enabled" + ", 异常: " + e.getMessage()); } } diff --git a/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/menu/BatteryLimitFreeActivity.java b/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/menu/BatteryLimitFreeActivity.java index 7b49b6a..2e5fdee 100644 --- a/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/menu/BatteryLimitFreeActivity.java +++ b/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/menu/BatteryLimitFreeActivity.java @@ -1,6 +1,11 @@ package com.auto.clicker.autoclicker.ui.activity.menu; +import android.content.Intent; +import android.net.Uri; import android.os.Bundle; +import android.provider.Settings; +import android.view.View; +import android.widget.Button; import androidx.activity.EdgeToEdge; import androidx.appcompat.app.AppCompatActivity; @@ -27,5 +32,16 @@ public class BatteryLimitFreeActivity extends AppCompatActivity { }); binding.back.setOnClickListener(v -> finish()); + + Button grantButton = binding.grant; + + grantButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS); + intent.setData(Uri.parse("package:" + getApplicationContext().getPackageName())); + startActivity(intent); + } + }); } } \ No newline at end of file diff --git a/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/menu/MenuActivity.java b/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/menu/MenuActivity.java index b92294f..aa0878b 100644 --- a/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/menu/MenuActivity.java +++ b/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/menu/MenuActivity.java @@ -69,6 +69,20 @@ public class MenuActivity extends AppCompatActivity { Intent intent = new Intent(this, HowToUseActivity.class); startActivity(intent); }); + + binding.share.arrow.setOnClickListener(v -> { + String packageName = getPackageName(); + String appShareLink = "https://play.google.com/store/apps/details?id=" + packageName; + + Intent shareIntent = new Intent(Intent.ACTION_SEND); + shareIntent.setType("text/plain"); + + shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Check out this awesome app!"); + + shareIntent.putExtra(Intent.EXTRA_TEXT, "Hey, you should check out this app! " + appShareLink); + + startActivity(Intent.createChooser(shareIntent, "Share app via...")); + }); } private void setupItem(int viewId, int iconRes, String title, String subtitle) { diff --git a/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/menu/TroubleshootingActivity.java b/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/menu/TroubleshootingActivity.java index e7f5262..62fa2b6 100644 --- a/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/menu/TroubleshootingActivity.java +++ b/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/menu/TroubleshootingActivity.java @@ -1,6 +1,10 @@ package com.auto.clicker.autoclicker.ui.activity.menu; +import android.content.Intent; import android.os.Bundle; +import android.provider.Settings; +import android.view.View; +import android.widget.Button; import androidx.activity.EdgeToEdge; import androidx.appcompat.app.AppCompatActivity; @@ -27,5 +31,15 @@ public class TroubleshootingActivity extends AppCompatActivity { }); binding.back.setOnClickListener(v -> finish()); + + Button regrantButton = binding.Regrant; + + regrantButton.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS); + startActivity(intent); + } + }); } } \ No newline at end of file diff --git a/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/welcome/LauncherActivity.java b/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/welcome/LauncherActivity.java index 9580dea..fbc6171 100644 --- a/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/welcome/LauncherActivity.java +++ b/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/welcome/LauncherActivity.java @@ -14,8 +14,9 @@ public class LauncherActivity extends AppCompatActivity { boolean agreed = getSharedPreferences("app_prefs", MODE_PRIVATE) .getBoolean("agreed_privacy", false); - Intent intent = new Intent(this, - agreed ? SplashActivity.class : AgreementActivity.class); +// Intent intent = new Intent(this, +// agreed ? SplashActivity.class : AgreementActivity.class); + Intent intent = new Intent(this, SplashActivity.class); startActivity(intent); finish(); } diff --git a/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/welcome/SplashActivity.java b/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/welcome/SplashActivity.java index c674287..bfd8de9 100644 --- a/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/welcome/SplashActivity.java +++ b/app/src/main/java/com/auto/clicker/autoclicker/ui/activity/welcome/SplashActivity.java @@ -18,7 +18,7 @@ import com.bumptech.glide.load.resource.bitmap.RoundedCorners; public class SplashActivity extends AppCompatActivity { private ActivitySplashBinding binding; - private static final long TOTAL_TIME = 100; + private static final long TOTAL_TIME = 1000; private CountDownTimer countDownTimer; @Override diff --git a/app/src/main/java/com/auto/clicker/autoclicker/view/FloatingSettingDialogManager.java b/app/src/main/java/com/auto/clicker/autoclicker/view/FloatingSettingDialogManager.java index 7b95e33..72cdca1 100644 --- a/app/src/main/java/com/auto/clicker/autoclicker/view/FloatingSettingDialogManager.java +++ b/app/src/main/java/com/auto/clicker/autoclicker/view/FloatingSettingDialogManager.java @@ -36,6 +36,14 @@ public class FloatingSettingDialogManager { private ConstraintLayout floatingDialogView; private WindowManager.LayoutParams floatingDialogParams; + private enum UnitType { + MS, SEC, MIN, INFINITELY, DURATION, CYCLE, UNKNOWN + } + + private UnitType currentIntervalUnit = UnitType.MS; + private UnitType currentSwipeDurationUnit = UnitType.MS; + private UnitType currentRepeatUnit = UnitType.INFINITELY; + private static final int TYPE_INTERVAL = 0; private static final int TYPE_SWIPE_DURATION = 1; private static final int TYPE_REPEAT = 2; @@ -54,9 +62,6 @@ public class FloatingSettingDialogManager { private AppCompatButton saveButton; private AppCompatButton closeButton; - private String currentIntervalUnit = ""; - private String currentSwipeDurationUnit = ""; - private String currentRepeatUnit = ""; private String currentIntervalValue = ""; private String currentDurationValue = ""; private String currentRepeatValue = ""; @@ -65,6 +70,9 @@ public class FloatingSettingDialogManager { public FloatingSettingDialogManager(Context context) { this.context = context; this.windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); + currentIntervalUnit = UnitType.MS; + currentSwipeDurationUnit = UnitType.MS; + currentRepeatUnit = UnitType.INFINITELY; } public void showFloatingTabDialog() { @@ -201,28 +209,6 @@ public class FloatingSettingDialogManager { repeatSelectorContainer.setOnClickListener(v -> showUnitSelection(v, TYPE_REPEAT)); } - private void updateRepeatUI(boolean isChecked) { - if (isChecked) { - repeatInput.setVisibility(View.VISIBLE); - repeatSelectorContainer.setVisibility(View.VISIBLE); - if (currentRepeatUnit.equals(context.getString(R.string.infinitely_unit)) || repeatSelectedUnit.getText().toString().equals(context.getString(R.string.infinitely_unit))) { - etRepeatValue.setText(""); - etRepeatValue.setEnabled(false); - etRepeatValue.setInputType(InputType.TYPE_NULL); - repeatSelectedUnit.setText(context.getString(R.string.infinitely_unit)); - } else { - etRepeatValue.setEnabled(true); - etRepeatValue.setInputType(InputType.TYPE_CLASS_NUMBER); - etRepeatValue.setText(currentRepeatValue); - repeatSelectedUnit.setText(currentRepeatUnit.isEmpty() ? context.getString(R.string.cycle_unit) : currentRepeatUnit); - } - - } else { - repeatInput.setVisibility(View.GONE); - repeatSelectorContainer.setVisibility(View.GONE); - } - } - private void showUnitSelection(View anchorView, int type) { View popupView = LayoutInflater.from(context).inflate(R.layout.dialog_unit_selection, null); PopupWindow popupWindow = new PopupWindow( @@ -272,34 +258,24 @@ public class FloatingSettingDialogManager { if (type == TYPE_INTERVAL || type == TYPE_SWIPE_DURATION) { tvMs.setOnClickListener(v -> { + UnitType selectedUnitType = UnitType.MS; String unitText = context.getString(R.string.milliseconds_unit); - if (type == TYPE_INTERVAL) { - intervalSelectedUnit.setText(unitText); - currentIntervalUnit = unitText; - } else { - tvSelectedUnit.setText(unitText); - currentSwipeDurationUnit = unitText; - } + updateUIAndSaveSettings(type, selectedUnitType, unitText); popupWindow.dismiss(); }); tvSec.setOnClickListener(v -> { + UnitType selectedUnitType = UnitType.SEC; String unitText = context.getString(R.string.seconds_unit); - if (type == TYPE_INTERVAL) { - intervalSelectedUnit.setText(unitText); - currentIntervalUnit = unitText; - } else { - tvSelectedUnit.setText(unitText); - currentSwipeDurationUnit = unitText; - } + updateUIAndSaveSettings(type, selectedUnitType, unitText); popupWindow.dismiss(); }); if (type == TYPE_INTERVAL) { tvMin.setOnClickListener(v -> { + UnitType selectedUnitType = UnitType.MIN; String unitText = context.getString(R.string.minutes_unit); - intervalSelectedUnit.setText(unitText); - currentIntervalUnit = unitText; + updateUIAndSaveSettings(type, selectedUnitType, unitText); popupWindow.dismiss(); }); } @@ -307,32 +283,26 @@ public class FloatingSettingDialogManager { if (type == TYPE_REPEAT) { tvInfinitely.setOnClickListener(v -> { + UnitType selectedUnitType = UnitType.INFINITELY; String unitText = context.getString(R.string.infinitely_unit); - repeatSelectedUnit.setText(unitText); - currentRepeatUnit = unitText; - etRepeatValue.setText(""); - etRepeatValue.setEnabled(false); - etRepeatValue.setInputType(InputType.TYPE_NULL); + updateUIAndSaveSettings(type, selectedUnitType, unitText); + updateRepeatUI(true); // 悬浮窗中,需要在选择后立即更新UI popupWindow.dismiss(); }); tvDuration.setOnClickListener(v -> { + UnitType selectedUnitType = UnitType.DURATION; String unitText = context.getString(R.string.duration_unit); - repeatSelectedUnit.setText(unitText); - currentRepeatUnit = unitText; - etRepeatValue.setText(""); - etRepeatValue.setEnabled(true); - etRepeatValue.setInputType(InputType.TYPE_CLASS_NUMBER); + updateUIAndSaveSettings(type, selectedUnitType, unitText); + updateRepeatUI(true); popupWindow.dismiss(); }); tvCycle.setOnClickListener(v -> { + UnitType selectedUnitType = UnitType.CYCLE; String unitText = context.getString(R.string.cycle_unit); - repeatSelectedUnit.setText(unitText); - currentRepeatUnit = unitText; - etRepeatValue.setText(""); - etRepeatValue.setEnabled(true); - etRepeatValue.setInputType(InputType.TYPE_CLASS_NUMBER); + updateUIAndSaveSettings(type, selectedUnitType, unitText); + updateRepeatUI(true); popupWindow.dismiss(); }); } @@ -344,6 +314,49 @@ public class FloatingSettingDialogManager { } } + private void updateUIAndSaveSettings(int type, UnitType selectedUnitType, String unitText) { + switch (type) { + case TYPE_INTERVAL: + intervalSelectedUnit.setText(unitText); + currentIntervalUnit = selectedUnitType; + break; + case TYPE_SWIPE_DURATION: + tvSelectedUnit.setText(unitText); + currentSwipeDurationUnit = selectedUnitType; + break; + case TYPE_REPEAT: + repeatSelectedUnit.setText(unitText); + currentRepeatUnit = selectedUnitType; + break; + } + } + + private void updateRepeatUI(boolean isChecked) { + if (isChecked) { + repeatInput.setVisibility(View.VISIBLE); + repeatSelectorContainer.setVisibility(View.VISIBLE); + if (currentRepeatUnit == UnitType.INFINITELY) { + etRepeatValue.setText(""); + etRepeatValue.setEnabled(false); + etRepeatValue.setInputType(InputType.TYPE_NULL); + repeatSelectedUnit.setText(context.getString(R.string.infinitely_unit)); + } else if (currentRepeatUnit == UnitType.DURATION) { + etRepeatValue.setText(currentRepeatValue); + etRepeatValue.setEnabled(true); + etRepeatValue.setInputType(InputType.TYPE_CLASS_NUMBER); + repeatSelectedUnit.setText(context.getString(R.string.duration_unit)); + } else if (currentRepeatUnit == UnitType.CYCLE) { + etRepeatValue.setText(currentRepeatValue); + etRepeatValue.setEnabled(true); + etRepeatValue.setInputType(InputType.TYPE_CLASS_NUMBER); + repeatSelectedUnit.setText(context.getString(R.string.cycle_unit)); + } + } else { + repeatInput.setVisibility(View.GONE); + repeatSelectorContainer.setVisibility(View.GONE); + } + } + private void saveCurrentSettings() { currentIntervalValue = etIntervalValue.getText().toString(); currentDurationValue = etDurationValue.getText().toString(); @@ -363,14 +376,13 @@ public class FloatingSettingDialogManager { return; } - // 应用点击间隔 long intervalValue = 0; if (!currentIntervalValue.isEmpty()) { try { intervalValue = Long.parseLong(currentIntervalValue); - if (currentIntervalUnit.equals(context.getString(R.string.seconds_unit))) { + if (currentIntervalUnit == UnitType.SEC) { intervalValue *= 1000; - } else if (currentIntervalUnit.equals(context.getString(R.string.minutes_unit))) { + } else if (currentIntervalUnit == UnitType.MIN) { intervalValue *= 60 * 1000; } service.setClickInterval(intervalValue); @@ -387,7 +399,7 @@ public class FloatingSettingDialogManager { if (!currentDurationValue.isEmpty()) { try { slideDurationValue = Integer.parseInt(currentDurationValue); - if (currentSwipeDurationUnit.equals(context.getString(R.string.seconds_unit))) { + if (currentSwipeDurationUnit == UnitType.SEC) { slideDurationValue *= 1000; } service.setSlideDuration(slideDurationValue); @@ -401,10 +413,10 @@ public class FloatingSettingDialogManager { } if (isRepeatSwitchChecked) { - if (currentRepeatUnit.equals(context.getString(R.string.infinitely_unit))) { - service.setLoopCount(0); // 无限循环 + if (currentRepeatUnit == UnitType.INFINITELY) { + service.setLoopCount(0); Log.d(TAG, "应用重复模式: 无限次。"); - } else if (currentRepeatUnit.equals(context.getString(R.string.duration_unit))) { + } else if (currentRepeatUnit == UnitType.DURATION) { long repeatDurationMillis = 0; if (!currentRepeatValue.isEmpty()) { try { @@ -421,7 +433,7 @@ public class FloatingSettingDialogManager { Log.d(TAG, "重复时长值为空,取消时间循环。"); } service.setLoopCount(0); // 确保与时间循环互斥 - } else if (currentRepeatUnit.equals(context.getString(R.string.cycle_unit))) { + } else if (currentRepeatUnit == UnitType.CYCLE) { int repeatCount = 0; if (!currentRepeatValue.isEmpty()) { try { @@ -447,51 +459,40 @@ public class FloatingSettingDialogManager { } private void restoreUIState() { - // 恢复点击间隔 if (!currentIntervalValue.isEmpty()) { etIntervalValue.setText(currentIntervalValue); } - if (!currentIntervalUnit.isEmpty()) { - intervalSelectedUnit.setText(currentIntervalUnit); - } else { - intervalSelectedUnit.setText(context.getString(R.string.milliseconds_unit)); // 默认单位 - currentIntervalUnit = context.getString(R.string.milliseconds_unit); - } + intervalSelectedUnit.setText(getUnitString(currentIntervalUnit)); - // 恢复滑动时长 if (!currentDurationValue.isEmpty()) { etDurationValue.setText(currentDurationValue); } - if (!currentSwipeDurationUnit.isEmpty()) { - tvSelectedUnit.setText(currentSwipeDurationUnit); - } else { - tvSelectedUnit.setText(context.getString(R.string.milliseconds_unit)); - currentSwipeDurationUnit = context.getString(R.string.milliseconds_unit); - } + tvSelectedUnit.setText(getUnitString(currentSwipeDurationUnit)); - // 恢复重复设置 repeatSwitch.setChecked(isRepeatSwitchChecked); updateRepeatUI(isRepeatSwitchChecked); if (isRepeatSwitchChecked) { - if (currentRepeatUnit.isEmpty()) { - repeatSelectedUnit.setText(context.getString(R.string.infinitely_unit)); - currentRepeatUnit = context.getString(R.string.infinitely_unit); - etRepeatValue.setText(""); - etRepeatValue.setEnabled(false); - etRepeatValue.setInputType(InputType.TYPE_NULL); - } else { - repeatSelectedUnit.setText(currentRepeatUnit); - if (currentRepeatUnit.equals(context.getString(R.string.infinitely_unit))) { - etRepeatValue.setText(""); - etRepeatValue.setEnabled(false); - etRepeatValue.setInputType(InputType.TYPE_NULL); - } else { - etRepeatValue.setText(currentRepeatValue); - etRepeatValue.setEnabled(true); - etRepeatValue.setInputType(InputType.TYPE_CLASS_NUMBER); - } - } + repeatSelectedUnit.setText(getUnitString(currentRepeatUnit)); + } + } + + private String getUnitString(UnitType unitType) { + switch (unitType) { + case MS: + return context.getString(R.string.milliseconds_unit); + case SEC: + return context.getString(R.string.seconds_unit); + case MIN: + return context.getString(R.string.minutes_unit); + case INFINITELY: + return context.getString(R.string.infinitely_unit); + case DURATION: + return context.getString(R.string.duration_unit); + case CYCLE: + return context.getString(R.string.cycle_unit); + default: + return ""; } } diff --git a/app/src/main/java/com/auto/clicker/autoclicker/view/FloatingViewManager.java b/app/src/main/java/com/auto/clicker/autoclicker/view/FloatingViewManager.java index 514afb9..53aca59 100644 --- a/app/src/main/java/com/auto/clicker/autoclicker/view/FloatingViewManager.java +++ b/app/src/main/java/com/auto/clicker/autoclicker/view/FloatingViewManager.java @@ -639,8 +639,18 @@ public class FloatingViewManager { @Override public void onReceive(Context context, Intent intent) { if ("com.auto.clicker.autoclicker.FLASH_TOUCH_POINT".equals(intent.getAction())) { - int index = intent.getIntExtra("index", -1); - flashTouchPoint(index); + boolean isStopEvent = intent.getBooleanExtra("isStopEvent", false); + + if (isStopEvent) { + Log.d(TAG, "接收到停止点击完成广播,更新触点背景"); + updateTouchPointsBackground(R.drawable.ring_has_bg); + setControlButtonsEnabled(true); + isMultipleRunning = false; + updatePlayButtonImage(false); + } else { + int index = intent.getIntExtra("index", -1); + flashTouchPoint(index); + } } } }, @@ -740,9 +750,9 @@ public class FloatingViewManager { } } updateServicePositions(); - Toast.makeText(context, "方案 '" + solutionData.solution.solutionName + "' 加载成功!", Toast.LENGTH_SHORT).show(); + Toast.makeText(context, "Script '" + solutionData.solution.solutionName + "' Loading successful!", Toast.LENGTH_SHORT).show(); } else { - Toast.makeText(context, "加载方案失败或方案不存在。", Toast.LENGTH_SHORT).show(); + Toast.makeText(context, "The loading scheme fails or the scheme does not exist。", Toast.LENGTH_SHORT).show(); } }); } @@ -751,7 +761,7 @@ public class FloatingViewManager { public void onError(Exception e) { Log.e(TAG, "加载方案失败: " + e.getMessage(), e); new Handler(Looper.getMainLooper()).post(() -> - Toast.makeText(context, "加载方案失败: " + e.getMessage(), Toast.LENGTH_SHORT).show() + Toast.makeText(context, "The loading scheme failed.: " + e.getMessage(), Toast.LENGTH_SHORT).show() ); } }); diff --git a/app/src/main/res/layout/activity_battery_limit_free.xml b/app/src/main/res/layout/activity_battery_limit_free.xml index 1a40ddb..f6936a1 100644 --- a/app/src/main/res/layout/activity_battery_limit_free.xml +++ b/app/src/main/res/layout/activity_battery_limit_free.xml @@ -87,6 +87,7 @@ Feedback" android:textSize="16sp" />