From 3dfa9d912ef1c07e4339aa445eb5ed36f3349351 Mon Sep 17 00:00:00 2001 From: toby Date: Tue, 27 Aug 2024 19:04:02 +0000 Subject: [PATCH 001/333] Translated using Weblate (French) Currently translated at 100.0% (99 of 99 strings) Translation: jrpie-Launcher/Launcher Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/fr/ --- app/src/main/res/values-fr/strings.xml | 95 ++++++++++++++------------ 1 file changed, 51 insertions(+), 44 deletions(-) diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 3cf0c7b..38a2e2f 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -6,7 +6,7 @@ - --> Impossible d\'ouvrir l\'application - Vous souhaitez modifier ses paramètres? + Souhaitez-vous modifier ses paramètres ? Ouvrez les paramètres pour choisir une application pour cette action Réglages - Apps + Applications Launcher Meta - Balayez haut + Balayer vers le haut Double haut - Balayez bas + Balayer vers le bas Double bas - Balayez gauche + Balayer vers la gauche Double gauche - Balayez droit + Balayer vers la droite Double droit - Monter volume - Baisser volume + Appui bouton volume haut + Appui bouton volume bas Double clic Clic long - Touchez date - Touchez horloge + Toucher la date + Toucher de l\'horloge Choisir App - Toutes les applications - Installer applications - Pas trouvé le Store + Voir les applications + Installer des applications + Magasin d\'applications introuvable - Choisir Launcher + Choisir Launcher comme application d\'écran d\'accueil par défaut Informations sur l\'application - Votre appareil ne prend pas en charge cette fonctionnalité. Gérez plutôt les détails de l\'application? - Regardez le tutoriel + Votre appareil ne prend pas en charge cette fonctionnalité. Souhaitez-vous plutôt accéder aux détails de l\'application ? + Regarder le tutoriel Réinitialiser - Vous allez supprimer toutes vos préférences. Continuer? + Vous allez réinitialiser tous vos paramètres. Souhaitez-vous poursuivre ? Signaler une erreur - Rejoindre le serveur Discord + Rejoins-nous sur Discord ! Contacter le développeur https://www.finnmglas.com/fr/contact/ Contact the developer of the fork (malheureusement, il ne parle pas français) @@ -93,39 +93,46 @@ --> Applications Choisir App - Apps + Applications Autre Désinstaller Informations Application supprimée - Impossible de supprimer l\'application - rechercher des applications - Launcher Réglages + Impossible de désinstaller l\'application + Chercher des applications + Réglages du launcher Applications - Musique: plus fort - Musique: plus calme - Musique: suivant - Musique: dernier - Rien + Augmenter le volume + Diminuer le volume + Musique : passer au titre suivant + Musique : revenir au titre précédent + Ne rien faire - Le Tutoriel - Prenez un moment et apprenez à utiliser ce lanceur! + Tutoriel + Prenez quelques instants pour apprendre à utiliser ce \'launcher\' ! Concept Launcher vous offre un environnement minimaliste, efficace et sans distraction.\n\nIl ne vous coûte rien, ne contient aucune publicité, ne recueille pas de données personnelles. - L\'application est open-source (licence MIT) et disponible sur GitHub!\n\nAssurez-vous de visiter le repo! + L\'application est open-source (sous licence MIT) et disponible sur GitHub! +\n +\nN\'hésitez pas à y faire un tour ! Utilisation - Vous ne voyez que la date et l\'heure sur votre écran d\'accueil. Aucune distraction. - Vous ouvrez des applications en faisant glisser l\'écran ou en appuyant sur les touches de volume. Choisissez-les maintenant. - Installer - Nous avons choisi quelques applications standards pour vous, vous pouvez changer-les maintenant. - Vous pouvez également modifier votre sélection ultérieurement. - Allez! - Vous êtes prêt à commencer!\n\nJ\'espère que cette application vous sera très précieuse!\n\n- Finn M Glas\n(le développeur) - Ouvrir + Sur votre écran d\'accueil vous ne trouverez rien d\'autre que la date et l\'heure : rien qui pourrait vous distraire. + Vous pouvez ouvrir des applications en effectuant des mouvelents latéraux sur l\'écran ou en appuyant sur les touches de volume. Vous pourrez en définir le comportement dans le panneau suivant. + Configuration + Voici quelques paramètres par défaut. Vous pouvez les changer dès à présent. + Vous pourrez bien sûr tout reconfigurer plus tard. + C\'est parti ! + Vous êtes prêt à démarrer ! +\n +\nJ\'espère que cette application vous sera précieuse ! +\n +\n- Finn M Glas +\n(le développeur originel) et Josia (le développeur de la branche μLauncher) + Démarrer Réglages Plus d\'options Balayer vers la droite (en haut de l\'écran) From 7c6ea1a16e255ac188005959a6c8351eb84800e0 Mon Sep 17 00:00:00 2001 From: Josia Pietsch Date: Wed, 28 Aug 2024 21:06:58 +0200 Subject: [PATCH 002/333] updated changelog --- fastlane/metadata/android/en-US/changelogs/21.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fastlane/metadata/android/en-US/changelogs/21.txt b/fastlane/metadata/android/en-US/changelogs/21.txt index 3838e1f..9abeb95 100644 --- a/fastlane/metadata/android/en-US/changelogs/21.txt +++ b/fastlane/metadata/android/en-US/changelogs/21.txt @@ -1,5 +1,6 @@ - Chinese translation (thank you, yzqzss!) -- improved French translation +- improved French translation (thank you, toby-bro!) +- improved German translation All Apps: - Removed three dots in app list (use long click instead) From ac30fc6ed51717947666f08ba6a8b5c9ccaa91cc Mon Sep 17 00:00:00 2001 From: Josia Pietsch Date: Thu, 29 Aug 2024 01:00:50 +0200 Subject: [PATCH 003/333] increase version code, enable gradle configuration cache --- app/build.gradle | 2 +- gradle.properties | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index 3324ccf..f48fd2e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -23,7 +23,7 @@ android { applicationId "de.jrpie.android.launcher" minSdkVersion 21 targetSdkVersion 35 - versionCode 21 + versionCode 22 versionName "j-0.0.9" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/gradle.properties b/gradle.properties index 4795480..519dc7f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,3 +21,4 @@ android.enableJetifier=true kotlin.code.style=official android.nonTransitiveRClass=false android.nonFinalResIds=false +org.gradle.configuration-cache=true From 91a636bf039bd078a76874e2866ff9063fbc03b3 Mon Sep 17 00:00:00 2001 From: Jean-Nicolas Date: Sat, 31 Aug 2024 17:29:32 +0200 Subject: [PATCH 004/333] feat: add french translation of short and full description --- .../android/fr-FR/full_description.txt | 20 +++++++++++++++++++ .../android/fr-FR/short_description.txt | 1 + 2 files changed, 21 insertions(+) create mode 100644 fastlane/metadata/android/fr-FR/full_description.txt create mode 100644 fastlane/metadata/android/fr-FR/short_description.txt diff --git a/fastlane/metadata/android/fr-FR/full_description.txt b/fastlane/metadata/android/fr-FR/full_description.txt new file mode 100644 index 0000000..69e20f9 --- /dev/null +++ b/fastlane/metadata/android/fr-FR/full_description.txt @@ -0,0 +1,20 @@ +µLauncher est une application d'écran d'accueil qui vous permet de démarrer des application à partir de gestes ou des boutons de votre appareil. +C'est une application minimaliste, efficace, sans distraction et ergonomique. + +L'écran d'accueil n'affiche rien de plus que la date, l'heure et votre fond d'écran. +Appuyer sur la touche retour ou faire un geste de défilement vers le haut (ce qui peut être modifié) permet d'ouvrir +une liste de toutes les applications installées, qui peuvent d'ailleurs être démarrées par une simple recherche. + +Cette application est une branche de l'application Launcher +de Finn M Glas. + +Changements notables : +* Mouvements sur les bords de l'écran : il est possible d'ouvrir les applications par des mouvements le long des bords de l'écran, permettant de rajouter de nombreux raccourcis. +* Compatible avec le profil "travail", rendant l'utilisation d'applications telles que Shelter possible. +* Cette application utilise le fond d'écran système au lieu d'une solution "fait maison". +* La police de l'application a été changée à Hack. +* Les icônes "Font Awesome" ont étées changées par des icônes "Material" +* Le bouton réglages sur l'écran d'accueil a été retiré, pour accéder aux réglages il faut à présent appuyer sur le bouton retour. +* L'algorithme de recherche a été amélioré pour prioriser les correspondances dans le début du nom de l'application, i.e. "te" classera "termux" avant "notes". +* La barre de recherche a été déplacée en bas de l'écran +* Correction de bugs diff --git a/fastlane/metadata/android/fr-FR/short_description.txt b/fastlane/metadata/android/fr-FR/short_description.txt new file mode 100644 index 0000000..c66ec80 --- /dev/null +++ b/fastlane/metadata/android/fr-FR/short_description.txt @@ -0,0 +1 @@ +Une application d'écran d'accueil minimaliste pour Android. From 1ff26ac036c04e04d0b27647e49b591f1a9d91ea Mon Sep 17 00:00:00 2001 From: Jean-Nicolas Date: Sat, 31 Aug 2024 19:49:47 +0200 Subject: [PATCH 005/333] chore: remove local parameters from global configuration --- .gitignore | 1 + .idea/deploymentTargetSelector.xml | 18 ------------------ 2 files changed, 1 insertion(+), 18 deletions(-) delete mode 100644 .idea/deploymentTargetSelector.xml diff --git a/.gitignore b/.gitignore index a6f4d90..e8c588d 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,7 @@ captures/ .idea/assetWizardSettings.xml .idea/dictionaries .idea/libraries +.idea/deploymentTargetSelector.xml # Android Studio 3 in .gitignore file. .idea/caches .idea/modules.xml diff --git a/.idea/deploymentTargetSelector.xml b/.idea/deploymentTargetSelector.xml deleted file mode 100644 index 81acdf9..0000000 --- a/.idea/deploymentTargetSelector.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - \ No newline at end of file From 0d9d85f25374225135d197f38e5b04b808bbe6da Mon Sep 17 00:00:00 2001 From: Jean-Nicolas Date: Sat, 31 Aug 2024 20:26:16 +0200 Subject: [PATCH 006/333] fix: add defaults so as to fix bug --- .../settings/actions/SettingsFragmentActionsRecycler.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActionsRecycler.kt b/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActionsRecycler.kt index d8e3026..6bd5297 100644 --- a/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActionsRecycler.kt +++ b/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActionsRecycler.kt @@ -81,7 +81,10 @@ class ActionsRecyclerAdapter(val activity: Activity): fun updateViewHolder() { val app = gesture.getApp(activity) val content = app.first - if (content == ""){ + viewHolder.img.visibility = View.VISIBLE + viewHolder.removeAction.visibility = View.VISIBLE + viewHolder.chooseButton.visibility = View.INVISIBLE + if (content.isEmpty()){ viewHolder.img.visibility = View.INVISIBLE viewHolder.removeAction.visibility = View.GONE viewHolder.chooseButton.visibility = View.VISIBLE From 23ca9eb4cfa2810b1018037586bbb20ae2efc7c2 Mon Sep 17 00:00:00 2001 From: Jean-Nicolas Date: Sat, 31 Aug 2024 23:07:48 +0200 Subject: [PATCH 007/333] chore: bump gradle --- app/build.gradle | 8 ++++---- build.gradle | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f48fd2e..8cd05df 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,9 +1,8 @@ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' +apply plugin: 'kotlin-kapt' android { - compileSdkVersion 34 - buildToolsVersion "34.0.0" dataBinding { enabled = true @@ -23,6 +22,7 @@ android { applicationId "de.jrpie.android.launcher" minSdkVersion 21 targetSdkVersion 35 + compileSdk 35 versionCode 22 versionName "j-0.0.9" @@ -63,12 +63,12 @@ dependencies { implementation 'androidx.core:core-ktx:1.13.1' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.legacy:legacy-support-v4:1.0.0' - testImplementation 'junit:junit:4.12' + 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.android.material:material:1.12.0' implementation 'androidx.gridlayout:gridlayout:1.0.0' implementation 'androidx.palette:palette-ktx:1.0.0' - implementation "com.android.databinding:compiler:$android_plugin_version" + annotationProcessor "com.android.databinding:compiler:$android_plugin_version" } diff --git a/build.gradle b/build.gradle index 5b47d1b..c7551a0 100644 --- a/build.gradle +++ b/build.gradle @@ -5,12 +5,12 @@ buildscript { ext.android_plugin_version = '8.5.1' repositories { google() - jcenter() + mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:8.5.1' + classpath 'com.android.tools.build:gradle:8.5.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "com.android.tools.build:gradle:$android_plugin_version" @@ -22,12 +22,12 @@ buildscript { allprojects { repositories { google() - jcenter() + mavenCentral() } } -task clean(type: Delete) { - delete rootProject.buildDir +tasks.register('clean', Delete) { + delete layout.buildDirectory } From 5b906389b517049f2761e8f53dc0de8359136039 Mon Sep 17 00:00:00 2001 From: toby Date: Sat, 31 Aug 2024 16:36:09 +0000 Subject: [PATCH 008/333] Translated using Weblate (French) Currently translated at 100.0% (103 of 103 strings) Translation: jrpie-Launcher/Launcher Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/fr/ --- app/src/main/res/values-fr/strings.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 21b2b46..7d265bb 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -35,7 +35,7 @@ Double clic Clic long Toucher la date - Toucher de l\'horloge + Toucher l\'horloge Choisir App Voir les applications Installer des applications @@ -137,4 +137,8 @@ Balayer vers le haut (à gauche de l\'écran) Balayer vers le haut (à droite de l\'écran) Balayer vers le bas (à droite de l\'écran) - + Afficher l\'heure + Échanger la date et l\'heure + Afficher la date + Utiliser le format de date local + \ No newline at end of file From 4ce399ac62b8992307f2bc24aba4594eadc473d3 Mon Sep 17 00:00:00 2001 From: Symphonic5855 Date: Sat, 31 Aug 2024 03:19:45 +0000 Subject: [PATCH 009/333] Translated using Weblate (Chinese (Simplified)) Currently translated at 100.0% (103 of 103 strings) Translation: jrpie-Launcher/Launcher Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/ --- app/src/main/res/values-zh-rCN/strings.xml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 48fde2c..66cc2d0 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -40,7 +40,7 @@ 浏览全部应用 安装应用 没有找到应用市场 - 日期格式 + 日期和时间 选择一个壁纸 换壁纸 保持屏幕常亮 @@ -100,4 +100,8 @@ \n- Finn (Launcher 的作者) \n以及 Josia(做了一些改进并维护了 μLauncher 分支) 双滑动作 - + 使用本地日期格式 + 显示时间 + 显示日期 + 翻转日期和时间 + \ No newline at end of file From 9582113bcf5e82d25ad468adb42a29ccd4dfce3c Mon Sep 17 00:00:00 2001 From: Josia Pietsch Date: Sun, 1 Sep 2024 21:11:32 +0200 Subject: [PATCH 010/333] Merge pull request #22 from toby-bro/chore/android_permissions --- app/src/main/AndroidManifest.xml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ee17c5b..ccacabb 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,7 +3,6 @@ xmlns:tools="http://schemas.android.com/tools"> - @@ -17,7 +16,8 @@ android:supportsRtl="true" android:theme="@style/launcherBaseTheme"> - - - - @@ -52,4 +55,4 @@ - \ No newline at end of file + From 25905f11160c5bb28473c5bd7aeacdeebb7562e2 Mon Sep 17 00:00:00 2001 From: Josia Pietsch Date: Fri, 6 Sep 2024 13:32:38 +0200 Subject: [PATCH 011/333] feature #28: action to open notification panel --- app/src/main/AndroidManifest.xml | 1 + .../java/de/jrpie/android/launcher/Functions.kt | 13 +++++++++++++ .../java/de/jrpie/android/launcher/Preferences.kt | 2 ++ .../android/launcher/list/other/LauncherAction.kt | 5 +++++ .../main/res/drawable/baseline_notifications_24.xml | 5 +++++ app/src/main/res/values/strings.xml | 2 ++ 6 files changed, 28 insertions(+) create mode 100644 app/src/main/java/de/jrpie/android/launcher/Preferences.kt create mode 100644 app/src/main/res/drawable/baseline_notifications_24.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index ccacabb..6aa938b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -6,6 +6,7 @@ + + + + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4f93a71..6fd6b14 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -157,6 +157,7 @@ Music: Quieter Music: Next Music: Previous + Expand notifications panel Do nothing Aussehen - Zeit anzeigen - Datum anzeigen - Lokalisiertes Datumsformat verwenden - Datum und Uhrzeit tauschen + Zeit anzeigen + Datum anzeigen + Lokalisiertes Datumsformat verwenden + Datum und Uhrzeit tauschen - Theme + Theme Standard Dunkel - Hintergrund auswählen + Hintergrund auswählen Hintergrund ändern Bildschirm - Bildschirm nicht ausschalten + Bildschirm nicht ausschalten Vollbild - Funktionen + Funktionen - Doppelte Wischaktionen - Kantenwischaktionen - Suchergebnis starten - Tastatur automatisch öffnen + Doppelte Wischaktionen + Kantenwischaktionen + Suchergebnis starten + Tastatur automatisch öffnen Empfindlichkeit @@ -95,7 +95,7 @@ - Settings : Meta - --> - Launcher wählen + Launcher wählen App Info Dein Gerät unterstützt diese Funktion nicht. Stattdessen die App Details bearbeiten? diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 2922da8..07bf72a 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -70,19 +70,19 @@ Oscuro - Seleccionar fondo de pantalla + Seleccionar fondo de pantalla Cambiar fondo de pantalla Pantalla - Mantener encendida + Mantener encendida Pantalla completa - Funciones + Funciones - Deslizar con dos dedos - Auto-lanzar búsquedas - Abrir teclado en búsqueda + Deslizar con dos dedos + Auto-lanzar búsquedas + Abrir teclado en búsqueda Sensibilidad @@ -91,7 +91,7 @@ - Settings : Meta - --> - Seleccionar Launcher + Seleccionar Launcher Información de la aplicación Su dispositivo no posee esta caracrerística. Desea cambiar los detalles de la aplicación? diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 7d265bb..e6a8b64 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -47,27 +47,27 @@ --> Apparence Format de date - Thème + Thème Défaut Noir - Choisir un fond d\'écran + Choisir un fond d\'écran Changer le fond d\'écran Écran - Garder l\'écran allumé + Garder l\'écran allumé Utiliser le plein écran - Fonctions - Actions de double balayage - Lancer apps par recherche - Ouvrir le clavier automatiquement pour la recherche + Fonctions + Actions de double balayage + Lancer apps par recherche + Ouvrir le clavier automatiquement pour la recherche Sensibilité - Choisir Launcher comme application d\'écran d\'accueil par défaut + Choisir Launcher comme application d\'écran d\'accueil par défaut Informations sur l\'application Votre appareil ne prend pas en charge cette fonctionnalité. Souhaitez-vous plutôt accéder aux détails de l\'application ? Regarder le tutoriel @@ -129,7 +129,7 @@ Réglages Plus d\'options Balayer vers la droite (en haut de l\'écran) - Actions associées aux mouvements sur les bords de l\'écran + Actions associées aux mouvements sur les bords de l\'écran Balayer vers la droite (en bas de l\'écran) Balayer vers le bas (à gauche de l\'écran) Balayer vers la gauche (en bas de l\'écran) @@ -137,8 +137,8 @@ Balayer vers le haut (à gauche de l\'écran) Balayer vers le haut (à droite de l\'écran) Balayer vers le bas (à droite de l\'écran) - Afficher l\'heure - Échanger la date et l\'heure - Afficher la date - Utiliser le format de date local + Afficher l\'heure + Échanger la date et l\'heure + Afficher la date + Utiliser le format de date local \ No newline at end of file diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 66cc2d0..9e51f32 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -5,7 +5,7 @@ 更多选项 设置 外观 - 主题 + 主题 显示 其他 上滑 @@ -41,14 +41,14 @@ 安装应用 没有找到应用市场 日期和时间 - 选择一个壁纸 + 选择一个壁纸 换壁纸 - 保持屏幕常亮 + 保持屏幕常亮 使用全屏 - 功能 - 边缘滑动动作 - 零点击启动唯一搜索结果 - 搜索时呼出键盘 + 功能 + 边缘滑动动作 + 零点击启动唯一搜索结果 + 搜索时呼出键盘 灵敏度 应用信息 您的设备不支持此功能。要不打开应用程序详细? @@ -92,16 +92,16 @@ \n \n它不付费、无广告、不追踪。 您只需滑动屏幕或按下按钮即可启动应用程序。在下一步向导中选择一些应用程序。 - 将 μLauncher 设为默认桌面 + 将 μLauncher 设为默认桌面 您已经准备好开始了! \n \n我希望这对你有很大的价值! \n \n- Finn (Launcher 的作者) \n以及 Josia(做了一些改进并维护了 μLauncher 分支) - 双滑动作 - 使用本地日期格式 - 显示时间 - 显示日期 - 翻转日期和时间 + 双滑动作 + 使用本地日期格式 + 显示时间 + 显示日期 + 翻转日期和时间 \ No newline at end of file diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml new file mode 100644 index 0000000..bf854df --- /dev/null +++ b/app/src/main/res/values/donottranslate.xml @@ -0,0 +1,97 @@ + + + μLauncher + + V3RYR4ND0MK3YCR4P + startedBefore + firstStartup + version_code + settings.general.select_launcher + + Swipe Up + Double Up + Swipe Down + Double Down + Swipe Left + Double Left + Swipe Right + Double Right + Swipe Right (Top) + Swipe Right (Bottom) + Swipe Left (Bottom) + Swipe Left (Top) + Swipe Up (Left Edge) + Swipe Up (Right Edge) + Swipe Down (Left Edge) + Swipe Down (Right Edge) + Volume Up + Volume Down + Double Click + Long Click + Click on Date + Click on Time + + + theme + settings.theme.wallpaper + custom_dominant + custom_vibrant + + + timeVisible + dateVisible + dateLocalized + dateTimeFlip + + + + disableTimeout + useFullScreen + + enableDoubleActions + enableEdgeActions + searchAutoLaunch + searchAutoKeyboard + + + + + https://github.com/jrpie/Launcher + https://github.com/jrpie/Launcher/issues/new + https://s.jrpie.de/contact + https://s.jrpie.de/android-legal + https://www.finnmglas.com/contact/ + https://discord.com/invite/jV2AhF8 + + + + >>>>>]]> + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6fd6b14..170a86b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,13 +1,5 @@ - - μLauncher - V3RYR4ND0MK3YCR4P - - - Set μLauncher as home screen + Set μLauncher as home screen App Info Your device does not support this feature. Manage application details instead? @@ -114,23 +108,15 @@ Reset Settings You are going to discard all your preferences. Continue? - https://github.com/jrpie/Launcher - Report a bug - https://github.com/jrpie/Launcher/issues/new Contact the developer of the fork - https://s.jrpie.de/contact Privacy Policy - https://s.jrpie.de/android-legal Contact the original developer - https://www.finnmglas.com/contact/ - Join us on discord! - https://discord.com/invite/jV2AhF8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 5492039b892850b907c52dcf06003250da85d9ce Mon Sep 17 00:00:00 2001 From: toolatebot Date: Tue, 10 Sep 2024 00:53:57 +0000 Subject: [PATCH 015/333] Update translation files Updated by "Cleanup translation files" add-on in Weblate. Translation: jrpie-Launcher/Launcher Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/ --- app/src/main/res/values-de/strings.xml | 41 +-------------------- app/src/main/res/values-es/strings.xml | 43 ++-------------------- app/src/main/res/values-fr/strings.xml | 2 - app/src/main/res/values-zh-rCN/strings.xml | 2 - 4 files changed, 5 insertions(+), 83 deletions(-) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 2f1a92c..099c124 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -1,3 +1,4 @@ + App kann nicht geöffnet werden Willst du die App-Einstellungen anpassen? - Öffne die Einstellungen um für diese Aktion eine App zu wählen - Einstellungen - Apps Launcher Meta - Aussehen - Zeit anzeigen Datum anzeigen Lokalisiertes Datumsformat verwenden @@ -72,24 +64,16 @@ Standard Dunkel - Hintergrund auswählen Hintergrund ändern - Bildschirm - Bildschirm nicht ausschalten - Vollbild - Funktionen - Doppelte Wischaktionen Kantenwischaktionen Suchergebnis starten Tastatur automatisch öffnen - Empfindlichkeit - Alle Apps App wählen - Apps Andere - Deinstallieren App Info - Die App wurde entfernt Die App konnte nicht entfernt werden - Anwendungen suchen - App Einstellungen Alle Anwendungen Musik: Lauter @@ -141,7 +111,6 @@ Musik: Weiter Musik: Zurück Nichts tun - Tutorial Nimm dir kurz Zeit und lerne, wie du diesen Launcher verwendest! - Konzept Launcher bietet dir eine minimalistische, effiziente und ablenkungsfreie digitale Umgebung.\n\nDie App kostet dich nichts, enthält keine Werbung, sammelt keine persönlichen Daten. Launcher ist open-source (MIT license) und auf GitHub!\n\nSchau gerne mal dort vorbei! - Benutzung Auf deinem Homescreen siehst du nur das Datum und die Uhrzeit. Keine Ablenkung. Du öffnest Apps indem du über den Bildschirm wischt oder die Lautstärketasten drückst. Gleich wählst du deine Apps. - Einrichtung Wir haben dir ein paar Standardapps ausgewählt, du kannst sie gerne ändern. Du kannst deine Einstellungen auch später noch ändern. - Los gehts! Du bist bereit loszulegen!\n\nIch hoffe diese App ist nützlich für dich!\n\n- Finn (der Entwickler)\n\tund Josia (der einige Änderungen vorgenommen hat und den Fork μLauncher entwickelt. Starten - Einstellungen Mehr Optionen - - + \ No newline at end of file diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 07bf72a..cc341a1 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -1,6 +1,6 @@ + - - No se pudo abrir la aplicación ¿Desea cambiar la configuración? - Abra la configuración para elegir una aplicación para esta acción - Configuración - Aplicaciones Launcher Meta - Apariencia - Formato de fecha Normal Oscuro - Seleccionar fondo de pantalla Cambiar fondo de pantalla - Pantalla - Mantener encendida - Pantalla completa - Funciones - Deslizar con dos dedos Auto-lanzar búsquedas Abrir teclado en búsqueda - Sensibilidad - Aplicaciones Seleccionar App - Apps Otros - Desinstalar Información - Se eliminó la aplicación No se pudo eliminar la aplicación - Buscar Aplicaciones - Configuración de Launcher Aplicaciones Música: Subir @@ -135,7 +106,6 @@ Música: Siguiente Música: Anterior Nada - Tutorial Tómate unos segundos para aprender a usar este launcher - Concepto Launcher está diseñado para ser minimalista, eficiente y libre de distracciones.\n\nEs gratis y libre de anuncios y servicios de rastreo. La aplicación es de código abierto (licencia MIT) y está disponible en GitHub!\n\nNo olvides echarle un vistazo al repositorio! - Uso Tu pantalla de inicio contiene la fecha y hora local. Sin distracciones. Puedes iniciar tus aplicaciones con solo presionar o deslizar una vez. Elige algunas en la siguiente pantalla. - Puesta a punto Elegimos algunas aplicaciones por defecto para ti, si lo deseas puedes cambiarlas ahora. También puedes cambiar tu selección más tarde. - Vamos! Estás listo para iniciar!\n\n Esperamos que esto te sea de gran ayuda!\n\n- Finn M Glas\n(el desarrollador) Iniciar - - Configuración Más opciones - - + \ No newline at end of file diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index e6a8b64..2e7f950 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -56,7 +56,6 @@ Changer le fond d\'écran Écran Garder l\'écran allumé - Utiliser le plein écran Fonctions Actions de double balayage Lancer apps par recherche @@ -76,7 +75,6 @@ Signaler une erreur Rejoins-nous sur Discord ! Contacter le développeur - https://www.finnmglas.com/fr/contact/ Contact the developer of the fork (malheureusement, il ne parle pas français) Déclaration de confidentialité \ No newline at end of file diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 2f1a92c..95210ee 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -67,10 +67,11 @@ Lokalisiertes Datumsformat verwenden Datum und Uhrzeit tauschen - Theme - + Farbschema + Standard Dunkel + Hintergrund auswählen diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 07bf72a..152016a 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -65,7 +65,7 @@ Apariencia Formato de fecha - + Normal Oscuro diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index e6a8b64..ebbee0e 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -47,8 +47,8 @@ --> Apparence Format de date - Thème - + Thème + Défaut Noir diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 9e51f32..b046b1b 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -5,7 +5,7 @@ 更多选项 设置 外观 - 主题 + 主题 显示 其他 上滑 diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index c4a008d..c9b8a2f 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -7,4 +7,9 @@ #000 #444 #fff + + #fff + #5555ff + #000 + diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml index bf854df..5d0f696 100644 --- a/app/src/main/res/values/donottranslate.xml +++ b/app/src/main/res/values/donottranslate.xml @@ -44,11 +44,26 @@ - Settings : Theme - --> - theme - settings.theme.wallpaper - custom_dominant - custom_vibrant - + theme.color_theme + + DEFAULT + DARK + + + theme.background + + TRANSPARENT + DIM + BLUR + SOLID + + theme.wallpaper + theme.font + + HACK + SYSTEM_DEFAULT + + theme.monochrome_icons + Background (app list and setting) + + Transparent + Dim + Blur + Solid + + Font + + Hack + System default + + Monochrome app icons Dominant color Vibrant color diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index aaf8158..db2f80f 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,43 +1,73 @@ - + + + + + + + + + + + + + + + + + + + - - diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 7a32795..14334d3 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -1,66 +1,65 @@ - + + android:title="@string/settings_general_choose_home_screen" /> + android:title="@string/settings_launcher_section_appearance" + app:allowDividerAbove="false"> + android:title="@string/settings_theme_wallpaper" /> + android:summary="%s" + android:title="@string/settings_theme_color_theme" /> + android:title="@string/settings_theme_font" /> + android:key="@string/settings_theme_background_key" + android:summary="%s" + android:title="@string/settings_theme_background" /> + android:title="@string/settings_theme_monochrome_icons" /> - + @@ -69,21 +68,21 @@ app:allowDividerAbove="false"> + android:title="@string/settings_enabled_gestures_double_swipe" /> + android:key="@string/settings_enabled_gestures_edge_swipe_key" + android:title="@string/settings_enabled_gestures_edge_swipe" /> @@ -92,10 +91,10 @@ app:allowDividerAbove="false"> + android:title="@string/settings_display_full_screen" /> + android:title="@string/settings_display_screen_timeout_disabled" /> From 89093f6b9ed369339d22fb0683f28aea4ce0e9e3 Mon Sep 17 00:00:00 2001 From: Josia Pietsch Date: Wed, 11 Sep 2024 10:49:45 +0200 Subject: [PATCH 018/333] renamed preferences --- app/build.gradle | 9 +- app/src/main/AndroidManifest.xml | 18 +- .../de/jrpie/android/launcher/Application.kt | 8 +- .../de/jrpie/android/launcher/Functions.kt | 112 ++++----- .../java/de/jrpie/android/launcher/Gesture.kt | 214 +++++------------- .../de/jrpie/android/launcher/HomeActivity.kt | 76 +++---- .../de/jrpie/android/launcher/UIObject.kt | 6 +- .../android/launcher/list/ListActivity.kt | 12 +- .../launcher/list/apps/AppsRecyclerAdapter.kt | 72 ++---- .../launcher/list/apps/ListFragmentApps.kt | 5 +- .../launcher/list/other/LauncherAction.kt | 51 ++--- .../launcher/list/other/ListFragmentOther.kt | 1 + .../list/other/OtherRecyclerAdapter.kt | 10 +- .../LauncherPreferences$Config.java | 70 +++--- .../launcher/preferences/Preferences.kt | 161 +++++++++---- .../launcher/settings/SettingsActivity.kt | 35 ++- .../actions/SettingsFragmentActions.kt | 10 +- .../SettingsFragmentActionsRecycler.kt | 67 +++--- .../launcher/SettingsFragmentLauncher.kt | 12 +- .../settings/meta/SettingsFragmentMeta.kt | 10 +- .../launcher/tutorial/TutorialActivity.kt | 31 ++- .../tutorial/tabs/TutorialFragmentConcept.kt | 3 +- .../tutorial/tabs/TutorialFragmentFinish.kt | 9 +- .../tutorial/tabs/TutorialFragmentSetup.kt | 2 +- .../tutorial/tabs/TutorialFragmentStart.kt | 7 +- .../tutorial/tabs/TutorialFragmentUsage.kt | 2 +- app/src/main/res/anim/bottom_up.xml | 4 +- app/src/main/res/anim/left_right.xml | 4 +- app/src/main/res/anim/right_left.xml | 4 +- app/src/main/res/anim/top_down.xml | 4 +- .../main/res/drawable/baseline_close_24.xml | 11 +- .../main/res/drawable/baseline_menu_24.xml | 11 +- .../res/drawable/baseline_more_horiz_24.xml | 11 +- .../drawable/baseline_not_interested_24.xml | 11 +- .../drawable/baseline_notifications_24.xml | 11 +- .../main/res/drawable/baseline_search_24.xml | 11 +- .../res/drawable/baseline_settings_24.xml | 11 +- .../baseline_settings_applications_24.xml | 11 +- .../res/drawable/baseline_skip_next_24.xml | 11 +- .../drawable/baseline_skip_previous_24.xml | 11 +- .../res/drawable/baseline_volume_down_24.xml | 12 +- .../res/drawable/baseline_volume_up_24.xml | 12 +- .../res/drawable/tutorial_default_dot.xml | 2 +- .../res/drawable/tutorial_selected_dot.xml | 2 +- .../res/drawable/tutorial_tab_selector.xml | 5 +- app/src/main/res/layout/home.xml | 4 +- app/src/main/res/layout/list.xml | 7 +- app/src/main/res/layout/list_apps.xml | 1 + app/src/main/res/layout/list_apps_row.xml | 3 +- app/src/main/res/layout/list_other.xml | 3 +- app/src/main/res/layout/list_other_row.xml | 3 +- app/src/main/res/layout/settings.xml | 9 +- app/src/main/res/layout/settings_actions.xml | 2 +- .../main/res/layout/settings_actions_row.xml | 6 +- app/src/main/res/layout/settings_meta.xml | 4 +- app/src/main/res/layout/tutorial.xml | 12 +- app/src/main/res/layout/tutorial_concept.xml | 9 +- app/src/main/res/layout/tutorial_finish.xml | 8 +- app/src/main/res/layout/tutorial_setup.xml | 3 +- app/src/main/res/layout/tutorial_start.xml | 7 +- app/src/main/res/menu/menu_app.xml | 6 +- .../res/mipmap-anydpi-v26/ic_launcher.xml | 4 +- .../mipmap-anydpi-v26/ic_launcher_round.xml | 4 +- app/src/main/res/values-de/strings.xml | 3 +- app/src/main/res/values-es/strings.xml | 5 +- app/src/main/res/values-fr/strings.xml | 3 +- app/src/main/res/values-zh-rCN/strings.xml | 3 +- app/src/main/res/values/donottranslate.xml | 201 ++++++++-------- app/src/main/res/values/strings.xml | 11 +- app/src/main/res/values/styles.xml | 4 +- app/src/main/res/xml/preferences.xml | 63 +++--- 71 files changed, 676 insertions(+), 884 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 6b6df2f..6cf0a85 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -41,10 +41,12 @@ android { } + + buildTypes { release { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + // minifyEnabled true + // proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } namespace 'de.jrpie.android.launcher' @@ -62,9 +64,8 @@ dependencies { implementation 'androidx.constraintlayout:constraintlayout:2.1.4' implementation 'androidx.legacy:legacy-support-v4:1.0.0' implementation "eu.jonahbauer:android-preference-annotations:1.1.2" + annotationProcessor "eu.jonahbauer:android-preference-annotations:1.1.2" implementation 'androidx.preference:preference-ktx:1.2.1' - //kapt "eu.jonahbauer:android-preference-annotations:1.1.2" - //annotationProcessor "eu.jonahbauer:android-preference-annotations:1.1.2" testImplementation 'junit:junit:4.13.2' androidTestImplementation 'androidx.test.ext:junit:1.2.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index dfa90e2..6b4cbae 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,8 +3,7 @@ xmlns:tools="http://schemas.android.com/tools"> - @@ -21,15 +20,14 @@ - @@ -38,20 +36,22 @@ + tools:ignore="LockedOrientationActivity"> + + tools:ignore="LockedOrientationActivity"> + - - + + diff --git a/app/src/main/java/de/jrpie/android/launcher/Application.kt b/app/src/main/java/de/jrpie/android/launcher/Application.kt index 50c41a3..49a9014 100644 --- a/app/src/main/java/de/jrpie/android/launcher/Application.kt +++ b/app/src/main/java/de/jrpie/android/launcher/Application.kt @@ -1,16 +1,14 @@ package de.jrpie.android.launcher import android.content.Context +import androidx.preference.PreferenceManager import de.jrpie.android.launcher.preferences.LauncherPreferences -class Application : android.app.Application() { +class Application: android.app.Application() { override fun onCreate() { super.onCreate() - val preferences = getSharedPreferences( - this.getString(R.string.preference_file_key), - Context.MODE_PRIVATE - ) + val preferences = PreferenceManager.getDefaultSharedPreferences(this) LauncherPreferences.init(preferences, this.resources) } } \ No newline at end of file diff --git a/app/src/main/java/de/jrpie/android/launcher/Functions.kt b/app/src/main/java/de/jrpie/android/launcher/Functions.kt index 76e78db..13023d7 100644 --- a/app/src/main/java/de/jrpie/android/launcher/Functions.kt +++ b/app/src/main/java/de/jrpie/android/launcher/Functions.kt @@ -10,8 +10,12 @@ import android.content.pm.ApplicationInfo import android.content.pm.LauncherActivityInfo import android.content.pm.LauncherApps import android.content.pm.PackageManager +import android.graphics.BlendMode +import android.graphics.BlendModeColorFilter import android.graphics.ColorMatrix import android.graphics.ColorMatrixColorFilter +import android.graphics.PorterDuff +import android.graphics.PorterDuffColorFilter import android.graphics.Rect import android.graphics.drawable.Drawable import android.media.AudioManager @@ -26,11 +30,16 @@ import android.util.DisplayMetrics import android.util.Log import android.view.KeyEvent import android.view.View +import android.view.Window +import android.view.WindowManager import android.view.animation.AlphaAnimation import android.view.animation.Animation import android.view.inputmethod.InputMethodManager +import android.widget.Button import android.widget.ImageView +import android.widget.Switch import android.widget.Toast +import androidx.annotation.RequiresApi import de.jrpie.android.launcher.list.ListActivity import de.jrpie.android.launcher.list.apps.AppInfo import de.jrpie.android.launcher.list.apps.AppsRecyclerAdapter @@ -78,23 +87,19 @@ fun setDefaultHomeScreen(context: Context, checkDefault: Boolean = false) { if (checkDefault && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q - && context is Activity - ) { + && context is Activity) { val roleManager = context.getSystemService(RoleManager::class.java) - if (!roleManager.isRoleHeld(RoleManager.ROLE_HOME)) { - context.startActivityForResult( - roleManager.createRequestRoleIntent(RoleManager.ROLE_HOME), - REQUEST_SET_DEFAULT_HOME - ) + if(!roleManager.isRoleHeld(RoleManager.ROLE_HOME)) { + context.startActivityForResult(roleManager.createRequestRoleIntent(RoleManager.ROLE_HOME), REQUEST_SET_DEFAULT_HOME) } return } - if (checkDefault) { + if(checkDefault) { val testIntent = Intent(Intent.ACTION_MAIN) testIntent.addCategory(Intent.CATEGORY_HOME) val defaultHome = testIntent.resolveActivity(context.packageManager)?.packageName - if (defaultHome == context.packageName) { + if(defaultHome == context.packageName){ // Launcher is already the default home app return } @@ -111,8 +116,7 @@ fun isInstalled(uri: String, context: Context): Boolean { try { context.packageManager.getPackageInfo(uri, PackageManager.GET_ACTIVITIES) return true - } catch (_: PackageManager.NameNotFoundException) { - } + } catch (_: PackageManager.NameNotFoundException) { } return false } @@ -129,8 +133,9 @@ fun launch( ) { if (LauncherAction.isOtherAction(data)) { // [type]:[info] - LauncherAction.byId(data)?.let { it.launch(activity) } - } else launchApp(data, user, activity) // app + LauncherAction.byId(data)?.let {it.launch(activity) } + } + else launchApp(data, user, activity) // app activity.overridePendingTransition(animationIn, animationOut) } @@ -143,8 +148,7 @@ fun audioNextTrack(activity: Activity) { val eventTime: Long = SystemClock.uptimeMillis() - val downEvent = - KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT, 0) + val downEvent = KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT, 0) mAudioManager.dispatchMediaKeyEvent(downEvent) val upEvent = KeyEvent(eventTime, eventTime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_NEXT, 0) @@ -160,8 +164,7 @@ fun audioPreviousTrack(activity: Activity) { KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PREVIOUS, 0) mAudioManager.dispatchMediaKeyEvent(downEvent) - val upEvent = - KeyEvent(eventTime, eventTime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PREVIOUS, 0) + val upEvent = KeyEvent(eventTime, eventTime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PREVIOUS, 0) mAudioManager.dispatchMediaKeyEvent(upEvent) } @@ -196,11 +199,7 @@ fun expandNotificationsPanel(context: Context) { val showStatusBar = statusBarManager.getMethod("expandNotificationsPanel") showStatusBar.invoke(statusBarService) } catch (e: Exception) { - Toast.makeText( - context, - context.getString(R.string.alert_cant_expand_notifications_panel), - Toast.LENGTH_LONG - ).show() + Toast.makeText(context, context.getString(R.string.alert_cant_expand_notifications_panel), Toast.LENGTH_LONG).show() } } @@ -210,39 +209,32 @@ fun getUserFromId(user: Int?, context: Context): UserHandle? { val userManager = context.getSystemService(Service.USER_SERVICE) as UserManager return userManager.userProfiles.firstOrNull { it.hashCode() == user } } - -fun getLauncherActivityInfo( - packageName: String, - user: Int?, - context: Context -): LauncherActivityInfo? { +fun getLauncherActivityInfo(packageName: String, user: Int?, context: Context): LauncherActivityInfo? { val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps - return getUserFromId(user, context)?.let { userHandle -> - launcherApps.getActivityList(packageName, userHandle).firstOrNull() + return getUserFromId(user,context)?.let { + userHandle -> launcherApps.getActivityList(packageName, userHandle).firstOrNull() } } - fun uninstallApp(packageName: String, user: Int?, activity: Activity) { Log.i("Launcher", "uninstalling $packageName ($user)") val intent = Intent(Intent.ACTION_UNINSTALL_PACKAGE) intent.data = Uri.parse("package:$packageName") - getUserFromId(user, activity)?.let { user -> - intent.putExtra(Intent.EXTRA_USER, user) + getUserFromId(user, activity)?.let { + user -> intent.putExtra(Intent.EXTRA_USER, user) } intent.putExtra(Intent.EXTRA_RETURN_RESULT, true) - activity.startActivityForResult( - intent, + activity.startActivityForResult(intent, REQUEST_UNINSTALL ) } fun launchApp(packageName: String, user: Int?, context: Context, rect: Rect? = null) { - Log.i("Launcher", "Starting: " + packageName + " (user " + user.toString() + ")") - if (user != null) { + Log.i("Launcher", "Starting: " + packageName + " (user " +user.toString()+ ")") + if (user != null && user != INVALID_USER) { val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps - getLauncherActivityInfo(packageName, user, context)?.let { app -> - launcherApps.startMainActivity(app.componentName, app.user, rect, null) + getLauncherActivityInfo(packageName,user,context)?.let { + app -> launcherApps.startMainActivity(app.componentName, app.user, rect, null) return } } @@ -252,7 +244,7 @@ fun launchApp(packageName: String, user: Int?, context: Context, rect: Rect? = n if (intent != null) { context.startActivity(intent) } else { - if (isInstalled(packageName, context)) { + if (isInstalled(packageName, context)){ AlertDialog.Builder( context, @@ -260,8 +252,7 @@ fun launchApp(packageName: String, user: Int?, context: Context, rect: Rect? = n ) .setTitle(context.getString(R.string.alert_cant_open_title)) .setMessage(context.getString(R.string.alert_cant_open_message)) - .setPositiveButton( - android.R.string.ok + .setPositiveButton(android.R.string.ok ) { _, _ -> openAppSettings( packageName, @@ -292,16 +283,10 @@ fun openNewTabWindow(urls: String, context: Context) { } -fun openAppSettings( - packageName: String, - user: Int?, - context: Context, - sourceBounds: Rect? = null, - opts: Bundle? = null -) { +fun openAppSettings(packageName: String, user: Int?, context: Context, sourceBounds: Rect? = null, opts: Bundle? = null) { val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps - getLauncherActivityInfo(packageName, user, context)?.let { app -> - launcherApps.startAppDetailsActivity(app.componentName, app.user, sourceBounds, opts) + getLauncherActivityInfo(packageName, user, context)?.let { + app -> launcherApps.startAppDetailsActivity(app.componentName, app.user, sourceBounds, opts) } } @@ -309,11 +294,11 @@ fun openSettings(activity: Activity) { activity.startActivity(Intent(activity, SettingsActivity::class.java)) } -fun openTutorial(activity: Activity) { +fun openTutorial(activity: Activity){ activity.startActivity(Intent(activity, TutorialActivity::class.java)) } -fun openAppsList(activity: Activity) { +fun openAppsList(activity: Activity){ val intent = Intent(activity, ListActivity::class.java) intent.putExtra("intention", ListActivity.ListActivityIntention.VIEW.toString()) activity.startActivity(intent) @@ -322,9 +307,9 @@ fun openAppsList(activity: Activity) { fun getAppIcon(context: Context, packageName: String, user: Int?): Drawable { if (user != null) { val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps - getUserFromId(user, context)?.let { userHandle -> - launcherApps.getActivityList(packageName, userHandle).firstOrNull()?.let { app -> - return app.getBadgedIcon(0) + getUserFromId(user,context)?.let { + userHandle -> launcherApps.getActivityList(packageName, userHandle).firstOrNull()?.let { + app -> return app.getBadgedIcon(0) } } } @@ -343,22 +328,21 @@ fun loadApps(packageManager: PackageManager, context: Context) { // TODO: shortcuts - launcherApps.getShortcuts() val users = userManager.userProfiles - for (user in users) { - for (activityInfo in launcherApps.getActivityList(null, user)) { + for(user in users) { + for (activityInfo in launcherApps.getActivityList(null,user)) { val app = AppInfo() app.label = activityInfo.label app.packageName = activityInfo.applicationInfo.packageName app.icon = activityInfo.getBadgedIcon(0) app.user = user.hashCode() - app.isSystemApp = - activityInfo.applicationInfo.flags.and(ApplicationInfo.FLAG_SYSTEM) != 0 + app.isSystemApp = activityInfo.applicationInfo.flags.and(ApplicationInfo.FLAG_SYSTEM) != 0 loadList.add(app) } } // fallback option - if (loadList.isEmpty()) { + if(loadList.isEmpty()){ Log.i("Launcher", "using fallback option to load packages") val i = Intent(Intent.ACTION_MAIN, null) i.addCategory(Intent.CATEGORY_LAUNCHER) @@ -380,8 +364,8 @@ fun loadApps(packageManager: PackageManager, context: Context) { // Used in Tutorial and Settings `ActivityOnResult` fun saveListActivityChoice(context: Context, data: Intent?) { val value = data?.getStringExtra("value") - var user = data?.getIntExtra("user", INVALID_USER) - user = user?.let { if (it == INVALID_USER) null else it } + var user = data?.getIntExtra("user", INVALID_USER) + user = user?.let{ if(it == INVALID_USER) null else it } val forGesture = data?.getStringExtra("forGesture") ?: return @@ -397,7 +381,7 @@ fun openSoftKeyboard(context: Context, view: View) { } // Taken from: https://stackoverflow.com/a/30340794/12787264 -fun transformGrayscale(imageView: ImageView) { +fun transformGrayscale(imageView: ImageView){ val matrix = ColorMatrix() matrix.setSaturation(0f) diff --git a/app/src/main/java/de/jrpie/android/launcher/Gesture.kt b/app/src/main/java/de/jrpie/android/launcher/Gesture.kt index 7fcd95b..9d9f9b0 100644 --- a/app/src/main/java/de/jrpie/android/launcher/Gesture.kt +++ b/app/src/main/java/de/jrpie/android/launcher/Gesture.kt @@ -2,6 +2,7 @@ package de.jrpie.android.launcher import android.app.Activity import android.content.Context +import android.util.Log import de.jrpie.android.launcher.preferences.LauncherPreferences /** @@ -11,160 +12,59 @@ import de.jrpie.android.launcher.preferences.LauncherPreferences * @param animationIn res id of transition animation (in) when using the gesture to launch an app. * @param animationOut res id of transition animation (out) when using the gesture to launch an app. */ -enum class Gesture( - val id: String, private val labelResource: Int, - private val defaultsResource: Int, - private val animationIn: Int = android.R.anim.fade_in, - private val animationOut: Int = android.R.anim.fade_out -) { - VOLUME_UP( - "action_volumeUpApp", - R.string.settings_gesture_vol_up, - R.array.default_volume_up, - 0, - 0 - ), - VOLUME_DOWN( - "action_volumeDownApp", - R.string.settings_gesture_vol_down, - R.array.default_volume_down, - 0, - 0 - ), - TIME("action_timeApp", R.string.settings_gesture_time, R.array.default_time), - DATE("action_dateApp", R.string.settings_gesture_date, R.array.default_date), - LONG_CLICK( - "action_longClickApp", - R.string.settings_gesture_long_click, - R.array.default_long_click, - 0, - 0 - ), - DOUBLE_CLICK( - "action_doubleClickApp", - R.string.settings_gesture_double_click, - R.array.default_double_click, - 0, - 0 - ), - SWIPE_UP("action_upApp", R.string.settings_gesture_up, R.array.default_up, R.anim.bottom_up), - SWIPE_UP_LEFT_EDGE( - "action_up_leftApp", - R.string.settings_gesture_up_left_edge, - R.array.default_up_left, - R.anim.bottom_up - ), - SWIPE_UP_RIGHT_EDGE( - "action_up_rightApp", - R.string.settings_gesture_up_right_edge, - R.array.default_up_right, - R.anim.bottom_up - ), - SWIPE_UP_DOUBLE( - "action_doubleUpApp", - R.string.settings_gesture_double_up, - R.array.default_double_up, - R.anim.bottom_up - ), - SWIPE_DOWN( - "action_downApp", - R.string.settings_gesture_down, - R.array.default_down, - R.anim.top_down - ), - SWIPE_DOWN_LEFT_EDGE( - "action_down_leftApp", - R.string.settings_gesture_down_left_edge, - R.array.default_down_left, - R.anim.top_down - ), - SWIPE_DOWN_RIGHT_EDGE( - "action_down_rightApp", - R.string.settings_gesture_down_right_edge, - R.array.default_down_right, - R.anim.top_down - ), - SWIPE_DOWN_DOUBLE( - "action_doubleDownApp", - R.string.settings_gesture_double_down, - R.array.default_double_down, - R.anim.top_down - ), - SWIPE_LEFT( - "action_leftApp", - R.string.settings_gesture_left, - R.array.default_left, - R.anim.right_left - ), - SWIPE_LEFT_TOP_EDGE( - "action_left_topApp", - R.string.settings_gesture_left_top_edge, - R.array.default_left_top, - R.anim.right_left - ), - SWIPE_LEFT_BOTTOM_EDGE( - "action_left_bottomApp", - R.string.settings_gesture_left_bottom_edge, - R.array.default_left_bottom, - R.anim.right_left - ), - SWIPE_LEFT_DOUBLE( - "action_doubleLeftApp", - R.string.settings_gesture_double_left, - R.array.default_double_left, - R.anim.right_left - ), - SWIPE_RIGHT( - "action_rightApp", - R.string.settings_gesture_right, - R.array.default_right, - R.anim.left_right - ), - SWIPE_RIGHT_TOP_EDGE( - "action_right_topApp", - R.string.settings_gesture_right_top_edge, - R.array.default_right_top, - R.anim.left_right - ), - SWIPE_RIGHT_BOTTOM_EDGE( - "action_right_bottomApp", - R.string.settings_gesture_right_bottom_edge, - R.array.default_right_bottom, - R.anim.left_right - ), - SWIPE_RIGHT_DOUBLE( - "action_doubleRightApp", - R.string.settings_gesture_double_right, - R.array.default_double_right, - R.anim.left_right - ); +enum class Gesture (val id: String, private val labelResource: Int, + private val defaultsResource: Int, + private val animationIn: Int = android.R.anim.fade_in, + private val animationOut: Int = android.R.anim.fade_out){ + VOLUME_UP("action.volume_up", R.string.settings_gesture_vol_up, R.array.default_volume_up, 0,0), + VOLUME_DOWN("action.volume_down", R.string.settings_gesture_vol_down, R.array.default_volume_down,0,0), + TIME("action.time", R.string.settings_gesture_time, R.array.default_time), + DATE("action.date", R.string.settings_gesture_date, R.array.default_date), + LONG_CLICK("action.long_click", R.string.settings_gesture_long_click, R.array.default_long_click, 0,0), + DOUBLE_CLICK("action.double_click", R.string.settings_gesture_double_click, R.array.default_double_click,0,0), + SWIPE_UP("action.up", R.string.settings_gesture_up, R.array.default_up, R.anim.bottom_up), + SWIPE_UP_LEFT_EDGE("action.up_left", R.string.settings_gesture_up_left_edge, R.array.default_up_left, R.anim.bottom_up), + SWIPE_UP_RIGHT_EDGE("action.up_right", R.string.settings_gesture_up_right_edge, R.array.default_up_right, R.anim.bottom_up), + SWIPE_UP_DOUBLE( "action.double_up", R.string.settings_gesture_double_up, R.array.default_double_up, R.anim.bottom_up), + SWIPE_DOWN("action.down", R.string.settings_gesture_down, R.array.default_down, R.anim.top_down), + SWIPE_DOWN_LEFT_EDGE("action.down_left", R.string.settings_gesture_down_left_edge, R.array.default_down_left, R.anim.top_down), + SWIPE_DOWN_RIGHT_EDGE("action.down_right", R.string.settings_gesture_down_right_edge, R.array.default_down_right, R.anim.top_down), + SWIPE_DOWN_DOUBLE("action.double_down", R.string.settings_gesture_double_down, R.array.default_double_down, R.anim.top_down), + SWIPE_LEFT("action.left", R.string.settings_gesture_left, R.array.default_left, R.anim.right_left), + SWIPE_LEFT_TOP_EDGE("action.left_top", R.string.settings_gesture_left_top_edge, R.array.default_left_top, R.anim.right_left), + SWIPE_LEFT_BOTTOM_EDGE("action.left_bottom", R.string.settings_gesture_left_bottom_edge, R.array.default_left_bottom, R.anim.right_left), + SWIPE_LEFT_DOUBLE("action.double_left", R.string.settings_gesture_double_left, R.array.default_double_left, R.anim.right_left), + SWIPE_RIGHT("action.right", R.string.settings_gesture_right, R.array.default_right, R.anim.left_right), + SWIPE_RIGHT_TOP_EDGE("action.right_top", R.string.settings_gesture_right_top_edge, R.array.default_right_top, R.anim.left_right), + SWIPE_RIGHT_BOTTOM_EDGE("action.right_bottom", R.string.settings_gesture_right_bottom_edge, R.array.default_right_bottom, R.anim.left_right), + SWIPE_RIGHT_DOUBLE("action.double_right", R.string.settings_gesture_double_right, R.array.default_double_right, R.anim.left_right); - enum class Edge { - TOP, BOTTOM, LEFT, RIGHT + enum class Edge{ + TOP, BOTTOM, LEFT, RIGHT } fun getApp(context: Context): Pair { val preferences = LauncherPreferences.getSharedPreferences() - var packageName = preferences.getString(this.id, "")!! - var u: Int? = preferences.getInt(this.id + "_user", INVALID_USER) - u = if (u == INVALID_USER) null else u - return Pair(packageName, u) + var packageName = preferences.getString(this.id + ".app", "")!! + var u: Int? = preferences.getInt(this.id + ".user", INVALID_USER) + u = if(u == INVALID_USER) null else u + return Pair(packageName,u) } fun removeApp(context: Context) { LauncherPreferences.getSharedPreferences().edit() - .putString(this.id, "") // clear it + .putString(this.id + ".app", "") // clear it .apply() } fun setApp(context: Context, app: String, user: Int?) { LauncherPreferences.getSharedPreferences().edit() - .putString(this.id, app) + .putString(this.id + ".app", app) .apply() - val u = user ?: INVALID_USER + val u = user?: INVALID_USER LauncherPreferences.getSharedPreferences().edit() - .putInt(this.id + "_user", u) + .putInt(this.id + ".user", u) .apply() } @@ -172,7 +72,7 @@ enum class Gesture( return context.resources.getString(this.labelResource) } - fun pickDefaultApp(context: Context): String { + fun pickDefaultApp(context: Context) : String { return context.resources .getStringArray(this.defaultsResource) .firstOrNull { isInstalled(it, context) } @@ -180,7 +80,7 @@ enum class Gesture( } fun getDoubleVariant(): Gesture { - return when (this) { + return when(this) { SWIPE_UP -> SWIPE_UP_DOUBLE SWIPE_DOWN -> SWIPE_DOWN_DOUBLE SWIPE_LEFT -> SWIPE_LEFT_DOUBLE @@ -190,30 +90,27 @@ enum class Gesture( } fun getEdgeVariant(edge: Edge): Gesture { - return when (edge) { + return when(edge) { Edge.TOP -> - when (this) { + when(this) { SWIPE_LEFT -> SWIPE_LEFT_TOP_EDGE SWIPE_RIGHT -> SWIPE_RIGHT_TOP_EDGE else -> this } - Edge.BOTTOM -> - when (this) { + when(this) { SWIPE_LEFT -> SWIPE_LEFT_BOTTOM_EDGE SWIPE_RIGHT -> SWIPE_RIGHT_BOTTOM_EDGE else -> this } - Edge.LEFT -> - when (this) { + when(this) { SWIPE_UP -> SWIPE_UP_LEFT_EDGE SWIPE_DOWN -> SWIPE_DOWN_LEFT_EDGE else -> this } - Edge.RIGHT -> - when (this) { + when(this) { SWIPE_UP -> SWIPE_UP_RIGHT_EDGE SWIPE_DOWN -> SWIPE_DOWN_RIGHT_EDGE else -> this @@ -222,39 +119,38 @@ enum class Gesture( } fun isDoubleVariant(): Boolean { - return when (this) { + return when(this){ SWIPE_UP_DOUBLE, SWIPE_DOWN_DOUBLE, SWIPE_LEFT_DOUBLE, SWIPE_RIGHT_DOUBLE -> true - else -> false } } fun isEdgeVariant(): Boolean { - return when (this) { + return when(this){ SWIPE_UP_RIGHT_EDGE, - SWIPE_UP_LEFT_EDGE, - SWIPE_DOWN_LEFT_EDGE, - SWIPE_DOWN_RIGHT_EDGE, - SWIPE_LEFT_TOP_EDGE, - SWIPE_LEFT_BOTTOM_EDGE, - SWIPE_RIGHT_TOP_EDGE, - SWIPE_RIGHT_BOTTOM_EDGE -> true - + SWIPE_UP_LEFT_EDGE, + SWIPE_DOWN_LEFT_EDGE, + SWIPE_DOWN_RIGHT_EDGE, + SWIPE_LEFT_TOP_EDGE, + SWIPE_LEFT_BOTTOM_EDGE, + SWIPE_RIGHT_TOP_EDGE, + SWIPE_RIGHT_BOTTOM_EDGE -> true else -> false } } operator fun invoke(activity: Activity) { val app = this.getApp(activity) + Log.d("LAUNCHER", "Launching ${app.first} (user: ${app.second}) ${this.toString()}") launch(app.first, app.second, activity, this.animationIn, this.animationOut) } companion object { fun byId(id: String): Gesture? { - return Gesture.values().firstOrNull { it.id == id } + return Gesture.values().firstOrNull {it.id == id } } } diff --git a/app/src/main/java/de/jrpie/android/launcher/HomeActivity.kt b/app/src/main/java/de/jrpie/android/launcher/HomeActivity.kt index 5f4c157..9e6f568 100644 --- a/app/src/main/java/de/jrpie/android/launcher/HomeActivity.kt +++ b/app/src/main/java/de/jrpie/android/launcher/HomeActivity.kt @@ -4,6 +4,7 @@ import android.content.Intent import android.content.res.Resources import android.os.AsyncTask import android.os.Bundle +import android.util.Log import android.view.GestureDetector import android.view.KeyEvent import android.view.MotionEvent @@ -13,7 +14,6 @@ import androidx.core.view.isVisible import de.jrpie.android.launcher.databinding.HomeBinding import de.jrpie.android.launcher.list.other.LauncherAction import de.jrpie.android.launcher.preferences.LauncherPreferences -import de.jrpie.android.launcher.preferences.migrateToNewVersion import de.jrpie.android.launcher.tutorial.TutorialActivity import java.text.SimpleDateFormat import java.util.* @@ -21,6 +21,9 @@ import kotlin.concurrent.fixedRateTimer import kotlin.math.abs import kotlin.math.max import kotlin.math.min +import android.util.DisplayMetrics +import de.jrpie.android.launcher.preferences.migratePreferencesToNewVersion +import de.jrpie.android.launcher.preferences.resetPreferences /** @@ -35,7 +38,7 @@ import kotlin.math.min * - Setting global variables (preferences etc.) * - Opening the [TutorialActivity] on new installations */ -class HomeActivity : UIObject, AppCompatActivity(), +class HomeActivity: UIObject, AppCompatActivity(), GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener { private lateinit var binding: HomeBinding @@ -52,14 +55,15 @@ class HomeActivity : UIObject, AppCompatActivity(), override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) + // Try to restore old preferences + migratePreferencesToNewVersion(this) - // First time opening the app: show Tutorial, else: check versions + // First time opening the app: set defaults and start tutorial if (!LauncherPreferences.internal().started()) { + resetPreferences(this) LauncherPreferences.internal().started(true) startActivity(Intent(this, TutorialActivity::class.java)) - } else { - migrateToNewVersion(this) } // Preload apps to speed up the Apps Recycler @@ -70,7 +74,7 @@ class HomeActivity : UIObject, AppCompatActivity(), setContentView(binding.root) } - override fun onStart() { + override fun onStart(){ super.onStart() mDetector = GestureDetectorCompat(this, this) @@ -97,7 +101,7 @@ class HomeActivity : UIObject, AppCompatActivity(), var upperVisible = dateVisible var lowerVisible = timeVisible - if (LauncherPreferences.clock().flipDateTime()) { + if(LauncherPreferences.clock().flipDateTime()) { upperFormat = lowerFormat.also { lowerFormat = upperFormat } upperVisible = lowerVisible.also { lowerVisible = upperVisible } } @@ -151,8 +155,15 @@ class HomeActivity : UIObject, AppCompatActivity(), if (e1 == null) return false - val width = displayMetrics.widthPixels - val height = displayMetrics.heightPixels + + + val displayMetrics: DisplayMetrics? = DisplayMetrics() + windowManager.defaultDisplay.getMetrics(displayMetrics) + + val width = displayMetrics!!.widthPixels + val height = displayMetrics!!.heightPixels + + Log.i("LAUNCHER", "width: $width, height: $height, ${e1.x}, ${e1.y}, ${e2.x}, ${e2.y}") val diffX = e1.x - e2.x val diffY = e1.y - e2.y @@ -161,7 +172,7 @@ class HomeActivity : UIObject, AppCompatActivity(), val edgeActions = LauncherPreferences.enabled_gestures().edgeSwipe() val edgeStrictness = 0.15 - var gesture = if (abs(diffX) > abs(diffY)) { // horizontal swipe + var gesture = if(abs(diffX) > abs(diffY)) { // horizontal swipe if (diffX > width / 4) Gesture.SWIPE_LEFT else if (diffX < -width / 4) @@ -181,16 +192,16 @@ class HomeActivity : UIObject, AppCompatActivity(), } if (edgeActions) { - if (max(e1.x, e2.x) < edgeStrictness * width) { - gesture = gesture?.let { it.getEdgeVariant(Gesture.Edge.LEFT) } - } else if (min(e1.x, e2.x) > (1 - edgeStrictness) * width) { - gesture = gesture?.let { it.getEdgeVariant(Gesture.Edge.RIGHT) } + if(max(e1.x, e2.x) < edgeStrictness * width){ + gesture = gesture?.let{it.getEdgeVariant(Gesture.Edge.LEFT)} + } else if (min(e1.x, e2.x) > (1-edgeStrictness) * width){ + gesture = gesture?.let{it.getEdgeVariant(Gesture.Edge.RIGHT)} } - if (max(e1.y, e2.y) < edgeStrictness * height) { - gesture = gesture?.let { it.getEdgeVariant(Gesture.Edge.TOP) } - } else if (min(e1.y, e2.y) > (1 - edgeStrictness) * height) { - gesture = gesture?.let { it.getEdgeVariant(Gesture.Edge.BOTTOM) } + if(max(e1.y, e2.y) < edgeStrictness * height){ + gesture = gesture?.let{it.getEdgeVariant(Gesture.Edge.TOP)} + } else if (min(e1.y, e2.y) > (1-edgeStrictness) * height){ + gesture = gesture?.let{it.getEdgeVariant(Gesture.Edge.BOTTOM)} } } gesture?.invoke(this) @@ -224,17 +235,13 @@ class HomeActivity : UIObject, AppCompatActivity(), } } - return if (mDetector.onTouchEvent(event)) { - false - } else { - super.onTouchEvent(event) - } + return if (mDetector.onTouchEvent(event)) { false } else { super.onTouchEvent(event) } } override fun setOnClicks() { binding.homeUpperView.setOnClickListener { - if (LauncherPreferences.clock().flipDateTime()) { + if(LauncherPreferences.clock().flipDateTime()) { Gesture.TIME(this) } else { Gesture.DATE(this) @@ -242,7 +249,7 @@ class HomeActivity : UIObject, AppCompatActivity(), } binding.homeLowerView.setOnClickListener { - if (LauncherPreferences.clock().flipDateTime()) { + if(LauncherPreferences.clock().flipDateTime()) { Gesture.DATE(this) } else { Gesture.TIME(this) @@ -252,22 +259,11 @@ class HomeActivity : UIObject, AppCompatActivity(), /* TODO: Remove those. For now they are necessary * because this inherits from GestureDetector.OnGestureListener */ - override fun onDoubleTapEvent(event: MotionEvent): Boolean { - return false - } - - override fun onDown(event: MotionEvent): Boolean { - return false - } - - override fun onScroll(e1: MotionEvent?, e2: MotionEvent, dX: Float, dY: Float): Boolean { - return false - } - + override fun onDoubleTapEvent(event: MotionEvent): Boolean { return false } + override fun onDown(event: MotionEvent): Boolean { return false } + override fun onScroll(e1: MotionEvent?, e2: MotionEvent, dX: Float, dY: Float): Boolean { return false } override fun onShowPress(event: MotionEvent) {} - override fun onSingleTapUp(event: MotionEvent): Boolean { - return false - } + override fun onSingleTapUp(event: MotionEvent): Boolean { return false } override fun isHomeScreen(): Boolean { return true diff --git a/app/src/main/java/de/jrpie/android/launcher/UIObject.kt b/app/src/main/java/de/jrpie/android/launcher/UIObject.kt index bc55345..7bf0fd7 100644 --- a/app/src/main/java/de/jrpie/android/launcher/UIObject.kt +++ b/app/src/main/java/de/jrpie/android/launcher/UIObject.kt @@ -2,6 +2,7 @@ package de.jrpie.android.launcher import android.app.Activity import android.content.res.Resources +import android.os.Build import android.view.Window import android.view.WindowManager import de.jrpie.android.launcher.preferences.LauncherPreferences @@ -42,7 +43,6 @@ interface UIObject { setOnClicks() adjustLayout() } - fun modifyTheme(theme: Resources.Theme): Resources.Theme { LauncherPreferences.theme().colorTheme().applyToTheme(theme) LauncherPreferences.theme().background().applyToTheme(theme) @@ -52,8 +52,8 @@ interface UIObject { } // fun applyTheme() { } - fun setOnClicks() {} - fun adjustLayout() {} + fun setOnClicks() { } + fun adjustLayout() { } fun isHomeScreen(): Boolean { return false diff --git a/app/src/main/java/de/jrpie/android/launcher/list/ListActivity.kt b/app/src/main/java/de/jrpie/android/launcher/list/ListActivity.kt index f3d58df..1bc304e 100644 --- a/app/src/main/java/de/jrpie/android/launcher/list/ListActivity.kt +++ b/app/src/main/java/de/jrpie/android/launcher/list/ListActivity.kt @@ -44,7 +44,6 @@ class ListActivity : AppCompatActivity(), UIObject { VIEW(R.string.list_title_view), /* view list of apps */ PICK(R.string.list_title_pick) /* choose app or action to associate to a gesture */ } - override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -67,8 +66,7 @@ class ListActivity : AppCompatActivity(), UIObject { binding.listContainer.context.resources.displayMetrics.heightPixels val diff = height - r.bottom if (diff != 0 && - LauncherPreferences.display().fullScreen() - ) { + LauncherPreferences.display().fullScreen()) { if (binding.listContainer.paddingBottom !== diff) { binding.listContainer.setPadding(0, 0, 0, diff) } @@ -82,7 +80,7 @@ class ListActivity : AppCompatActivity(), UIObject { } - override fun onStart() { + override fun onStart(){ super.onStart() super.onStart() } @@ -148,11 +146,11 @@ private val TAB_TITLES = arrayOf( * The [ListSectionsPagerAdapter] returns the fragment, * which corresponds to the selected tab in [ListActivity]. */ -class ListSectionsPagerAdapter(private val context: Context, fm: FragmentManager) : - FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { +class ListSectionsPagerAdapter(private val context: Context, fm: FragmentManager) + : FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { override fun getItem(position: Int): Fragment { - return when (position) { + return when (position){ 0 -> ListFragmentApps() 1 -> ListFragmentOther() else -> Fragment() diff --git a/app/src/main/java/de/jrpie/android/launcher/list/apps/AppsRecyclerAdapter.kt b/app/src/main/java/de/jrpie/android/launcher/list/apps/AppsRecyclerAdapter.kt index 1fb5c31..86fdb6f 100644 --- a/app/src/main/java/de/jrpie/android/launcher/list/apps/AppsRecyclerAdapter.kt +++ b/app/src/main/java/de/jrpie/android/launcher/list/apps/AppsRecyclerAdapter.kt @@ -34,12 +34,10 @@ import kotlin.text.Regex.Companion.escapeReplacement * @param intention - why the list is displayed ("view", "pick") * @param forGesture - the action which an app is chosen for (when the intention is "pick") */ -class AppsRecyclerAdapter( - val activity: Activity, - private val intention: ListActivity.ListActivityIntention - = ListActivity.ListActivityIntention.VIEW, - private val forGesture: String? = "" -) : +class AppsRecyclerAdapter(val activity: Activity, + private val intention: ListActivity.ListActivityIntention + = ListActivity.ListActivityIntention.VIEW, + private val forGesture: String? = ""): RecyclerView.Adapter() { private val appsListDisplayed: MutableList @@ -55,9 +53,7 @@ class AppsRecyclerAdapter( selectItem(adapterPosition, rect) } - init { - itemView.setOnClickListener(this) - } + init { itemView.setOnClickListener(this) } } override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) { @@ -76,35 +72,16 @@ class AppsRecyclerAdapter( // decide when to show the options popup menu about if (intention == ListActivity.ListActivityIntention.VIEW) { - viewHolder.textView.setOnLongClickListener { - showOptionsPopup( - viewHolder, - appPackageName, - appUser, - isSystemApp - ) - } - viewHolder.img.setOnLongClickListener { - showOptionsPopup( - viewHolder, - appPackageName, - appUser, - isSystemApp - ) - } + viewHolder.textView.setOnLongClickListener{ showOptionsPopup(viewHolder, appPackageName, appUser, isSystemApp) } + viewHolder.img.setOnLongClickListener{ showOptionsPopup(viewHolder, appPackageName, appUser, isSystemApp) } // ensure onClicks are actually caught - viewHolder.textView.setOnClickListener { viewHolder.onClick(viewHolder.textView) } - viewHolder.img.setOnClickListener { viewHolder.onClick(viewHolder.img) } + viewHolder.textView.setOnClickListener{ viewHolder.onClick(viewHolder.textView) } + viewHolder.img.setOnClickListener{ viewHolder.onClick(viewHolder.img) } } } @Suppress("SameReturnValue") - private fun showOptionsPopup( - viewHolder: ViewHolder, - appPackageName: String, - user: Int?, - isSystemApp: Boolean - ): Boolean { + private fun showOptionsPopup(viewHolder: ViewHolder, appPackageName: String, user: Int?, isSystemApp: Boolean): Boolean { //create the popup menu val popup = PopupMenu(activity, viewHolder.img) @@ -120,12 +97,10 @@ class AppsRecyclerAdapter( uninstallApp(appPackageName, user, activity) true } - R.id.app_menu_info -> { openAppSettings(appPackageName, user, activity) true } - else -> false } } @@ -134,9 +109,7 @@ class AppsRecyclerAdapter( return true } - override fun getItemCount(): Int { - return appsListDisplayed.size - } + override fun getItemCount(): Int { return appsListDisplayed.size } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val inflater = LayoutInflater.from(parent.context) @@ -158,20 +131,19 @@ class AppsRecyclerAdapter( } fun selectItem(pos: Int, rect: Rect = Rect()) { - if (pos >= appsListDisplayed.size) { + if(pos >= appsListDisplayed.size) { return } val appPackageName = appsListDisplayed[pos].packageName.toString() val appUser = appsListDisplayed[pos].user - when (intention) { + when (intention){ ListActivity.ListActivityIntention.VIEW -> { launchApp(appPackageName, appUser, activity, rect) } - ListActivity.ListActivityIntention.PICK -> { val returnIntent = Intent() returnIntent.putExtra("value", appPackageName) - appUser?.let { returnIntent.putExtra("user", it) } + appUser?.let{ returnIntent.putExtra("user", it) } returnIntent.putExtra("forGesture", forGesture) activity.setResult(REQUEST_CHOOSE_APP, returnIntent) activity.finish() @@ -188,12 +160,12 @@ class AppsRecyclerAdapter( .lowercase(Locale.ROOT) .toCharArray() .distinct() - .filter { c -> !((c in 'a'..'z') || (c in '0'..'9')) } - .map { c -> escapeReplacement(c.toString()) } - .fold("") { x, y -> x + y } + .filter { c -> ! ((c in 'a'..'z') || (c in '0'..'9')) } + .map { c -> escapeReplacement(c.toString())} + .fold("") { x,y -> x+y } var disallowedCharsRegex = "[^a-z0-9$allowedSpecialCharacters]".toRegex() - fun normalize(text: String): String { + fun normalize(text: String): String{ return text.lowercase(Locale.ROOT).replace(disallowedCharsRegex, "") } appsListDisplayed.clear() @@ -207,7 +179,7 @@ class AppsRecyclerAdapter( if (itemLabel.startsWith(normalizedText)) { appsListDisplayed.add(item) - } else if (itemLabel.contains(normalizedText)) { + }else if(itemLabel.contains(normalizedText)){ appsSecondary.add(item) } } @@ -215,13 +187,11 @@ class AppsRecyclerAdapter( } if (appsListDisplayed.size == 1 && intention == ListActivity.ListActivityIntention.VIEW - && LauncherPreferences.functionality().searchAutoLaunch() - ) { + && LauncherPreferences.functionality().searchAutoLaunch()) { val info = appsListDisplayed[0] launch(info.packageName.toString(), info.user, activity) - val inputMethodManager = - activity.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager + val inputMethodManager = activity.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager inputMethodManager.hideSoftInputFromWindow(View(activity).windowToken, 0) } diff --git a/app/src/main/java/de/jrpie/android/launcher/list/apps/ListFragmentApps.kt b/app/src/main/java/de/jrpie/android/launcher/list/apps/ListFragmentApps.kt index 2a13c2e..72f3f48 100644 --- a/app/src/main/java/de/jrpie/android/launcher/list/apps/ListFragmentApps.kt +++ b/app/src/main/java/de/jrpie/android/launcher/list/apps/ListFragmentApps.kt @@ -36,7 +36,7 @@ class ListFragmentApps : Fragment(), UIObject { super.onStart() } - override fun setOnClicks() {} + override fun setOnClicks() { } override fun adjustLayout() { @@ -66,8 +66,7 @@ class ListFragmentApps : Fragment(), UIObject { }) if (intention == ListActivity.ListActivityIntention.VIEW - && LauncherPreferences.functionality().searchAutoOpenKeyboard() - ) { + && LauncherPreferences.functionality().searchAutoOpenKeyboard()){ openSoftKeyboard(requireContext(), binding.listAppsSearchview) } } diff --git a/app/src/main/java/de/jrpie/android/launcher/list/other/LauncherAction.kt b/app/src/main/java/de/jrpie/android/launcher/list/other/LauncherAction.kt index 54daceb..b1137f3 100644 --- a/app/src/main/java/de/jrpie/android/launcher/list/other/LauncherAction.kt +++ b/app/src/main/java/de/jrpie/android/launcher/list/other/LauncherAction.kt @@ -10,50 +10,25 @@ import de.jrpie.android.launcher.expandNotificationsPanel import de.jrpie.android.launcher.openAppsList import de.jrpie.android.launcher.openSettings -enum class LauncherAction( - val id: String, - val label: Int, - val icon: Int, - val launch: (Activity) -> Unit -) { - SETTINGS( - "launcher:settings", - R.string.list_other_settings, - R.drawable.baseline_settings_24, - ::openSettings - ), - CHOOSE( - "launcher:choose", - R.string.list_other_list, - R.drawable.baseline_menu_24, - ::openAppsList - ), - VOLUME_UP( - "launcher:volumeUp", +enum class LauncherAction(val id: String, val label: Int, val icon: Int, val launch: (Activity) -> Unit) { + SETTINGS("launcher:settings", R.string.list_other_settings, R.drawable.baseline_settings_24, ::openSettings), + CHOOSE("launcher:choose", R.string.list_other_list, R.drawable.baseline_menu_24, ::openAppsList), + VOLUME_UP("launcher:volumeUp", R.string.list_other_volume_up, - R.drawable.baseline_volume_up_24, ::audioVolumeUp - ), - VOLUME_DOWN( - "launcher:volumeDown", + R.drawable.baseline_volume_up_24, ::audioVolumeUp), + VOLUME_DOWN("launcher:volumeDown", R.string.list_other_volume_down, - R.drawable.baseline_volume_down_24, ::audioVolumeDown - ), - TRACK_NEXT( - "launcher:nextTrack", + R.drawable.baseline_volume_down_24, ::audioVolumeDown), + TRACK_NEXT("launcher:nextTrack", R.string.list_other_track_next, - R.drawable.baseline_skip_next_24, ::audioNextTrack - ), - TRACK_PREV( - "launcher:previousTrack", + R.drawable.baseline_skip_next_24, ::audioNextTrack), + TRACK_PREV("launcher:previousTrack", R.string.list_other_track_previous, - R.drawable.baseline_skip_previous_24, ::audioPreviousTrack - ), - EXPAND_NOTIFICATIONS_PANEL( - "launcher:expandNotificationsPanel", + R.drawable.baseline_skip_previous_24, ::audioPreviousTrack), + EXPAND_NOTIFICATIONS_PANEL("launcher:expandNotificationsPanel", R.string.list_other_expand_notifications_panel, R.drawable.baseline_notifications_24, - ::expandNotificationsPanel - ), + ::expandNotificationsPanel), NOP("launcher:nop", R.string.list_other_nop, R.drawable.baseline_not_interested_24, {}); companion object { diff --git a/app/src/main/java/de/jrpie/android/launcher/list/other/ListFragmentOther.kt b/app/src/main/java/de/jrpie/android/launcher/list/other/ListFragmentOther.kt index b1cd93f..2c73aea 100644 --- a/app/src/main/java/de/jrpie/android/launcher/list/other/ListFragmentOther.kt +++ b/app/src/main/java/de/jrpie/android/launcher/list/other/ListFragmentOther.kt @@ -6,6 +6,7 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager +import de.jrpie.android.launcher.R import de.jrpie.android.launcher.databinding.ListOtherBinding /** diff --git a/app/src/main/java/de/jrpie/android/launcher/list/other/OtherRecyclerAdapter.kt b/app/src/main/java/de/jrpie/android/launcher/list/other/OtherRecyclerAdapter.kt index e9bee8d..0b54fa6 100644 --- a/app/src/main/java/de/jrpie/android/launcher/list/other/OtherRecyclerAdapter.kt +++ b/app/src/main/java/de/jrpie/android/launcher/list/other/OtherRecyclerAdapter.kt @@ -20,7 +20,7 @@ import de.jrpie.android.launcher.list.forGesture * It lists `other` things to be launched that are not really represented by a URI, * rather by Launcher- internal conventions. */ -class OtherRecyclerAdapter(val activity: Activity) : +class OtherRecyclerAdapter(val activity: Activity): RecyclerView.Adapter() { private val othersList: Array = LauncherAction.values() @@ -38,9 +38,7 @@ class OtherRecyclerAdapter(val activity: Activity) : forGesture?.let { returnChoiceIntent(it, content.id) } } - init { - itemView.setOnClickListener(this) - } + init { itemView.setOnClickListener(this) } } override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) { @@ -51,9 +49,7 @@ class OtherRecyclerAdapter(val activity: Activity) : viewHolder.iconView.setImageResource(icon) } - override fun getItemCount(): Int { - return othersList.size - } + override fun getItemCount(): Int { return othersList.size } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val inflater = LayoutInflater.from(parent.context) diff --git a/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java b/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java index c224b84..10c4b4d 100644 --- a/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java +++ b/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java @@ -13,41 +13,41 @@ import eu.jonahbauer.android.preference.annotations.Preferences; makeFile = true, r = R.class, value = { - @PreferenceGroup(name = "internal", prefix = "settings_internal_", suffix = "_key", value = { - @Preference(name = "started", type = boolean.class, defaultValue = "false"), - @Preference(name = "started_time", type = long.class), - @Preference(name = "version_code", type = int.class, defaultValue = "-1"), - }), - @PreferenceGroup(name = "gestures", prefix = "settings_gesture_", suffix = "_key", value = { - }), - @PreferenceGroup(name = "general", prefix = "settings_general_", suffix = "_key", value = { - @Preference(name = "choose_home_screen", type = void.class) - }), - @PreferenceGroup(name = "theme", prefix = "settings_theme_", suffix = "_key", value = { - @Preference(name = "wallpaper", type = void.class), - @Preference(name = "color_theme", type = ColorTheme.class, defaultValue = "DEFAULT"), - @Preference(name = "background", type = Background.class, defaultValue = "BLUR"), - @Preference(name = "font", type = Font.class, defaultValue = "HACK"), - @Preference(name = "monochrome_icons", type = boolean.class, defaultValue = "false"), - }), - @PreferenceGroup(name = "clock", prefix = "settings_clock_", suffix = "_key", value = { - @Preference(name = "date_visible", type = boolean.class, defaultValue = "true"), - @Preference(name = "time_visible", type = boolean.class, defaultValue = "true"), - @Preference(name = "flip_date_time", type = boolean.class, defaultValue = "false"), - @Preference(name = "localized", type = boolean.class, defaultValue = "false"), - }), - @PreferenceGroup(name = "display", prefix = "settings_display_", suffix = "_key", value = { - @Preference(name = "screen_timeout_disabled", type = boolean.class, defaultValue = "false"), - @Preference(name = "full_screen", type = boolean.class, defaultValue = "true"), - }), - @PreferenceGroup(name = "functionality", prefix = "settings_functionality_", suffix = "_key", value = { - @Preference(name = "search_auto_launch", type = boolean.class, defaultValue = "true"), - @Preference(name = "search_auto_open_keyboard", type = boolean.class, defaultValue = "true"), - }), - @PreferenceGroup(name = "enabled_gestures", prefix = "settings_enabled_gestures_", suffix = "_key", value = { - @Preference(name = "double_swipe", type = boolean.class, defaultValue = "true"), - @Preference(name = "edge_swipe", type = boolean.class, defaultValue = "true"), - }), + @PreferenceGroup(name = "internal", prefix = "settings_internal_", suffix = "_key", value = { + @Preference(name = "started", type = boolean.class, defaultValue = "false"), + @Preference(name = "started_time", type = long.class), + @Preference(name = "version_code", type = int.class, defaultValue = "-1"), + }), + @PreferenceGroup( name = "gestures", prefix = "settings_gesture_", suffix = "_key", value = { + }), + @PreferenceGroup(name = "general", prefix = "settings_general_", suffix = "_key", value = { + @Preference(name = "choose_home_screen", type = void.class) + }), + @PreferenceGroup(name = "theme", prefix = "settings_theme_", suffix = "_key", value = { + @Preference(name = "wallpaper", type = void.class), + @Preference(name = "color_theme", type = ColorTheme.class, defaultValue = "DEFAULT"), + @Preference(name = "background", type = Background.class, defaultValue = "BLUR"), + @Preference(name = "font", type = Font.class, defaultValue = "HACK"), + @Preference(name = "monochrome_icons", type = boolean.class, defaultValue = "false"), + }), + @PreferenceGroup(name = "clock", prefix = "settings_clock_", suffix = "_key", value = { + @Preference(name = "date_visible", type = boolean.class, defaultValue = "true"), + @Preference(name = "time_visible", type = boolean.class, defaultValue = "true"), + @Preference(name = "flip_date_time", type = boolean.class, defaultValue = "false"), + @Preference(name = "localized", type = boolean.class, defaultValue = "false"), + }), + @PreferenceGroup(name = "display", prefix = "settings_display_", suffix = "_key", value = { + @Preference(name = "screen_timeout_disabled", type = boolean.class, defaultValue = "false"), + @Preference(name = "full_screen", type = boolean.class, defaultValue = "true"), + }), + @PreferenceGroup( name = "functionality", prefix = "settings_functionality_", suffix = "_key", value = { + @Preference(name = "search_auto_launch", type = boolean.class, defaultValue = "true"), + @Preference(name = "search_auto_open_keyboard", type = boolean.class, defaultValue = "true"), + }), + @PreferenceGroup(name = "enabled_gestures", prefix = "settings_enabled_gestures_", suffix = "_key", value = { + @Preference(name = "double_swipe", type = boolean.class, defaultValue = "true"), + @Preference(name = "edge_swipe", type = boolean.class, defaultValue = "true"), + }), }) public final class LauncherPreferences$Config { } diff --git a/app/src/main/java/de/jrpie/android/launcher/preferences/Preferences.kt b/app/src/main/java/de/jrpie/android/launcher/preferences/Preferences.kt index 357cd6d..47382d6 100644 --- a/app/src/main/java/de/jrpie/android/launcher/preferences/Preferences.kt +++ b/app/src/main/java/de/jrpie/android/launcher/preferences/Preferences.kt @@ -1,58 +1,141 @@ package de.jrpie.android.launcher.preferences -import android.app.Activity import android.content.Context -import android.content.Intent -import de.jrpie.android.launcher.BuildConfig.VERSION_CODE +import android.content.SharedPreferences +import android.util.Log +import android.widget.Toast import de.jrpie.android.launcher.Gesture -import de.jrpie.android.launcher.R -import de.jrpie.android.launcher.tutorial.TutorialActivity +import de.jrpie.android.launcher.preferences.theme.Background +import de.jrpie.android.launcher.preferences.theme.ColorTheme + +/* Current version of the structure of preferences. + * Increase when breaking changes are introduced and write an appropriate case in + * `migratePreferencesToNewVersion` + */ +const val PREFERENCE_VERSION = 1 +const val UNKNOWN_PREFERENCE_VERSION = -1 -fun migrateToNewVersion(activity: Activity) { +private fun migrateStringPreference(oldPrefs: SharedPreferences, newPreferences: SharedPreferences.Editor, oldKey: String, newKey: String, default: String) { + val s = oldPrefs.getString(oldKey, default) + newPreferences.putString(newKey, s) +} +private fun migrateIntPreference(oldPrefs: SharedPreferences, newPreferences: SharedPreferences.Editor, oldKey: String, newKey: String, default: Int) { + val s = oldPrefs.getInt(oldKey, default) + newPreferences.putInt(newKey, s) +} +private fun migrateBooleanPreference(oldPrefs: SharedPreferences, newPreferences: SharedPreferences.Editor, oldKey: String, newKey: String, default: Boolean) { + val s = oldPrefs.getBoolean(oldKey, default) + newPreferences.putBoolean(newKey, s) +} + +fun migratePreferencesToNewVersion(context: Context) { when (LauncherPreferences.internal().versionCode()) { // Check versions, make sure transitions between versions go well + PREFERENCE_VERSION -> { /* the version installed and used previously are the same */ } + UNKNOWN_PREFERENCE_VERSION -> { /* still using the old preferences file */ + Log.i("Launcher", "Unknown preference version, trying to restore preferences from old version.") - VERSION_CODE -> { /* the version installed and used previously are the same */ - } - 21, 22, 23 -> { - // TODO - } + val oldPrefs = context.getSharedPreferences( + "V3RYR4ND0MK3YCR4P", + Context.MODE_PRIVATE + ) + if(!oldPrefs.contains("startedBefore")) { + Log.i("Launcher", "No old preferences found.") + return + } + val newPrefs = LauncherPreferences.getSharedPreferences().edit() - else -> { /* The version used before was pre- v1.3.0, - as version tracking started then */ + migrateBooleanPreference(oldPrefs, newPrefs, "startedBefore", "internal.started_before", false) + + migrateStringPreference(oldPrefs, newPrefs, "action_volumeUpApp", "action.volume_up.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_volumeUpApp_user", "action.volume_up.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_volumeDownApp", "action.volume_down.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_volumeDownApp_user", "action.volume_down.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_timeApp", "action.time.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_timeApp_user", "action.time.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_dateApp", "action.date.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_dateApp_user", "action.date.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_longClickApp", "action.long_click.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_longClickApp_user", "action.long_click.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_doubleClickApp", "action.double_click.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_doubleClickApp_user", "action.double_click.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_upApp", "action.up.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_upApp_user", "action.up.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_up_leftApp", "action.up_left.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_up_leftApp_user", "action.up_left.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_up_rightApp", "action.up_right.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_up_rightApp_user", "action.up_right.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_doubleUpApp", "action.double_up.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_doubleUpApp_user", "action.double_up.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_downApp", "action.down.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_downApp_user", "action.down.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_down_leftApp", "action.down_left.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_down_leftApp_user", "action.down_left.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_down_rightApp", "action.down_right.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_down_rightApp_user", "action.down_right.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_doubleDownApp", "action.double_down.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_doubleDownApp_user", "action.double_down.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_leftApp", "action.left.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_leftApp_user", "action.left.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_left_topApp", "action.left_top.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_left_topApp_user", "action.left_top.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_left_bottomApp", "action.left_bottom.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_left_bottomApp_user", "action.left_bottom.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_doubleLeftApp", "action.double_left.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_doubleLeftApp_user", "action.double_left.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_rightApp", "action.right.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_rightApp_user", "action.right.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_right_topApp", "action.right_top.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_right_topApp_user", "action.right_top.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_right_bottomApp", "action.right_bottom.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_right_bottomApp_user", "action.right_bottom.user", -1) + migrateStringPreference(oldPrefs, newPrefs, "action_doubleRightApp", "action.double_right.app", "") + migrateIntPreference(oldPrefs, newPrefs, "action_doubleRightApp_user", "action.double_right.user", -1) + migrateBooleanPreference(oldPrefs, newPrefs, "timeVisible", "clock.time_visible", true) + migrateBooleanPreference(oldPrefs, newPrefs, "dateVisible", "clock.date_visible", true) + migrateBooleanPreference(oldPrefs, newPrefs, "dateLocalized", "clock.date_localized", false) + migrateBooleanPreference(oldPrefs, newPrefs, "dateTimeFlip", "clock.date_time_flip", false) + migrateBooleanPreference(oldPrefs, newPrefs, "disableTimeout", "display.disable_timeout", false) + migrateBooleanPreference(oldPrefs, newPrefs, "useFullScreen", "display.use_full_screen", true) + migrateBooleanPreference(oldPrefs, newPrefs, "enableDoubleActions", "enabled_gestures.double_actions", true) + migrateBooleanPreference(oldPrefs, newPrefs, "enableEdgeActions", "enabled_gestures.edge_actions", true) + migrateBooleanPreference(oldPrefs, newPrefs, "searchAutoLaunch", "functionality.search_auto_launch", true) + migrateBooleanPreference(oldPrefs, newPrefs, "searchAutoKeyboard", "functionality.search_auto_keyboard", true) + + newPrefs.apply() + + when(oldPrefs.getString("theme", "finn")) { + "finn" -> { + LauncherPreferences.theme().colorTheme(ColorTheme.DEFAULT) + LauncherPreferences.theme().monochromeIcons(false) + LauncherPreferences.theme().background(Background.BLUR) + } + "dark" -> { + LauncherPreferences.theme().colorTheme(ColorTheme.DARK) + LauncherPreferences.theme().monochromeIcons(true) + LauncherPreferences.theme().background(Background.BLUR) + } + } + + + LauncherPreferences.internal().versionCode(PREFERENCE_VERSION) + Log.i("Launcher", "migration of preferences complete.") - /* - * before, the dominant and vibrant color of the `finn` and `dark` theme - * were not stored anywhere. Now they have to be stored: - * -> we just reset them using newly implemented functions - */ - /*when (LauncherPreferences.theme().colorTheme()) { - "finn" -> resetToDefaultTheme(activity) - "dark" -> resetToDarkTheme(activity) - } */ - LauncherPreferences.internal().versionCode(VERSION_CODE) // show the new tutorial - activity.startActivity(Intent(activity, TutorialActivity::class.java)) + // context.startActivity(Intent(context, TutorialActivity::class.java)) } + else -> {} } } -fun resetSettings(context: Context) { - +fun resetPreferences(context: Context) { + Log.i("Launcher", "resetting preferences") + LauncherPreferences.clear() + LauncherPreferences.internal().versionCode(PREFERENCE_VERSION) val editor = LauncherPreferences.getSharedPreferences().edit() - Gesture.values().forEach { editor.putString(it.id, it.pickDefaultApp(context)) } + Gesture.values().forEach { editor.putString(it.id + ".app", it.pickDefaultApp(context)) } + Gesture.values().forEach { editor.putInt(it.id + ".user", -1) } editor.apply() - - // set default theme - val dominantColor = context.resources.getColor(R.color.finnmglasTheme_background_color) - val vibrantColor = context.resources.getColor(R.color.finnmglasTheme_accent_color) - - - LauncherPreferences.theme().dominant(dominantColor) - LauncherPreferences.theme().vibrant(vibrantColor) -} - - - +} \ No newline at end of file diff --git a/app/src/main/java/de/jrpie/android/launcher/settings/SettingsActivity.kt b/app/src/main/java/de/jrpie/android/launcher/settings/SettingsActivity.kt index 9f4278b..c021f34 100644 --- a/app/src/main/java/de/jrpie/android/launcher/settings/SettingsActivity.kt +++ b/app/src/main/java/de/jrpie/android/launcher/settings/SettingsActivity.kt @@ -7,17 +7,14 @@ import android.content.res.Resources import android.os.Bundle import android.provider.Settings import androidx.appcompat.app.AppCompatActivity +import androidx.viewpager.widget.ViewPager +import de.jrpie.android.launcher.* +import com.google.android.material.tabs.TabLayout +import de.jrpie.android.launcher.databinding.SettingsBinding import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentPagerAdapter -import androidx.viewpager.widget.ViewPager -import com.google.android.material.tabs.TabLayout -import de.jrpie.android.launcher.R -import de.jrpie.android.launcher.REQUEST_CHOOSE_APP -import de.jrpie.android.launcher.UIObject -import de.jrpie.android.launcher.databinding.SettingsBinding import de.jrpie.android.launcher.preferences.LauncherPreferences -import de.jrpie.android.launcher.saveListActivityChoice import de.jrpie.android.launcher.settings.actions.SettingsFragmentActions import de.jrpie.android.launcher.settings.launcher.SettingsFragmentLauncher import de.jrpie.android.launcher.settings.meta.SettingsFragmentMeta @@ -31,11 +28,11 @@ import de.jrpie.android.launcher.settings.meta.SettingsFragmentMeta * * Settings are closed automatically if the activity goes `onPause` unexpectedly. */ -class SettingsActivity : AppCompatActivity(), UIObject { +class SettingsActivity: AppCompatActivity(), UIObject { private var sharedPreferencesListener = - SharedPreferences.OnSharedPreferenceChangeListener { _, prefKey -> - if (prefKey?.startsWith("theme.") == true) { + SharedPreferences.OnSharedPreferenceChangeListener { _,prefKey -> + if(prefKey?.startsWith("theme.") == true) { recreate() } } @@ -59,13 +56,11 @@ class SettingsActivity : AppCompatActivity(), UIObject { override fun onStart() { super.onStart() super.onStart() - LauncherPreferences.getSharedPreferences() - .registerOnSharedPreferenceChangeListener(sharedPreferencesListener) + LauncherPreferences.getSharedPreferences().registerOnSharedPreferenceChangeListener(sharedPreferencesListener) } override fun onPause() { - LauncherPreferences.getSharedPreferences() - .unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener) + LauncherPreferences.getSharedPreferences().unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener) super.onPause() } @@ -73,7 +68,7 @@ class SettingsActivity : AppCompatActivity(), UIObject { return modifyTheme(super.getTheme()) } - override fun setOnClicks() { + override fun setOnClicks(){ // As older APIs somehow do not recognize the xml defined onClick binding.settingsClose.setOnClickListener { finish() } // open device settings (see https://stackoverflow.com/a/62092663/12787264) @@ -96,11 +91,11 @@ private val TAB_TITLES = arrayOf( R.string.settings_tab_meta ) -class SettingsSectionsPagerAdapter(private val context: Context, fm: FragmentManager) : - FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { +class SettingsSectionsPagerAdapter(private val context: Context, fm: FragmentManager) + : FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { override fun getItem(position: Int): Fragment { - return when (position) { + return when (position){ 0 -> SettingsFragmentActions() 1 -> SettingsFragmentLauncher() 2 -> SettingsFragmentMeta() @@ -112,7 +107,5 @@ class SettingsSectionsPagerAdapter(private val context: Context, fm: FragmentMan return context.resources.getString(TAB_TITLES[position]) } - override fun getCount(): Int { - return 3 - } + override fun getCount(): Int { return 3 } } diff --git a/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActions.kt b/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActions.kt index e03f610..bd0fa19 100644 --- a/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActions.kt +++ b/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActions.kt @@ -44,22 +44,18 @@ SettingsFragmentActions : Fragment(), UIObject { override fun setOnClicks() { // App management buttons - binding!!.settingsActionsButtonViewApps.setOnClickListener { + binding!!.settingsActionsButtonViewApps.setOnClickListener{ val intent = Intent(this.context, ListActivity::class.java) intent.putExtra("intention", ListActivity.ListActivityIntention.VIEW.toString()) startActivity(intent) } - binding!!.settingsActionsButtonInstallApps.setOnClickListener { + binding!!.settingsActionsButtonInstallApps.setOnClickListener{ try { val intent = Intent(Intent.ACTION_MAIN) intent.addCategory(Intent.CATEGORY_APP_MARKET) startActivity(intent) } catch (e: ActivityNotFoundException) { - Toast.makeText( - context, - getString(R.string.settings_apps_toast_store_not_found), - Toast.LENGTH_SHORT - ).show() + Toast.makeText(context, getString(R.string.settings_apps_toast_store_not_found), Toast.LENGTH_SHORT).show() } } } diff --git a/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActionsRecycler.kt b/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActionsRecycler.kt index d87c10c..50bfa6c 100644 --- a/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActionsRecycler.kt +++ b/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActionsRecycler.kt @@ -1,28 +1,25 @@ package de.jrpie.android.launcher.settings.actions -import android.app.Activity -import android.content.Intent -import android.content.SharedPreferences import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import androidx.fragment.app.Fragment +import androidx.recyclerview.widget.LinearLayoutManager +import de.jrpie.android.launcher.* +import de.jrpie.android.launcher.list.ListActivity +import android.app.Activity +import android.content.Intent +import android.content.SharedPreferences +import android.util.Log import android.widget.Button import android.widget.ImageView import android.widget.TextView -import androidx.fragment.app.Fragment -import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import de.jrpie.android.launcher.Gesture -import de.jrpie.android.launcher.R -import de.jrpie.android.launcher.REQUEST_CHOOSE_APP -import de.jrpie.android.launcher.UIObject -import de.jrpie.android.launcher.databinding.SettingsActionsRecyclerBinding -import de.jrpie.android.launcher.getAppIcon -import de.jrpie.android.launcher.list.ListActivity import de.jrpie.android.launcher.list.other.LauncherAction +import de.jrpie.android.launcher.databinding.SettingsActionsRecyclerBinding import de.jrpie.android.launcher.preferences.LauncherPreferences -import de.jrpie.android.launcher.transformGrayscale +import java.lang.Exception /** * The [SettingsFragmentActionsRecycler] is a fragment containing the [ActionsRecyclerAdapter], @@ -52,7 +49,7 @@ class SettingsFragmentActionsRecycler : Fragment(), UIObject { // set up the list / recycler val actionViewManager = LinearLayoutManager(context) - actionViewAdapter = ActionsRecyclerAdapter(requireActivity()) + actionViewAdapter = ActionsRecyclerAdapter( requireActivity() ) binding.settingsActionsRview.apply { // improve performance (since content changes don't change the layout size) @@ -60,21 +57,19 @@ class SettingsFragmentActionsRecycler : Fragment(), UIObject { layoutManager = actionViewManager adapter = actionViewAdapter } - LauncherPreferences.getSharedPreferences() - .registerOnSharedPreferenceChangeListener(sharedPreferencesListener) + LauncherPreferences.getSharedPreferences().registerOnSharedPreferenceChangeListener(sharedPreferencesListener) super.onStart() } override fun onDestroy() { - LauncherPreferences.getSharedPreferences() - .unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener) + LauncherPreferences.getSharedPreferences().unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener) super.onDestroy() } } -class ActionsRecyclerAdapter(val activity: Activity) : +class ActionsRecyclerAdapter(val activity: Activity): RecyclerView.Adapter() { private val gesturesList: ArrayList @@ -86,11 +81,9 @@ class ActionsRecyclerAdapter(val activity: Activity) : var chooseButton: Button = itemView.findViewById(R.id.settings_actions_row_button_choose) var removeAction: ImageView = itemView.findViewById(R.id.settings_actions_row_remove) - override fun onClick(v: View) {} + override fun onClick(v: View) { } - init { - itemView.setOnClickListener(this) - } + init { itemView.setOnClickListener(this) } } private fun updateViewHolder(gesture: Gesture, viewHolder: ViewHolder) { @@ -99,11 +92,12 @@ class ActionsRecyclerAdapter(val activity: Activity) : viewHolder.img.visibility = View.VISIBLE viewHolder.removeAction.visibility = View.VISIBLE viewHolder.chooseButton.visibility = View.INVISIBLE - if (content.isEmpty()) { + if (content.isEmpty()){ viewHolder.img.visibility = View.INVISIBLE viewHolder.removeAction.visibility = View.GONE viewHolder.chooseButton.visibility = View.VISIBLE - } else if (LauncherAction.isOtherAction(content)) { + } + else if (LauncherAction.isOtherAction(content)) { LauncherAction.byId(content)?.let { viewHolder.img.setImageResource(it.icon) } @@ -111,7 +105,7 @@ class ActionsRecyclerAdapter(val activity: Activity) : // Set image icon (by packageName) try { viewHolder.img.setImageDrawable(getAppIcon(activity, content, app.second)) - } catch (e: Exception) { + } catch (e : Exception) { // Probably the app was uninstalled // the button is shown, user asked to select an action viewHolder.img.visibility = View.INVISIBLE @@ -125,16 +119,14 @@ class ActionsRecyclerAdapter(val activity: Activity) : val gesture = gesturesList[i] viewHolder.textView.text = gesture.getLabel(activity) if (LauncherPreferences.theme().monochromeIcons()) - transformGrayscale(viewHolder.img) + transformGrayscale( viewHolder.img ) updateViewHolder(gesture, viewHolder) - viewHolder.img.setOnClickListener { chooseApp(gesture) } - viewHolder.chooseButton.setOnClickListener { chooseApp(gesture) } - viewHolder.removeAction.setOnClickListener { gesture.removeApp(activity) } + viewHolder.img.setOnClickListener{ chooseApp(gesture) } + viewHolder.chooseButton.setOnClickListener{ chooseApp(gesture) } + viewHolder.removeAction.setOnClickListener{ gesture.removeApp(activity) } } - override fun getItemCount(): Int { - return gesturesList.size - } + override fun getItemCount(): Int { return gesturesList.size } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val inflater = LayoutInflater.from(parent.context) @@ -147,8 +139,7 @@ class ActionsRecyclerAdapter(val activity: Activity) : val edgeActions = LauncherPreferences.enabled_gestures().edgeSwipe() gesturesList = Gesture.values().filter { (doubleActions || !it.isDoubleVariant()) - && (edgeActions || !it.isEdgeVariant()) - } as ArrayList + && (edgeActions || !it.isEdgeVariant())} as ArrayList } fun updateActions() { @@ -157,8 +148,7 @@ class ActionsRecyclerAdapter(val activity: Activity) : this.gesturesList.clear() gesturesList.addAll(Gesture.values().filter { (doubleActions || !it.isDoubleVariant()) - && (edgeActions || !it.isEdgeVariant()) - }) + && (edgeActions || !it.isEdgeVariant())}) notifyDataSetChanged() } @@ -168,8 +158,7 @@ class ActionsRecyclerAdapter(val activity: Activity) : val intent = Intent(activity, ListActivity::class.java) intent.putExtra("intention", ListActivity.ListActivityIntention.PICK.toString()) intent.putExtra("forGesture", gesture.id) // for which action we choose the app - activity.startActivityForResult( - intent, + activity.startActivityForResult(intent, REQUEST_CHOOSE_APP ) } diff --git a/app/src/main/java/de/jrpie/android/launcher/settings/launcher/SettingsFragmentLauncher.kt b/app/src/main/java/de/jrpie/android/launcher/settings/launcher/SettingsFragmentLauncher.kt index 94d1e10..10fdc44 100644 --- a/app/src/main/java/de/jrpie/android/launcher/settings/launcher/SettingsFragmentLauncher.kt +++ b/app/src/main/java/de/jrpie/android/launcher/settings/launcher/SettingsFragmentLauncher.kt @@ -4,8 +4,8 @@ import android.content.Context import android.content.Intent import android.os.Bundle import androidx.preference.PreferenceFragmentCompat -import de.jrpie.android.launcher.R import de.jrpie.android.launcher.preferences.LauncherPreferences +import de.jrpie.android.launcher.R import de.jrpie.android.launcher.setDefaultHomeScreen @@ -17,13 +17,9 @@ import de.jrpie.android.launcher.setDefaultHomeScreen class SettingsFragmentLauncher : PreferenceFragmentCompat() { override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { - preferenceManager.sharedPreferencesName = getString(R.string.preference_file_key) - preferenceManager.sharedPreferencesMode = Context.MODE_PRIVATE setPreferencesFromResource(R.xml.preferences, rootKey) - val selectWallpaper = findPreference( - LauncherPreferences.theme().keys().wallpaper() - ) + val selectWallpaper = findPreference(LauncherPreferences.theme().keys().wallpaper()) selectWallpaper?.setOnPreferenceClickListener { // https://github.com/LineageOS/android_packages_apps_Trebuchet/blob/6caab89b21b2b91f0a439e1fd8c4510dcb255819/src/com/android/launcher3/views/OptionsPopupView.java#L271 val intent = Intent(Intent.ACTION_SET_WALLPAPER) @@ -32,9 +28,7 @@ class SettingsFragmentLauncher : PreferenceFragmentCompat() { startActivity(intent) true } - val chooseHomeScreen = findPreference( - LauncherPreferences.general().keys().chooseHomeScreen() - ) + val chooseHomeScreen = findPreference(LauncherPreferences.general().keys().chooseHomeScreen()) chooseHomeScreen?.setOnPreferenceClickListener { setDefaultHomeScreen(requireContext(), checkDefault = false) true diff --git a/app/src/main/java/de/jrpie/android/launcher/settings/meta/SettingsFragmentMeta.kt b/app/src/main/java/de/jrpie/android/launcher/settings/meta/SettingsFragmentMeta.kt index bcec08f..2a19c13 100644 --- a/app/src/main/java/de/jrpie/android/launcher/settings/meta/SettingsFragmentMeta.kt +++ b/app/src/main/java/de/jrpie/android/launcher/settings/meta/SettingsFragmentMeta.kt @@ -10,10 +10,10 @@ import android.view.ViewGroup import androidx.fragment.app.Fragment import de.jrpie.android.launcher.R import de.jrpie.android.launcher.UIObject -import de.jrpie.android.launcher.databinding.SettingsMetaBinding import de.jrpie.android.launcher.openNewTabWindow -import de.jrpie.android.launcher.preferences.resetSettings import de.jrpie.android.launcher.tutorial.TutorialActivity +import de.jrpie.android.launcher.databinding.SettingsMetaBinding +import de.jrpie.android.launcher.preferences.resetPreferences /** * The [SettingsFragmentMeta] is a used as a tab in the SettingsActivity. @@ -65,10 +65,9 @@ class SettingsFragmentMeta : Fragment(), UIObject { AlertDialog.Builder(this.requireContext(), R.style.AlertDialogCustom) .setTitle(getString(R.string.settings_meta_reset)) .setMessage(getString(R.string.settings_meta_reset_confirm)) - .setPositiveButton( - android.R.string.ok + .setPositiveButton(android.R.string.ok ) { _, _ -> - resetSettings(this.requireContext()) + resetPreferences(this.requireContext()) requireActivity().finish() } .setNegativeButton(android.R.string.cancel, null) @@ -86,6 +85,7 @@ class SettingsFragmentMeta : Fragment(), UIObject { } + // contact developer binding.settingsMetaButtonContact.setOnClickListener { openNewTabWindow( diff --git a/app/src/main/java/de/jrpie/android/launcher/tutorial/TutorialActivity.kt b/app/src/main/java/de/jrpie/android/launcher/tutorial/TutorialActivity.kt index 0c0e75b..a9e0478 100644 --- a/app/src/main/java/de/jrpie/android/launcher/tutorial/TutorialActivity.kt +++ b/app/src/main/java/de/jrpie/android/launcher/tutorial/TutorialActivity.kt @@ -1,6 +1,7 @@ package de.jrpie.android.launcher.tutorial import android.content.Intent +import android.content.res.Resources import android.os.Bundle import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment @@ -8,11 +9,10 @@ import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentPagerAdapter import androidx.viewpager.widget.ViewPager import com.google.android.material.tabs.TabLayout +import de.jrpie.android.launcher.preferences.LauncherPreferences import de.jrpie.android.launcher.R import de.jrpie.android.launcher.REQUEST_CHOOSE_APP import de.jrpie.android.launcher.UIObject -import de.jrpie.android.launcher.preferences.LauncherPreferences -import de.jrpie.android.launcher.preferences.resetSettings import de.jrpie.android.launcher.saveListActivityChoice import de.jrpie.android.launcher.tutorial.tabs.TutorialFragmentConcept import de.jrpie.android.launcher.tutorial.tabs.TutorialFragmentFinish @@ -27,7 +27,7 @@ import de.jrpie.android.launcher.tutorial.tabs.TutorialFragmentUsage * It tells the user about the concept behind launcher * and helps with the setup process (on new installations) */ -class TutorialActivity : AppCompatActivity(), UIObject { +class TutorialActivity: AppCompatActivity(), UIObject { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -35,10 +35,6 @@ class TutorialActivity : AppCompatActivity(), UIObject { // Initialise layout setContentView(R.layout.tutorial) - // Check if the app was started before - if (!LauncherPreferences.internal().started()) - resetSettings(this) - // set up tabs and swiping in settings val sectionsPagerAdapter = TutorialSectionsPagerAdapter(supportFragmentManager) val viewPager: ViewPager = findViewById(R.id.tutorial_viewpager) @@ -47,6 +43,10 @@ class TutorialActivity : AppCompatActivity(), UIObject { tabs.setupWithViewPager(viewPager) } + override fun getTheme(): Resources.Theme { + return modifyTheme(super.getTheme()) + } + override fun onStart() { super.onStart() super.onStart() @@ -54,7 +54,7 @@ class TutorialActivity : AppCompatActivity(), UIObject { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { when (requestCode) { - REQUEST_CHOOSE_APP -> saveListActivityChoice(this, data) + REQUEST_CHOOSE_APP -> saveListActivityChoice(this,data) else -> super.onActivityResult(requestCode, resultCode, data) } } @@ -73,11 +73,11 @@ class TutorialActivity : AppCompatActivity(), UIObject { * * Tabs: (Start | Concept | Usage | Setup | Finish) */ -class TutorialSectionsPagerAdapter(fm: FragmentManager) : - FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { +class TutorialSectionsPagerAdapter(fm: FragmentManager) + : FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { override fun getItem(position: Int): Fragment { - return when (position) { + return when (position){ 0 -> TutorialFragmentStart() 1 -> TutorialFragmentConcept() 2 -> TutorialFragmentUsage() @@ -88,11 +88,6 @@ class TutorialSectionsPagerAdapter(fm: FragmentManager) : } /* We don't use titles here, as we have the dots */ - override fun getPageTitle(position: Int): CharSequence { - return "" - } - - override fun getCount(): Int { - return 5 - } + override fun getPageTitle(position: Int): CharSequence { return "" } + override fun getCount(): Int { return 5 } } diff --git a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentConcept.kt b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentConcept.kt index 4296e3d..ffeb464 100644 --- a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentConcept.kt +++ b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentConcept.kt @@ -8,7 +8,6 @@ import androidx.fragment.app.Fragment import de.jrpie.android.launcher.BuildConfig import de.jrpie.android.launcher.UIObject import de.jrpie.android.launcher.databinding.TutorialConceptBinding - /** * The [TutorialFragmentConcept] is a used as a tab in the TutorialActivity. * @@ -26,7 +25,7 @@ class TutorialFragmentConcept : Fragment(), UIObject { return binding.root } - override fun onStart() { + override fun onStart(){ super.onStart() super.onStart() } diff --git a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentFinish.kt b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentFinish.kt index 94940f5..f4598b1 100644 --- a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentFinish.kt +++ b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentFinish.kt @@ -1,15 +1,14 @@ package de.jrpie.android.launcher.tutorial.tabs import android.os.Bundle +import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.fragment.app.Fragment +import de.jrpie.android.launcher.* import de.jrpie.android.launcher.BuildConfig.VERSION_CODE -import de.jrpie.android.launcher.UIObject import de.jrpie.android.launcher.databinding.TutorialFinishBinding import de.jrpie.android.launcher.preferences.LauncherPreferences -import de.jrpie.android.launcher.setDefaultHomeScreen /** * The [TutorialFragmentFinish] is a used as a tab in the TutorialActivity. @@ -35,11 +34,11 @@ class TutorialFragmentFinish : Fragment(), UIObject { override fun setOnClicks() { super.setOnClicks() - binding.tutorialFinishButtonStart.setOnClickListener { finishTutorial() } + binding.tutorialFinishButtonStart.setOnClickListener{ finishTutorial() } } private fun finishTutorial() { - if (!LauncherPreferences.internal().started()) { + if(!LauncherPreferences.internal().started()) { LauncherPreferences.internal().started(true) LauncherPreferences.internal().startedTime(System.currentTimeMillis() / 1000L) LauncherPreferences.internal().versionCode(VERSION_CODE) diff --git a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentSetup.kt b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentSetup.kt index 2aab7c9..a71088d 100644 --- a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentSetup.kt +++ b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentSetup.kt @@ -22,7 +22,7 @@ class TutorialFragmentSetup : Fragment(), UIObject { return inflater.inflate(R.layout.tutorial_setup, container, false) } - override fun onStart() { + override fun onStart(){ super.onStart() super.onStart() } diff --git a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentStart.kt b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentStart.kt index 40b5e7c..433da9b 100644 --- a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentStart.kt +++ b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentStart.kt @@ -1,12 +1,11 @@ package de.jrpie.android.launcher.tutorial.tabs import android.os.Bundle +import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.fragment.app.Fragment -import de.jrpie.android.launcher.UIObject -import de.jrpie.android.launcher.blink +import de.jrpie.android.launcher.* import de.jrpie.android.launcher.databinding.TutorialStartBinding /** @@ -26,7 +25,7 @@ class TutorialFragmentStart : Fragment(), UIObject { return binding.root } - override fun onStart() { + override fun onStart(){ super.onStart() super.onStart() } diff --git a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentUsage.kt b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentUsage.kt index 8cd7f9d..00cd9d3 100644 --- a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentUsage.kt +++ b/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentUsage.kt @@ -22,7 +22,7 @@ class TutorialFragmentUsage : Fragment(), UIObject { return inflater.inflate(R.layout.tutorial_usage, container, false) } - override fun onStart() { + override fun onStart(){ super.onStart() super.onStart() } diff --git a/app/src/main/res/anim/bottom_up.xml b/app/src/main/res/anim/bottom_up.xml index 50889e5..1a128eb 100644 --- a/app/src/main/res/anim/bottom_up.xml +++ b/app/src/main/res/anim/bottom_up.xml @@ -2,9 +2,9 @@ + android:duration="100"/> \ No newline at end of file diff --git a/app/src/main/res/anim/left_right.xml b/app/src/main/res/anim/left_right.xml index 7b5eb38..1dd2cb4 100644 --- a/app/src/main/res/anim/left_right.xml +++ b/app/src/main/res/anim/left_right.xml @@ -2,9 +2,9 @@ + android:duration="100"/> \ No newline at end of file diff --git a/app/src/main/res/anim/right_left.xml b/app/src/main/res/anim/right_left.xml index ecccc1f..58e2060 100644 --- a/app/src/main/res/anim/right_left.xml +++ b/app/src/main/res/anim/right_left.xml @@ -2,9 +2,9 @@ + android:duration="100"/> \ No newline at end of file diff --git a/app/src/main/res/anim/top_down.xml b/app/src/main/res/anim/top_down.xml index 84798ce..239c475 100644 --- a/app/src/main/res/anim/top_down.xml +++ b/app/src/main/res/anim/top_down.xml @@ -2,9 +2,9 @@ + android:duration="100"/> \ No newline at end of file diff --git a/app/src/main/res/drawable/baseline_close_24.xml b/app/src/main/res/drawable/baseline_close_24.xml index fcfb043..a6a4319 100644 --- a/app/src/main/res/drawable/baseline_close_24.xml +++ b/app/src/main/res/drawable/baseline_close_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_menu_24.xml b/app/src/main/res/drawable/baseline_menu_24.xml index 4802bd8..69b6549 100644 --- a/app/src/main/res/drawable/baseline_menu_24.xml +++ b/app/src/main/res/drawable/baseline_menu_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_more_horiz_24.xml b/app/src/main/res/drawable/baseline_more_horiz_24.xml index c9007c6..a370298 100644 --- a/app/src/main/res/drawable/baseline_more_horiz_24.xml +++ b/app/src/main/res/drawable/baseline_more_horiz_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_not_interested_24.xml b/app/src/main/res/drawable/baseline_not_interested_24.xml index 6cc4b8c..8666b2e 100644 --- a/app/src/main/res/drawable/baseline_not_interested_24.xml +++ b/app/src/main/res/drawable/baseline_not_interested_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_notifications_24.xml b/app/src/main/res/drawable/baseline_notifications_24.xml index fd97353..c80cfc4 100644 --- a/app/src/main/res/drawable/baseline_notifications_24.xml +++ b/app/src/main/res/drawable/baseline_notifications_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_search_24.xml b/app/src/main/res/drawable/baseline_search_24.xml index c599843..2fd74fb 100644 --- a/app/src/main/res/drawable/baseline_search_24.xml +++ b/app/src/main/res/drawable/baseline_search_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_settings_24.xml b/app/src/main/res/drawable/baseline_settings_24.xml index 5f1bc1c..1a56e8f 100644 --- a/app/src/main/res/drawable/baseline_settings_24.xml +++ b/app/src/main/res/drawable/baseline_settings_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_settings_applications_24.xml b/app/src/main/res/drawable/baseline_settings_applications_24.xml index 0f3525c..9fb4bf4 100644 --- a/app/src/main/res/drawable/baseline_settings_applications_24.xml +++ b/app/src/main/res/drawable/baseline_settings_applications_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_skip_next_24.xml b/app/src/main/res/drawable/baseline_skip_next_24.xml index 164be15..dd1ec32 100644 --- a/app/src/main/res/drawable/baseline_skip_next_24.xml +++ b/app/src/main/res/drawable/baseline_skip_next_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_skip_previous_24.xml b/app/src/main/res/drawable/baseline_skip_previous_24.xml index ef93ccf..678e831 100644 --- a/app/src/main/res/drawable/baseline_skip_previous_24.xml +++ b/app/src/main/res/drawable/baseline_skip_previous_24.xml @@ -1,12 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_volume_down_24.xml b/app/src/main/res/drawable/baseline_volume_down_24.xml index 15840c2..fa9f447 100644 --- a/app/src/main/res/drawable/baseline_volume_down_24.xml +++ b/app/src/main/res/drawable/baseline_volume_down_24.xml @@ -1,13 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/baseline_volume_up_24.xml b/app/src/main/res/drawable/baseline_volume_up_24.xml index 95b0f36..f9555f0 100644 --- a/app/src/main/res/drawable/baseline_volume_up_24.xml +++ b/app/src/main/res/drawable/baseline_volume_up_24.xml @@ -1,13 +1,5 @@ - + - + diff --git a/app/src/main/res/drawable/tutorial_default_dot.xml b/app/src/main/res/drawable/tutorial_default_dot.xml index d870a0f..29ebcd3 100644 --- a/app/src/main/res/drawable/tutorial_default_dot.xml +++ b/app/src/main/res/drawable/tutorial_default_dot.xml @@ -6,7 +6,7 @@ android:shape="ring" android:thickness="5dp" android:useLevel="false"> - + \ No newline at end of file diff --git a/app/src/main/res/drawable/tutorial_selected_dot.xml b/app/src/main/res/drawable/tutorial_selected_dot.xml index 68a3299..1adc83c 100644 --- a/app/src/main/res/drawable/tutorial_selected_dot.xml +++ b/app/src/main/res/drawable/tutorial_selected_dot.xml @@ -6,7 +6,7 @@ android:shape="ring" android:thickness="5dp" android:useLevel="false"> - + \ No newline at end of file diff --git a/app/src/main/res/drawable/tutorial_tab_selector.xml b/app/src/main/res/drawable/tutorial_tab_selector.xml index 2171911..67dbf34 100644 --- a/app/src/main/res/drawable/tutorial_tab_selector.xml +++ b/app/src/main/res/drawable/tutorial_tab_selector.xml @@ -1,7 +1,8 @@ - + - + \ No newline at end of file diff --git a/app/src/main/res/layout/home.xml b/app/src/main/res/layout/home.xml index 598c57b..b213078 100644 --- a/app/src/main/res/layout/home.xml +++ b/app/src/main/res/layout/home.xml @@ -1,6 +1,8 @@ - - - - - - + custom:type="solid" + android:layout_marginStart="8dp" /> + app:layout_constraintTop_toTopOf="parent"/> - + app:layout_constraintTop_toTopOf="parent" + /> - - + app:tabIndicatorHeight="0dp" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" /> \ No newline at end of file diff --git a/app/src/main/res/layout/tutorial_concept.xml b/app/src/main/res/layout/tutorial_concept.xml index 93fb3e1..c04f7c9 100644 --- a/app/src/main/res/layout/tutorial_concept.xml +++ b/app/src/main/res/layout/tutorial_concept.xml @@ -1,12 +1,13 @@ - - - - - - diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml index c9ad5f9..036d09b 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml index c9ad5f9..036d09b 100644 --- a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -1,5 +1,5 @@ - - + + \ No newline at end of file diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 95210ee..22b0866 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -80,7 +80,7 @@ Bildschirm Bildschirm nicht ausschalten - Vollbild + Vollbild Funktionen @@ -110,7 +110,6 @@ Unserem Discord beitreten Entwickler kontaktieren - https://www.finnmglas.com/de/kontakt/ Entwickler des Fork kontaktieren Datenschutzerklärung diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index db4c077..6ebb81a 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -1,6 +1,6 @@ - - V3RYR4ND0MK3YCR4P - startedBefore - firstStartup - version_code - settings.general.select_launcher - - Swipe Up - Double Up - Swipe Down - Double Down - Swipe Left - Double Left - Swipe Right - Double Right - Swipe Right (Top) - Swipe Right (Bottom) - Swipe Left (Bottom) - Swipe Left (Top) - Swipe Up (Left Edge) - Swipe Up (Right Edge) - Swipe Down (Left Edge) - Swipe Down (Right Edge) - Volume Up - Volume Down - Double Click - Long Click - Click on Date - Click on Time + μLauncher + + internal.started_before + internal.first_startup + internal.version_code + general.select_launcher + + Swipe Up + Double Up + Swipe Down + Double Down + Swipe Left + Double Left + Swipe Right + Double Right + Swipe Right (Top) + Swipe Right (Bottom) + Swipe Left (Bottom) + Swipe Left (Top) + Swipe Up (Left Edge) + Swipe Up (Right Edge) + Swipe Down (Left Edge) + Swipe Down (Right Edge) + Volume Up + Volume Down + Double Click + Long Click + Click on Date + Click on Time - - theme.color_theme - - DEFAULT - DARK - - - theme.background - - TRANSPARENT - DIM - BLUR - SOLID - - theme.wallpaper - theme.font - - HACK - SYSTEM_DEFAULT - - theme.monochrome_icons - - timeVisible - dateVisible - dateLocalized - dateTimeFlip + + theme.color_theme + + DEFAULT + DARK + + + theme.background + + TRANSPARENT + DIM + BLUR + SOLID + + theme.wallpaper + theme.font + + HACK + SYSTEM_DEFAULT + + theme.monochrome_icons + + + clock.time_visible + clock.date_visible + clock.date_localized + clock.date_time_flip - - disableTimeout - useFullScreen + + display.disable_timeout + display.use_full_screen - enableDoubleActions - enableEdgeActions - searchAutoLaunch - searchAutoKeyboard + enabled_gestures.double_actions + enabled_gestures.edge_actions + functionality.search_auto_launch + functionality.search_auto_keyboard - - https://github.com/jrpie/Launcher - https://github.com/jrpie/Launcher/issues/new - https://s.jrpie.de/contact - https://s.jrpie.de/android-legal - https://www.finnmglas.com/contact/ - https://discord.com/invite/jV2AhF8 + + + https://github.com/jrpie/Launcher + https://github.com/jrpie/Launcher/issues/new + https://s.jrpie.de/contact + https://s.jrpie.de/android-legal + https://www.finnmglas.com/contact/ + https://discord.com/invite/jV2AhF8 - - >>>>>]]> + + >>>>>]]> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9c3218b..2f4bd22 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,9 +1,9 @@ - + Can\'t open app Want to change its settings? @@ -185,6 +185,7 @@ Start + Settings More options Error: Can\'t expand status bar.\nThis action is using functionality that is not part of the published Android API. Unfortunately, it does not seem to work on your device. diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index ea7d1f7..db2f80f 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -28,7 +28,6 @@ @color/darkTheme_background_color @color/darkTheme_text_color - - + + diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 14334d3..7a32795 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -1,65 +1,66 @@ - + + android:title="@string/settings_general_choose_home_screen"/> + app:allowDividerAbove="false" + android:title="@string/settings_launcher_section_appearance"> + android:title="@string/settings_theme_wallpaper"/> + android:defaultValue="DEFAULT" + android:key="@string/settings_theme_color_theme_key" + android:title="@string/settings_theme_color_theme"/> + android:defaultValue="HACK"/> + android:defaultValue="BLUR"/> + android:title="@string/settings_theme_monochrome_icons" + android:defaultValue="false" /> - + @@ -68,21 +69,21 @@ app:allowDividerAbove="false"> - + + android:defaultValue="true" + android:title="@string/settings_enabled_gestures_edge_swipe"/> @@ -91,10 +92,10 @@ app:allowDividerAbove="false"> + android:title="@string/settings_display_full_screen"/> + android:title="@string/settings_display_screen_timeout_disabled"/> From 0e18eb1a781dff517da71a9f8d2fd909b088eef8 Mon Sep 17 00:00:00 2001 From: Josia Pietsch Date: Wed, 11 Sep 2024 11:38:12 +0200 Subject: [PATCH 019/333] fixed typo in german translation --- app/src/main/res/values-de/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 22b0866..41413b6 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -163,7 +163,7 @@ Du kannst deine Einstellungen auch später noch ändern. Los gehts! - Du bist bereit loszulegen!\n\nIch hoffe diese App ist nützlich für dich!\n\n- Finn (der Entwickler)\n\tund Josia (der einige Änderungen vorgenommen hat und den Fork μLauncher entwickelt. + Du bist bereit loszulegen!\n\nIch hoffe diese App ist nützlich für dich!\n\n- Finn (der Entwickler)\n\tund Josia (der einige Änderungen vorgenommen hat und den Fork μLauncher entwickelt) Starten Einstellungen From f788a11489496431cb7e056d0243958fb890c1ef Mon Sep 17 00:00:00 2001 From: Josia Pietsch Date: Wed, 11 Sep 2024 11:50:53 +0200 Subject: [PATCH 020/333] updated translations --- app/src/main/res/values-de/strings.xml | 5 +++++ app/src/main/res/values/donottranslate.xml | 4 ++-- app/src/main/res/values/strings.xml | 4 +--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index d7eff31..5460b5b 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -58,6 +58,9 @@ Datum anzeigen Lokalisiertes Datumsformat verwenden Datum und Uhrzeit tauschen + Hintergrund (Alle Apps und Einstellungen) + Schriftart + Einfarbige Icons Farbschema @@ -134,4 +137,6 @@ Starten Einstellungen Mehr Optionen + Benachrichtigungen + Fehler: Die Funktion \"Benachrichtigungen\" wird von deinem Gerät leider nicht unterstützt. diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml index a7735c8..4b501ff 100644 --- a/app/src/main/res/values/donottranslate.xml +++ b/app/src/main/res/values/donottranslate.xml @@ -9,7 +9,7 @@ internal.started_before internal.first_startup internal.version_code - general.select_launcher + general.select_launcher display.disable_timeout display.use_full_screen + display.rotate_screen enabled_gestures.double_actions enabled_gestures.edge_actions diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4c9031a..90b1a87 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -96,6 +96,7 @@ Keep screen on Use full screen + Rotate screen Functionality diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 7a32795..c462d8e 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -93,6 +93,9 @@ + From 32c3c41266e0e60e816d51ef3621acdaad7d8b08 Mon Sep 17 00:00:00 2001 From: Josia Pietsch Date: Wed, 11 Sep 2024 14:26:08 +0200 Subject: [PATCH 023/333] more fonts --- .../de/jrpie/android/launcher/HomeActivity.kt | 16 ++++++++++++++++ .../preferences/LauncherPreferences$Config.java | 1 + .../android/launcher/preferences/theme/Font.kt | 7 +++++++ .../launcher/settings/SettingsActivity.kt | 4 +++- app/src/main/res/values/donottranslate.xml | 7 +++++++ app/src/main/res/values/strings.xml | 6 ++++++ app/src/main/res/values/styles.xml | 12 ++++++++++++ app/src/main/res/xml/preferences.xml | 7 +++++++ 8 files changed, 59 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/de/jrpie/android/launcher/HomeActivity.kt b/app/src/main/java/de/jrpie/android/launcher/HomeActivity.kt index 3fb83b4..d0d074d 100644 --- a/app/src/main/java/de/jrpie/android/launcher/HomeActivity.kt +++ b/app/src/main/java/de/jrpie/android/launcher/HomeActivity.kt @@ -1,6 +1,7 @@ package de.jrpie.android.launcher import android.content.Intent +import android.content.SharedPreferences import android.content.res.Resources import android.os.AsyncTask import android.os.Bundle @@ -42,6 +43,13 @@ class HomeActivity: UIObject, AppCompatActivity(), private lateinit var binding: HomeBinding + private var sharedPreferencesListener = + SharedPreferences.OnSharedPreferenceChangeListener { _, prefKey -> + if(prefKey?.startsWith("clock.") == true || + prefKey?.startsWith("display.") == true) { + recreate() + } + } private var bufferedPointerCount = 1 // how many fingers on screen private var pointerBufferTimer = Timer() @@ -71,6 +79,7 @@ class HomeActivity: UIObject, AppCompatActivity(), // Initialise layout binding = HomeBinding.inflate(layoutInflater) setContentView(binding.root) + } override fun onStart(){ @@ -80,6 +89,8 @@ class HomeActivity: UIObject, AppCompatActivity(), mDetector.setOnDoubleTapListener(this) super.onStart() + + LauncherPreferences.getSharedPreferences().registerOnSharedPreferenceChangeListener(sharedPreferencesListener) } private fun updateClock() { @@ -127,6 +138,7 @@ class HomeActivity: UIObject, AppCompatActivity(), override fun getTheme(): Resources.Theme { val mTheme = modifyTheme(super.getTheme()) mTheme.applyStyle(R.style.backgroundWallpaper, true) + LauncherPreferences.clock().font().applyToTheme(mTheme) return mTheme } @@ -138,7 +150,11 @@ class HomeActivity: UIObject, AppCompatActivity(), override fun onPause() { super.onPause() clockTimer.cancel() + } + override fun onDestroy() { + LauncherPreferences.getSharedPreferences().unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener) + super.onDestroy() } override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean { diff --git a/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java b/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java index 3e67d91..0205c74 100644 --- a/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java +++ b/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java @@ -31,6 +31,7 @@ import eu.jonahbauer.android.preference.annotations.Preferences; @Preference(name = "monochrome_icons", type = boolean.class, defaultValue = "false"), }), @PreferenceGroup(name = "clock", prefix = "settings_clock_", suffix = "_key", value = { + @Preference(name = "font", type = Font.class, defaultValue = "HACK"), @Preference(name = "date_visible", type = boolean.class, defaultValue = "true"), @Preference(name = "time_visible", type = boolean.class, defaultValue = "true"), @Preference(name = "flip_date_time", type = boolean.class, defaultValue = "false"), diff --git a/app/src/main/java/de/jrpie/android/launcher/preferences/theme/Font.kt b/app/src/main/java/de/jrpie/android/launcher/preferences/theme/Font.kt index 15d9398..c8c415d 100644 --- a/app/src/main/java/de/jrpie/android/launcher/preferences/theme/Font.kt +++ b/app/src/main/java/de/jrpie/android/launcher/preferences/theme/Font.kt @@ -3,9 +3,16 @@ package de.jrpie.android.launcher.preferences.theme import android.content.res.Resources import de.jrpie.android.launcher.R +/** + * Changes here must also be added to @array/settings_theme_font_values + */ enum class Font(val id: Int) { HACK(R.style.fontHack), SYSTEM_DEFAULT(R.style.fontSystemDefault), + SANS_SERIF(R.style.fontSansSerif), + SERIF(R.style.fontSerifMonospace), + MONOSPACE(R.style.fontMonospace), + SERIF_MONOSPACE(R.style.fontSerifMonospace), ; fun applyToTheme(theme: Resources.Theme) { diff --git a/app/src/main/java/de/jrpie/android/launcher/settings/SettingsActivity.kt b/app/src/main/java/de/jrpie/android/launcher/settings/SettingsActivity.kt index c021f34..54938fd 100644 --- a/app/src/main/java/de/jrpie/android/launcher/settings/SettingsActivity.kt +++ b/app/src/main/java/de/jrpie/android/launcher/settings/SettingsActivity.kt @@ -32,7 +32,8 @@ class SettingsActivity: AppCompatActivity(), UIObject { private var sharedPreferencesListener = SharedPreferences.OnSharedPreferenceChangeListener { _,prefKey -> - if(prefKey?.startsWith("theme.") == true) { + if(prefKey?.startsWith("theme.") == true || + prefKey?.startsWith("display.") == true) { recreate() } } @@ -49,6 +50,7 @@ class SettingsActivity: AppCompatActivity(), UIObject { val sectionsPagerAdapter = SettingsSectionsPagerAdapter(this, supportFragmentManager) val viewPager: ViewPager = findViewById(R.id.settings_viewpager) viewPager.adapter = sectionsPagerAdapter + val tabs: TabLayout = findViewById(R.id.settings_tabs) tabs.setupWithViewPager(viewPager) } diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml index 96233d5..658a03d 100644 --- a/app/src/main/res/values/donottranslate.xml +++ b/app/src/main/res/values/donottranslate.xml @@ -58,9 +58,15 @@ theme.wallpaper theme.font + + HACK SYSTEM_DEFAULT + SANS_SERIF + SERIF + MONOSPACE + SERIF_MONOSPACE theme.monochrome_icons @@ -69,6 +75,7 @@ - Settings : Clock - --> + clock.font clock.time_visible clock.date_visible clock.date_localized diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 90b1a87..95bbbce 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -77,9 +77,15 @@ Solid Font + + Hack System default + Sans serif + Serif + Monospace + Serif monospace Monochrome app icons diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index db2f80f..9d94609 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -65,6 +65,18 @@ @font/hack + + + + diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index c462d8e..87ba943 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -46,6 +46,13 @@ + Date: Wed, 11 Sep 2024 15:05:05 +0200 Subject: [PATCH 024/333] added option to hide seconds --- .../de/jrpie/android/launcher/HomeActivity.kt | 13 +++++-- .../LauncherPreferences$Config.java | 1 + .../launcher/SettingsFragmentLauncher.kt | 36 +++++++++++++++++-- app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values/donottranslate.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/preferences.xml | 4 +++ 7 files changed, 53 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/de/jrpie/android/launcher/HomeActivity.kt b/app/src/main/java/de/jrpie/android/launcher/HomeActivity.kt index d0d074d..fd02fa4 100644 --- a/app/src/main/java/de/jrpie/android/launcher/HomeActivity.kt +++ b/app/src/main/java/de/jrpie/android/launcher/HomeActivity.kt @@ -100,7 +100,16 @@ class HomeActivity: UIObject, AppCompatActivity(), val timeVisible = LauncherPreferences.clock().timeVisible() var dateFMT = "yyyy-MM-dd" - var timeFMT = "HH:mm:ss" + var timeFMT = "HH:mm" + var period = 100L + if (LauncherPreferences.clock().showSeconds()) { + timeFMT += ":ss" + } + /* + I thought about adding an option to show microseconds as well ( timeFMT += ".SSS" ). + However setting period ot 1L (or even 10L) causes high CPU load, + so that doesn't seem to be a good idea. + */ if (LauncherPreferences.clock().localized()) { dateFMT = android.text.format.DateFormat.getBestDateTimePattern(locale, dateFMT) timeFMT = android.text.format.DateFormat.getBestDateTimePattern(locale, timeFMT) @@ -119,7 +128,7 @@ class HomeActivity: UIObject, AppCompatActivity(), binding.homeUpperView.isVisible = upperVisible binding.homeLowerView.isVisible = lowerVisible - clockTimer = fixedRateTimer("clockTimer", true, 0L, 100) { + clockTimer = fixedRateTimer("clockTimer", true, 0L, period) { this@HomeActivity.runOnUiThread { if (lowerVisible) { val t = lowerFormat.format(Date()) diff --git a/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java b/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java index 0205c74..b63b06f 100644 --- a/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java +++ b/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java @@ -36,6 +36,7 @@ import eu.jonahbauer.android.preference.annotations.Preferences; @Preference(name = "time_visible", type = boolean.class, defaultValue = "true"), @Preference(name = "flip_date_time", type = boolean.class, defaultValue = "false"), @Preference(name = "localized", type = boolean.class, defaultValue = "false"), + @Preference(name = "show_seconds", type = boolean.class, defaultValue = "true"), }), @PreferenceGroup(name = "display", prefix = "settings_display_", suffix = "_key", value = { @Preference(name = "screen_timeout_disabled", type = boolean.class, defaultValue = "false"), diff --git a/app/src/main/java/de/jrpie/android/launcher/settings/launcher/SettingsFragmentLauncher.kt b/app/src/main/java/de/jrpie/android/launcher/settings/launcher/SettingsFragmentLauncher.kt index 10fdc44..adfc67b 100644 --- a/app/src/main/java/de/jrpie/android/launcher/settings/launcher/SettingsFragmentLauncher.kt +++ b/app/src/main/java/de/jrpie/android/launcher/settings/launcher/SettingsFragmentLauncher.kt @@ -2,6 +2,7 @@ package de.jrpie.android.launcher.settings.launcher import android.content.Context import android.content.Intent +import android.content.SharedPreferences import android.os.Bundle import androidx.preference.PreferenceFragmentCompat import de.jrpie.android.launcher.preferences.LauncherPreferences @@ -16,10 +17,38 @@ import de.jrpie.android.launcher.setDefaultHomeScreen */ class SettingsFragmentLauncher : PreferenceFragmentCompat() { + + private var sharedPreferencesListener = + SharedPreferences.OnSharedPreferenceChangeListener { _, prefKey -> + if(prefKey?.startsWith("clock.") == true) { + updateVisibility() + } + } + + private fun updateVisibility(){ + val showSeconds = findPreference( + LauncherPreferences.clock().keys().showSeconds() + ) + val timeVisible = LauncherPreferences.clock().timeVisible() + showSeconds?.isVisible = timeVisible + } + + override fun onStart() { + super.onStart() + LauncherPreferences.getSharedPreferences().registerOnSharedPreferenceChangeListener(sharedPreferencesListener) + } + + override fun onPause() { + LauncherPreferences.getSharedPreferences().unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener) + super.onPause() + } + override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) { setPreferencesFromResource(R.xml.preferences, rootKey) - val selectWallpaper = findPreference(LauncherPreferences.theme().keys().wallpaper()) + val selectWallpaper = findPreference( + LauncherPreferences.theme().keys().wallpaper() + ) selectWallpaper?.setOnPreferenceClickListener { // https://github.com/LineageOS/android_packages_apps_Trebuchet/blob/6caab89b21b2b91f0a439e1fd8c4510dcb255819/src/com/android/launcher3/views/OptionsPopupView.java#L271 val intent = Intent(Intent.ACTION_SET_WALLPAPER) @@ -28,10 +57,13 @@ class SettingsFragmentLauncher : PreferenceFragmentCompat() { startActivity(intent) true } - val chooseHomeScreen = findPreference(LauncherPreferences.general().keys().chooseHomeScreen()) + val chooseHomeScreen = findPreference( + LauncherPreferences.general().keys().chooseHomeScreen() + ) chooseHomeScreen?.setOnPreferenceClickListener { setDefaultHomeScreen(requireContext(), checkDefault = false) true } + updateVisibility() } } diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 5460b5b..99cd7f0 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -139,4 +139,5 @@ Mehr Optionen Benachrichtigungen Fehler: Die Funktion \"Benachrichtigungen\" wird von deinem Gerät leider nicht unterstützt. + Sekunden anzeigen diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml index 658a03d..10a1d86 100644 --- a/app/src/main/res/values/donottranslate.xml +++ b/app/src/main/res/values/donottranslate.xml @@ -77,6 +77,7 @@ --> clock.font clock.time_visible + clock.show_seconds clock.date_visible clock.date_localized clock.date_time_flip diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 95bbbce..1c98158 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -93,6 +93,7 @@ Show time Show date Use localized date format + Show seconds Flip date and time Choose a wallpaper diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 87ba943..774f4be 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -61,6 +61,10 @@ android:key="@string/settings_clock_time_visible_key" android:defaultValue="true" android:title="@string/settings_clock_time_visible" /> + Date: Wed, 11 Sep 2024 21:07:18 +0200 Subject: [PATCH 025/333] chore: refactored code --- app/src/main/AndroidManifest.xml | 8 +- .../de/jrpie/android/launcher/Application.kt | 3 +- .../de/jrpie/android/launcher/Functions.kt | 255 +++--------- .../java/de/jrpie/android/launcher/Gesture.kt | 155 ------- .../jrpie/android/launcher/actions/Action.kt | 100 +++++ .../android/launcher/actions/AppAction.kt | 85 ++++ .../jrpie/android/launcher/actions/AppInfo.kt | 49 +++ .../jrpie/android/launcher/actions/Gesture.kt | 222 ++++++++++ .../launcher/actions/LauncherAction.kt | 185 +++++++++ .../android/launcher/list/apps/AppInfo.kt | 16 - .../launcher/list/other/LauncherAction.kt | 43 -- .../LauncherPreferences$Config.java | 76 ++-- .../launcher/preferences/Preferences.kt | 386 +++++++++++++++--- .../android/launcher/{ => ui}/HomeActivity.kt | 84 ++-- .../android/launcher/{ => ui}/UIObject.kt | 8 +- .../launcher/{ => ui}/list/ListActivity.kt | 22 +- .../{ => ui}/list/apps/AppsRecyclerAdapter.kt | 92 +++-- .../{ => ui}/list/apps/ListFragmentApps.kt | 15 +- .../{ => ui}/list/other/ListFragmentOther.kt | 3 +- .../list/other/OtherRecyclerAdapter.kt | 23 +- .../{ => ui}/settings/SettingsActivity.kt | 48 ++- .../actions/SettingsFragmentActions.kt | 16 +- .../SettingsFragmentActionsRecycler.kt | 92 ++--- .../launcher/SettingsFragmentLauncher.kt | 15 +- .../settings/meta/SettingsFragmentMeta.kt | 12 +- .../{ => ui}/tutorial/TutorialActivity.kt | 35 +- .../tutorial/tabs/TutorialFragmentConcept.kt | 7 +- .../tutorial/tabs/TutorialFragmentFinish.kt | 11 +- .../tutorial/tabs/TutorialFragmentSetup.kt | 6 +- .../tutorial/tabs/TutorialFragmentStart.kt | 9 +- .../tutorial/tabs/TutorialFragmentUsage.kt | 6 +- app/src/main/res/layout/home.xml | 2 +- app/src/main/res/layout/list.xml | 2 +- app/src/main/res/layout/settings.xml | 2 +- app/src/main/res/layout/settings_actions.xml | 2 +- app/src/main/res/layout/settings_meta.xml | 2 +- app/src/main/res/layout/tutorial.xml | 2 +- app/src/main/res/layout/tutorial_concept.xml | 2 +- app/src/main/res/layout/tutorial_finish.xml | 2 +- app/src/main/res/layout/tutorial_setup.xml | 4 +- app/src/main/res/layout/tutorial_start.xml | 2 +- app/src/main/res/layout/tutorial_usage.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- 43 files changed, 1367 insertions(+), 746 deletions(-) delete mode 100644 app/src/main/java/de/jrpie/android/launcher/Gesture.kt create mode 100644 app/src/main/java/de/jrpie/android/launcher/actions/Action.kt create mode 100644 app/src/main/java/de/jrpie/android/launcher/actions/AppAction.kt create mode 100644 app/src/main/java/de/jrpie/android/launcher/actions/AppInfo.kt create mode 100644 app/src/main/java/de/jrpie/android/launcher/actions/Gesture.kt create mode 100644 app/src/main/java/de/jrpie/android/launcher/actions/LauncherAction.kt delete mode 100644 app/src/main/java/de/jrpie/android/launcher/list/apps/AppInfo.kt delete mode 100644 app/src/main/java/de/jrpie/android/launcher/list/other/LauncherAction.kt rename app/src/main/java/de/jrpie/android/launcher/{ => ui}/HomeActivity.kt (80%) rename app/src/main/java/de/jrpie/android/launcher/{ => ui}/UIObject.kt (94%) rename app/src/main/java/de/jrpie/android/launcher/{ => ui}/list/ListActivity.kt (91%) rename app/src/main/java/de/jrpie/android/launcher/{ => ui}/list/apps/AppsRecyclerAdapter.kt (71%) rename app/src/main/java/de/jrpie/android/launcher/{ => ui}/list/apps/ListFragmentApps.kt (87%) rename app/src/main/java/de/jrpie/android/launcher/{ => ui}/list/other/ListFragmentOther.kt (94%) rename app/src/main/java/de/jrpie/android/launcher/{ => ui}/list/other/OtherRecyclerAdapter.kt (77%) rename app/src/main/java/de/jrpie/android/launcher/{ => ui}/settings/SettingsActivity.kt (71%) rename app/src/main/java/de/jrpie/android/launcher/{ => ui}/settings/actions/SettingsFragmentActions.kt (82%) rename app/src/main/java/de/jrpie/android/launcher/{ => ui}/settings/actions/SettingsFragmentActionsRecycler.kt (69%) rename app/src/main/java/de/jrpie/android/launcher/{ => ui}/settings/launcher/SettingsFragmentLauncher.kt (84%) rename app/src/main/java/de/jrpie/android/launcher/{ => ui}/settings/meta/SettingsFragmentMeta.kt (93%) rename app/src/main/java/de/jrpie/android/launcher/{ => ui}/tutorial/TutorialActivity.kt (74%) rename app/src/main/java/de/jrpie/android/launcher/{ => ui}/tutorial/tabs/TutorialFragmentConcept.kt (88%) rename app/src/main/java/de/jrpie/android/launcher/{ => ui}/tutorial/tabs/TutorialFragmentFinish.kt (82%) rename app/src/main/java/de/jrpie/android/launcher/{ => ui}/tutorial/tabs/TutorialFragmentSetup.kt (84%) rename app/src/main/java/de/jrpie/android/launcher/{ => ui}/tutorial/tabs/TutorialFragmentStart.kt (83%) rename app/src/main/java/de/jrpie/android/launcher/{ => ui}/tutorial/tabs/TutorialFragmentUsage.kt (84%) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5ccea00..b3b266f 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,7 +19,7 @@ android:theme="@style/launcherBaseTheme"> diff --git a/app/src/main/java/de/jrpie/android/launcher/Application.kt b/app/src/main/java/de/jrpie/android/launcher/Application.kt index 49a9014..6f0aaad 100644 --- a/app/src/main/java/de/jrpie/android/launcher/Application.kt +++ b/app/src/main/java/de/jrpie/android/launcher/Application.kt @@ -1,10 +1,9 @@ package de.jrpie.android.launcher -import android.content.Context import androidx.preference.PreferenceManager import de.jrpie.android.launcher.preferences.LauncherPreferences -class Application: android.app.Application() { +class Application : android.app.Application() { override fun onCreate() { super.onCreate() diff --git a/app/src/main/java/de/jrpie/android/launcher/Functions.kt b/app/src/main/java/de/jrpie/android/launcher/Functions.kt index 3358909..cf6a511 100644 --- a/app/src/main/java/de/jrpie/android/launcher/Functions.kt +++ b/app/src/main/java/de/jrpie/android/launcher/Functions.kt @@ -1,7 +1,6 @@ package de.jrpie.android.launcher import android.app.Activity -import android.app.AlertDialog import android.app.Service import android.app.role.RoleManager import android.content.Context @@ -10,42 +9,27 @@ import android.content.pm.ApplicationInfo import android.content.pm.LauncherActivityInfo import android.content.pm.LauncherApps import android.content.pm.PackageManager -import android.graphics.BlendMode -import android.graphics.BlendModeColorFilter import android.graphics.ColorMatrix import android.graphics.ColorMatrixColorFilter -import android.graphics.PorterDuff -import android.graphics.PorterDuffColorFilter import android.graphics.Rect -import android.graphics.drawable.Drawable -import android.media.AudioManager import android.net.Uri import android.os.Build import android.os.Bundle -import android.os.SystemClock import android.os.UserHandle import android.os.UserManager import android.provider.Settings import android.util.DisplayMetrics import android.util.Log -import android.view.KeyEvent import android.view.View -import android.view.Window -import android.view.WindowManager import android.view.animation.AlphaAnimation import android.view.animation.Animation import android.view.inputmethod.InputMethodManager -import android.widget.Button import android.widget.ImageView -import android.widget.Switch -import android.widget.Toast -import androidx.annotation.RequiresApi -import de.jrpie.android.launcher.list.ListActivity -import de.jrpie.android.launcher.list.apps.AppInfo -import de.jrpie.android.launcher.list.apps.AppsRecyclerAdapter -import de.jrpie.android.launcher.list.other.LauncherAction -import de.jrpie.android.launcher.settings.SettingsActivity -import de.jrpie.android.launcher.tutorial.TutorialActivity +import de.jrpie.android.launcher.actions.Action +import de.jrpie.android.launcher.actions.AppInfo +import de.jrpie.android.launcher.actions.Gesture +import de.jrpie.android.launcher.ui.list.apps.AppsRecyclerAdapter +import de.jrpie.android.launcher.ui.tutorial.TutorialActivity const val INVALID_USER = -1 @@ -87,19 +71,23 @@ fun setDefaultHomeScreen(context: Context, checkDefault: Boolean = false) { if (checkDefault && Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q - && context is Activity) { + && context is Activity + ) { val roleManager = context.getSystemService(RoleManager::class.java) - if(!roleManager.isRoleHeld(RoleManager.ROLE_HOME)) { - context.startActivityForResult(roleManager.createRequestRoleIntent(RoleManager.ROLE_HOME), REQUEST_SET_DEFAULT_HOME) + if (!roleManager.isRoleHeld(RoleManager.ROLE_HOME)) { + context.startActivityForResult( + roleManager.createRequestRoleIntent(RoleManager.ROLE_HOME), + REQUEST_SET_DEFAULT_HOME + ) } return } - if(checkDefault) { + if (checkDefault) { val testIntent = Intent(Intent.ACTION_MAIN) testIntent.addCategory(Intent.CATEGORY_HOME) val defaultHome = testIntent.resolveActivity(context.packageManager)?.packageName - if(defaultHome == context.packageName){ + if (defaultHome == context.packageName) { // Launcher is already the default home app return } @@ -108,170 +96,48 @@ fun setDefaultHomeScreen(context: Context, checkDefault: Boolean = false) { context.startActivity(intent) } -/* Activity related */ -fun isInstalled(uri: String, context: Context): Boolean { - if (uri.startsWith("launcher:")) return true // All internal actions - - try { - context.packageManager.getPackageInfo(uri, PackageManager.GET_ACTIVITIES) - return true - } catch (_: PackageManager.NameNotFoundException) { } - return false -} - -private fun getIntent(packageName: String, context: Context): Intent? { +fun getIntent(packageName: String, context: Context): Intent? { val intent: Intent? = context.packageManager.getLaunchIntentForPackage(packageName) intent?.addCategory(Intent.CATEGORY_LAUNCHER) return intent } - -fun launch( - data: String, user: Int?, - activity: Activity, - animationIn: Int = android.R.anim.fade_in, animationOut: Int = android.R.anim.fade_out -) { - - if (LauncherAction.isOtherAction(data)) { // [type]:[info] - LauncherAction.byId(data)?.let {it.launch(activity) } - } - else launchApp(data, user, activity) // app - - activity.overridePendingTransition(animationIn, animationOut) -} - -/* Media player actions */ - -fun audioNextTrack(activity: Activity) { - - val mAudioManager = activity.getSystemService(Context.AUDIO_SERVICE) as AudioManager - - val eventTime: Long = SystemClock.uptimeMillis() - - val downEvent = KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT, 0) - mAudioManager.dispatchMediaKeyEvent(downEvent) - - val upEvent = KeyEvent(eventTime, eventTime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_NEXT, 0) - mAudioManager.dispatchMediaKeyEvent(upEvent) -} - -fun audioPreviousTrack(activity: Activity) { - val mAudioManager = activity.getSystemService(Context.AUDIO_SERVICE) as AudioManager - - val eventTime: Long = SystemClock.uptimeMillis() - - val downEvent = - KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PREVIOUS, 0) - mAudioManager.dispatchMediaKeyEvent(downEvent) - - val upEvent = KeyEvent(eventTime, eventTime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PREVIOUS, 0) - mAudioManager.dispatchMediaKeyEvent(upEvent) -} - -fun audioVolumeUp(activity: Activity) { - val audioManager = - activity.getSystemService(Context.AUDIO_SERVICE) as AudioManager - - audioManager.adjustStreamVolume( - AudioManager.STREAM_MUSIC, - AudioManager.ADJUST_RAISE, - AudioManager.FLAG_SHOW_UI - ) -} - -fun audioVolumeDown(activity: Activity) { - val audioManager = - activity.getSystemService(Context.AUDIO_SERVICE) as AudioManager - - audioManager.adjustStreamVolume( - AudioManager.STREAM_MUSIC, - AudioManager.ADJUST_LOWER, - AudioManager.FLAG_SHOW_UI - ) -} - -fun expandNotificationsPanel(context: Context) { - /* https://stackoverflow.com/a/15582509 */ - try { - @Suppress("SpellCheckingInspection") - val statusBarService: Any? = context.getSystemService("statusbar") - val statusBarManager = Class.forName("android.app.StatusBarManager") - val showStatusBar = statusBarManager.getMethod("expandNotificationsPanel") - showStatusBar.invoke(statusBarService) - } catch (e: Exception) { - Toast.makeText(context, context.getString(R.string.alert_cant_expand_notifications_panel), Toast.LENGTH_LONG).show() - } -} - /* --- */ fun getUserFromId(user: Int?, context: Context): UserHandle? { val userManager = context.getSystemService(Service.USER_SERVICE) as UserManager return userManager.userProfiles.firstOrNull { it.hashCode() == user } } -fun getLauncherActivityInfo(packageName: String, user: Int?, context: Context): LauncherActivityInfo? { + +fun getLauncherActivityInfo( + packageName: String, + user: Int?, + context: Context +): LauncherActivityInfo? { val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps - return getUserFromId(user,context)?.let { - userHandle -> launcherApps.getActivityList(packageName, userHandle).firstOrNull() + return getUserFromId(user, context)?.let { userHandle -> + launcherApps.getActivityList(packageName, userHandle).firstOrNull() } } -fun uninstallApp(packageName: String, user: Int?, activity: Activity) { + +fun uninstallApp(appInfo: AppInfo, activity: Activity) { + val packageName = appInfo.packageName.toString() + val user = appInfo.user + Log.i("Launcher", "uninstalling $packageName ($user)") val intent = Intent(Intent.ACTION_UNINSTALL_PACKAGE) intent.data = Uri.parse("package:$packageName") - getUserFromId(user, activity)?.let { - user -> intent.putExtra(Intent.EXTRA_USER, user) + getUserFromId(user, activity)?.let { user -> + intent.putExtra(Intent.EXTRA_USER, user) } intent.putExtra(Intent.EXTRA_RETURN_RESULT, true) - activity.startActivityForResult(intent, + activity.startActivityForResult( + intent, REQUEST_UNINSTALL ) } -fun launchApp(packageName: String, user: Int?, context: Context, rect: Rect? = null) { - if (user != null && user != INVALID_USER) { - val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps - getLauncherActivityInfo(packageName,user,context)?.let { - app -> launcherApps.startMainActivity(app.componentName, app.user, rect, null) - return - } - } - - val intent = getIntent(packageName, context) - - if (intent != null) { - context.startActivity(intent) - } else { - if (isInstalled(packageName, context)){ - - AlertDialog.Builder( - context, - R.style.AlertDialogCustom - ) - .setTitle(context.getString(R.string.alert_cant_open_title)) - .setMessage(context.getString(R.string.alert_cant_open_message)) - .setPositiveButton(android.R.string.ok - ) { _, _ -> - openAppSettings( - packageName, - user, - context - ) - } - .setNegativeButton(android.R.string.cancel, null) - .setIcon(android.R.drawable.ic_dialog_info) - .show() - } else { - Toast.makeText( - context, - context.getString(R.string.toast_cant_open_message), - Toast.LENGTH_SHORT - ).show() - } - } -} - fun openNewTabWindow(urls: String, context: Context) { val uris = Uri.parse(urls) val intents = Intent(Intent.ACTION_VIEW, uris) @@ -281,39 +147,22 @@ fun openNewTabWindow(urls: String, context: Context) { context.startActivity(intents) } - -fun openAppSettings(packageName: String, user: Int?, context: Context, sourceBounds: Rect? = null, opts: Bundle? = null) { +fun openAppSettings( + appInfo: AppInfo, + context: Context, + sourceBounds: Rect? = null, + opts: Bundle? = null +) { val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps - getLauncherActivityInfo(packageName, user, context)?.let { - app -> launcherApps.startAppDetailsActivity(app.componentName, app.user, sourceBounds, opts) + getLauncherActivityInfo(appInfo.packageName.toString(), appInfo.user, context)?.let { app -> + launcherApps.startAppDetailsActivity(app.componentName, app.user, sourceBounds, opts) } } -fun openSettings(activity: Activity) { - activity.startActivity(Intent(activity, SettingsActivity::class.java)) +fun openTutorial(context: Context) { + context.startActivity(Intent(context, TutorialActivity::class.java)) } -fun openTutorial(activity: Activity){ - activity.startActivity(Intent(activity, TutorialActivity::class.java)) -} - -fun openAppsList(activity: Activity){ - val intent = Intent(activity, ListActivity::class.java) - intent.putExtra("intention", ListActivity.ListActivityIntention.VIEW.toString()) - activity.startActivity(intent) -} - -fun getAppIcon(context: Context, packageName: String, user: Int?): Drawable { - if (user != null) { - val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps - getUserFromId(user,context)?.let { - userHandle -> launcherApps.getActivityList(packageName, userHandle).firstOrNull()?.let { - app -> return app.getBadgedIcon(0) - } - } - } - return context.packageManager.getApplicationIcon(packageName) -} /** * [loadApps] is used to speed up the [AppsRecyclerAdapter] loading time, @@ -327,21 +176,22 @@ fun loadApps(packageManager: PackageManager, context: Context) { // TODO: shortcuts - launcherApps.getShortcuts() val users = userManager.userProfiles - for(user in users) { - for (activityInfo in launcherApps.getActivityList(null,user)) { + for (user in users) { + for (activityInfo in launcherApps.getActivityList(null, user)) { val app = AppInfo() app.label = activityInfo.label app.packageName = activityInfo.applicationInfo.packageName app.icon = activityInfo.getBadgedIcon(0) app.user = user.hashCode() - app.isSystemApp = activityInfo.applicationInfo.flags.and(ApplicationInfo.FLAG_SYSTEM) != 0 + app.isSystemApp = + activityInfo.applicationInfo.flags.and(ApplicationInfo.FLAG_SYSTEM) != 0 loadList.add(app) } } // fallback option - if(loadList.isEmpty()){ + if (loadList.isEmpty()) { Log.i("Launcher", "using fallback option to load packages") val i = Intent(Intent.ACTION_MAIN, null) i.addCategory(Intent.CATEGORY_LAUNCHER) @@ -361,14 +211,9 @@ fun loadApps(packageManager: PackageManager, context: Context) { // Used in Tutorial and Settings `ActivityOnResult` -fun saveListActivityChoice(context: Context, data: Intent?) { - val value = data?.getStringExtra("value") - var user = data?.getIntExtra("user", INVALID_USER) - user = user?.let{ if(it == INVALID_USER) null else it } - +fun saveListActivityChoice(data: Intent?) { val forGesture = data?.getStringExtra("forGesture") ?: return - - Gesture.byId(forGesture)?.setApp(context, value.toString(), user) + Gesture.byId(forGesture)?.let { Action.setActionForGesture(it, Action.fromIntent(data)) } } // Taken from https://stackoverflow.com/a/50743764/12787264 @@ -380,7 +225,7 @@ fun openSoftKeyboard(context: Context, view: View) { } // Taken from: https://stackoverflow.com/a/30340794/12787264 -fun transformGrayscale(imageView: ImageView){ +fun transformGrayscale(imageView: ImageView) { val matrix = ColorMatrix() matrix.setSaturation(0f) diff --git a/app/src/main/java/de/jrpie/android/launcher/Gesture.kt b/app/src/main/java/de/jrpie/android/launcher/Gesture.kt deleted file mode 100644 index 53745b5..0000000 --- a/app/src/main/java/de/jrpie/android/launcher/Gesture.kt +++ /dev/null @@ -1,155 +0,0 @@ -package de.jrpie.android.launcher - -import android.app.Activity -import android.content.Context -import de.jrpie.android.launcher.preferences.LauncherPreferences - -/** - * @param id internal id to serialize the action. Used as a key in shared preferences. - * @param defaultsResource res id of array of default actions for the gesture. - * @param labelResource res id of the name of the gesture. - * @param animationIn res id of transition animation (in) when using the gesture to launch an app. - * @param animationOut res id of transition animation (out) when using the gesture to launch an app. - */ -enum class Gesture (val id: String, private val labelResource: Int, - private val defaultsResource: Int, - private val animationIn: Int = android.R.anim.fade_in, - private val animationOut: Int = android.R.anim.fade_out){ - VOLUME_UP("action.volume_up", R.string.settings_gesture_vol_up, R.array.default_volume_up, 0,0), - VOLUME_DOWN("action.volume_down", R.string.settings_gesture_vol_down, R.array.default_volume_down,0,0), - TIME("action.time", R.string.settings_gesture_time, R.array.default_time), - DATE("action.date", R.string.settings_gesture_date, R.array.default_date), - LONG_CLICK("action.long_click", R.string.settings_gesture_long_click, R.array.default_long_click, 0,0), - DOUBLE_CLICK("action.double_click", R.string.settings_gesture_double_click, R.array.default_double_click,0,0), - SWIPE_UP("action.up", R.string.settings_gesture_up, R.array.default_up, R.anim.bottom_up), - SWIPE_UP_LEFT_EDGE("action.up_left", R.string.settings_gesture_up_left_edge, R.array.default_up_left, R.anim.bottom_up), - SWIPE_UP_RIGHT_EDGE("action.up_right", R.string.settings_gesture_up_right_edge, R.array.default_up_right, R.anim.bottom_up), - SWIPE_UP_DOUBLE( "action.double_up", R.string.settings_gesture_double_up, R.array.default_double_up, R.anim.bottom_up), - SWIPE_DOWN("action.down", R.string.settings_gesture_down, R.array.default_down, R.anim.top_down), - SWIPE_DOWN_LEFT_EDGE("action.down_left", R.string.settings_gesture_down_left_edge, R.array.default_down_left, R.anim.top_down), - SWIPE_DOWN_RIGHT_EDGE("action.down_right", R.string.settings_gesture_down_right_edge, R.array.default_down_right, R.anim.top_down), - SWIPE_DOWN_DOUBLE("action.double_down", R.string.settings_gesture_double_down, R.array.default_double_down, R.anim.top_down), - SWIPE_LEFT("action.left", R.string.settings_gesture_left, R.array.default_left, R.anim.right_left), - SWIPE_LEFT_TOP_EDGE("action.left_top", R.string.settings_gesture_left_top_edge, R.array.default_left_top, R.anim.right_left), - SWIPE_LEFT_BOTTOM_EDGE("action.left_bottom", R.string.settings_gesture_left_bottom_edge, R.array.default_left_bottom, R.anim.right_left), - SWIPE_LEFT_DOUBLE("action.double_left", R.string.settings_gesture_double_left, R.array.default_double_left, R.anim.right_left), - SWIPE_RIGHT("action.right", R.string.settings_gesture_right, R.array.default_right, R.anim.left_right), - SWIPE_RIGHT_TOP_EDGE("action.right_top", R.string.settings_gesture_right_top_edge, R.array.default_right_top, R.anim.left_right), - SWIPE_RIGHT_BOTTOM_EDGE("action.right_bottom", R.string.settings_gesture_right_bottom_edge, R.array.default_right_bottom, R.anim.left_right), - SWIPE_RIGHT_DOUBLE("action.double_right", R.string.settings_gesture_double_right, R.array.default_double_right, R.anim.left_right); - - enum class Edge{ - TOP, BOTTOM, LEFT, RIGHT - } - - fun getApp(context: Context): Pair { - val preferences = LauncherPreferences.getSharedPreferences() - var packageName = preferences.getString(this.id + ".app", "")!! - var u: Int? = preferences.getInt(this.id + ".user", INVALID_USER) - u = if(u == INVALID_USER) null else u - return Pair(packageName,u) - } - - fun removeApp(context: Context) { - LauncherPreferences.getSharedPreferences().edit() - .putString(this.id + ".app", "") // clear it - .apply() - } - - fun setApp(context: Context, app: String, user: Int?) { - LauncherPreferences.getSharedPreferences().edit() - .putString(this.id + ".app", app) - .apply() - - val u = user?: INVALID_USER - LauncherPreferences.getSharedPreferences().edit() - .putInt(this.id + ".user", u) - .apply() - } - - fun getLabel(context: Context): String { - return context.resources.getString(this.labelResource) - } - - fun pickDefaultApp(context: Context) : String { - return context.resources - .getStringArray(this.defaultsResource) - .firstOrNull { isInstalled(it, context) } - ?: "" - } - - fun getDoubleVariant(): Gesture { - return when(this) { - SWIPE_UP -> SWIPE_UP_DOUBLE - SWIPE_DOWN -> SWIPE_DOWN_DOUBLE - SWIPE_LEFT -> SWIPE_LEFT_DOUBLE - SWIPE_RIGHT -> SWIPE_RIGHT_DOUBLE - else -> this - } - } - - fun getEdgeVariant(edge: Edge): Gesture { - return when(edge) { - Edge.TOP -> - when(this) { - SWIPE_LEFT -> SWIPE_LEFT_TOP_EDGE - SWIPE_RIGHT -> SWIPE_RIGHT_TOP_EDGE - else -> this - } - Edge.BOTTOM -> - when(this) { - SWIPE_LEFT -> SWIPE_LEFT_BOTTOM_EDGE - SWIPE_RIGHT -> SWIPE_RIGHT_BOTTOM_EDGE - else -> this - } - Edge.LEFT -> - when(this) { - SWIPE_UP -> SWIPE_UP_LEFT_EDGE - SWIPE_DOWN -> SWIPE_DOWN_LEFT_EDGE - else -> this - } - Edge.RIGHT -> - when(this) { - SWIPE_UP -> SWIPE_UP_RIGHT_EDGE - SWIPE_DOWN -> SWIPE_DOWN_RIGHT_EDGE - else -> this - } - } - } - - fun isDoubleVariant(): Boolean { - return when(this){ - SWIPE_UP_DOUBLE, - SWIPE_DOWN_DOUBLE, - SWIPE_LEFT_DOUBLE, - SWIPE_RIGHT_DOUBLE -> true - else -> false - } - } - - fun isEdgeVariant(): Boolean { - return when(this){ - SWIPE_UP_RIGHT_EDGE, - SWIPE_UP_LEFT_EDGE, - SWIPE_DOWN_LEFT_EDGE, - SWIPE_DOWN_RIGHT_EDGE, - SWIPE_LEFT_TOP_EDGE, - SWIPE_LEFT_BOTTOM_EDGE, - SWIPE_RIGHT_TOP_EDGE, - SWIPE_RIGHT_BOTTOM_EDGE -> true - else -> false - } - } - - operator fun invoke(activity: Activity) { - val app = this.getApp(activity) - launch(app.first, app.second, activity, this.animationIn, this.animationOut) - } - - companion object { - fun byId(id: String): Gesture? { - return Gesture.values().firstOrNull {it.id == id } - } - } - -} diff --git a/app/src/main/java/de/jrpie/android/launcher/actions/Action.kt b/app/src/main/java/de/jrpie/android/launcher/actions/Action.kt new file mode 100644 index 0000000..d35a157 --- /dev/null +++ b/app/src/main/java/de/jrpie/android/launcher/actions/Action.kt @@ -0,0 +1,100 @@ +package de.jrpie.android.launcher.actions + +import android.app.Activity +import android.content.Context +import android.content.Intent +import android.content.SharedPreferences.Editor +import android.graphics.Rect +import android.graphics.drawable.Drawable +import android.widget.Toast +import de.jrpie.android.launcher.INVALID_USER +import de.jrpie.android.launcher.R +import de.jrpie.android.launcher.preferences.LauncherPreferences + +interface Action { + fun invoke(context: Context, rect: Rect? = null): Boolean + fun bindToGesture(prefEditor: Editor, id: String) + fun label(context: Context): String + fun getIcon(context: Context): Drawable? + fun isAvailable(context: Context): Boolean + + fun writeToIntent(intent: Intent) + + companion object { + private fun fromId(id: String, user: Int?): Action? { + if (id.isEmpty()) { + return null + } + if (LauncherAction.isOtherAction(id)) { + return LauncherAction.byId(id) + } + + return AppAction(AppInfo(id, user)) + } + + fun forGesture(gesture: Gesture): Action? { + val id = gesture.id + + val preferences = LauncherPreferences.getSharedPreferences() + var actionId = preferences.getString("$id.app", "")!! + var u: Int? = preferences.getInt("$id.user", INVALID_USER) + u = if (u == INVALID_USER) null else u + + return fromId(actionId, u) + } + + fun resetToDefaultActions(context: Context) { + val editor = LauncherPreferences.getSharedPreferences().edit() + Gesture.values().forEach { gesture -> + context.resources + .getStringArray(gesture.defaultsResource) + .map { fromId(it, null) } + .firstOrNull { it?.isAvailable(context) ?: false } + ?.bindToGesture(editor, gesture.id) + } + editor.apply() + } + + fun setActionForGesture(gesture: Gesture, action: Action?) { + if (action == null) { + clearActionForGesture(gesture) + return + } + val editor = LauncherPreferences.getSharedPreferences().edit() + action.bindToGesture(editor, gesture.id) + editor.apply() + } + + fun clearActionForGesture(gesture: Gesture) { + LauncherPreferences.getSharedPreferences().edit() + .putString(gesture.id + ".app", "") + .putInt(gesture.id + ".user", INVALID_USER) + .apply() + } + + fun launch( + action: Action?, + context: Context, + animationIn: Int = android.R.anim.fade_in, + animationOut: Int = android.R.anim.fade_out + ) { + if (action != null && action.invoke(context)) { + if (context is Activity) { + context.overridePendingTransition(animationIn, animationOut) + } + } else { + Toast.makeText( + context, + context.getString(R.string.toast_cant_open_message), + Toast.LENGTH_SHORT + ).show() + } + } + + fun fromIntent(data: Intent): Action? { + val value = data.getStringExtra("action_id") ?: return null + var user = data.getIntExtra("user", INVALID_USER) + return fromId(value, user) + } + } +} \ No newline at end of file diff --git a/app/src/main/java/de/jrpie/android/launcher/actions/AppAction.kt b/app/src/main/java/de/jrpie/android/launcher/actions/AppAction.kt new file mode 100644 index 0000000..f1a377a --- /dev/null +++ b/app/src/main/java/de/jrpie/android/launcher/actions/AppAction.kt @@ -0,0 +1,85 @@ +package de.jrpie.android.launcher.actions + +import android.app.AlertDialog +import android.app.Service +import android.content.Context +import android.content.Intent +import android.content.SharedPreferences +import android.content.pm.LauncherApps +import android.graphics.Rect +import android.graphics.drawable.Drawable +import de.jrpie.android.launcher.INVALID_USER +import de.jrpie.android.launcher.R +import de.jrpie.android.launcher.getIntent +import de.jrpie.android.launcher.getLauncherActivityInfo +import de.jrpie.android.launcher.openAppSettings + +class AppAction(private var appInfo: AppInfo) : Action { + + override fun invoke(context: Context, rect: Rect?): Boolean { + val packageName = appInfo.packageName.toString() + val user = appInfo.user + if (user != null && user != INVALID_USER) { + val launcherApps = + context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps + getLauncherActivityInfo(packageName, user, context)?.let { app -> + launcherApps.startMainActivity(app.componentName, app.user, rect, null) + return true + } + } + + val intent = getIntent(packageName, context) + + if (intent != null) { + context.startActivity(intent) + return true + } + + if (AppInfo(packageName).isInstalled(context)) { + AlertDialog.Builder( + context, + R.style.AlertDialogCustom + ) + .setTitle(context.getString(R.string.alert_cant_open_title)) + .setMessage(context.getString(R.string.alert_cant_open_message)) + .setPositiveButton(android.R.string.ok) { _, _ -> + openAppSettings(appInfo, context) + } + .setNegativeButton(android.R.string.cancel, null) + .setIcon(android.R.drawable.ic_dialog_info) + .show() + return true + } + return false + } + + override fun label(context: Context): String { + return appInfo.label.toString() + } + + override fun getIcon(context: Context): Drawable? { + var icon: Drawable? = null + try { + icon = appInfo.getAppIcon(context) + } catch (e: Exception) { + // probably the app was uninstalled + } + return icon + } + + override fun isAvailable(context: Context): Boolean { + return appInfo.isInstalled(context) + } + + override fun bindToGesture(editor: SharedPreferences.Editor, id: String) { + val u = appInfo.user ?: INVALID_USER + editor + .putString("$id.app", appInfo.packageName.toString()) + .putInt("$id.user", u) + } + + override fun writeToIntent(intent: Intent) { + intent.putExtra("action_id", appInfo.packageName) + appInfo.user?.let { intent.putExtra("user", it) } + } +} \ No newline at end of file diff --git a/app/src/main/java/de/jrpie/android/launcher/actions/AppInfo.kt b/app/src/main/java/de/jrpie/android/launcher/actions/AppInfo.kt new file mode 100644 index 0000000..8e1e7f1 --- /dev/null +++ b/app/src/main/java/de/jrpie/android/launcher/actions/AppInfo.kt @@ -0,0 +1,49 @@ +package de.jrpie.android.launcher.actions + +import android.app.Service +import android.content.Context +import android.content.pm.LauncherApps +import android.content.pm.PackageManager +import android.graphics.drawable.Drawable +import de.jrpie.android.launcher.INVALID_USER +import de.jrpie.android.launcher.getUserFromId + +/** + * Stores information used to create [AppsRecyclerAdapter] rows. + * + * Represents an app installed on the users device. + */ +class AppInfo(var packageName: CharSequence? = null, var user: Int? = null) { + var label: CharSequence? = null + var icon: Drawable? = null + var isSystemApp: Boolean = false + + fun getAppIcon(context: Context): Drawable { + if (user != null && user != INVALID_USER) { + val launcherApps = + context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps + getUserFromId(user, context)?.let { userHandle -> + launcherApps.getActivityList(packageName.toString(), userHandle).firstOrNull() + ?.let { app -> + return app.getBadgedIcon(0) + } + } + } + return context.packageManager.getApplicationIcon(packageName.toString()) + } + + fun isInstalled(context: Context): Boolean { + /* TODO: this should also check the user */ + try { + context.packageManager.getPackageInfo( + packageName.toString(), + PackageManager.GET_ACTIVITIES + ) + return true + } catch (_: PackageManager.NameNotFoundException) { + } + return false + } + + +} \ No newline at end of file diff --git a/app/src/main/java/de/jrpie/android/launcher/actions/Gesture.kt b/app/src/main/java/de/jrpie/android/launcher/actions/Gesture.kt new file mode 100644 index 0000000..6725e27 --- /dev/null +++ b/app/src/main/java/de/jrpie/android/launcher/actions/Gesture.kt @@ -0,0 +1,222 @@ +package de.jrpie.android.launcher.actions + +import android.content.Context +import de.jrpie.android.launcher.R + +/** + * @param id internal id to serialize the action. Used as a key in shared preferences. + * @param defaultsResource res id of array of default actions for the gesture. + * @param labelResource res id of the name of the gesture. + * @param animationIn res id of transition animation (in) when using the gesture to launch an app. + * @param animationOut res id of transition animation (out) when using the gesture to launch an app. + */ +enum class Gesture( + val id: String, private val labelResource: Int, + internal val defaultsResource: Int, + private val animationIn: Int = android.R.anim.fade_in, + private val animationOut: Int = android.R.anim.fade_out +) { + VOLUME_UP( + "action.volume_up", + R.string.settings_gesture_vol_up, + R.array.default_volume_up, + 0, + 0 + ), + VOLUME_DOWN( + "action.volume_down", + R.string.settings_gesture_vol_down, + R.array.default_volume_down, 0, 0 + ), + TIME("action.time", R.string.settings_gesture_time, R.array.default_time), + DATE("action.date", R.string.settings_gesture_date, R.array.default_date), + LONG_CLICK( + "action.long_click", + R.string.settings_gesture_long_click, + R.array.default_long_click, 0, 0 + ), + DOUBLE_CLICK( + "action.double_click", + R.string.settings_gesture_double_click, + R.array.default_double_click, 0, 0 + ), + SWIPE_UP("action.up", R.string.settings_gesture_up, R.array.default_up, R.anim.bottom_up), + SWIPE_UP_LEFT_EDGE( + "action.up_left", + R.string.settings_gesture_up_left_edge, + R.array.default_up_left, + R.anim.bottom_up + ), + SWIPE_UP_RIGHT_EDGE( + "action.up_right", + R.string.settings_gesture_up_right_edge, + R.array.default_up_right, + R.anim.bottom_up + ), + SWIPE_UP_DOUBLE( + "action.double_up", + R.string.settings_gesture_double_up, + R.array.default_double_up, + R.anim.bottom_up + ), + SWIPE_DOWN( + "action.down", + R.string.settings_gesture_down, + R.array.default_down, + R.anim.top_down + ), + SWIPE_DOWN_LEFT_EDGE( + "action.down_left", + R.string.settings_gesture_down_left_edge, + R.array.default_down_left, + R.anim.top_down + ), + SWIPE_DOWN_RIGHT_EDGE( + "action.down_right", + R.string.settings_gesture_down_right_edge, + R.array.default_down_right, + R.anim.top_down + ), + SWIPE_DOWN_DOUBLE( + "action.double_down", + R.string.settings_gesture_double_down, + R.array.default_double_down, + R.anim.top_down + ), + SWIPE_LEFT( + "action.left", + R.string.settings_gesture_left, + R.array.default_left, + R.anim.right_left + ), + SWIPE_LEFT_TOP_EDGE( + "action.left_top", + R.string.settings_gesture_left_top_edge, + R.array.default_left_top, + R.anim.right_left + ), + SWIPE_LEFT_BOTTOM_EDGE( + "action.left_bottom", + R.string.settings_gesture_left_bottom_edge, + R.array.default_left_bottom, + R.anim.right_left + ), + SWIPE_LEFT_DOUBLE( + "action.double_left", + R.string.settings_gesture_double_left, + R.array.default_double_left, + R.anim.right_left + ), + SWIPE_RIGHT( + "action.right", + R.string.settings_gesture_right, + R.array.default_right, + R.anim.left_right + ), + SWIPE_RIGHT_TOP_EDGE( + "action.right_top", + R.string.settings_gesture_right_top_edge, + R.array.default_right_top, + R.anim.left_right + ), + SWIPE_RIGHT_BOTTOM_EDGE( + "action.right_bottom", + R.string.settings_gesture_right_bottom_edge, + R.array.default_right_bottom, + R.anim.left_right + ), + SWIPE_RIGHT_DOUBLE( + "action.double_right", + R.string.settings_gesture_double_right, + R.array.default_double_right, + R.anim.left_right + ); + + enum class Edge { + TOP, BOTTOM, LEFT, RIGHT + } + + fun getLabel(context: Context): String { + return context.resources.getString(this.labelResource) + } + + fun getDoubleVariant(): Gesture { + return when (this) { + SWIPE_UP -> SWIPE_UP_DOUBLE + SWIPE_DOWN -> SWIPE_DOWN_DOUBLE + SWIPE_LEFT -> SWIPE_LEFT_DOUBLE + SWIPE_RIGHT -> SWIPE_RIGHT_DOUBLE + else -> this + } + } + + fun getEdgeVariant(edge: Edge): Gesture { + return when (edge) { + Edge.TOP -> + when (this) { + SWIPE_LEFT -> SWIPE_LEFT_TOP_EDGE + SWIPE_RIGHT -> SWIPE_RIGHT_TOP_EDGE + else -> this + } + + Edge.BOTTOM -> + when (this) { + SWIPE_LEFT -> SWIPE_LEFT_BOTTOM_EDGE + SWIPE_RIGHT -> SWIPE_RIGHT_BOTTOM_EDGE + else -> this + } + + Edge.LEFT -> + when (this) { + SWIPE_UP -> SWIPE_UP_LEFT_EDGE + SWIPE_DOWN -> SWIPE_DOWN_LEFT_EDGE + else -> this + } + + Edge.RIGHT -> + when (this) { + SWIPE_UP -> SWIPE_UP_RIGHT_EDGE + SWIPE_DOWN -> SWIPE_DOWN_RIGHT_EDGE + else -> this + } + } + } + + fun isDoubleVariant(): Boolean { + return when (this) { + SWIPE_UP_DOUBLE, + SWIPE_DOWN_DOUBLE, + SWIPE_LEFT_DOUBLE, + SWIPE_RIGHT_DOUBLE -> true + + else -> false + } + } + + fun isEdgeVariant(): Boolean { + return when (this) { + SWIPE_UP_RIGHT_EDGE, + SWIPE_UP_LEFT_EDGE, + SWIPE_DOWN_LEFT_EDGE, + SWIPE_DOWN_RIGHT_EDGE, + SWIPE_LEFT_TOP_EDGE, + SWIPE_LEFT_BOTTOM_EDGE, + SWIPE_RIGHT_TOP_EDGE, + SWIPE_RIGHT_BOTTOM_EDGE -> true + + else -> false + } + } + + operator fun invoke(context: Context) { + val action = Action.forGesture(this) + Action.launch(action, context, this.animationIn, this.animationOut) + } + + companion object { + fun byId(id: String): Gesture? { + return Gesture.values().firstOrNull { it.id == id } + } + } + +} diff --git a/app/src/main/java/de/jrpie/android/launcher/actions/LauncherAction.kt b/app/src/main/java/de/jrpie/android/launcher/actions/LauncherAction.kt new file mode 100644 index 0000000..6d455eb --- /dev/null +++ b/app/src/main/java/de/jrpie/android/launcher/actions/LauncherAction.kt @@ -0,0 +1,185 @@ +package de.jrpie.android.launcher.actions + +import android.content.Context +import android.content.Intent +import android.content.SharedPreferences.Editor +import android.graphics.Rect +import android.graphics.drawable.Drawable +import android.media.AudioManager +import android.os.SystemClock +import android.view.KeyEvent +import android.widget.Toast +import de.jrpie.android.launcher.INVALID_USER +import de.jrpie.android.launcher.R +import de.jrpie.android.launcher.ui.list.ListActivity +import de.jrpie.android.launcher.ui.settings.SettingsActivity + +enum class LauncherAction( + val id: String, + val label: Int, + val icon: Int, + val launch: (Context) -> Unit +) : Action { + SETTINGS( + "launcher:settings", + R.string.list_other_settings, + R.drawable.baseline_settings_24, + ::openSettings + ), + CHOOSE( + "launcher:choose", + R.string.list_other_list, + R.drawable.baseline_menu_24, + ::openAppsList + ), + VOLUME_UP( + "launcher:volumeUp", + R.string.list_other_volume_up, + R.drawable.baseline_volume_up_24, ::audioVolumeUp + ), + VOLUME_DOWN( + "launcher:volumeDown", + R.string.list_other_volume_down, + R.drawable.baseline_volume_down_24, ::audioVolumeDown + ), + TRACK_NEXT( + "launcher:nextTrack", + R.string.list_other_track_next, + R.drawable.baseline_skip_next_24, ::audioNextTrack + ), + TRACK_PREV( + "launcher:previousTrack", + R.string.list_other_track_previous, + R.drawable.baseline_skip_previous_24, ::audioPreviousTrack + ), + EXPAND_NOTIFICATIONS_PANEL( + "launcher:expandNotificationsPanel", + R.string.list_other_expand_notifications_panel, + R.drawable.baseline_notifications_24, + ::expandNotificationsPanel + ), + NOP("launcher:nop", R.string.list_other_nop, R.drawable.baseline_not_interested_24, {}); + + override fun invoke(context: Context, rect: Rect?): Boolean { + launch(context) + return true + } + + override fun label(context: Context): String { + return context.getString(label) + } + + override fun getIcon(context: Context): Drawable? { + return context.getDrawable(icon) + } + + override fun bindToGesture(editor: Editor, id: String) { + editor + .putString("$id.app", this.id) + .putInt("$id.user", INVALID_USER) + } + + override fun writeToIntent(intent: Intent) { + intent.putExtra("action_id", id) + } + + override fun isAvailable(context: Context): Boolean { + return true + } + + companion object { + fun byId(id: String): LauncherAction? { + return LauncherAction.values().singleOrNull { it.id == id } + } + + fun isOtherAction(id: String): Boolean { + return id.startsWith("launcher") + } + } +} + + +/* Media player actions */ + +private fun audioNextTrack(context: Context) { + + val mAudioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager + + val eventTime: Long = SystemClock.uptimeMillis() + + val downEvent = + KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_NEXT, 0) + mAudioManager.dispatchMediaKeyEvent(downEvent) + + val upEvent = KeyEvent(eventTime, eventTime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_NEXT, 0) + mAudioManager.dispatchMediaKeyEvent(upEvent) +} + +private fun audioPreviousTrack(context: Context) { + val mAudioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager + + val eventTime: Long = SystemClock.uptimeMillis() + + val downEvent = + KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_MEDIA_PREVIOUS, 0) + mAudioManager.dispatchMediaKeyEvent(downEvent) + + val upEvent = + KeyEvent(eventTime, eventTime, KeyEvent.ACTION_UP, KeyEvent.KEYCODE_MEDIA_PREVIOUS, 0) + mAudioManager.dispatchMediaKeyEvent(upEvent) +} + +private fun audioVolumeUp(context: Context) { + val audioManager = + context.getSystemService(Context.AUDIO_SERVICE) as AudioManager + + audioManager.adjustStreamVolume( + AudioManager.STREAM_MUSIC, + AudioManager.ADJUST_RAISE, + AudioManager.FLAG_SHOW_UI + ) +} + +private fun audioVolumeDown(context: Context) { + val audioManager = + context.getSystemService(Context.AUDIO_SERVICE) as AudioManager + + audioManager.adjustStreamVolume( + AudioManager.STREAM_MUSIC, + AudioManager.ADJUST_LOWER, + AudioManager.FLAG_SHOW_UI + ) +} +/* End media player actions */ + +private fun expandNotificationsPanel(context: Context) { + /* https://stackoverflow.com/a/15582509 */ + try { + @Suppress("SpellCheckingInspection") + val statusBarService: Any? = context.getSystemService("statusbar") + val statusBarManager = Class.forName("android.app.StatusBarManager") + val showStatusBar = statusBarManager.getMethod("expandNotificationsPanel") + showStatusBar.invoke(statusBarService) + } catch (e: Exception) { + Toast.makeText( + context, + context.getString(R.string.alert_cant_expand_notifications_panel), + Toast.LENGTH_LONG + ).show() + } +} + + +private fun openSettings(context: Context) { + context.startActivity(Intent(context, SettingsActivity::class.java)) +} + +private fun openAppsList(context: Context) { + val intent = Intent(context, ListActivity::class.java) + intent.putExtra("intention", ListActivity.ListActivityIntention.VIEW.toString()) + context.startActivity(intent) +} + + + + diff --git a/app/src/main/java/de/jrpie/android/launcher/list/apps/AppInfo.kt b/app/src/main/java/de/jrpie/android/launcher/list/apps/AppInfo.kt deleted file mode 100644 index f19fd0e..0000000 --- a/app/src/main/java/de/jrpie/android/launcher/list/apps/AppInfo.kt +++ /dev/null @@ -1,16 +0,0 @@ -package de.jrpie.android.launcher.list.apps - -import android.graphics.drawable.Drawable - -/** - * Stores information used to create [AppsRecyclerAdapter] rows. - * - * Represents an app installed on the users device. - */ -class AppInfo { - var user: Int? = null - var label: CharSequence? = null - var packageName: CharSequence? = null - var icon: Drawable? = null - var isSystemApp: Boolean = false -} \ No newline at end of file diff --git a/app/src/main/java/de/jrpie/android/launcher/list/other/LauncherAction.kt b/app/src/main/java/de/jrpie/android/launcher/list/other/LauncherAction.kt deleted file mode 100644 index b1137f3..0000000 --- a/app/src/main/java/de/jrpie/android/launcher/list/other/LauncherAction.kt +++ /dev/null @@ -1,43 +0,0 @@ -package de.jrpie.android.launcher.list.other - -import android.app.Activity -import de.jrpie.android.launcher.R -import de.jrpie.android.launcher.audioNextTrack -import de.jrpie.android.launcher.audioPreviousTrack -import de.jrpie.android.launcher.audioVolumeDown -import de.jrpie.android.launcher.audioVolumeUp -import de.jrpie.android.launcher.expandNotificationsPanel -import de.jrpie.android.launcher.openAppsList -import de.jrpie.android.launcher.openSettings - -enum class LauncherAction(val id: String, val label: Int, val icon: Int, val launch: (Activity) -> Unit) { - SETTINGS("launcher:settings", R.string.list_other_settings, R.drawable.baseline_settings_24, ::openSettings), - CHOOSE("launcher:choose", R.string.list_other_list, R.drawable.baseline_menu_24, ::openAppsList), - VOLUME_UP("launcher:volumeUp", - R.string.list_other_volume_up, - R.drawable.baseline_volume_up_24, ::audioVolumeUp), - VOLUME_DOWN("launcher:volumeDown", - R.string.list_other_volume_down, - R.drawable.baseline_volume_down_24, ::audioVolumeDown), - TRACK_NEXT("launcher:nextTrack", - R.string.list_other_track_next, - R.drawable.baseline_skip_next_24, ::audioNextTrack), - TRACK_PREV("launcher:previousTrack", - R.string.list_other_track_previous, - R.drawable.baseline_skip_previous_24, ::audioPreviousTrack), - EXPAND_NOTIFICATIONS_PANEL("launcher:expandNotificationsPanel", - R.string.list_other_expand_notifications_panel, - R.drawable.baseline_notifications_24, - ::expandNotificationsPanel), - NOP("launcher:nop", R.string.list_other_nop, R.drawable.baseline_not_interested_24, {}); - - companion object { - fun byId(id: String): LauncherAction? { - return LauncherAction.values().singleOrNull { it.id == id } - } - - fun isOtherAction(id: String): Boolean { - return id.startsWith("launcher") - } - } -} diff --git a/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java b/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java index b63b06f..dde600f 100644 --- a/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java +++ b/app/src/main/java/de/jrpie/android/launcher/preferences/LauncherPreferences$Config.java @@ -13,44 +13,44 @@ import eu.jonahbauer.android.preference.annotations.Preferences; makeFile = true, r = R.class, value = { - @PreferenceGroup(name = "internal", prefix = "settings_internal_", suffix = "_key", value = { - @Preference(name = "started", type = boolean.class, defaultValue = "false"), - @Preference(name = "started_time", type = long.class), - @Preference(name = "version_code", type = int.class, defaultValue = "-1"), - }), - @PreferenceGroup( name = "gestures", prefix = "settings_gesture_", suffix = "_key", value = { - }), - @PreferenceGroup(name = "general", prefix = "settings_general_", suffix = "_key", value = { - @Preference(name = "choose_home_screen", type = void.class) - }), - @PreferenceGroup(name = "theme", prefix = "settings_theme_", suffix = "_key", value = { - @Preference(name = "wallpaper", type = void.class), - @Preference(name = "color_theme", type = ColorTheme.class, defaultValue = "DEFAULT"), - @Preference(name = "background", type = Background.class, defaultValue = "BLUR"), - @Preference(name = "font", type = Font.class, defaultValue = "HACK"), - @Preference(name = "monochrome_icons", type = boolean.class, defaultValue = "false"), - }), - @PreferenceGroup(name = "clock", prefix = "settings_clock_", suffix = "_key", value = { - @Preference(name = "font", type = Font.class, defaultValue = "HACK"), - @Preference(name = "date_visible", type = boolean.class, defaultValue = "true"), - @Preference(name = "time_visible", type = boolean.class, defaultValue = "true"), - @Preference(name = "flip_date_time", type = boolean.class, defaultValue = "false"), - @Preference(name = "localized", type = boolean.class, defaultValue = "false"), - @Preference(name = "show_seconds", type = boolean.class, defaultValue = "true"), - }), - @PreferenceGroup(name = "display", prefix = "settings_display_", suffix = "_key", value = { - @Preference(name = "screen_timeout_disabled", type = boolean.class, defaultValue = "false"), - @Preference(name = "full_screen", type = boolean.class, defaultValue = "true"), - @Preference(name = "rotate_screen", type = boolean.class, defaultValue = "false"), - }), - @PreferenceGroup( name = "functionality", prefix = "settings_functionality_", suffix = "_key", value = { - @Preference(name = "search_auto_launch", type = boolean.class, defaultValue = "true"), - @Preference(name = "search_auto_open_keyboard", type = boolean.class, defaultValue = "true"), - }), - @PreferenceGroup(name = "enabled_gestures", prefix = "settings_enabled_gestures_", suffix = "_key", value = { - @Preference(name = "double_swipe", type = boolean.class, defaultValue = "true"), - @Preference(name = "edge_swipe", type = boolean.class, defaultValue = "true"), - }), + @PreferenceGroup(name = "internal", prefix = "settings_internal_", suffix = "_key", value = { + @Preference(name = "started", type = boolean.class, defaultValue = "false"), + @Preference(name = "started_time", type = long.class), + @Preference(name = "version_code", type = int.class, defaultValue = "-1"), + }), + @PreferenceGroup(name = "gestures", prefix = "settings_gesture_", suffix = "_key", value = { + }), + @PreferenceGroup(name = "general", prefix = "settings_general_", suffix = "_key", value = { + @Preference(name = "choose_home_screen", type = void.class) + }), + @PreferenceGroup(name = "theme", prefix = "settings_theme_", suffix = "_key", value = { + @Preference(name = "wallpaper", type = void.class), + @Preference(name = "color_theme", type = ColorTheme.class, defaultValue = "DEFAULT"), + @Preference(name = "background", type = Background.class, defaultValue = "BLUR"), + @Preference(name = "font", type = Font.class, defaultValue = "HACK"), + @Preference(name = "monochrome_icons", type = boolean.class, defaultValue = "false"), + }), + @PreferenceGroup(name = "clock", prefix = "settings_clock_", suffix = "_key", value = { + @Preference(name = "font", type = Font.class, defaultValue = "HACK"), + @Preference(name = "date_visible", type = boolean.class, defaultValue = "true"), + @Preference(name = "time_visible", type = boolean.class, defaultValue = "true"), + @Preference(name = "flip_date_time", type = boolean.class, defaultValue = "false"), + @Preference(name = "localized", type = boolean.class, defaultValue = "false"), + @Preference(name = "show_seconds", type = boolean.class, defaultValue = "true"), + }), + @PreferenceGroup(name = "display", prefix = "settings_display_", suffix = "_key", value = { + @Preference(name = "screen_timeout_disabled", type = boolean.class, defaultValue = "false"), + @Preference(name = "full_screen", type = boolean.class, defaultValue = "true"), + @Preference(name = "rotate_screen", type = boolean.class, defaultValue = "false"), + }), + @PreferenceGroup(name = "functionality", prefix = "settings_functionality_", suffix = "_key", value = { + @Preference(name = "search_auto_launch", type = boolean.class, defaultValue = "true"), + @Preference(name = "search_auto_open_keyboard", type = boolean.class, defaultValue = "true"), + }), + @PreferenceGroup(name = "enabled_gestures", prefix = "settings_enabled_gestures_", suffix = "_key", value = { + @Preference(name = "double_swipe", type = boolean.class, defaultValue = "true"), + @Preference(name = "edge_swipe", type = boolean.class, defaultValue = "true"), + }), }) public final class LauncherPreferences$Config { } diff --git a/app/src/main/java/de/jrpie/android/launcher/preferences/Preferences.kt b/app/src/main/java/de/jrpie/android/launcher/preferences/Preferences.kt index 1115ee8..df847ec 100644 --- a/app/src/main/java/de/jrpie/android/launcher/preferences/Preferences.kt +++ b/app/src/main/java/de/jrpie/android/launcher/preferences/Preferences.kt @@ -3,8 +3,7 @@ package de.jrpie.android.launcher.preferences import android.content.Context import android.content.SharedPreferences import android.util.Log -import android.widget.Toast -import de.jrpie.android.launcher.Gesture +import de.jrpie.android.launcher.actions.Action import de.jrpie.android.launcher.preferences.theme.Background import de.jrpie.android.launcher.preferences.theme.ColorTheme @@ -17,15 +16,35 @@ const val UNKNOWN_PREFERENCE_VERSION = -1 private const val TAG = "Launcher - Preferences" -private fun migrateStringPreference(oldPrefs: SharedPreferences, newPreferences: SharedPreferences.Editor, oldKey: String, newKey: String, default: String) { +private fun migrateStringPreference( + oldPrefs: SharedPreferences, + newPreferences: SharedPreferences.Editor, + oldKey: String, + newKey: String, + default: String +) { val s = oldPrefs.getString(oldKey, default) newPreferences.putString(newKey, s) } -private fun migrateIntPreference(oldPrefs: SharedPreferences, newPreferences: SharedPreferences.Editor, oldKey: String, newKey: String, default: Int) { + +private fun migrateIntPreference( + oldPrefs: SharedPreferences, + newPreferences: SharedPreferences.Editor, + oldKey: String, + newKey: String, + default: Int +) { val s = oldPrefs.getInt(oldKey, default) newPreferences.putInt(newKey, s) } -private fun migrateBooleanPreference(oldPrefs: SharedPreferences, newPreferences: SharedPreferences.Editor, oldKey: String, newKey: String, default: Boolean) { + +private fun migrateBooleanPreference( + oldPrefs: SharedPreferences, + newPreferences: SharedPreferences.Editor, + oldKey: String, + newKey: String, + default: Boolean +) { val s = oldPrefs.getBoolean(oldKey, default) newPreferences.putBoolean(newKey, s) } @@ -33,86 +52,344 @@ private fun migrateBooleanPreference(oldPrefs: SharedPreferences, newPreferences fun migratePreferencesToNewVersion(context: Context) { when (LauncherPreferences.internal().versionCode()) { // Check versions, make sure transitions between versions go well - PREFERENCE_VERSION -> { /* the version installed and used previously are the same */ } + PREFERENCE_VERSION -> { /* the version installed and used previously are the same */ + } + UNKNOWN_PREFERENCE_VERSION -> { /* still using the old preferences file */ - Log.i(TAG, "Unknown preference version, trying to restore preferences from old version.") + Log.i( + TAG, + "Unknown preference version, trying to restore preferences from old version." + ) val oldPrefs = context.getSharedPreferences( "V3RYR4ND0MK3YCR4P", Context.MODE_PRIVATE ) - if(!oldPrefs.contains("startedBefore")) { + if (!oldPrefs.contains("startedBefore")) { Log.i(TAG, "No old preferences found.") return } val newPrefs = LauncherPreferences.getSharedPreferences().edit() - migrateBooleanPreference(oldPrefs, newPrefs, "startedBefore", "internal.started_before", false) + migrateBooleanPreference( + oldPrefs, + newPrefs, + "startedBefore", + "internal.started_before", + false + ) - migrateStringPreference(oldPrefs, newPrefs, "action_volumeUpApp", "action.volume_up.app", "") - migrateIntPreference(oldPrefs, newPrefs, "action_volumeUpApp_user", "action.volume_up.user", -1) - migrateStringPreference(oldPrefs, newPrefs, "action_volumeDownApp", "action.volume_down.app", "") - migrateIntPreference(oldPrefs, newPrefs, "action_volumeDownApp_user", "action.volume_down.user", -1) + migrateStringPreference( + oldPrefs, + newPrefs, + "action_volumeUpApp", + "action.volume_up.app", + "" + ) + migrateIntPreference( + oldPrefs, + newPrefs, + "action_volumeUpApp_user", + "action.volume_up.user", + -1 + ) + migrateStringPreference( + oldPrefs, + newPrefs, + "action_volumeDownApp", + "action.volume_down.app", + "" + ) + migrateIntPreference( + oldPrefs, + newPrefs, + "action_volumeDownApp_user", + "action.volume_down.user", + -1 + ) migrateStringPreference(oldPrefs, newPrefs, "action_timeApp", "action.time.app", "") migrateIntPreference(oldPrefs, newPrefs, "action_timeApp_user", "action.time.user", -1) migrateStringPreference(oldPrefs, newPrefs, "action_dateApp", "action.date.app", "") migrateIntPreference(oldPrefs, newPrefs, "action_dateApp_user", "action.date.user", -1) - migrateStringPreference(oldPrefs, newPrefs, "action_longClickApp", "action.long_click.app", "") - migrateIntPreference(oldPrefs, newPrefs, "action_longClickApp_user", "action.long_click.user", -1) - migrateStringPreference(oldPrefs, newPrefs, "action_doubleClickApp", "action.double_click.app", "") - migrateIntPreference(oldPrefs, newPrefs, "action_doubleClickApp_user", "action.double_click.user", -1) + migrateStringPreference( + oldPrefs, + newPrefs, + "action_longClickApp", + "action.long_click.app", + "" + ) + migrateIntPreference( + oldPrefs, + newPrefs, + "action_longClickApp_user", + "action.long_click.user", + -1 + ) + migrateStringPreference( + oldPrefs, + newPrefs, + "action_doubleClickApp", + "action.double_click.app", + "" + ) + migrateIntPreference( + oldPrefs, + newPrefs, + "action_doubleClickApp_user", + "action.double_click.user", + -1 + ) migrateStringPreference(oldPrefs, newPrefs, "action_upApp", "action.up.app", "") migrateIntPreference(oldPrefs, newPrefs, "action_upApp_user", "action.up.user", -1) - migrateStringPreference(oldPrefs, newPrefs, "action_up_leftApp", "action.up_left.app", "") - migrateIntPreference(oldPrefs, newPrefs, "action_up_leftApp_user", "action.up_left.user", -1) - migrateStringPreference(oldPrefs, newPrefs, "action_up_rightApp", "action.up_right.app", "") - migrateIntPreference(oldPrefs, newPrefs, "action_up_rightApp_user", "action.up_right.user", -1) - migrateStringPreference(oldPrefs, newPrefs, "action_doubleUpApp", "action.double_up.app", "") - migrateIntPreference(oldPrefs, newPrefs, "action_doubleUpApp_user", "action.double_up.user", -1) + migrateStringPreference( + oldPrefs, + newPrefs, + "action_up_leftApp", + "action.up_left.app", + "" + ) + migrateIntPreference( + oldPrefs, + newPrefs, + "action_up_leftApp_user", + "action.up_left.user", + -1 + ) + migrateStringPreference( + oldPrefs, + newPrefs, + "action_up_rightApp", + "action.up_right.app", + "" + ) + migrateIntPreference( + oldPrefs, + newPrefs, + "action_up_rightApp_user", + "action.up_right.user", + -1 + ) + migrateStringPreference( + oldPrefs, + newPrefs, + "action_doubleUpApp", + "action.double_up.app", + "" + ) + migrateIntPreference( + oldPrefs, + newPrefs, + "action_doubleUpApp_user", + "action.double_up.user", + -1 + ) migrateStringPreference(oldPrefs, newPrefs, "action_downApp", "action.down.app", "") migrateIntPreference(oldPrefs, newPrefs, "action_downApp_user", "action.down.user", -1) - migrateStringPreference(oldPrefs, newPrefs, "action_down_leftApp", "action.down_left.app", "") - migrateIntPreference(oldPrefs, newPrefs, "action_down_leftApp_user", "action.down_left.user", -1) - migrateStringPreference(oldPrefs, newPrefs, "action_down_rightApp", "action.down_right.app", "") - migrateIntPreference(oldPrefs, newPrefs, "action_down_rightApp_user", "action.down_right.user", -1) - migrateStringPreference(oldPrefs, newPrefs, "action_doubleDownApp", "action.double_down.app", "") - migrateIntPreference(oldPrefs, newPrefs, "action_doubleDownApp_user", "action.double_down.user", -1) + migrateStringPreference( + oldPrefs, + newPrefs, + "action_down_leftApp", + "action.down_left.app", + "" + ) + migrateIntPreference( + oldPrefs, + newPrefs, + "action_down_leftApp_user", + "action.down_left.user", + -1 + ) + migrateStringPreference( + oldPrefs, + newPrefs, + "action_down_rightApp", + "action.down_right.app", + "" + ) + migrateIntPreference( + oldPrefs, + newPrefs, + "action_down_rightApp_user", + "action.down_right.user", + -1 + ) + migrateStringPreference( + oldPrefs, + newPrefs, + "action_doubleDownApp", + "action.double_down.app", + "" + ) + migrateIntPreference( + oldPrefs, + newPrefs, + "action_doubleDownApp_user", + "action.double_down.user", + -1 + ) migrateStringPreference(oldPrefs, newPrefs, "action_leftApp", "action.left.app", "") migrateIntPreference(oldPrefs, newPrefs, "action_leftApp_user", "action.left.user", -1) - migrateStringPreference(oldPrefs, newPrefs, "action_left_topApp", "action.left_top.app", "") - migrateIntPreference(oldPrefs, newPrefs, "action_left_topApp_user", "action.left_top.user", -1) - migrateStringPreference(oldPrefs, newPrefs, "action_left_bottomApp", "action.left_bottom.app", "") - migrateIntPreference(oldPrefs, newPrefs, "action_left_bottomApp_user", "action.left_bottom.user", -1) - migrateStringPreference(oldPrefs, newPrefs, "action_doubleLeftApp", "action.double_left.app", "") - migrateIntPreference(oldPrefs, newPrefs, "action_doubleLeftApp_user", "action.double_left.user", -1) + migrateStringPreference( + oldPrefs, + newPrefs, + "action_left_topApp", + "action.left_top.app", + "" + ) + migrateIntPreference( + oldPrefs, + newPrefs, + "action_left_topApp_user", + "action.left_top.user", + -1 + ) + migrateStringPreference( + oldPrefs, + newPrefs, + "action_left_bottomApp", + "action.left_bottom.app", + "" + ) + migrateIntPreference( + oldPrefs, + newPrefs, + "action_left_bottomApp_user", + "action.left_bottom.user", + -1 + ) + migrateStringPreference( + oldPrefs, + newPrefs, + "action_doubleLeftApp", + "action.double_left.app", + "" + ) + migrateIntPreference( + oldPrefs, + newPrefs, + "action_doubleLeftApp_user", + "action.double_left.user", + -1 + ) migrateStringPreference(oldPrefs, newPrefs, "action_rightApp", "action.right.app", "") - migrateIntPreference(oldPrefs, newPrefs, "action_rightApp_user", "action.right.user", -1) - migrateStringPreference(oldPrefs, newPrefs, "action_right_topApp", "action.right_top.app", "") - migrateIntPreference(oldPrefs, newPrefs, "action_right_topApp_user", "action.right_top.user", -1) - migrateStringPreference(oldPrefs, newPrefs, "action_right_bottomApp", "action.right_bottom.app", "") - migrateIntPreference(oldPrefs, newPrefs, "action_right_bottomApp_user", "action.right_bottom.user", -1) - migrateStringPreference(oldPrefs, newPrefs, "action_doubleRightApp", "action.double_right.app", "") - migrateIntPreference(oldPrefs, newPrefs, "action_doubleRightApp_user", "action.double_right.user", -1) + migrateIntPreference( + oldPrefs, + newPrefs, + "action_rightApp_user", + "action.right.user", + -1 + ) + migrateStringPreference( + oldPrefs, + newPrefs, + "action_right_topApp", + "action.right_top.app", + "" + ) + migrateIntPreference( + oldPrefs, + newPrefs, + "action_right_topApp_user", + "action.right_top.user", + -1 + ) + migrateStringPreference( + oldPrefs, + newPrefs, + "action_right_bottomApp", + "action.right_bottom.app", + "" + ) + migrateIntPreference( + oldPrefs, + newPrefs, + "action_right_bottomApp_user", + "action.right_bottom.user", + -1 + ) + migrateStringPreference( + oldPrefs, + newPrefs, + "action_doubleRightApp", + "action.double_right.app", + "" + ) + migrateIntPreference( + oldPrefs, + newPrefs, + "action_doubleRightApp_user", + "action.double_right.user", + -1 + ) migrateBooleanPreference(oldPrefs, newPrefs, "timeVisible", "clock.time_visible", true) migrateBooleanPreference(oldPrefs, newPrefs, "dateVisible", "clock.date_visible", true) - migrateBooleanPreference(oldPrefs, newPrefs, "dateLocalized", "clock.date_localized", false) - migrateBooleanPreference(oldPrefs, newPrefs, "dateTimeFlip", "clock.date_time_flip", false) - migrateBooleanPreference(oldPrefs, newPrefs, "disableTimeout", "display.disable_timeout", false) - migrateBooleanPreference(oldPrefs, newPrefs, "useFullScreen", "display.use_full_screen", true) - migrateBooleanPreference(oldPrefs, newPrefs, "enableDoubleActions", "enabled_gestures.double_actions", true) - migrateBooleanPreference(oldPrefs, newPrefs, "enableEdgeActions", "enabled_gestures.edge_actions", true) - migrateBooleanPreference(oldPrefs, newPrefs, "searchAutoLaunch", "functionality.search_auto_launch", true) - migrateBooleanPreference(oldPrefs, newPrefs, "searchAutoKeyboard", "functionality.search_auto_keyboard", true) + migrateBooleanPreference( + oldPrefs, + newPrefs, + "dateLocalized", + "clock.date_localized", + false + ) + migrateBooleanPreference( + oldPrefs, + newPrefs, + "dateTimeFlip", + "clock.date_time_flip", + false + ) + migrateBooleanPreference( + oldPrefs, + newPrefs, + "disableTimeout", + "display.disable_timeout", + false + ) + migrateBooleanPreference( + oldPrefs, + newPrefs, + "useFullScreen", + "display.use_full_screen", + true + ) + migrateBooleanPreference( + oldPrefs, + newPrefs, + "enableDoubleActions", + "enabled_gestures.double_actions", + true + ) + migrateBooleanPreference( + oldPrefs, + newPrefs, + "enableEdgeActions", + "enabled_gestures.edge_actions", + true + ) + migrateBooleanPreference( + oldPrefs, + newPrefs, + "searchAutoLaunch", + "functionality.search_auto_launch", + true + ) + migrateBooleanPreference( + oldPrefs, + newPrefs, + "searchAutoKeyboard", + "functionality.search_auto_keyboard", + true + ) newPrefs.apply() - when(oldPrefs.getString("theme", "finn")) { + when (oldPrefs.getString("theme", "finn")) { "finn" -> { LauncherPreferences.theme().colorTheme(ColorTheme.DEFAULT) LauncherPreferences.theme().monochromeIcons(false) LauncherPreferences.theme().background(Background.BLUR) } + "dark" -> { LauncherPreferences.theme().colorTheme(ColorTheme.DARK) LauncherPreferences.theme().monochromeIcons(true) @@ -127,6 +404,7 @@ fun migratePreferencesToNewVersion(context: Context) { // show the new tutorial // context.startActivity(Intent(context, TutorialActivity::class.java)) } + else -> {} } } @@ -135,8 +413,6 @@ fun resetPreferences(context: Context) { Log.i(TAG, "resetting preferences") LauncherPreferences.clear() LauncherPreferences.internal().versionCode(PREFERENCE_VERSION) - val editor = LauncherPreferences.getSharedPreferences().edit() - Gesture.values().forEach { editor.putString(it.id + ".app", it.pickDefaultApp(context)) } - Gesture.values().forEach { editor.putInt(it.id + ".user", -1) } - editor.apply() + + Action.resetToDefaultActions(context) } diff --git a/app/src/main/java/de/jrpie/android/launcher/HomeActivity.kt b/app/src/main/java/de/jrpie/android/launcher/ui/HomeActivity.kt similarity index 80% rename from app/src/main/java/de/jrpie/android/launcher/HomeActivity.kt rename to app/src/main/java/de/jrpie/android/launcher/ui/HomeActivity.kt index fd02fa4..f2fe06e 100644 --- a/app/src/main/java/de/jrpie/android/launcher/HomeActivity.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/HomeActivity.kt @@ -1,29 +1,32 @@ -package de.jrpie.android.launcher +package de.jrpie.android.launcher.ui -import android.content.Intent import android.content.SharedPreferences import android.content.res.Resources import android.os.AsyncTask import android.os.Bundle +import android.util.DisplayMetrics import android.view.GestureDetector import android.view.KeyEvent import android.view.MotionEvent import androidx.appcompat.app.AppCompatActivity import androidx.core.view.GestureDetectorCompat import androidx.core.view.isVisible +import de.jrpie.android.launcher.R +import de.jrpie.android.launcher.actions.Gesture +import de.jrpie.android.launcher.actions.LauncherAction import de.jrpie.android.launcher.databinding.HomeBinding -import de.jrpie.android.launcher.list.other.LauncherAction +import de.jrpie.android.launcher.loadApps +import de.jrpie.android.launcher.openTutorial import de.jrpie.android.launcher.preferences.LauncherPreferences -import de.jrpie.android.launcher.tutorial.TutorialActivity +import de.jrpie.android.launcher.preferences.migratePreferencesToNewVersion +import de.jrpie.android.launcher.preferences.resetPreferences +import de.jrpie.android.launcher.ui.tutorial.TutorialActivity import java.text.SimpleDateFormat import java.util.* import kotlin.concurrent.fixedRateTimer import kotlin.math.abs import kotlin.math.max import kotlin.math.min -import android.util.DisplayMetrics -import de.jrpie.android.launcher.preferences.migratePreferencesToNewVersion -import de.jrpie.android.launcher.preferences.resetPreferences /** @@ -38,15 +41,16 @@ import de.jrpie.android.launcher.preferences.resetPreferences * - Setting global variables (preferences etc.) * - Opening the [TutorialActivity] on new installations */ -class HomeActivity: UIObject, AppCompatActivity(), +class HomeActivity : UIObject, AppCompatActivity(), GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener { private lateinit var binding: HomeBinding private var sharedPreferencesListener = SharedPreferences.OnSharedPreferenceChangeListener { _, prefKey -> - if(prefKey?.startsWith("clock.") == true || - prefKey?.startsWith("display.") == true) { + if (prefKey?.startsWith("clock.") == true || + prefKey?.startsWith("display.") == true + ) { recreate() } } @@ -70,7 +74,7 @@ class HomeActivity: UIObject, AppCompatActivity(), resetPreferences(this) LauncherPreferences.internal().started(true) - startActivity(Intent(this, TutorialActivity::class.java)) + openTutorial(this) } // Preload apps to speed up the Apps Recycler @@ -82,7 +86,7 @@ class HomeActivity: UIObject, AppCompatActivity(), } - override fun onStart(){ + override fun onStart() { super.onStart() mDetector = GestureDetectorCompat(this, this) @@ -90,7 +94,8 @@ class HomeActivity: UIObject, AppCompatActivity(), super.onStart() - LauncherPreferences.getSharedPreferences().registerOnSharedPreferenceChangeListener(sharedPreferencesListener) + LauncherPreferences.getSharedPreferences() + .registerOnSharedPreferenceChangeListener(sharedPreferencesListener) } private fun updateClock() { @@ -120,7 +125,7 @@ class HomeActivity: UIObject, AppCompatActivity(), var upperVisible = dateVisible var lowerVisible = timeVisible - if(LauncherPreferences.clock().flipDateTime()) { + if (LauncherPreferences.clock().flipDateTime()) { upperFormat = lowerFormat.also { lowerFormat = upperFormat } upperVisible = lowerVisible.also { lowerVisible = upperVisible } } @@ -162,7 +167,8 @@ class HomeActivity: UIObject, AppCompatActivity(), } override fun onDestroy() { - LauncherPreferences.getSharedPreferences().unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener) + LauncherPreferences.getSharedPreferences() + .unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener) super.onDestroy() } @@ -180,7 +186,6 @@ class HomeActivity: UIObject, AppCompatActivity(), if (e1 == null) return false - val displayMetrics: DisplayMetrics? = DisplayMetrics() windowManager.defaultDisplay.getMetrics(displayMetrics) @@ -194,7 +199,7 @@ class HomeActivity: UIObject, AppCompatActivity(), val edgeActions = LauncherPreferences.enabled_gestures().edgeSwipe() val edgeStrictness = 0.15 - var gesture = if(abs(diffX) > abs(diffY)) { // horizontal swipe + var gesture = if (abs(diffX) > abs(diffY)) { // horizontal swipe if (diffX > width / 4) Gesture.SWIPE_LEFT else if (diffX < -width / 4) @@ -214,16 +219,16 @@ class HomeActivity: UIObject, AppCompatActivity(), } if (edgeActions) { - if(max(e1.x, e2.x) < edgeStrictness * width){ - gesture = gesture?.let{it.getEdgeVariant(Gesture.Edge.LEFT)} - } else if (min(e1.x, e2.x) > (1-edgeStrictness) * width){ - gesture = gesture?.let{it.getEdgeVariant(Gesture.Edge.RIGHT)} + if (max(e1.x, e2.x) < edgeStrictness * width) { + gesture = gesture?.let { it.getEdgeVariant(Gesture.Edge.LEFT) } + } else if (min(e1.x, e2.x) > (1 - edgeStrictness) * width) { + gesture = gesture?.let { it.getEdgeVariant(Gesture.Edge.RIGHT) } } - if(max(e1.y, e2.y) < edgeStrictness * height){ - gesture = gesture?.let{it.getEdgeVariant(Gesture.Edge.TOP)} - } else if (min(e1.y, e2.y) > (1-edgeStrictness) * height){ - gesture = gesture?.let{it.getEdgeVariant(Gesture.Edge.BOTTOM)} + if (max(e1.y, e2.y) < edgeStrictness * height) { + gesture = gesture?.let { it.getEdgeVariant(Gesture.Edge.TOP) } + } else if (min(e1.y, e2.y) > (1 - edgeStrictness) * height) { + gesture = gesture?.let { it.getEdgeVariant(Gesture.Edge.BOTTOM) } } } gesture?.invoke(this) @@ -257,13 +262,17 @@ class HomeActivity: UIObject, AppCompatActivity(), } } - return if (mDetector.onTouchEvent(event)) { false } else { super.onTouchEvent(event) } + return if (mDetector.onTouchEvent(event)) { + false + } else { + super.onTouchEvent(event) + } } override fun setOnClicks() { binding.homeUpperView.setOnClickListener { - if(LauncherPreferences.clock().flipDateTime()) { + if (LauncherPreferences.clock().flipDateTime()) { Gesture.TIME(this) } else { Gesture.DATE(this) @@ -271,7 +280,7 @@ class HomeActivity: UIObject, AppCompatActivity(), } binding.homeLowerView.setOnClickListener { - if(LauncherPreferences.clock().flipDateTime()) { + if (LauncherPreferences.clock().flipDateTime()) { Gesture.DATE(this) } else { Gesture.TIME(this) @@ -281,11 +290,22 @@ class HomeActivity: UIObject, AppCompatActivity(), /* TODO: Remove those. For now they are necessary * because this inherits from GestureDetector.OnGestureListener */ - override fun onDoubleTapEvent(event: MotionEvent): Boolean { return false } - override fun onDown(event: MotionEvent): Boolean { return false } - override fun onScroll(e1: MotionEvent?, e2: MotionEvent, dX: Float, dY: Float): Boolean { return false } + override fun onDoubleTapEvent(event: MotionEvent): Boolean { + return false + } + + override fun onDown(event: MotionEvent): Boolean { + return false + } + + override fun onScroll(e1: MotionEvent?, e2: MotionEvent, dX: Float, dY: Float): Boolean { + return false + } + override fun onShowPress(event: MotionEvent) {} - override fun onSingleTapUp(event: MotionEvent): Boolean { return false } + override fun onSingleTapUp(event: MotionEvent): Boolean { + return false + } override fun isHomeScreen(): Boolean { return true diff --git a/app/src/main/java/de/jrpie/android/launcher/UIObject.kt b/app/src/main/java/de/jrpie/android/launcher/ui/UIObject.kt similarity index 94% rename from app/src/main/java/de/jrpie/android/launcher/UIObject.kt rename to app/src/main/java/de/jrpie/android/launcher/ui/UIObject.kt index f661572..94bf347 100644 --- a/app/src/main/java/de/jrpie/android/launcher/UIObject.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/UIObject.kt @@ -1,9 +1,8 @@ -package de.jrpie.android.launcher +package de.jrpie.android.launcher.ui import android.app.Activity import android.content.pm.ActivityInfo import android.content.res.Resources -import android.os.Build import android.view.Window import android.view.WindowManager import de.jrpie.android.launcher.preferences.LauncherPreferences @@ -51,6 +50,7 @@ interface UIObject { setOnClicks() adjustLayout() } + fun modifyTheme(theme: Resources.Theme): Resources.Theme { LauncherPreferences.theme().colorTheme().applyToTheme(theme) LauncherPreferences.theme().background().applyToTheme(theme) @@ -60,8 +60,8 @@ interface UIObject { } // fun applyTheme() { } - fun setOnClicks() { } - fun adjustLayout() { } + fun setOnClicks() {} + fun adjustLayout() {} fun isHomeScreen(): Boolean { return false diff --git a/app/src/main/java/de/jrpie/android/launcher/list/ListActivity.kt b/app/src/main/java/de/jrpie/android/launcher/ui/list/ListActivity.kt similarity index 91% rename from app/src/main/java/de/jrpie/android/launcher/list/ListActivity.kt rename to app/src/main/java/de/jrpie/android/launcher/ui/list/ListActivity.kt index 1bc304e..fbe9e28 100644 --- a/app/src/main/java/de/jrpie/android/launcher/list/ListActivity.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/list/ListActivity.kt @@ -1,4 +1,4 @@ -package de.jrpie.android.launcher.list +package de.jrpie.android.launcher.ui.list import android.app.Activity import android.content.Context @@ -17,12 +17,12 @@ import androidx.viewpager.widget.ViewPager import com.google.android.material.tabs.TabLayout import de.jrpie.android.launcher.R import de.jrpie.android.launcher.REQUEST_UNINSTALL -import de.jrpie.android.launcher.UIObject +import de.jrpie.android.launcher.actions.LauncherAction import de.jrpie.android.launcher.databinding.ListBinding -import de.jrpie.android.launcher.list.apps.ListFragmentApps -import de.jrpie.android.launcher.list.other.LauncherAction -import de.jrpie.android.launcher.list.other.ListFragmentOther import de.jrpie.android.launcher.preferences.LauncherPreferences +import de.jrpie.android.launcher.ui.UIObject +import de.jrpie.android.launcher.ui.list.apps.ListFragmentApps +import de.jrpie.android.launcher.ui.list.other.ListFragmentOther // TODO: Better solution for this intercommunication functionality (used in list-fragments) @@ -44,6 +44,7 @@ class ListActivity : AppCompatActivity(), UIObject { VIEW(R.string.list_title_view), /* view list of apps */ PICK(R.string.list_title_pick) /* choose app or action to associate to a gesture */ } + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -66,7 +67,8 @@ class ListActivity : AppCompatActivity(), UIObject { binding.listContainer.context.resources.displayMetrics.heightPixels val diff = height - r.bottom if (diff != 0 && - LauncherPreferences.display().fullScreen()) { + LauncherPreferences.display().fullScreen() + ) { if (binding.listContainer.paddingBottom !== diff) { binding.listContainer.setPadding(0, 0, 0, diff) } @@ -80,7 +82,7 @@ class ListActivity : AppCompatActivity(), UIObject { } - override fun onStart(){ + override fun onStart() { super.onStart() super.onStart() } @@ -146,11 +148,11 @@ private val TAB_TITLES = arrayOf( * The [ListSectionsPagerAdapter] returns the fragment, * which corresponds to the selected tab in [ListActivity]. */ -class ListSectionsPagerAdapter(private val context: Context, fm: FragmentManager) - : FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { +class ListSectionsPagerAdapter(private val context: Context, fm: FragmentManager) : + FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { override fun getItem(position: Int): Fragment { - return when (position){ + return when (position) { 0 -> ListFragmentApps() 1 -> ListFragmentOther() else -> Fragment() diff --git a/app/src/main/java/de/jrpie/android/launcher/list/apps/AppsRecyclerAdapter.kt b/app/src/main/java/de/jrpie/android/launcher/ui/list/apps/AppsRecyclerAdapter.kt similarity index 71% rename from app/src/main/java/de/jrpie/android/launcher/list/apps/AppsRecyclerAdapter.kt rename to app/src/main/java/de/jrpie/android/launcher/ui/list/apps/AppsRecyclerAdapter.kt index 86fdb6f..5c1cc9a 100644 --- a/app/src/main/java/de/jrpie/android/launcher/list/apps/AppsRecyclerAdapter.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/list/apps/AppsRecyclerAdapter.kt @@ -1,4 +1,4 @@ -package de.jrpie.android.launcher.list.apps +package de.jrpie.android.launcher.ui.list.apps import android.app.Activity import android.content.Intent @@ -14,14 +14,14 @@ import android.widget.TextView import androidx.recyclerview.widget.RecyclerView import de.jrpie.android.launcher.R import de.jrpie.android.launcher.REQUEST_CHOOSE_APP +import de.jrpie.android.launcher.actions.AppAction +import de.jrpie.android.launcher.actions.AppInfo import de.jrpie.android.launcher.appsList -import de.jrpie.android.launcher.launch -import de.jrpie.android.launcher.launchApp -import de.jrpie.android.launcher.list.ListActivity import de.jrpie.android.launcher.loadApps import de.jrpie.android.launcher.openAppSettings import de.jrpie.android.launcher.preferences.LauncherPreferences import de.jrpie.android.launcher.transformGrayscale +import de.jrpie.android.launcher.ui.list.ListActivity import de.jrpie.android.launcher.uninstallApp import java.util.* import kotlin.text.Regex.Companion.escapeReplacement @@ -34,10 +34,12 @@ import kotlin.text.Regex.Companion.escapeReplacement * @param intention - why the list is displayed ("view", "pick") * @param forGesture - the action which an app is chosen for (when the intention is "pick") */ -class AppsRecyclerAdapter(val activity: Activity, - private val intention: ListActivity.ListActivityIntention - = ListActivity.ListActivityIntention.VIEW, - private val forGesture: String? = ""): +class AppsRecyclerAdapter( + val activity: Activity, + private val intention: ListActivity.ListActivityIntention + = ListActivity.ListActivityIntention.VIEW, + private val forGesture: String? = "" +) : RecyclerView.Adapter() { private val appsListDisplayed: MutableList @@ -53,7 +55,9 @@ class AppsRecyclerAdapter(val activity: Activity, selectItem(adapterPosition, rect) } - init { itemView.setOnClickListener(this) } + init { + itemView.setOnClickListener(this) + } } override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) { @@ -72,16 +76,35 @@ class AppsRecyclerAdapter(val activity: Activity, // decide when to show the options popup menu about if (intention == ListActivity.ListActivityIntention.VIEW) { - viewHolder.textView.setOnLongClickListener{ showOptionsPopup(viewHolder, appPackageName, appUser, isSystemApp) } - viewHolder.img.setOnLongClickListener{ showOptionsPopup(viewHolder, appPackageName, appUser, isSystemApp) } + viewHolder.textView.setOnLongClickListener { + showOptionsPopup( + viewHolder, + appPackageName, + appUser, + isSystemApp + ) + } + viewHolder.img.setOnLongClickListener { + showOptionsPopup( + viewHolder, + appPackageName, + appUser, + isSystemApp + ) + } // ensure onClicks are actually caught - viewHolder.textView.setOnClickListener{ viewHolder.onClick(viewHolder.textView) } - viewHolder.img.setOnClickListener{ viewHolder.onClick(viewHolder.img) } + viewHolder.textView.setOnClickListener { viewHolder.onClick(viewHolder.textView) } + viewHolder.img.setOnClickListener { viewHolder.onClick(viewHolder.img) } } } @Suppress("SameReturnValue") - private fun showOptionsPopup(viewHolder: ViewHolder, appPackageName: String, user: Int?, isSystemApp: Boolean): Boolean { + private fun showOptionsPopup( + viewHolder: ViewHolder, + appPackageName: String, + user: Int?, + isSystemApp: Boolean + ): Boolean { //create the popup menu val popup = PopupMenu(activity, viewHolder.img) @@ -94,13 +117,15 @@ class AppsRecyclerAdapter(val activity: Activity, popup.setOnMenuItemClickListener { when (it.itemId) { R.id.app_menu_delete -> { - uninstallApp(appPackageName, user, activity) + uninstallApp(AppInfo(appPackageName, user), activity) true } + R.id.app_menu_info -> { - openAppSettings(appPackageName, user, activity) + openAppSettings(AppInfo(appPackageName, user), activity) true } + else -> false } } @@ -109,7 +134,9 @@ class AppsRecyclerAdapter(val activity: Activity, return true } - override fun getItemCount(): Int { return appsListDisplayed.size } + override fun getItemCount(): Int { + return appsListDisplayed.size + } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val inflater = LayoutInflater.from(parent.context) @@ -131,19 +158,18 @@ class AppsRecyclerAdapter(val activity: Activity, } fun selectItem(pos: Int, rect: Rect = Rect()) { - if(pos >= appsListDisplayed.size) { + if (pos >= appsListDisplayed.size) { return } - val appPackageName = appsListDisplayed[pos].packageName.toString() - val appUser = appsListDisplayed[pos].user - when (intention){ + val appInfo = appsListDisplayed[pos] + when (intention) { ListActivity.ListActivityIntention.VIEW -> { - launchApp(appPackageName, appUser, activity, rect) + AppAction(appInfo).invoke(activity, rect) } + ListActivity.ListActivityIntention.PICK -> { val returnIntent = Intent() - returnIntent.putExtra("value", appPackageName) - appUser?.let{ returnIntent.putExtra("user", it) } + AppAction(appInfo).writeToIntent(returnIntent) returnIntent.putExtra("forGesture", forGesture) activity.setResult(REQUEST_CHOOSE_APP, returnIntent) activity.finish() @@ -160,12 +186,12 @@ class AppsRecyclerAdapter(val activity: Activity, .lowercase(Locale.ROOT) .toCharArray() .distinct() - .filter { c -> ! ((c in 'a'..'z') || (c in '0'..'9')) } - .map { c -> escapeReplacement(c.toString())} - .fold("") { x,y -> x+y } + .filter { c -> !((c in 'a'..'z') || (c in '0'..'9')) } + .map { c -> escapeReplacement(c.toString()) } + .fold("") { x, y -> x + y } var disallowedCharsRegex = "[^a-z0-9$allowedSpecialCharacters]".toRegex() - fun normalize(text: String): String{ + fun normalize(text: String): String { return text.lowercase(Locale.ROOT).replace(disallowedCharsRegex, "") } appsListDisplayed.clear() @@ -179,7 +205,7 @@ class AppsRecyclerAdapter(val activity: Activity, if (itemLabel.startsWith(normalizedText)) { appsListDisplayed.add(item) - }else if(itemLabel.contains(normalizedText)){ + } else if (itemLabel.contains(normalizedText)) { appsSecondary.add(item) } } @@ -187,11 +213,13 @@ class AppsRecyclerAdapter(val activity: Activity, } if (appsListDisplayed.size == 1 && intention == ListActivity.ListActivityIntention.VIEW - && LauncherPreferences.functionality().searchAutoLaunch()) { + && LauncherPreferences.functionality().searchAutoLaunch() + ) { val info = appsListDisplayed[0] - launch(info.packageName.toString(), info.user, activity) + AppAction(info).invoke(activity) - val inputMethodManager = activity.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager + val inputMethodManager = + activity.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager inputMethodManager.hideSoftInputFromWindow(View(activity).windowToken, 0) } diff --git a/app/src/main/java/de/jrpie/android/launcher/list/apps/ListFragmentApps.kt b/app/src/main/java/de/jrpie/android/launcher/ui/list/apps/ListFragmentApps.kt similarity index 87% rename from app/src/main/java/de/jrpie/android/launcher/list/apps/ListFragmentApps.kt rename to app/src/main/java/de/jrpie/android/launcher/ui/list/apps/ListFragmentApps.kt index 72f3f48..6712e2c 100644 --- a/app/src/main/java/de/jrpie/android/launcher/list/apps/ListFragmentApps.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/list/apps/ListFragmentApps.kt @@ -1,4 +1,4 @@ -package de.jrpie.android.launcher.list.apps +package de.jrpie.android.launcher.ui.list.apps import android.os.Bundle import android.view.LayoutInflater @@ -6,13 +6,13 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager -import de.jrpie.android.launcher.UIObject import de.jrpie.android.launcher.databinding.ListAppsBinding -import de.jrpie.android.launcher.list.ListActivity -import de.jrpie.android.launcher.list.forGesture -import de.jrpie.android.launcher.list.intention import de.jrpie.android.launcher.openSoftKeyboard import de.jrpie.android.launcher.preferences.LauncherPreferences +import de.jrpie.android.launcher.ui.UIObject +import de.jrpie.android.launcher.ui.list.ListActivity +import de.jrpie.android.launcher.ui.list.forGesture +import de.jrpie.android.launcher.ui.list.intention /** @@ -36,7 +36,7 @@ class ListFragmentApps : Fragment(), UIObject { super.onStart() } - override fun setOnClicks() { } + override fun setOnClicks() {} override fun adjustLayout() { @@ -66,7 +66,8 @@ class ListFragmentApps : Fragment(), UIObject { }) if (intention == ListActivity.ListActivityIntention.VIEW - && LauncherPreferences.functionality().searchAutoOpenKeyboard()){ + && LauncherPreferences.functionality().searchAutoOpenKeyboard() + ) { openSoftKeyboard(requireContext(), binding.listAppsSearchview) } } diff --git a/app/src/main/java/de/jrpie/android/launcher/list/other/ListFragmentOther.kt b/app/src/main/java/de/jrpie/android/launcher/ui/list/other/ListFragmentOther.kt similarity index 94% rename from app/src/main/java/de/jrpie/android/launcher/list/other/ListFragmentOther.kt rename to app/src/main/java/de/jrpie/android/launcher/ui/list/other/ListFragmentOther.kt index 2c73aea..097f9c5 100644 --- a/app/src/main/java/de/jrpie/android/launcher/list/other/ListFragmentOther.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/list/other/ListFragmentOther.kt @@ -1,4 +1,4 @@ -package de.jrpie.android.launcher.list.other +package de.jrpie.android.launcher.ui.list.other import android.os.Bundle import android.view.LayoutInflater @@ -6,7 +6,6 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import androidx.recyclerview.widget.LinearLayoutManager -import de.jrpie.android.launcher.R import de.jrpie.android.launcher.databinding.ListOtherBinding /** diff --git a/app/src/main/java/de/jrpie/android/launcher/list/other/OtherRecyclerAdapter.kt b/app/src/main/java/de/jrpie/android/launcher/ui/list/other/OtherRecyclerAdapter.kt similarity index 77% rename from app/src/main/java/de/jrpie/android/launcher/list/other/OtherRecyclerAdapter.kt rename to app/src/main/java/de/jrpie/android/launcher/ui/list/other/OtherRecyclerAdapter.kt index 0b54fa6..ddfcfd1 100644 --- a/app/src/main/java/de/jrpie/android/launcher/list/other/OtherRecyclerAdapter.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/list/other/OtherRecyclerAdapter.kt @@ -1,4 +1,4 @@ -package de.jrpie.android.launcher.list.other +package de.jrpie.android.launcher.ui.list.other import android.app.Activity import android.content.Intent @@ -8,10 +8,10 @@ import android.view.ViewGroup import android.widget.ImageView import android.widget.TextView import androidx.recyclerview.widget.RecyclerView -import de.jrpie.android.launcher.INVALID_USER import de.jrpie.android.launcher.R import de.jrpie.android.launcher.REQUEST_CHOOSE_APP -import de.jrpie.android.launcher.list.forGesture +import de.jrpie.android.launcher.actions.LauncherAction +import de.jrpie.android.launcher.ui.list.forGesture /** * The [OtherRecyclerAdapter] will only be displayed in the ListActivity, @@ -20,7 +20,7 @@ import de.jrpie.android.launcher.list.forGesture * It lists `other` things to be launched that are not really represented by a URI, * rather by Launcher- internal conventions. */ -class OtherRecyclerAdapter(val activity: Activity): +class OtherRecyclerAdapter(val activity: Activity) : RecyclerView.Adapter() { private val othersList: Array = LauncherAction.values() @@ -35,10 +35,12 @@ class OtherRecyclerAdapter(val activity: Activity): val pos = adapterPosition val content = othersList[pos] - forGesture?.let { returnChoiceIntent(it, content.id) } + forGesture?.let { returnChoiceIntent(it, content) } } - init { itemView.setOnClickListener(this) } + init { + itemView.setOnClickListener(this) + } } override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) { @@ -49,7 +51,9 @@ class OtherRecyclerAdapter(val activity: Activity): viewHolder.iconView.setImageResource(icon) } - override fun getItemCount(): Int { return othersList.size } + override fun getItemCount(): Int { + return othersList.size + } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val inflater = LayoutInflater.from(parent.context) @@ -57,11 +61,10 @@ class OtherRecyclerAdapter(val activity: Activity): return ViewHolder(view) } - private fun returnChoiceIntent(forGesture: String, value: String) { + private fun returnChoiceIntent(forGesture: String, action: LauncherAction) { val returnIntent = Intent() - returnIntent.putExtra("value", value) returnIntent.putExtra("forGesture", forGesture) - returnIntent.putExtra("user", INVALID_USER) + action.writeToIntent(returnIntent) activity.setResult(REQUEST_CHOOSE_APP, returnIntent) activity.finish() } diff --git a/app/src/main/java/de/jrpie/android/launcher/settings/SettingsActivity.kt b/app/src/main/java/de/jrpie/android/launcher/ui/settings/SettingsActivity.kt similarity index 71% rename from app/src/main/java/de/jrpie/android/launcher/settings/SettingsActivity.kt rename to app/src/main/java/de/jrpie/android/launcher/ui/settings/SettingsActivity.kt index 54938fd..f509235 100644 --- a/app/src/main/java/de/jrpie/android/launcher/settings/SettingsActivity.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/settings/SettingsActivity.kt @@ -1,4 +1,4 @@ -package de.jrpie.android.launcher.settings +package de.jrpie.android.launcher.ui.settings import android.content.Context import android.content.Intent @@ -7,17 +7,20 @@ import android.content.res.Resources import android.os.Bundle import android.provider.Settings import androidx.appcompat.app.AppCompatActivity -import androidx.viewpager.widget.ViewPager -import de.jrpie.android.launcher.* -import com.google.android.material.tabs.TabLayout -import de.jrpie.android.launcher.databinding.SettingsBinding import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentPagerAdapter +import androidx.viewpager.widget.ViewPager +import com.google.android.material.tabs.TabLayout +import de.jrpie.android.launcher.R +import de.jrpie.android.launcher.REQUEST_CHOOSE_APP +import de.jrpie.android.launcher.databinding.SettingsBinding import de.jrpie.android.launcher.preferences.LauncherPreferences -import de.jrpie.android.launcher.settings.actions.SettingsFragmentActions -import de.jrpie.android.launcher.settings.launcher.SettingsFragmentLauncher -import de.jrpie.android.launcher.settings.meta.SettingsFragmentMeta +import de.jrpie.android.launcher.saveListActivityChoice +import de.jrpie.android.launcher.ui.UIObject +import de.jrpie.android.launcher.ui.settings.actions.SettingsFragmentActions +import de.jrpie.android.launcher.ui.settings.launcher.SettingsFragmentLauncher +import de.jrpie.android.launcher.ui.settings.meta.SettingsFragmentMeta /** * The [SettingsActivity] is a tabbed activity: @@ -28,12 +31,13 @@ import de.jrpie.android.launcher.settings.meta.SettingsFragmentMeta * * Settings are closed automatically if the activity goes `onPause` unexpectedly. */ -class SettingsActivity: AppCompatActivity(), UIObject { +class SettingsActivity : AppCompatActivity(), UIObject { private var sharedPreferencesListener = - SharedPreferences.OnSharedPreferenceChangeListener { _,prefKey -> - if(prefKey?.startsWith("theme.") == true || - prefKey?.startsWith("display.") == true) { + SharedPreferences.OnSharedPreferenceChangeListener { _, prefKey -> + if (prefKey?.startsWith("theme.") == true || + prefKey?.startsWith("display.") == true + ) { recreate() } } @@ -58,11 +62,13 @@ class SettingsActivity: AppCompatActivity(), UIObject { override fun onStart() { super.onStart() super.onStart() - LauncherPreferences.getSharedPreferences().registerOnSharedPreferenceChangeListener(sharedPreferencesListener) + LauncherPreferences.getSharedPreferences() + .registerOnSharedPreferenceChangeListener(sharedPreferencesListener) } override fun onPause() { - LauncherPreferences.getSharedPreferences().unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener) + LauncherPreferences.getSharedPreferences() + .unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener) super.onPause() } @@ -70,7 +76,7 @@ class SettingsActivity: AppCompatActivity(), UIObject { return modifyTheme(super.getTheme()) } - override fun setOnClicks(){ + override fun setOnClicks() { // As older APIs somehow do not recognize the xml defined onClick binding.settingsClose.setOnClickListener { finish() } // open device settings (see https://stackoverflow.com/a/62092663/12787264) @@ -81,7 +87,7 @@ class SettingsActivity: AppCompatActivity(), UIObject { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { when (requestCode) { - REQUEST_CHOOSE_APP -> saveListActivityChoice(this, data) + REQUEST_CHOOSE_APP -> saveListActivityChoice(data) else -> super.onActivityResult(requestCode, resultCode, data) } } @@ -93,11 +99,11 @@ private val TAB_TITLES = arrayOf( R.string.settings_tab_meta ) -class SettingsSectionsPagerAdapter(private val context: Context, fm: FragmentManager) - : FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { +class SettingsSectionsPagerAdapter(private val context: Context, fm: FragmentManager) : + FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { override fun getItem(position: Int): Fragment { - return when (position){ + return when (position) { 0 -> SettingsFragmentActions() 1 -> SettingsFragmentLauncher() 2 -> SettingsFragmentMeta() @@ -109,5 +115,7 @@ class SettingsSectionsPagerAdapter(private val context: Context, fm: FragmentMan return context.resources.getString(TAB_TITLES[position]) } - override fun getCount(): Int { return 3 } + override fun getCount(): Int { + return 3 + } } diff --git a/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActions.kt b/app/src/main/java/de/jrpie/android/launcher/ui/settings/actions/SettingsFragmentActions.kt similarity index 82% rename from app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActions.kt rename to app/src/main/java/de/jrpie/android/launcher/ui/settings/actions/SettingsFragmentActions.kt index bd0fa19..976e08e 100644 --- a/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActions.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/settings/actions/SettingsFragmentActions.kt @@ -1,4 +1,4 @@ -package de.jrpie.android.launcher.settings.actions +package de.jrpie.android.launcher.ui.settings.actions import android.content.ActivityNotFoundException import android.content.Intent @@ -9,9 +9,9 @@ import android.view.ViewGroup import android.widget.Toast import androidx.fragment.app.Fragment import de.jrpie.android.launcher.R -import de.jrpie.android.launcher.UIObject import de.jrpie.android.launcher.databinding.SettingsActionsBinding -import de.jrpie.android.launcher.list.ListActivity +import de.jrpie.android.launcher.ui.UIObject +import de.jrpie.android.launcher.ui.list.ListActivity /** @@ -44,18 +44,22 @@ SettingsFragmentActions : Fragment(), UIObject { override fun setOnClicks() { // App management buttons - binding!!.settingsActionsButtonViewApps.setOnClickListener{ + binding!!.settingsActionsButtonViewApps.setOnClickListener { val intent = Intent(this.context, ListActivity::class.java) intent.putExtra("intention", ListActivity.ListActivityIntention.VIEW.toString()) startActivity(intent) } - binding!!.settingsActionsButtonInstallApps.setOnClickListener{ + binding!!.settingsActionsButtonInstallApps.setOnClickListener { try { val intent = Intent(Intent.ACTION_MAIN) intent.addCategory(Intent.CATEGORY_APP_MARKET) startActivity(intent) } catch (e: ActivityNotFoundException) { - Toast.makeText(context, getString(R.string.settings_apps_toast_store_not_found), Toast.LENGTH_SHORT).show() + Toast.makeText( + context, + getString(R.string.settings_apps_toast_store_not_found), + Toast.LENGTH_SHORT + ).show() } } } diff --git a/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActionsRecycler.kt b/app/src/main/java/de/jrpie/android/launcher/ui/settings/actions/SettingsFragmentActionsRecycler.kt similarity index 69% rename from app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActionsRecycler.kt rename to app/src/main/java/de/jrpie/android/launcher/ui/settings/actions/SettingsFragmentActionsRecycler.kt index 898f6f7..9d9685f 100644 --- a/app/src/main/java/de/jrpie/android/launcher/settings/actions/SettingsFragmentActionsRecycler.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/settings/actions/SettingsFragmentActionsRecycler.kt @@ -1,24 +1,27 @@ -package de.jrpie.android.launcher.settings.actions +package de.jrpie.android.launcher.ui.settings.actions +import android.app.Activity +import android.content.Intent +import android.content.SharedPreferences import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.fragment.app.Fragment -import androidx.recyclerview.widget.LinearLayoutManager -import de.jrpie.android.launcher.* -import de.jrpie.android.launcher.list.ListActivity -import android.app.Activity -import android.content.Intent -import android.content.SharedPreferences import android.widget.Button import android.widget.ImageView import android.widget.TextView +import androidx.fragment.app.Fragment +import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView -import de.jrpie.android.launcher.list.other.LauncherAction +import de.jrpie.android.launcher.R +import de.jrpie.android.launcher.REQUEST_CHOOSE_APP +import de.jrpie.android.launcher.actions.Action +import de.jrpie.android.launcher.actions.Gesture import de.jrpie.android.launcher.databinding.SettingsActionsRecyclerBinding import de.jrpie.android.launcher.preferences.LauncherPreferences -import java.lang.Exception +import de.jrpie.android.launcher.transformGrayscale +import de.jrpie.android.launcher.ui.UIObject +import de.jrpie.android.launcher.ui.list.ListActivity /** * The [SettingsFragmentActionsRecycler] is a fragment containing the [ActionsRecyclerAdapter], @@ -48,7 +51,7 @@ class SettingsFragmentActionsRecycler : Fragment(), UIObject { // set up the list / recycler val actionViewManager = LinearLayoutManager(context) - actionViewAdapter = ActionsRecyclerAdapter( requireActivity() ) + actionViewAdapter = ActionsRecyclerAdapter(requireActivity()) binding.settingsActionsRview.apply { // improve performance (since content changes don't change the layout size) @@ -56,19 +59,21 @@ class SettingsFragmentActionsRecycler : Fragment(), UIObject { layoutManager = actionViewManager adapter = actionViewAdapter } - LauncherPreferences.getSharedPreferences().registerOnSharedPreferenceChangeListener(sharedPreferencesListener) + LauncherPreferences.getSharedPreferences() + .registerOnSharedPreferenceChangeListener(sharedPreferencesListener) super.onStart() } override fun onDestroy() { - LauncherPreferences.getSharedPreferences().unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener) + LauncherPreferences.getSharedPreferences() + .unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener) super.onDestroy() } } -class ActionsRecyclerAdapter(val activity: Activity): +class ActionsRecyclerAdapter(val activity: Activity) : RecyclerView.Adapter() { private val gesturesList: ArrayList @@ -80,52 +85,44 @@ class ActionsRecyclerAdapter(val activity: Activity): var chooseButton: Button = itemView.findViewById(R.id.settings_actions_row_button_choose) var removeAction: ImageView = itemView.findViewById(R.id.settings_actions_row_remove) - override fun onClick(v: View) { } + override fun onClick(v: View) {} - init { itemView.setOnClickListener(this) } + init { + itemView.setOnClickListener(this) + } } private fun updateViewHolder(gesture: Gesture, viewHolder: ViewHolder) { - val app = gesture.getApp(activity) - val content = app.first - viewHolder.img.visibility = View.VISIBLE - viewHolder.removeAction.visibility = View.VISIBLE - viewHolder.chooseButton.visibility = View.INVISIBLE - if (content.isEmpty()){ + val action = Action.forGesture(gesture) + val drawable = action?.getIcon(activity) + + if (action == null || drawable == null) { viewHolder.img.visibility = View.INVISIBLE viewHolder.removeAction.visibility = View.GONE viewHolder.chooseButton.visibility = View.VISIBLE + return } - else if (LauncherAction.isOtherAction(content)) { - LauncherAction.byId(content)?.let { - viewHolder.img.setImageResource(it.icon) - } - } else { - // Set image icon (by packageName) - try { - viewHolder.img.setImageDrawable(getAppIcon(activity, content, app.second)) - } catch (e : Exception) { - // Probably the app was uninstalled - // the button is shown, user asked to select an action - viewHolder.img.visibility = View.INVISIBLE - viewHolder.removeAction.visibility = View.GONE - viewHolder.chooseButton.visibility = View.VISIBLE - } - } + + viewHolder.img.visibility = View.VISIBLE + viewHolder.removeAction.visibility = View.VISIBLE + viewHolder.chooseButton.visibility = View.INVISIBLE + viewHolder.img.setImageDrawable(drawable) } override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) { val gesture = gesturesList[i] viewHolder.textView.text = gesture.getLabel(activity) if (LauncherPreferences.theme().monochromeIcons()) - transformGrayscale( viewHolder.img ) + transformGrayscale(viewHolder.img) updateViewHolder(gesture, viewHolder) - viewHolder.img.setOnClickListener{ chooseApp(gesture) } - viewHolder.chooseButton.setOnClickListener{ chooseApp(gesture) } - viewHolder.removeAction.setOnClickListener{ gesture.removeApp(activity) } + viewHolder.img.setOnClickListener { chooseApp(gesture) } + viewHolder.chooseButton.setOnClickListener { chooseApp(gesture) } + viewHolder.removeAction.setOnClickListener { Action.clearActionForGesture(gesture) } } - override fun getItemCount(): Int { return gesturesList.size } + override fun getItemCount(): Int { + return gesturesList.size + } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { val inflater = LayoutInflater.from(parent.context) @@ -138,7 +135,8 @@ class ActionsRecyclerAdapter(val activity: Activity): val edgeActions = LauncherPreferences.enabled_gestures().edgeSwipe() gesturesList = Gesture.values().filter { (doubleActions || !it.isDoubleVariant()) - && (edgeActions || !it.isEdgeVariant())} as ArrayList + && (edgeActions || !it.isEdgeVariant()) + } as ArrayList } fun updateActions() { @@ -147,7 +145,8 @@ class ActionsRecyclerAdapter(val activity: Activity): this.gesturesList.clear() gesturesList.addAll(Gesture.values().filter { (doubleActions || !it.isDoubleVariant()) - && (edgeActions || !it.isEdgeVariant())}) + && (edgeActions || !it.isEdgeVariant()) + }) notifyDataSetChanged() } @@ -157,7 +156,8 @@ class ActionsRecyclerAdapter(val activity: Activity): val intent = Intent(activity, ListActivity::class.java) intent.putExtra("intention", ListActivity.ListActivityIntention.PICK.toString()) intent.putExtra("forGesture", gesture.id) // for which action we choose the app - activity.startActivityForResult(intent, + activity.startActivityForResult( + intent, REQUEST_CHOOSE_APP ) } diff --git a/app/src/main/java/de/jrpie/android/launcher/settings/launcher/SettingsFragmentLauncher.kt b/app/src/main/java/de/jrpie/android/launcher/ui/settings/launcher/SettingsFragmentLauncher.kt similarity index 84% rename from app/src/main/java/de/jrpie/android/launcher/settings/launcher/SettingsFragmentLauncher.kt rename to app/src/main/java/de/jrpie/android/launcher/ui/settings/launcher/SettingsFragmentLauncher.kt index adfc67b..d436ca3 100644 --- a/app/src/main/java/de/jrpie/android/launcher/settings/launcher/SettingsFragmentLauncher.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/settings/launcher/SettingsFragmentLauncher.kt @@ -1,12 +1,11 @@ -package de.jrpie.android.launcher.settings.launcher +package de.jrpie.android.launcher.ui.settings.launcher -import android.content.Context import android.content.Intent import android.content.SharedPreferences import android.os.Bundle import androidx.preference.PreferenceFragmentCompat -import de.jrpie.android.launcher.preferences.LauncherPreferences import de.jrpie.android.launcher.R +import de.jrpie.android.launcher.preferences.LauncherPreferences import de.jrpie.android.launcher.setDefaultHomeScreen @@ -20,12 +19,12 @@ class SettingsFragmentLauncher : PreferenceFragmentCompat() { private var sharedPreferencesListener = SharedPreferences.OnSharedPreferenceChangeListener { _, prefKey -> - if(prefKey?.startsWith("clock.") == true) { + if (prefKey?.startsWith("clock.") == true) { updateVisibility() } } - private fun updateVisibility(){ + private fun updateVisibility() { val showSeconds = findPreference( LauncherPreferences.clock().keys().showSeconds() ) @@ -35,11 +34,13 @@ class SettingsFragmentLauncher : PreferenceFragmentCompat() { override fun onStart() { super.onStart() - LauncherPreferences.getSharedPreferences().registerOnSharedPreferenceChangeListener(sharedPreferencesListener) + LauncherPreferences.getSharedPreferences() + .registerOnSharedPreferenceChangeListener(sharedPreferencesListener) } override fun onPause() { - LauncherPreferences.getSharedPreferences().unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener) + LauncherPreferences.getSharedPreferences() + .unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener) super.onPause() } diff --git a/app/src/main/java/de/jrpie/android/launcher/settings/meta/SettingsFragmentMeta.kt b/app/src/main/java/de/jrpie/android/launcher/ui/settings/meta/SettingsFragmentMeta.kt similarity index 93% rename from app/src/main/java/de/jrpie/android/launcher/settings/meta/SettingsFragmentMeta.kt rename to app/src/main/java/de/jrpie/android/launcher/ui/settings/meta/SettingsFragmentMeta.kt index 2a19c13..a1e0eba 100644 --- a/app/src/main/java/de/jrpie/android/launcher/settings/meta/SettingsFragmentMeta.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/settings/meta/SettingsFragmentMeta.kt @@ -1,4 +1,4 @@ -package de.jrpie.android.launcher.settings.meta +package de.jrpie.android.launcher.ui.settings.meta import android.app.AlertDialog import android.content.Intent @@ -9,11 +9,11 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import de.jrpie.android.launcher.R -import de.jrpie.android.launcher.UIObject -import de.jrpie.android.launcher.openNewTabWindow -import de.jrpie.android.launcher.tutorial.TutorialActivity import de.jrpie.android.launcher.databinding.SettingsMetaBinding +import de.jrpie.android.launcher.openNewTabWindow import de.jrpie.android.launcher.preferences.resetPreferences +import de.jrpie.android.launcher.ui.UIObject +import de.jrpie.android.launcher.ui.tutorial.TutorialActivity /** * The [SettingsFragmentMeta] is a used as a tab in the SettingsActivity. @@ -65,7 +65,8 @@ class SettingsFragmentMeta : Fragment(), UIObject { AlertDialog.Builder(this.requireContext(), R.style.AlertDialogCustom) .setTitle(getString(R.string.settings_meta_reset)) .setMessage(getString(R.string.settings_meta_reset_confirm)) - .setPositiveButton(android.R.string.ok + .setPositiveButton( + android.R.string.ok ) { _, _ -> resetPreferences(this.requireContext()) requireActivity().finish() @@ -85,7 +86,6 @@ class SettingsFragmentMeta : Fragment(), UIObject { } - // contact developer binding.settingsMetaButtonContact.setOnClickListener { openNewTabWindow( diff --git a/app/src/main/java/de/jrpie/android/launcher/tutorial/TutorialActivity.kt b/app/src/main/java/de/jrpie/android/launcher/ui/tutorial/TutorialActivity.kt similarity index 74% rename from app/src/main/java/de/jrpie/android/launcher/tutorial/TutorialActivity.kt rename to app/src/main/java/de/jrpie/android/launcher/ui/tutorial/TutorialActivity.kt index a9e0478..490f42d 100644 --- a/app/src/main/java/de/jrpie/android/launcher/tutorial/TutorialActivity.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/tutorial/TutorialActivity.kt @@ -1,4 +1,4 @@ -package de.jrpie.android.launcher.tutorial +package de.jrpie.android.launcher.ui.tutorial import android.content.Intent import android.content.res.Resources @@ -9,16 +9,16 @@ import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentPagerAdapter import androidx.viewpager.widget.ViewPager import com.google.android.material.tabs.TabLayout -import de.jrpie.android.launcher.preferences.LauncherPreferences import de.jrpie.android.launcher.R import de.jrpie.android.launcher.REQUEST_CHOOSE_APP -import de.jrpie.android.launcher.UIObject +import de.jrpie.android.launcher.preferences.LauncherPreferences import de.jrpie.android.launcher.saveListActivityChoice -import de.jrpie.android.launcher.tutorial.tabs.TutorialFragmentConcept -import de.jrpie.android.launcher.tutorial.tabs.TutorialFragmentFinish -import de.jrpie.android.launcher.tutorial.tabs.TutorialFragmentSetup -import de.jrpie.android.launcher.tutorial.tabs.TutorialFragmentStart -import de.jrpie.android.launcher.tutorial.tabs.TutorialFragmentUsage +import de.jrpie.android.launcher.ui.UIObject +import de.jrpie.android.launcher.ui.tutorial.tabs.TutorialFragmentConcept +import de.jrpie.android.launcher.ui.tutorial.tabs.TutorialFragmentFinish +import de.jrpie.android.launcher.ui.tutorial.tabs.TutorialFragmentSetup +import de.jrpie.android.launcher.ui.tutorial.tabs.TutorialFragmentStart +import de.jrpie.android.launcher.ui.tutorial.tabs.TutorialFragmentUsage /** * The [TutorialActivity] is displayed automatically on new installations. @@ -27,7 +27,7 @@ import de.jrpie.android.launcher.tutorial.tabs.TutorialFragmentUsage * It tells the user about the concept behind launcher * and helps with the setup process (on new installations) */ -class TutorialActivity: AppCompatActivity(), UIObject { +class TutorialActivity : AppCompatActivity(), UIObject { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -54,7 +54,7 @@ class TutorialActivity: AppCompatActivity(), UIObject { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { when (requestCode) { - REQUEST_CHOOSE_APP -> saveListActivityChoice(this,data) + REQUEST_CHOOSE_APP -> saveListActivityChoice(data) else -> super.onActivityResult(requestCode, resultCode, data) } } @@ -73,11 +73,11 @@ class TutorialActivity: AppCompatActivity(), UIObject { * * Tabs: (Start | Concept | Usage | Setup | Finish) */ -class TutorialSectionsPagerAdapter(fm: FragmentManager) - : FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { +class TutorialSectionsPagerAdapter(fm: FragmentManager) : + FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { override fun getItem(position: Int): Fragment { - return when (position){ + return when (position) { 0 -> TutorialFragmentStart() 1 -> TutorialFragmentConcept() 2 -> TutorialFragmentUsage() @@ -88,6 +88,11 @@ class TutorialSectionsPagerAdapter(fm: FragmentManager) } /* We don't use titles here, as we have the dots */ - override fun getPageTitle(position: Int): CharSequence { return "" } - override fun getCount(): Int { return 5 } + override fun getPageTitle(position: Int): CharSequence { + return "" + } + + override fun getCount(): Int { + return 5 + } } diff --git a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentConcept.kt b/app/src/main/java/de/jrpie/android/launcher/ui/tutorial/tabs/TutorialFragmentConcept.kt similarity index 88% rename from app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentConcept.kt rename to app/src/main/java/de/jrpie/android/launcher/ui/tutorial/tabs/TutorialFragmentConcept.kt index ffeb464..26d4141 100644 --- a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentConcept.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/tutorial/tabs/TutorialFragmentConcept.kt @@ -1,4 +1,4 @@ -package de.jrpie.android.launcher.tutorial.tabs +package de.jrpie.android.launcher.ui.tutorial.tabs import android.os.Bundle import android.view.LayoutInflater @@ -6,8 +6,9 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import de.jrpie.android.launcher.BuildConfig -import de.jrpie.android.launcher.UIObject import de.jrpie.android.launcher.databinding.TutorialConceptBinding +import de.jrpie.android.launcher.ui.UIObject + /** * The [TutorialFragmentConcept] is a used as a tab in the TutorialActivity. * @@ -25,7 +26,7 @@ class TutorialFragmentConcept : Fragment(), UIObject { return binding.root } - override fun onStart(){ + override fun onStart() { super.onStart() super.onStart() } diff --git a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentFinish.kt b/app/src/main/java/de/jrpie/android/launcher/ui/tutorial/tabs/TutorialFragmentFinish.kt similarity index 82% rename from app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentFinish.kt rename to app/src/main/java/de/jrpie/android/launcher/ui/tutorial/tabs/TutorialFragmentFinish.kt index f4598b1..2d01d0a 100644 --- a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentFinish.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/tutorial/tabs/TutorialFragmentFinish.kt @@ -1,14 +1,15 @@ -package de.jrpie.android.launcher.tutorial.tabs +package de.jrpie.android.launcher.ui.tutorial.tabs import android.os.Bundle -import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import de.jrpie.android.launcher.* +import androidx.fragment.app.Fragment import de.jrpie.android.launcher.BuildConfig.VERSION_CODE import de.jrpie.android.launcher.databinding.TutorialFinishBinding import de.jrpie.android.launcher.preferences.LauncherPreferences +import de.jrpie.android.launcher.setDefaultHomeScreen +import de.jrpie.android.launcher.ui.UIObject /** * The [TutorialFragmentFinish] is a used as a tab in the TutorialActivity. @@ -34,11 +35,11 @@ class TutorialFragmentFinish : Fragment(), UIObject { override fun setOnClicks() { super.setOnClicks() - binding.tutorialFinishButtonStart.setOnClickListener{ finishTutorial() } + binding.tutorialFinishButtonStart.setOnClickListener { finishTutorial() } } private fun finishTutorial() { - if(!LauncherPreferences.internal().started()) { + if (!LauncherPreferences.internal().started()) { LauncherPreferences.internal().started(true) LauncherPreferences.internal().startedTime(System.currentTimeMillis() / 1000L) LauncherPreferences.internal().versionCode(VERSION_CODE) diff --git a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentSetup.kt b/app/src/main/java/de/jrpie/android/launcher/ui/tutorial/tabs/TutorialFragmentSetup.kt similarity index 84% rename from app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentSetup.kt rename to app/src/main/java/de/jrpie/android/launcher/ui/tutorial/tabs/TutorialFragmentSetup.kt index a71088d..09ef4c9 100644 --- a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentSetup.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/tutorial/tabs/TutorialFragmentSetup.kt @@ -1,4 +1,4 @@ -package de.jrpie.android.launcher.tutorial.tabs +package de.jrpie.android.launcher.ui.tutorial.tabs import android.os.Bundle import android.view.LayoutInflater @@ -6,7 +6,7 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import de.jrpie.android.launcher.R -import de.jrpie.android.launcher.UIObject +import de.jrpie.android.launcher.ui.UIObject /** * The [TutorialFragmentSetup] is a used as a tab in the TutorialActivity. @@ -22,7 +22,7 @@ class TutorialFragmentSetup : Fragment(), UIObject { return inflater.inflate(R.layout.tutorial_setup, container, false) } - override fun onStart(){ + override fun onStart() { super.onStart() super.onStart() } diff --git a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentStart.kt b/app/src/main/java/de/jrpie/android/launcher/ui/tutorial/tabs/TutorialFragmentStart.kt similarity index 83% rename from app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentStart.kt rename to app/src/main/java/de/jrpie/android/launcher/ui/tutorial/tabs/TutorialFragmentStart.kt index 433da9b..160a1d4 100644 --- a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentStart.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/tutorial/tabs/TutorialFragmentStart.kt @@ -1,12 +1,13 @@ -package de.jrpie.android.launcher.tutorial.tabs +package de.jrpie.android.launcher.ui.tutorial.tabs import android.os.Bundle -import androidx.fragment.app.Fragment import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import de.jrpie.android.launcher.* +import androidx.fragment.app.Fragment +import de.jrpie.android.launcher.blink import de.jrpie.android.launcher.databinding.TutorialStartBinding +import de.jrpie.android.launcher.ui.UIObject /** * The [TutorialFragmentStart] is a used as a tab in the TutorialActivity. @@ -25,7 +26,7 @@ class TutorialFragmentStart : Fragment(), UIObject { return binding.root } - override fun onStart(){ + override fun onStart() { super.onStart() super.onStart() } diff --git a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentUsage.kt b/app/src/main/java/de/jrpie/android/launcher/ui/tutorial/tabs/TutorialFragmentUsage.kt similarity index 84% rename from app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentUsage.kt rename to app/src/main/java/de/jrpie/android/launcher/ui/tutorial/tabs/TutorialFragmentUsage.kt index 00cd9d3..90db232 100644 --- a/app/src/main/java/de/jrpie/android/launcher/tutorial/tabs/TutorialFragmentUsage.kt +++ b/app/src/main/java/de/jrpie/android/launcher/ui/tutorial/tabs/TutorialFragmentUsage.kt @@ -1,4 +1,4 @@ -package de.jrpie.android.launcher.tutorial.tabs +package de.jrpie.android.launcher.ui.tutorial.tabs import android.os.Bundle import android.view.LayoutInflater @@ -6,7 +6,7 @@ import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment import de.jrpie.android.launcher.R -import de.jrpie.android.launcher.UIObject +import de.jrpie.android.launcher.ui.UIObject /** * The [TutorialFragmentUsage] is a used as a tab in the TutorialActivity. @@ -22,7 +22,7 @@ class TutorialFragmentUsage : Fragment(), UIObject { return inflater.inflate(R.layout.tutorial_usage, container, false) } - override fun onStart(){ + override fun onStart() { super.onStart() super.onStart() } diff --git a/app/src/main/res/layout/home.xml b/app/src/main/res/layout/home.xml index d61c201..a99dcae 100644 --- a/app/src/main/res/layout/home.xml +++ b/app/src/main/res/layout/home.xml @@ -7,7 +7,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:longClickable="false" - tools:context=".HomeActivity"> + tools:context=".ui.HomeActivity"> + tools:context=".ui.list.ListActivity"> + tools:context=".ui.settings.SettingsActivity"> + tools:context=".ui.settings.meta.SettingsFragmentMeta">