From bbcc710450d50f369460c5bb310083b30eeedcf1 Mon Sep 17 00:00:00 2001 From: Mark Injerd Date: Wed, 19 Jul 2023 23:32:03 -0400 Subject: [PATCH] Convert all UI to Compose NOTICE: This will remove any active usages of the widget. - New app bar with back button in App List and TTS screens. - Ignore All/None now separate app bar buttons in App List. - Remove keyboard input option in Quiet Time. Should be temporary. - Device States and TTS Audio Stream dialogs now have both 'Cancel' and 'OK' buttons. Changes only saved with 'OK'. - TTS Text Replacement dialog is less janky. - Add title to Quiet Time dialog. - Widget image is now a white vector with tint applied. This changes the widget preview from green to white. - Include Git hash in release version name. - Shrink/optimize release build without obfuscation. This reduces APK size from about 13MB to 3MB while maintaining trust in the build. - minSdk: 18 (4.3) -> 21 (5.0) - compileSdk/targetSdk: 33 (13.0) -> 34 (14.0) - Update dependencies. - Reorganize strings. - Change copyright start year to start of project in all files. Too ambiguous to use the year the code in the file was created. - Other fixes and improvements. --- NOTICE | 2 +- app/build.gradle.kts | 43 +- app/src/main/AndroidManifest.xml | 8 +- .../main/java/com/pilot51/voicenotify/App.kt | 2 +- .../com/pilot51/voicenotify/AppDatabase.kt | 2 +- .../pilot51/voicenotify/AppListFragment.kt | 358 ----------- .../com/pilot51/voicenotify/AppListScreen.kt | 179 ++++++ .../pilot51/voicenotify/AppListViewModel.kt | 165 +++++ .../java/com/pilot51/voicenotify/AppWidget.kt | 80 +++ .../java/com/pilot51/voicenotify/Common.kt | 127 ++-- .../com/pilot51/voicenotify/IgnoreReason.kt | 2 +- .../com/pilot51/voicenotify/MainActivity.kt | 37 +- .../com/pilot51/voicenotify/MainFragment.kt | 203 ------ .../com/pilot51/voicenotify/MainScreen.kt | 402 ++++++++++++ .../pilot51/voicenotify/NotificationInfo.kt | 35 +- .../com/pilot51/voicenotify/NotifyList.kt | 274 ++++---- .../pilot51/voicenotify/PermissionHelper.kt | 103 ++- .../com/pilot51/voicenotify/PrefDialog.kt | 175 ----- .../pilot51/voicenotify/PreferenceDialogs.kt | 603 ++++++++++++++++++ .../pilot51/voicenotify/PreferenceHelper.kt | 131 ++++ .../com/pilot51/voicenotify/PreferenceRows.kt | 239 +++++++ .../java/com/pilot51/voicenotify/Service.kt | 156 ++--- .../java/com/pilot51/voicenotify/Shake.kt | 7 +- .../pilot51/voicenotify/TextReplaceDialog.kt | 237 +++++++ .../voicenotify/TextReplaceDialogViewModel.kt | 102 +++ .../voicenotify/TextReplacePreference.kt | 355 ----------- .../pilot51/voicenotify/TtsConfigFragment.kt | 80 --- .../pilot51/voicenotify/TtsConfigScreen.kt | 114 ++++ .../com/pilot51/voicenotify/VNApplication.kt | 2 +- .../com/pilot51/voicenotify/WidgetProvider.kt | 122 ---- .../main/res/drawable-anydpi/ic_search.xml | 10 - .../{widget_disabled.xml => widget.xml} | 2 +- .../res/drawable-anydpi/widget_running.xml | 9 - .../res/drawable-anydpi/widget_suspended.xml | 9 - app/src/main/res/layout/activity_main.xml | 14 - app/src/main/res/layout/app_list_item.xml | 43 -- app/src/main/res/layout/appwidget.xml | 8 - app/src/main/res/layout/notify_log_item.xml | 42 -- .../layout/preference_dialog_text_replace.xml | 19 - app/src/main/res/layout/text_replace_row.xml | 29 - app/src/main/res/menu/app_list.xml | 20 - app/src/main/res/navigation/nav_graph.xml | 35 - app/src/main/res/values/donottranslate.xml | 26 - app/src/main/res/values/strings.xml | 128 ++-- app/src/main/res/values/themes.xml | 6 - app/src/main/res/xml/appwidget_info.xml | 4 +- app/src/main/res/xml/preferences.xml | 94 --- app/src/main/res/xml/preferences_tts.xml | 61 -- build.gradle.kts | 7 +- gradle.properties | 1 - gradle/wrapper/gradle-wrapper.properties | 3 +- 51 files changed, 2823 insertions(+), 2092 deletions(-) delete mode 100644 app/src/main/java/com/pilot51/voicenotify/AppListFragment.kt create mode 100644 app/src/main/java/com/pilot51/voicenotify/AppListScreen.kt create mode 100644 app/src/main/java/com/pilot51/voicenotify/AppListViewModel.kt create mode 100644 app/src/main/java/com/pilot51/voicenotify/AppWidget.kt delete mode 100644 app/src/main/java/com/pilot51/voicenotify/MainFragment.kt create mode 100644 app/src/main/java/com/pilot51/voicenotify/MainScreen.kt delete mode 100644 app/src/main/java/com/pilot51/voicenotify/PrefDialog.kt create mode 100644 app/src/main/java/com/pilot51/voicenotify/PreferenceDialogs.kt create mode 100644 app/src/main/java/com/pilot51/voicenotify/PreferenceHelper.kt create mode 100644 app/src/main/java/com/pilot51/voicenotify/PreferenceRows.kt create mode 100644 app/src/main/java/com/pilot51/voicenotify/TextReplaceDialog.kt create mode 100644 app/src/main/java/com/pilot51/voicenotify/TextReplaceDialogViewModel.kt delete mode 100644 app/src/main/java/com/pilot51/voicenotify/TextReplacePreference.kt delete mode 100644 app/src/main/java/com/pilot51/voicenotify/TtsConfigFragment.kt create mode 100644 app/src/main/java/com/pilot51/voicenotify/TtsConfigScreen.kt delete mode 100644 app/src/main/java/com/pilot51/voicenotify/WidgetProvider.kt delete mode 100644 app/src/main/res/drawable-anydpi/ic_search.xml rename app/src/main/res/drawable-anydpi/{widget_disabled.xml => widget.xml} (98%) delete mode 100644 app/src/main/res/drawable-anydpi/widget_running.xml delete mode 100644 app/src/main/res/drawable-anydpi/widget_suspended.xml delete mode 100644 app/src/main/res/layout/activity_main.xml delete mode 100644 app/src/main/res/layout/app_list_item.xml delete mode 100644 app/src/main/res/layout/appwidget.xml delete mode 100644 app/src/main/res/layout/notify_log_item.xml delete mode 100644 app/src/main/res/layout/preference_dialog_text_replace.xml delete mode 100644 app/src/main/res/layout/text_replace_row.xml delete mode 100644 app/src/main/res/menu/app_list.xml delete mode 100644 app/src/main/res/navigation/nav_graph.xml delete mode 100644 app/src/main/res/values/themes.xml delete mode 100644 app/src/main/res/xml/preferences.xml delete mode 100644 app/src/main/res/xml/preferences_tts.xml diff --git a/NOTICE b/NOTICE index 764aea8..5f327d4 100644 --- a/NOTICE +++ b/NOTICE @@ -1,5 +1,5 @@ Voice Notify -Copyright 2011-2022 Mark Injerd +Copyright 2011-2023 Mark Injerd Voice Notify "bell" icon Copyright 2018 Ruel Cedeno, released under the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/). diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 8e26b4f..25a4a57 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2017-2023 Mark Injerd + * Copyright 2011-2023 Mark Injerd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,6 @@ plugins { id("com.android.application") kotlin("android") id("com.google.devtools.ksp") - id("androidx.navigation.safeargs.kotlin") } val keystorePropertiesFile: File = rootProject.file("keystore.properties") @@ -43,11 +42,11 @@ val gitCommitHash by lazy { android { namespace = "com.pilot51.voicenotify" - compileSdk = 33 + compileSdk = 34 defaultConfig { applicationId = "com.pilot51.voicenotify" - minSdk = 18 - targetSdk = 33 + minSdk = 21 + targetSdk = 34 versionName = "1.2.3" versionCode = 27 vectorDrawables.useSupportLibrary = true @@ -60,6 +59,15 @@ android { viewBinding = true } + buildFeatures { + buildConfig = true + compose = true + } + + composeOptions { + kotlinCompilerExtensionVersion = "1.5.7" + } + compileOptions { sourceCompatibility = JavaVersion.VERSION_17 targetCompatibility = JavaVersion.VERSION_17 @@ -78,8 +86,15 @@ android { buildTypes { getByName("release") { - isMinifyEnabled = false signingConfig = signingConfigs.getByName("release") + versionNameSuffix = " [$gitCommitHash]" + @Suppress("UnstableApiUsage") + postprocessing { + isRemoveUnusedCode = true + isOptimizeCode = true + isShrinkResources = true + isObfuscate = false + } } getByName("debug") { versionNameSuffix = "-debug [$gitCommitHash]" @@ -95,10 +110,16 @@ android { } dependencies { - implementation("androidx.core:core-ktx:1.10.1") + implementation("androidx.core:core-ktx:1.12.0") + implementation("androidx.activity:activity-compose:1.8.2") + implementation("androidx.compose.material3:material3:1.1.2") + implementation("androidx.compose.material:material-icons-extended-android:1.5.4") + implementation("androidx.compose.ui:ui-tooling-preview:1.5.4") + debugImplementation("androidx.compose.ui:ui-tooling:1.5.4") + implementation("androidx.navigation:navigation-compose:2.7.6") + implementation("androidx.glance:glance-appwidget:1.0.0") implementation("androidx.preference:preference-ktx:1.2.1") - implementation("androidx.navigation:navigation-fragment-ktx:2.6.0") - implementation("androidx.navigation:navigation-ui-ktx:2.6.0") - implementation("androidx.room:room-ktx:2.5.2") - ksp("androidx.room:room-compiler:2.5.2") + implementation("androidx.room:room-ktx:2.6.1") + ksp("androidx.room:room-compiler:2.6.1") + implementation("com.google.accompanist:accompanist-permissions:0.32.0") } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 7200fc5..ce9ecc8 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/layout/appwidget.xml b/app/src/main/res/layout/appwidget.xml deleted file mode 100644 index 30439a9..0000000 --- a/app/src/main/res/layout/appwidget.xml +++ /dev/null @@ -1,8 +0,0 @@ - - diff --git a/app/src/main/res/layout/notify_log_item.xml b/app/src/main/res/layout/notify_log_item.xml deleted file mode 100644 index aaa869c..0000000 --- a/app/src/main/res/layout/notify_log_item.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - diff --git a/app/src/main/res/layout/preference_dialog_text_replace.xml b/app/src/main/res/layout/preference_dialog_text_replace.xml deleted file mode 100644 index 871be54..0000000 --- a/app/src/main/res/layout/preference_dialog_text_replace.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - diff --git a/app/src/main/res/layout/text_replace_row.xml b/app/src/main/res/layout/text_replace_row.xml deleted file mode 100644 index 88eb536..0000000 --- a/app/src/main/res/layout/text_replace_row.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - diff --git a/app/src/main/res/menu/app_list.xml b/app/src/main/res/menu/app_list.xml deleted file mode 100644 index 607732d..0000000 --- a/app/src/main/res/menu/app_list.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - diff --git a/app/src/main/res/navigation/nav_graph.xml b/app/src/main/res/navigation/nav_graph.xml deleted file mode 100644 index 5327209..0000000 --- a/app/src/main/res/navigation/nav_graph.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml index 54efe8b..063db30 100644 --- a/app/src/main/res/values/donottranslate.xml +++ b/app/src/main/res/values/donottranslate.xml @@ -8,7 +8,6 @@ 2 4 - #a. #c. #m. test @string/support_rate @@ -23,29 +22,4 @@ Contacting about Voice Notify \n\nVoice Notify version: %1$s\nAndroid version: %2$s\nAndroid build number: %3$s\nDevice: %4$s\n - - - status - appList - ttsConfig - ttsSettings - ttsString - ttsTextReplace - ttsStream - ttsDelay - tts_repeat - shake_threshold - require_strings - ignore_strings - ignore_empty - ignore_groups - ignore_repeat - key_max_length - device_state - quietStart - quietEnd - test - notify_log - support - audio_focus diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a6f3f83..297b68e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,5 +1,5 @@ - Voice Notify - - - %s is ignored - %s is not ignored + + + Back + + Voice Notify service is running Voice Notify service is suspended - - + + + The phone calls permission is required to prevent Voice Notify from speaking during a call. + The post notifications permission is required for Voice Notify to post a test notification. + Voice Notify service is disabled + Open the Android notification access settings to disable Voice Notify + Open the Android notification access settings to enable Voice Notify + Select to activate Voice Notify. App List List installed apps which can be ignored Text-To-Speech Configure Text-To-Speech behavior - TTS Settings - Open the Android Text-To-Speech settings - Unable to find TTS settings! If it exists on your device (it should), please contact the developer. - TTS Message - Customize which parts of notifications are spoken - #a = App title\n#t = Ticker\n#s = Subtext\n#c = Content title\n#m = Content message\n#i = Content info\n\nDefault:\n#a. #c. #m.\n\nOld default (v1.0.x):\n#a: #t - TTS Text Replacement - Substitute text to be spoken, such as to fix pronunciation - Substitute text to be spoken, allowing you to customize how Text-To-Speech pronounces words or replace text for any other reason.\n\nText to replace is case insensitive. - TTS Audio Stream - Choose the audio stream that Text-To-Speech plays through - TTS Delay - Delay TTS a set number of seconds after notification - Number of seconds to wait after notification before speaking. - TTS Repeat - Continually repeat notifications over TTS until screen turns on - Notifications are repeated at the defined interval until the screen is turned on. Notifications created while the screen is on are not repeated.\n\nValue is in minutes. Blank or 0 to disable. Pause/dim media Request other media to pause/dim when speaking Shake-To-Silence @@ -70,9 +60,6 @@ Ignore Repeats Ignore subsequent identical notifications within a set time Set number of seconds that must pass since last notification before a repeat can be spoken.\nIgnored repeats reset the count and different notifications clear it.\nBlank = infinite. - Maximum Message - Maximum message length to speak. Larger messages will be truncated. - Maximum message length to speak\nLarger messages will be truncated. Device States Select whether to speak during certain device states Speak during these device states @@ -87,34 +74,22 @@ Don\'t speak after this time.\nLeave the same as end to disable. Quiet Time End Don\'t speak before this time.\nLeave the same as start to disable. + Test Post a notification (delayed 5 seconds) to test current settings Voice Notify is ignored in App List.\nTest will run, but notification will not be spoken. - List last 20 notifications.\nDisplays time, app name, message, and ignore reasons. - Rate & review, email the developer, community chat, translations, source code, issue tracker, privacy policy - - - Duplicate! Will not be saved. - - - Text to replace - Replacement text - - - Test - Notification Log - Help & Support - - - Voice Notify service is disabled - Open the Android notification access settings to disable Voice Notify - Open the Android notification access settings to enable Voice Notify - Select to activate Voice Notify. Used for test notification This is the ticker message The Subtext Content Title This is the content message. Content Info + Notification Log + List last 20 notifications.\nDisplays time, app name, message, and ignore reasons. + Ignore %s? + Unignore %s? + Yes + Help & Support + Rate & review, email the developer, community chat, translations, source code, issue tracker, privacy policy Rate & Review Email Developer Discord @@ -139,25 +114,52 @@ \n• Read Phone State - Required to interrupt TTS if a phone call becomes active. Error: Unable to find Google Play Store installed. Error: Unable to find an installed email app. - TTS Message setting updated to new default value - The phone calls permission is required to prevent Voice Notify from speaking during a call. - The post notifications permission is required for Voice Notify to post a test notification. - - - Notification from %s. - Error: Could not initialize TTS! Status code %d - - - Yes - Ignore %s? - Unignore %s? - - + + + Close Ignore All Ignore None Filter - - + + + TTS Settings + Open the Android Text-To-Speech settings + Unable to find TTS settings! If it exists on your device (it should), please contact the developer. + TTS Message + Customize which parts of notifications are spoken + #a = App title\n#t = Ticker\n#s = Subtext\n#c = Content title\n#m = Content message\n#i = Content info\n\nDefault:\n#a. #c. #m.\n\nOld default (v1.0.x):\n#a: #t + TTS Message setting updated to new default value + TTS Text Replacement + Substitute text to be spoken, such as to fix pronunciation + Substitute text to be spoken, allowing you to customize how Text-To-Speech pronounces words or replace text for any other reason.\n\nText to replace is case insensitive. + Duplicate! Will not be saved. + Text to replace + Replacement text + Remove + Error + Maximum Message + Maximum message length to speak. Larger messages will be truncated. + Maximum message length to speak\nLarger messages will be truncated. + TTS Audio Stream + Choose the audio stream that Text-To-Speech plays through + TTS Delay + Delay TTS a set number of seconds after notification + Number of seconds to wait after notification before speaking. + TTS Repeat + Continually repeat notifications over TTS until screen turns on + Notifications are repeated at the defined interval until the screen is turned on. Notifications created while the screen is on are not repeated.\n\nValue is in minutes. Blank or 0 to disable. + + + %s is ignored + %s is not ignored + + + Notification from %s. + + + Error: Could not initialize TTS! Status code %d + + Ignored app Ignored text Required text missing diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml deleted file mode 100644 index 7c5cf73..0000000 --- a/app/src/main/res/values/themes.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - diff --git a/app/src/main/res/xml/appwidget_info.xml b/app/src/main/res/xml/appwidget_info.xml index 44ae1e9..30caa47 100644 --- a/app/src/main/res/xml/appwidget_info.xml +++ b/app/src/main/res/xml/appwidget_info.xml @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/res/xml/preferences_tts.xml b/app/src/main/res/xml/preferences_tts.xml deleted file mode 100644 index 2eba63c..0000000 --- a/app/src/main/res/xml/preferences_tts.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - - - - - diff --git a/build.gradle.kts b/build.gradle.kts index 36ea9e4..4eeaab4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("com.google.devtools.ksp") version "1.9.0-1.0.13" apply false + id("com.google.devtools.ksp") version "1.9.21-1.0.15" apply false } buildscript { @@ -8,9 +8,8 @@ buildscript { google() } dependencies { - classpath("com.android.tools.build:gradle:8.1.0") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0") - classpath("androidx.navigation:navigation-safe-args-gradle-plugin:2.7.0") + classpath("com.android.tools.build:gradle:8.2.0") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.21") } } diff --git a/gradle.properties b/gradle.properties index 432756e..abde829 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,6 +13,5 @@ #Tue Jun 21 21:20:21 EDT 2022 org.gradle.jvmargs=-Xmx2048M -Dkotlin.daemon.jvm.options\="-Xmx2048M" android.useAndroidX=true -android.defaults.buildfeatures.buildconfig=true android.nonTransitiveRClass=false android.nonFinalResIds=false diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ec915a8..8d139cb 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,6 @@ +#Thu Dec 28 23:32:16 EST 2023 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip