diff --git a/app/build.gradle b/app/build.gradle index afd8b2c..8bbbe62 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,8 +10,8 @@ android { applicationId "me.lucky.duress" minSdk 23 targetSdk 32 - versionCode 1 - versionName "1.0.0" + versionCode 2 + versionName "1.0.1" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/me/lucky/duress/AccessibilityService.kt b/app/src/main/java/me/lucky/duress/AccessibilityService.kt index 3e024bd..6f1e39d 100644 --- a/app/src/main/java/me/lucky/duress/AccessibilityService.kt +++ b/app/src/main/java/me/lucky/duress/AccessibilityService.kt @@ -33,16 +33,17 @@ class AccessibilityService : AccessibilityService() { event.text.size != 1 || event.text[0].length < passwordLen) return val action = prefs.action - val receiver = prefs.receiver - val code = prefs.authenticationCode - if (action.isBlank() || receiver.isBlank() || code.isBlank()) return + if (action.isBlank()) return sendBroadcast(Intent(action).apply { - val cls = receiver.split('/') - if (cls.size != 2) return - val packageName = cls[0] - setClassName(packageName, "$packageName.${cls[1]}") + val cls = prefs.receiver.split('/') + val packageName = cls.firstOrNull() ?: "" + if (packageName.isNotBlank()) { + setPackage(packageName) + if (cls.size == 2) setClassName(packageName, "$packageName.${cls[1]}") + } addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES) - putExtra(KEY, code) + val code = prefs.authenticationCode + if (code.isNotBlank()) putExtra(KEY, code) }) } diff --git a/app/src/main/java/me/lucky/duress/MainActivity.kt b/app/src/main/java/me/lucky/duress/MainActivity.kt index 4ed9f42..5317974 100644 --- a/app/src/main/java/me/lucky/duress/MainActivity.kt +++ b/app/src/main/java/me/lucky/duress/MainActivity.kt @@ -14,15 +14,10 @@ import me.lucky.duress.databinding.ActivityMainBinding import java.util.regex.Pattern class MainActivity : AppCompatActivity() { - companion object { - private const val ACTION_REGEX = "\\w+(\\.\\w+)+" - } - private lateinit var binding: ActivityMainBinding private lateinit var prefs: Preferences private var accessibilityManager: AccessibilityManager? = null - private val actionPatternRegex by lazy { Pattern.compile("^$ACTION_REGEX\$") } - private val receiverPatternRegex by lazy { Pattern.compile("^$ACTION_REGEX/\\w+$") } + private val actionPatternRegex by lazy { Pattern.compile("^\\w+(\\.\\w+)+\$") } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -62,22 +57,10 @@ class MainActivity : AppCompatActivity() { } } receiver.editText?.doAfterTextChanged { - val str = it?.toString() ?: "" - if (receiverPatternRegex.matcher(str).matches()) { - prefs.receiver = str - receiver.error = null - } else { - receiver.error = getString(R.string.receiver_error) - } + prefs.receiver = it?.toString() ?: "" } authenticationCode.editText?.doAfterTextChanged { - val str = it?.toString() ?: "" - if (str.isNotBlank()) { - prefs.authenticationCode = str - authenticationCode.error = null - } else { - authenticationCode.error = getString(R.string.authentication_code_error) - } + prefs.authenticationCode = it?.toString() ?: "" } passwordLen.editText?.doAfterTextChanged { try { diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 00dd87b..305cdf9 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -8,11 +8,9 @@ Принять Выйти Действие * - Получатель * - Код аутентификации * + Получатель + Код аутентификации Длинна пароля * me.package.name.action.HELLO - me.package.name/MyReceiver - Не пустой Должна быть равной, как минимум, длинне вашего пароля плюс два. \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 850e4e5..cf7b5fb 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -8,11 +8,9 @@ Accept Exit Action * - Receiver * - Authentication code * + Receiver + Authentication code Password length * me.package.name.action.HELLO - me.package.name/MyReceiver - Not empty Has to be at least your password length plus two. \ No newline at end of file diff --git a/fastlane/metadata/android/en-US/changelogs/2.txt b/fastlane/metadata/android/en-US/changelogs/2.txt new file mode 100644 index 0000000..5d45bf6 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/2.txt @@ -0,0 +1 @@ +under the hood improvements diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png index 3544dda..3db59bc 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png and b/fastlane/metadata/android/en-US/images/phoneScreenshots/1.png differ diff --git a/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png b/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png index 58bafce..c5a489d 100644 Binary files a/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png and b/fastlane/metadata/android/en-US/images/phoneScreenshots/2.png differ