Compare commits

...

419 commits

Author SHA1 Message Date
22633bdac3
try to fix #138
Some checks failed
Android CI / build (push) Has been cancelled
2025-04-15 19:24:23 +02:00
4f795289d5
improve English translation 2025-04-15 18:55:13 +02:00
2774b74d9d
0.1.4 2025-04-15 18:38:00 +02:00
3d49ec16a7
Merge pull request #132 from toolatebot/weblate-jrpie-launcher-launcher
Some checks failed
Android CI / build (push) Has been cancelled
Translations update from Toolate
2025-04-13 16:27:29 +02:00
letterhaven
a0b2417363 Translated using Weblate (Arabic)
Currently translated at 99.6% (257 of 258 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/ar/
2025-04-13 14:07:19 +00:00
letterhaven
20a01e9f03 Added translation using Weblate (Arabic) 2025-04-13 14:07:19 +00:00
Lukas Hamm
24250ad345 Translated using Weblate (Lithuanian)
Currently translated at 5.4% (14 of 258 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/lt/
2025-04-13 14:07:18 +00:00
Lukas Hamm
7cce425339 Added translation using Weblate (Lithuanian) 2025-04-13 14:07:18 +00:00
class0068
0877ca6772 Translated using Weblate (Chinese (Simplified Han script))
Currently translated at 14.2% (3 of 21 strings)

Translation: jrpie-Launcher/metadata
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/metadata/zh_Hans/
2025-04-13 14:07:18 +00:00
class0068
03a9833b51 Translated using Weblate (Chinese (Simplified Han script))
Currently translated at 100.0% (258 of 258 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/
2025-04-13 14:07:18 +00:00
Vossa Excelencia
ce65741717 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (258 of 258 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2025-04-13 14:07:18 +00:00
class0068
c085087e1e Translated using Weblate (Chinese (Simplified Han script))
Currently translated at 100.0% (257 of 257 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/
2025-04-13 14:07:18 +00:00
class0068
cbd23159da Translated using Weblate (Chinese (Simplified Han script))
Currently translated at 98.8% (254 of 257 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/
2025-04-13 14:07:18 +00:00
Vossa Excelencia
940e5785dc Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (254 of 254 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2025-04-13 14:07:18 +00:00
class0068
14ffbd1f6c Translated using Weblate (Chinese (Simplified Han script))
Currently translated at 100.0% (254 of 254 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/
2025-04-13 14:07:18 +00:00
Vossa Excelencia
bfc84b57ca Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (254 of 254 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2025-04-13 14:07:18 +00:00
T
8b1963f3e1 Translated using Weblate (Spanish)
Currently translated at 98.0% (249 of 254 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/es/
2025-04-13 14:07:18 +00:00
toolatebot
4f801427a4 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/
2025-04-13 14:07:18 +00:00
class0068
8a487eb4c7 Translated using Weblate (Chinese (Simplified Han script))
Currently translated at 100.0% (254 of 254 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/
2025-04-13 14:07:18 +00:00
class0068
e6dd2634ae Translated using Weblate (Chinese (Simplified Han script))
Currently translated at 100.0% (254 of 254 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/
2025-04-13 14:07:18 +00:00
0441b3fd3d
set max width for choose app button; change label from scegliere l'applicazione to scegliere in Italian
Some checks are pending
Android CI / build (push) Waiting to run
2025-04-13 14:54:11 +02:00
e7c1d28576
upgrade AGP 2025-04-13 14:40:57 +02:00
653d16b269
new action: launch other launchers
Some checks failed
Android CI / build (push) Has been cancelled
2025-03-29 21:09:15 +01:00
5d695ec0ea
fix #135 2025-03-29 18:45:53 +01:00
b4608ef153
add new action: show recent apps
Some checks failed
Android CI / build (push) Has been cancelled
2025-03-24 13:21:58 +01:00
8e140e2e69
rename tab "Apps" to "Actions" and "Volume Up/Down" to "Volume Up/Down Key"
Some checks failed
Android CI / build (push) Has been cancelled
2025-03-20 16:23:01 +01:00
7fc58fe384
0.1.3 2025-03-20 15:52:12 +01:00
54409b6312
fix #133 2025-03-20 14:55:22 +01:00
865cd47583
0.1.2 2025-03-20 14:16:29 +01:00
58ddd3c8cc
fix #130 - revert part of 9043461 as ViewPager2 causes an issue with opening the keyboard 2025-03-20 14:09:00 +01:00
0baa889de5
0.1.1
Some checks are pending
Android CI / build (push) Waiting to run
2025-03-19 17:55:35 +01:00
fa34cbae90
Merge pull request #128 from toolatebot/weblate-jrpie-launcher-launcher
Some checks are pending
Android CI / build (push) Waiting to run
Translations update from Toolate
2025-03-19 17:05:33 +01:00
7ac09bd465 Translated using Weblate (Chinese (Simplified Han script))
Currently translated at 100.0% (254 of 254 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/
2025-03-18 19:30:19 +00:00
class0068
c8d7a1cc3e Translated using Weblate (Chinese (Simplified Han script))
Currently translated at 100.0% (254 of 254 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/
2025-03-18 19:30:19 +00:00
7094d55484 Translated using Weblate (German)
Currently translated at 100.0% (254 of 254 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/de/
2025-03-18 19:30:19 +00:00
b3e4d8834a
Merge pull request #127 from toolatebot/weblate-jrpie-launcher-launcher
Some checks failed
Android CI / build (push) Has been cancelled
Translations update from Toolate
2025-03-17 23:01:16 +01:00
008d0242ee Translated using Weblate (German)
Currently translated at 96.8% (246 of 254 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/de/
2025-03-17 17:07:17 +00:00
toolatebot
65034bf2fb 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/
2025-03-16 16:28:08 +00:00
Anonymous
3cec2c36c6 Translated using Weblate (German)
Currently translated at 92.7% (242 of 261 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/de/
2025-03-16 16:28:08 +00:00
00350d4c3a Translated using Weblate (German)
Currently translated at 92.7% (242 of 261 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/de/
2025-03-16 16:28:08 +00:00
0941062270
Merge pull request #121 from toolatebot/weblate-jrpie-launcher-launcher
Some checks failed
Android CI / build (push) Has been cancelled
Translations update from Toolate
2025-03-16 17:04:56 +01:00
c783a51658
upgrade AGP 2025-03-16 16:52:46 +01:00
da115bb2d9
refactor: remove unused stuff, fix lint warnings
Some checks are pending
Android CI / build (push) Waiting to run
2025-03-16 16:37:39 +01:00
90434617e7
replace (ViewPager, FragmentPagerAdapter) by (ViewPager2, FragmentStateAdapter) 2025-03-16 04:12:34 +01:00
47940811b4
fix #126
Some checks are pending
Android CI / build (push) Waiting to run
2025-03-16 02:30:49 +01:00
toolatebot
232046e986 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/
2025-03-16 00:07:18 +00:00
toolatebot
ff108ee323 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/
2025-03-16 00:07:18 +00:00
anmoti
943867d938 Translated using Weblate (Japanese)
Currently translated at 78.4% (200 of 255 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/ja/
2025-03-16 00:07:18 +00:00
anmoti
59f4a29044 Translated using Weblate (Japanese)
Currently translated at 17.6% (3 of 17 strings)

Translation: jrpie-Launcher/metadata
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/metadata/ja/
2025-03-16 00:07:18 +00:00
class0068
bd70b822cf Translated using Weblate (Chinese (Simplified Han script))
Currently translated at 98.4% (251 of 255 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/
2025-03-16 00:07:18 +00:00
72f9c0595f
handle MotionEvent.ACTION_CANCEL in TouchGestureDetector (see #126)
Some checks are pending
Android CI / build (push) Waiting to run
2025-03-15 19:23:51 +01:00
75b22400c5
try to fix #125 2025-03-15 17:24:19 +01:00
c1511cd475
merge #124 - improve tutorial
Some checks are pending
Android CI / build (push) Waiting to run
* Add new "app list" section
* Rename fragments
* Replace screenshots
* Replace ViewPager by ViewPager2
* Add navigation buttons

Co-authored-by: Luke Wass <wassupluke@gmail.com>
2025-03-15 03:26:37 +01:00
3597baee1f
fix problem which switching from grayscale icons back to normal
Some checks are pending
Android CI / build (push) Waiting to run
2025-03-14 22:33:08 +01:00
e02ca4091f
0.1.0 2025-03-14 16:35:41 +01:00
541e60356c
implement #98 - disable functionality because of Android bug: https://issuetracker.google.com/issues/352276244#comment5 2025-03-14 16:35:13 +01:00
492749a340
remove global variables from ListActivity 2025-03-14 16:03:59 +01:00
55af392706
add donate button
Some checks are pending
Android CI / build (push) Waiting to run
2025-03-14 15:40:06 +01:00
077ee4381a
lint 2025-03-14 15:27:26 +01:00
e250a58ef4
add new action: adjust volume 2025-03-14 13:37:41 +01:00
c7af387a94
implement #98 - hide lock icon when 'hide private space when locked' setting is set 2025-03-14 04:11:47 +01:00
6cd17343fc
show questionmark when unkown app or shortcut is bound to gesture 2025-03-14 04:09:28 +01:00
b156b68d53
improve German translation
Some checks are pending
Android CI / build (push) Waiting to run
2025-03-14 02:39:30 +01:00
c9ee2c6304
handle exception when acessing shortcuts 2025-03-14 02:00:42 +01:00
bf45b6602e
Merge pull request #112 from acanoe/features/hide-navigation-bar
Some checks are pending
Android CI / build (push) Waiting to run
feat: Add option to hide navigation bar on home screen
2025-03-13 16:30:34 +01:00
d7dd1aa71a
refactor hide navigation bar
* move code to UIObject
* remove listener
* rename 'full screen' to 'hide status bar'
2025-03-13 16:28:01 +01:00
3664159782
fix #116 2025-03-13 15:38:00 +01:00
8df9aae029
Merge pull request #118 from toolatebot/weblate-jrpie-launcher-launcher
Some checks are pending
Android CI / build (push) Waiting to run
Translations update from Toolate
2025-03-13 03:08:22 +01:00
anmoti
f776fbb88e Added translation using Weblate (Japanese) 2025-03-12 12:36:18 +00:00
Vossa Excelencia
a5ec8bb796 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (255 of 255 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2025-03-12 00:07:18 +00:00
3b2dca9af9
merge translation update
Some checks are pending
Android CI / build (push) Waiting to run
2025-03-11 22:38:34 +01:00
1b12032750
add FUNDING.yml
Some checks are pending
Android CI / build (push) Waiting to run
2025-03-11 15:58:07 +01:00
55a54fb9a5
implement #45: show pinned shortcuts in app list
Some checks failed
Android CI / build (push) Has been cancelled
2025-03-05 13:04:15 +01:00
Vossa Excelencia
e39ff62613 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (253 of 253 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2025-03-05 00:07:17 +00:00
9fe1a37ed6
implement #45: show pinned shortcuts in app list
Some checks are pending
Android CI / build (push) Waiting to run
2025-03-05 00:31:43 +01:00
1f825d6f00
implement #113: option to reverse app list
Some checks are pending
Android CI / build (push) Waiting to run
2025-03-04 16:49:29 +01:00
5ea03d39fa
fix blurred text in dialogs
Some checks are pending
Android CI / build (push) Waiting to run
2025-03-03 21:26:39 +01:00
ae119ac4ce
remove unused code 2025-03-03 21:23:16 +01:00
8948b34243
0.0.23
Some checks are pending
Android CI / build (push) Waiting to run
2025-03-02 23:04:59 +01:00
f18811bfa2
Merge pull request #111 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2025-03-02 23:00:17 +01:00
bd1f999a0e
Merge branch 'master' of https://github.com/jrpie/Launcher 2025-03-02 22:41:13 +01:00
941b06b258
minor reformatting 2025-02-22 03:03:52 +01:00
Hendika N
9935386ad8 Add option to hide navigation bar on home screen 2025-02-22 07:35:28 +07:00
Symphonic9861
d44224071f Translated using Weblate (Chinese (Simplified Han script))
Currently translated at 84.9% (214 of 252 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/
2025-02-21 09:07:16 +00:00
Symphonic9861
1f8f75dec8 Translated using Weblate (Chinese (Simplified Han script))
Currently translated at 76.9% (194 of 252 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/
2025-02-19 11:17:04 +00:00
86528f4e27
add tap-swipe combo gestures (see #110)
Some checks failed
Android CI / build (push) Has been cancelled
2025-02-18 19:20:53 +01:00
3aee137a3c
basic support for pinned shortcuts (see #45)
TODO: Show pinned shortcuts in app list
2025-02-18 19:02:25 +01:00
befa3afc5d
0.0.22
Some checks are pending
Android CI / build (push) Waiting to run
2025-02-17 22:39:49 +01:00
a295c0ab4b
Merge pull request #107 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2025-02-17 22:29:35 +01:00
Ahmet Çeliker
c448c51164 Translated using Weblate (Turkish)
Currently translated at 86.6% (13 of 15 strings)

Translation: jrpie-Launcher/metadata
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/metadata/tr/
2025-02-17 00:07:18 +00:00
Vossa Excelencia
68b79724e8 Translated using Weblate (Portuguese (Brazil))
Currently translated at 26.6% (4 of 15 strings)

Translation: jrpie-Launcher/metadata
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/metadata/pt_BR/
2025-02-17 00:07:18 +00:00
Vossa Excelencia
bef38c2657 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (225 of 225 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2025-02-17 00:07:18 +00:00
Vossa Excelencia
d0b0c27b2c Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (220 of 220 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2025-02-17 00:07:18 +00:00
Vossa Excelencia
4508e4ee5c Translated using Weblate (Portuguese (Brazil))
Currently translated at 20.0% (3 of 15 strings)

Translation: jrpie-Launcher/metadata
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/metadata/pt_BR/
2025-02-17 00:07:18 +00:00
Vossa Excelencia
e959e9d957 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (220 of 220 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2025-02-17 00:07:18 +00:00
Nicola Bortoletto
958d4879f5 Translated using Weblate (Italian)
Currently translated at 99.0% (216 of 218 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/it/
2025-02-17 00:07:18 +00:00
Vossa Excelencia
7841a99415 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (218 of 218 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2025-02-17 00:07:18 +00:00
Xanadul
18b4fca933 Translated using Weblate (German)
Currently translated at 13.3% (2 of 15 strings)

Translation: jrpie-Launcher/metadata
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/metadata/de/
2025-02-17 00:07:18 +00:00
Nicola Bortoletto
5792c7f38c Translated using Weblate (Italian)
Currently translated at 98.1% (214 of 218 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/it/
2025-02-17 00:07:18 +00:00
88a78749c2
add action: media play / pause 2025-02-17 00:31:18 +01:00
7257d4ca35
fix bug in gesture detection logic
Some checks are pending
Android CI / build (push) Waiting to run
2025-02-16 23:58:42 +01:00
47ae0bf35f
update README.md
Some checks are pending
Android CI / build (push) Waiting to run
2025-02-16 16:51:18 +01:00
5669279c64
add <,>,V,Λ gestures 2025-02-16 15:50:13 +01:00
0c0d90a357
improve gesture detection 2025-02-15 03:08:18 +01:00
012f13c827
update gradle wrapper
Some checks failed
Android CI / build (push) Has been cancelled
2025-02-11 18:06:06 +01:00
757486771d
reenable proguard
Some checks are pending
Android CI / build (push) Waiting to run
2025-02-10 22:56:45 +01:00
9c5500aa83
lint
Some checks are pending
Android CI / build (push) Waiting to run
2025-02-09 21:08:16 +01:00
d69e3caf71
implement #98 - add option to show private space in different list 2025-02-09 18:49:41 +01:00
944eb89fef
implement #93 - treat back button as a gesture
Some checks failed
Android CI / build (push) Has been cancelled
2025-02-06 22:27:58 +01:00
fa2f1c4127
fix #106 (ugly workaround)
Some checks are pending
Android CI / build (push) Waiting to run
2025-02-05 23:47:37 +01:00
8699b92246
update the bug report url 2025-02-05 22:07:23 +01:00
d6355afc54
updated bug report template
Some checks failed
Android CI / build (push) Has been cancelled
2025-01-31 02:01:23 +01:00
0a9890111c
add explanation for pressing space to disable auto launch 2025-01-31 01:38:20 +01:00
b2e7e4cacf
v0.0.21 2025-01-31 01:12:55 +01:00
d62815be12
improve German translation 2025-01-31 01:11:00 +01:00
768d27a7bb
Merge branch 'master' of https://github.com/jrpie/Launcher 2025-01-31 00:44:44 +01:00
a227a40b6e
Merge pull request #103 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2025-01-31 00:44:27 +01:00
f280d36667
add handler for ActivityNotFoundException 2025-01-28 02:15:04 +01:00
Vossa Excelencia
3973f1338f Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (215 of 215 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2025-01-28 00:11:10 +00:00
9f3142cb69
Merge branch 'master' of https://github.com/jrpie/Launcher
Some checks failed
Android CI / build (push) Has been cancelled
2025-01-27 02:05:36 +01:00
ecd58b91bb
some refactoring 2025-01-27 00:50:31 +01:00
2fc2b76fba
Merge pull request #97 from toolatebot/weblate-jrpie-launcher-launcher
Some checks are pending
Android CI / build (push) Waiting to run
Translations update from Toolate
2025-01-26 21:57:19 +01:00
Vossa Excelencia
c7895830e7 Translated using Weblate (Portuguese (Brazil))
Currently translated at 99.5% (201 of 202 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2025-01-25 00:07:17 +00:00
Vossa Excelencia
14766fe1d9 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (202 of 202 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2025-01-25 00:07:17 +00:00
Anonymous
b9a59c9e37 Translated using Weblate (Portuguese (Brazil))
Currently translated at 97.0% (196 of 202 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2025-01-25 00:07:17 +00:00
Anonymous
2d03bdbbef Translated using Weblate (Chinese (Simplified Han script))
Currently translated at 84.1% (170 of 202 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/
2025-01-25 00:07:17 +00:00
Anonymous
09b12834a9 Translated using Weblate (French)
Currently translated at 95.0% (192 of 202 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/fr/
2025-01-25 00:07:17 +00:00
23f8cfb70e
implement #102 - show version in settings and add bug report dialog
Some checks failed
Android CI / build (push) Has been cancelled
2025-01-24 23:45:19 +01:00
6d385e4e87
use TextClock instead of custom solution 2025-01-22 02:17:46 +01:00
785e024ddb
basic support for private space (#98)
* add an action to toggle private space lock
* hide apps from private space if private space is locked
2025-01-22 01:44:51 +01:00
679c90130d
re-enable the light theme
close #75
when the light theme is selected, the background is always set to solid, to prevent problems with dark wallpapers
2025-01-21 23:05:49 +01:00
95c9fcd292
shorten 'auto launch disabled' to 'no auto launch' 2025-01-13 16:51:49 +01:00
a188e06342
update README.md 2025-01-13 15:53:42 +01:00
5696ea73da
update short description 2025-01-13 03:01:28 +01:00
a7ce5b9222
update release script and BUILD.md 2025-01-13 02:50:41 +01:00
74b448cd0f
j-0.0.20 2025-01-12 22:50:22 +01:00
cd36fad8cd
add release script 2025-01-12 22:47:50 +01:00
64ccc4f300
update CI pipeline to use default build flavor 2025-01-12 21:08:03 +01:00
b5dcfeecec
update CI pipeline to use default build flavor 2025-01-12 21:00:05 +01:00
677453137a
Merge pull request #96 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2025-01-12 20:59:39 +01:00
f08f357bb3
add buildFlavor for accrescent 2025-01-12 01:31:49 +01:00
Vossa Excelencia
567d08fb3a Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (200 of 200 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2025-01-12 00:07:16 +00:00
fa0c880342
update LICENSE 2025-01-11 23:17:03 +01:00
8fc69e10e9
add list of open source licenses 2025-01-11 23:15:50 +01:00
eff7cfda5e
update AGP 2025-01-11 21:37:22 +01:00
ddca29067e
Merge branch 'master' of https://github.com/jrpie/Launcher 2025-01-10 00:23:27 +01:00
c6d0477e3a
fix #95: unicode normalization for search 2025-01-10 00:21:57 +01:00
eb9f43ec49
Merge pull request #94 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2025-01-09 01:09:44 +01:00
ce5fade39a
allow to prefix query with space to disable auto launch 2025-01-09 01:08:01 +01:00
09ca4410b9 Translated using Weblate (French)
Currently translated at 98.9% (197 of 199 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/fr/
2025-01-09 00:07:16 +00:00
92772d715c
Merge branch 'master' of https://github.com/jrpie/Launcher 2025-01-09 00:25:14 +01:00
36a04703c2
update changelog 2025-01-09 00:25:07 +01:00
31106158b3
Merge pull request #92 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2025-01-09 00:24:03 +01:00
6d5e3b36f9
update accessibility service warning 2025-01-09 00:23:35 +01:00
Nin Dan
e53b7682d8 Translated using Weblate (French)
Currently translated at 98.9% (197 of 199 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/fr/
2025-01-08 22:07:15 +00:00
Alexandre Ancel
3e4d22d3cd Translated using Weblate (French)
Currently translated at 98.9% (197 of 199 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/fr/
2025-01-05 00:07:16 +00:00
Anonymous
954bef4aac Translated using Weblate (German)
Currently translated at 91.3% (180 of 197 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/de/
2025-01-03 00:07:16 +00:00
e39d72ef3c
j-0.0.19 2025-01-02 23:15:14 +01:00
9216837879
add an option to search the web from the app list 2025-01-02 23:05:24 +01:00
2d53562d58
change the package id for debug builds 2025-01-02 22:47:00 +01:00
220ad4d18f
warn about problems with device encryption when using an accessibility service 2024-12-31 00:28:06 +01:00
cbaa853b1c
remove white box around cursor in EditText
android:background was erroneously used instead of android:windowBackground.
This was causing a white box around the cursor.
Neither android:background nor android:windowBackground is needed.
2024-12-30 23:25:57 +01:00
ad5ee5e10e
Merge branch 'master' of https://github.com/jrpie/Launcher 2024-12-30 23:06:13 +01:00
4ddb893d41
improve json serialization 2024-12-29 02:40:06 +01:00
970c160f4a
serialize to json 2024-12-23 02:29:17 +01:00
96c924fba5
Merge pull request #89 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2024-12-22 17:57:47 +00:00
9d96284719 Translated using Weblate (German)
Currently translated at 91.8% (181 of 197 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/de/
2024-12-22 00:03:32 +00:00
36ee8033ed
make device admin the preferred method for locking the screen 2024-12-21 15:05:24 +01:00
2b7999cfdc
use LiveData to store app list 2024-12-20 04:45:56 +01:00
3353719cc3
move stuff out of Functions.kt 2024-12-20 02:42:58 +01:00
c84675904d
update README.md 2024-12-16 22:39:40 +01:00
bf4131c603
Merge pull request #87 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2024-12-15 22:37:51 +00:00
Vossa Excelencia
db4a52a780 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (197 of 197 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2024-12-15 06:23:34 +00:00
8309b7c290
make lock screen dialog scrollable 2024-12-13 16:34:30 +01:00
aca7fe57d2
j-0.0.18 2024-12-12 21:27:03 +01:00
9e514050e2
Merge pull request #86 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2024-12-12 20:08:13 +00:00
Vossa Excelencia
ae9210a103 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (199 of 199 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2024-12-12 19:03:32 +00:00
40a80755d5
Merge pull request #82 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2024-12-12 12:38:01 +00:00
Vossa Excelencia
ef787f5417 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (199 of 199 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2024-12-10 17:03:31 +00:00
97d10d09b5
add consent dialog for accessibility service 2024-12-07 02:21:01 +01:00
46aaa91fe9
Merge pull request #78 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2024-12-06 22:53:47 +00:00
9423dcce11
fixed #76 2024-12-06 23:48:19 +01:00
Sarp Küçük
a88fb869cb Translated using Weblate (Turkish)
Currently translated at 100.0% (191 of 191 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/tr/
2024-12-06 21:52:44 +00:00
6eb4fd6104
created SECURITY.md 2024-12-06 02:00:04 +01:00
fc56d3c857
updated README.md 2024-12-06 01:59:50 +01:00
c4513236ec
fixed problem with italian translation 2024-12-06 01:13:22 +01:00
41011b7b35
removed audio.wav 2024-12-06 01:12:16 +01:00
8a8a148ebf
Merge pull request #74 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2024-12-06 00:11:49 +00:00
Samantha
cbfde12981 Translated using Weblate (Italian)
Currently translated at 97.7% (177 of 181 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/it/
2024-12-06 00:03:32 +00:00
Sarp Küçük
c68a59e4ee Translated using Weblate (Turkish)
Currently translated at 100.0% (181 of 181 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/tr/
2024-12-06 00:03:32 +00:00
3e1fa822e1 some refactoring 2024-12-06 00:03:32 +00:00
a9f3196f8e
preference for clock color (cf. #12, #75) 2024-12-06 00:51:50 +01:00
3c59ad4c41
removed light theme; added dynamic theme (cf. #75) 2024-12-06 00:35:49 +01:00
06777a4d34
updated AGP 2024-12-04 02:00:32 +01:00
08f0026dc3
optimized imports 2024-11-28 01:59:56 +01:00
9649b9b523
j-0.0.17 2024-11-28 01:44:58 +01:00
84c4fdfb47 remove audio.wav 2024-11-28 01:40:51 +01:00
77668d773f Merge branch 'pr-73' 2024-11-28 01:36:41 +01:00
0692db8084 added screenshots 2024-11-28 01:32:07 +01:00
27ebd728ef cleanup 2024-11-28 00:52:55 +01:00
2c4f5176b7 fixed bug: custom labels not shown in app list 2024-11-28 00:49:54 +01:00
98274fbd4f disable lock screen method setting on old devices 2024-11-27 23:51:00 +01:00
Vossa Excelencia
490bb0e3dc Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (181 of 181 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2024-11-27 17:46:06 +00:00
Vossa Excelencia
9bfe61c4f0 Translated using Weblate (Portuguese (Brazil))
Currently translated at 91.1% (165 of 181 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2024-11-27 17:27:19 +00:00
yzqzss
c44115a947 Translated using Weblate (Chinese (Simplified Han script))
Currently translated at 96.6% (175 of 181 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/
2024-11-27 17:27:18 +00:00
Vossa Excelencia
987acc93e4 Translated using Weblate (Portuguese (Brazil))
Currently translated at 90.6% (164 of 181 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2024-11-27 17:26:07 +00:00
yzqzss
79f3bf3d79 Translated using Weblate (Chinese (Simplified Han script))
Currently translated at 96.6% (175 of 181 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/
2024-11-27 17:26:07 +00:00
1a34b6234e Translated using Weblate (German)
Currently translated at 92.6% (152 of 164 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/de/
2024-11-27 16:49:52 +00:00
8ca67103bf Merge branch 'pr-72' 2024-11-27 17:32:56 +01:00
edc4927f1a some refactoring 2024-11-27 17:31:42 +01:00
897bfb9640
updated readme 2024-11-27 16:46:23 +01:00
yzqzss
cc64745c0f fix: accessbility isEnabled() false positive 2024-11-27 23:46:08 +08:00
57c2eab61e
updated german translation 2024-11-27 16:40:10 +01:00
3f0856b732
made string-arrays non-translatable 2024-11-27 16:35:21 +01:00
172de1f3dd
Merge branch 'feature/app-list-layout' 2024-11-27 16:15:21 +01:00
80cb8e995a
add list layout to preferences.xml 2024-11-27 16:13:28 +01:00
608f4c0bd0
j-0.0.16 2024-11-27 15:30:21 +01:00
3de4b7c56f
fix #71 2024-11-27 15:17:15 +01:00
7ee39ba3b8
use badged labels in text layout 2024-11-27 15:06:07 +01:00
89bf02fc06
padding for text only layout 2024-11-27 15:05:26 +01:00
a9e9f34260
add layout preference for app list 2024-11-27 15:05:19 +01:00
c3a31a97ef
renamed µLauncher tab back to Launcher (capital µ doesn't work too well) 2024-11-27 14:31:58 +01:00
d63461ea40
cleanup 2024-11-27 02:40:58 +01:00
7f2a52c79c
fix: hide µLauncher by default 2024-11-27 01:39:10 +01:00
3ae2e36ee0
improved german translation 2024-11-27 01:24:53 +01:00
fac3991f96
implement #68: renaming of apps 2024-11-27 00:56:29 +01:00
b8ef2a07c2
Fixed bug: Properly escape search string for regex
E.g. searching for [ caused a crash.
2024-11-26 22:33:52 +01:00
3bba7cfe74
updated README.md 2024-11-26 02:34:06 +01:00
a2db262dbc
updated README.md 2024-11-26 02:01:21 +01:00
ea964a50b9
updated README.md 2024-11-26 01:55:00 +01:00
58d5112f8a
updated README.md 2024-11-26 01:48:14 +01:00
cef92d2331
Merge branch 'master' of https://github.com/jrpie/Launcher 2024-11-26 01:41:31 +01:00
28ed2c78b3
updated README.md 2024-11-26 01:41:25 +01:00
038eaccc9c
Merge pull request #69 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2024-11-26 00:17:07 +00:00
659ac73c64
versionCode 31 2024-11-26 01:11:47 +01:00
ef96ba720c
don't dim background when using light theme 2024-11-26 01:07:06 +01:00
68fa4190f3
light theme 2024-11-26 01:03:59 +01:00
Vossa Excelencia
7b66611415 Translated using Weblate (Portuguese (Brazil))
Currently translated at 44.4% (4 of 9 strings)

Translation: jrpie-Launcher/metadata
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/metadata/pt_BR/
2024-11-25 11:03:30 +00:00
Vossa Excelencia
c42b648ea2 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (159 of 159 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2024-11-25 11:03:30 +00:00
Vossa Excelencia
a8d42d6b50 Translated using Weblate (Portuguese (Brazil))
Currently translated at 44.4% (4 of 9 strings)

Translation: jrpie-Launcher/metadata
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/metadata/pt_BR/
2024-11-22 06:09:11 +00:00
Vossa Excelencia
19d8db9ea8 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (159 of 159 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2024-11-22 06:09:11 +00:00
Nicola Bortoletto
76accf40da Added translation using Weblate (Italian) 2024-11-19 00:03:31 +00:00
b09c6a52b2
versionCode 30 2024-11-18 19:55:10 +01:00
bcb3f74a21
Merge branch 'master' of https://github.com/jrpie/Launcher 2024-11-18 19:37:41 +01:00
70e35db394
hide µLauncher by default 2024-11-18 19:37:33 +01:00
6a42ef0747
improved selection of default apps 2024-11-12 02:47:09 +01:00
acbcef5827
implemented #67 - option to hide apps that are bound to gestures 2024-11-12 01:53:41 +01:00
c1dcc0fe4e
Add screenshots to readme 2024-11-12 00:41:02 +01:00
90f5d5f5c5
update README.md 2024-11-12 00:20:03 +01:00
118352740c
Merge branch 'master' of https://github.com/jrpie/Launcher 2024-11-12 00:15:43 +01:00
aba23c370b
j-0.0.15 2024-11-12 00:03:02 +01:00
d1d3699233
add build instructions 2024-11-12 00:02:45 +01:00
60746c97be
updated screenshots 2024-11-12 00:00:34 +01:00
f6f09f1c2f
defaults: added thunderbird 2024-11-11 23:11:14 +01:00
7a3208ae23
CI: upload debug apk 2024-11-11 20:10:27 +01:00
d22d20d8f9
Merge branch 'master' of https://github.com/jrpie/Launcher 2024-11-11 19:20:31 +01:00
e915585dbb
lintOptions - don't abort on error 2024-11-11 19:20:22 +01:00
e0ce54bef1
Create android.yml 2024-11-11 19:01:43 +01:00
f61f861950
add accessibility service as second method for locking the screen (cf. #65) 2024-11-09 00:36:07 +01:00
9848785b3e
reintroduce AccessibilityService from 9bc8d6bb6d (cf. #65) 2024-11-08 04:07:33 +01:00
cd600af09f
j-0.0.14 2024-11-04 17:39:05 +01:00
592d2f6f8e
remove dependencyInfoBlock (cf. #66) 2024-11-04 17:38:23 +01:00
d98258b316
j-0.0.13 2024-11-03 22:12:56 +01:00
ec529dd75a
code cleanup 2024-11-03 21:32:17 +01:00
c509031954
save position of SettingsFragmentActionsRecycler (fixes #57) 2024-11-03 21:31:20 +01:00
6376845dc9
removed tooltips (cf. #55) 2024-11-03 20:53:55 +01:00
0543bcda55
improved german translation 2024-11-03 20:24:54 +01:00
4fc99c4337
update changelog for 27 2024-11-03 19:42:35 +01:00
a316ad21c0
code cleanup 2024-11-03 19:41:51 +01:00
7efe05011f
action: torch 2024-11-03 19:33:21 +01:00
d703a139f3
code cleanup 2024-11-03 19:31:53 +01:00
9b84d1ddcf
fast scroll in app list 2024-11-03 17:47:36 +01:00
589d5ec9ab
updated gradle and dependencies 2024-11-03 17:47:23 +01:00
0ee4814bd2
code cleanup 2024-11-03 16:13:17 +01:00
5b00c4b6bb
Improved handling of volume buttons
When the actions volume up / volume down are bound to the volume up
key resp. volume down key, key presses are now completely ignored
allowing other apps to bind something to those keys
(this is not possible on stock Android, but with some custom ROMs
or root).
2024-11-03 16:09:48 +01:00
3c1436e759
Merge branch 'master' of https://github.com/jrpie/Launcher 2024-11-03 15:08:03 +01:00
3037edfd83
updated default apps (cf. #64) 2024-11-03 15:07:56 +01:00
ecdb388f68
Merge pull request #63 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2024-11-03 01:05:06 +01:00
Anonymous
71ecf22ff7 Translated using Weblate (German)
Currently translated at 60.5% (86 of 142 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/de/
2024-11-03 00:03:39 +00:00
19fe0fdd8a
add button to join chat 2024-11-02 13:50:27 +01:00
55b48779cf
code cleanup 2024-11-02 13:48:37 +01:00
c1650fab84
code cleanup 2024-11-02 01:40:39 +01:00
9f235200fe
ListActivity: fixed typo in adjustResize workaround 2024-11-02 00:52:32 +01:00
4b14585c57
some cleanup 2024-11-02 00:51:44 +01:00
3f1263f648
gesture descriptions on android < 8 (cf. #55) 2024-11-02 00:17:10 +01:00
2cc4d02587
tooltips for gestures (cf. #55) 2024-11-01 23:46:50 +01:00
874a2bcdad
implemented #55 2024-11-01 23:23:19 +01:00
6b31f8dc3b
implemented #56: configurable edge width for edge gestures 2024-11-01 23:16:36 +01:00
3423534085
lock screen: use device admin instead of accessibility service 2024-11-01 21:35:31 +01:00
3c73a7f49d
update changelog for 27 2024-11-01 19:14:33 +01:00
yzqzss
9bc8d6bb6d action: lock screen 2024-10-26 22:32:15 +08:00
6cabcf51bd
limit angular tolerance of gesture detection (see #59) 2024-10-22 12:41:52 +02:00
5c28625b2a
updated github templates 2024-10-21 18:11:09 +02:00
b6965b0b10
fix #54 2024-10-21 15:07:03 +02:00
77800b27c3
Merge branch 'master' of https://github.com/jrpie/Launcher 2024-10-18 20:15:52 +02:00
3dced7ace6
include hidden apps when selecting an app 2024-10-18 20:15:23 +02:00
beabc94146
discord 2024-10-17 20:19:26 +02:00
145a2fc1f2
Merge branch 'master' of https://github.com/jrpie/Launcher 2024-10-17 20:16:01 +02:00
6bdd9ed340
discord 2024-10-17 20:15:51 +02:00
97f0c4e67e
Merge pull request #52 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2024-10-16 14:52:43 +00:00
toby
12501cad89 Translated using Weblate (French)
Currently translated at 100.0% (113 of 113 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/fr/
2024-10-16 09:03:29 +00:00
e3aedf250c
Merge pull request #50 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2024-10-14 20:33:36 +00:00
toolatebot
537db5e75c 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/
2024-10-09 00:03:39 +00:00
toby
a0c65d5ad4 Translated using Weblate (French)
Currently translated at 100.0% (7 of 7 strings)

Translation: jrpie-Launcher/metadata
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/metadata/fr/
2024-10-09 00:03:38 +00:00
toby
684ce6a29e Translated using Weblate (French)
Currently translated at 100.0% (112 of 112 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/fr/
2024-10-09 00:03:38 +00:00
Vossa Excelencia
76de557e1b Translated using Weblate (Portuguese (Brazil))
Currently translated at 42.8% (3 of 7 strings)

Translation: jrpie-Launcher/metadata
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/metadata/pt_BR/
2024-10-09 00:03:38 +00:00
Vossa Excelencia
0734d4df3b Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (112 of 112 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2024-10-09 00:03:38 +00:00
ea80bd9513
[matrix] 2024-10-09 01:56:28 +02:00
51184e7e8a
updated templates 2024-10-09 01:55:49 +02:00
ba5a784990
action: open quick settings 2024-10-07 01:36:28 +02:00
ab2ed14ab7
Merge pull request #49 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2024-10-06 21:16:47 +02:00
Vossa Excelencia
3541c04e82 Translated using Weblate (Portuguese (Brazil))
Currently translated at 100.0% (112 of 112 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/pt_BR/
2024-10-06 19:05:47 +00:00
9dae07a8eb
allow screen rotation by default (see #48) 2024-10-04 19:05:12 +02:00
af69f875af
fix #48 2024-10-04 18:40:03 +02:00
88e13c04d1
updated github templates 2024-10-04 01:06:30 +02:00
e2fa2e2987
j-0.0.12 2024-10-04 00:45:20 +02:00
b67f87e93d
fix: properly handle AppInfo with unknown user 2024-10-04 00:42:53 +02:00
4ee81bde4d
removed .idea 2024-10-03 23:00:31 +02:00
3da241c70b
j-0.0.11 2024-10-01 19:40:06 +02:00
04de9dcc3f
Merge pull request #47 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2024-09-26 23:33:56 +02:00
toolatebot
07f92a71c3 Update translation files
Updated by "Remove blank strings" add-on in Weblate.

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/
2024-09-26 18:04:20 +00:00
435qb
3eebb00a81 Translated using Weblate (Chinese (Simplified Han script))
Currently translated at 91.0% (102 of 112 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/
2024-09-26 18:04:20 +00:00
335aef1d7c
Merge branch 'master' of https://github.com/jrpie/Launcher 2024-09-25 21:54:48 +02:00
68acb43426
Merge branch 'master' of https://github.com/jrpie/Launcher 2024-09-25 21:54:24 +02:00
fe5bf8904b
Merge branch 'master' of https://github.com/jrpie/Launcher 2024-09-25 21:52:42 +02:00
a6c72f100a
fix: store activityName in AppInfo to support apps with multiple main activities 2024-09-25 21:52:32 +02:00
525ffe6b53
add some color to icon 2024-09-25 19:52:43 +02:00
7048c00ac0
Merge pull request #40 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2024-09-23 19:23:05 +02:00
662efd4ecb
Implemented #14 and #15: favorite apps and hidden apps 2024-09-23 18:45:20 +02:00
e4b1bccf85
chore: split AppInfo into AppInfo and DetailedAppInfo 2024-09-23 15:16:01 +02:00
Gnawmon
8a30d4acad Translated using Weblate (Turkish)
Currently translated at 40.0% (2 of 5 strings)

Translation: jrpie-Launcher/metadata
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/metadata/tr/
2024-09-18 15:04:20 +00:00
Gnawmon
f798b54a23 Added translation using Weblate (Turkish) 2024-09-17 14:35:42 +00:00
Anonymous
dade5d8e8f Translated using Weblate (Chinese (Simplified Han script))
Currently translated at 92.0% (93 of 101 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/
2024-09-17 14:35:42 +00:00
Anonymous
b9f31e1ff2 Translated using Weblate (French)
Currently translated at 92.0% (93 of 101 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/fr/
2024-09-17 14:35:42 +00:00
Anonymous
3537a2376c Translated using Weblate (Spanish)
Currently translated at 78.2% (79 of 101 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/es/
2024-09-17 14:35:42 +00:00
Anonymous
98b2ad16c8 Translated using Weblate (German)
Currently translated at 98.0% (99 of 101 strings)

Translation: jrpie-Launcher/Launcher
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/de/
2024-09-17 14:35:42 +00:00
95e2f82736
code cleanup 2024-09-14 15:20:23 +02:00
5cd3d62e1a
fixed bug in settings_actions (related to #36) 2024-09-14 13:44:22 +02:00
b0e4a0347a
Removed button "all apps" from settings. Hide button "install apps" on small screens. (see #36) 2024-09-13 18:55:28 +02:00
d547c89763
fixed #32 2024-09-13 17:25:14 +02:00
c40dce4ae1
updated README 2024-09-13 16:53:52 +02:00
6f241c0239
make settings_meta scrollable (see #36) 2024-09-13 13:21:35 +02:00
dddc2827b3
j-0.0.10 2024-09-13 00:37:27 +02:00
435250d704
set default background to dim as blur is quite CPU-intensive 2024-09-12 17:54:12 +02:00
1e1b89c0b7
removed untranslatable strings 2024-09-12 17:45:47 +02:00
738cddc51c
removed untranslatable strings 2024-09-12 17:44:57 +02:00
3fee30bebb
Translation to Brazilian Portuguese - thank you, Jonatas de Almeida Barros! 2024-09-12 17:39:34 +02:00
46ca5eada4
fix: navigation bar was covering settings. Might be related to #36 2024-09-12 13:34:27 +02:00
95e7b58c42
fix #37: treat all letters as letters, not just [a-z] 2024-09-12 12:48:44 +02:00
6d1e4a3780
force transparent navigation bar on home screen 2024-09-11 21:47:00 +02:00
6e28fbfea5
chore: refactored code 2024-09-11 21:07:18 +02:00
ac2aa49ca1
added option to hide seconds 2024-09-11 15:05:05 +02:00
32c3c41266
more fonts 2024-09-11 14:26:08 +02:00
c89e74205d
implemented #6: add option to allow rotation 2024-09-11 13:06:55 +02:00
9a3957be36
removed old logging 2024-09-11 11:55:00 +02:00
f788a11489
updated translations 2024-09-11 11:50:53 +02:00
672be6c9a0
merge 2024-09-11 11:41:38 +02:00
0e18eb1a78
fixed typo in german translation 2024-09-11 11:38:12 +02:00
89093f6b9e
renamed preferences 2024-09-11 11:37:33 +02:00
5dc2ee3901
reformat code 2024-09-10 19:54:53 +02:00
99acdba262
Implemented #2
Color theme, font, background and monochrome icons can now be set
independently.
2024-09-10 19:53:23 +02:00
b9dc66bc12
Merge pull request #30 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2024-09-10 12:43:23 +02:00
toolatebot
5492039b89 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/
2024-09-10 00:53:57 +00:00
870ee56b88
chore: migrated preferences to eu.jonahbauer.android.preference 2024-09-09 21:23:01 +02:00
5ab54ea1cb
chore: moved sharedPreferencesListener into FragementActionsRecycler. Might fix #27 2024-09-06 14:46:36 +02:00
25483f65ac
implemented #29: improved search 2024-09-06 14:14:42 +02:00
25905f1116
feature #28: action to open notification panel 2024-09-06 13:32:38 +02:00
9582113bcf
Merge pull request #22 from toby-bro/chore/android_permissions 2024-09-01 21:12:23 +02:00
764a75f680
Merge pull request #22 from toby-bro/chore/bump_gradle 2024-09-01 20:55:52 +02:00
1b4e2eb44d
Merge pull request #25 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2024-09-01 09:08:58 +02:00
Symphonic5855
4ce399ac62 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/
2024-09-01 04:04:19 +00:00
toby
5b906389b5 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/
2024-09-01 04:04:18 +00:00
Jean-Nicolas
23ca9eb4cf
chore: bump gradle 2024-09-01 00:10:45 +02:00
ca53aaa8cb
Merge pull request #17 from toby-bro/feat/french_translation_of_description
feat: french translation of short and full description for f-droid
2024-08-31 22:33:37 +02:00
c7068a31ce
Merge pull request #19 from toby-bro/fix/disappearing_icons
Fix  disappearing icons (#8)
2024-08-31 22:30:50 +02:00
Jean-Nicolas
0d9d85f253
fix: add defaults so as to fix bug 2024-08-31 20:26:16 +02:00
Jean-Nicolas
1ff26ac036
chore: remove local parameters from global configuration 2024-08-31 19:49:47 +02:00
Jean-Nicolas
91a636bf03
feat: add french translation of short and full description 2024-08-31 17:29:32 +02:00
861895750c
Merge pull request #13 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2024-08-29 16:33:05 +02:00
fcf96e64ad
Merge branch 'master' into weblate-jrpie-launcher-launcher 2024-08-29 16:32:41 +02:00
ac30fc6ed5
increase version code, enable gradle configuration cache 2024-08-29 01:00:50 +02:00
7c6ea1a16e
updated changelog 2024-08-28 21:06:58 +02:00
eeb31d6cf1
version j-0.0.9 2024-08-28 21:02:27 +02:00
d4f672fc51
changed default settings 2024-08-28 20:57:24 +02:00
631dbf0cdb
fix: improved german translation 2024-08-28 20:54:54 +02:00
e86ed34fe5
feature: reworked date & time settings 2024-08-28 20:40:48 +02:00
toby
3dfa9d912e 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/
2024-08-28 18:09:03 +00:00
7ecab3d9ae
updated README.md 2024-08-28 15:39:28 +02:00
849db934ac
feature: removed sensitivity setting
Removed the sensitivity setting.
Many people were complaining about the default sensitivity
being too low. Nobody every complained about sensitivity being too high.
2024-08-28 10:54:57 +02:00
b0deb94b7a
updated changelog 2024-08-28 10:27:50 +02:00
ef16d70576
feature: home button always starts HomeActivity
Removed intendedSettingsPause and intendedChoosePause.
Using android:clearTaskOnLaunch together with
android:launchMode="singleTask" instead.
This makes the home button work properly.
2024-08-28 10:14:21 +02:00
2e82fec002
updated .gitignore 2024-08-28 09:58:29 +02:00
f0c06ba6e5
feature: make settnings available from system settings 2024-08-28 09:55:53 +02:00
f792271a5a
feature: submitting search opens first app matching the query 2024-08-28 09:43:05 +02:00
62c6e1fc2f
fixed #10: layout of settings on small screens 2024-08-28 02:05:09 +02:00
bc0ecad1ac
fix #5: don't show uninstall option for system apps.
The three dot menu button was removed, since the menu is already
available by long clicking
2024-08-28 01:46:06 +02:00
522353a62c
Merge branch 'master' of https://github.com/jrpie/Launcher 2024-08-28 01:00:54 +02:00
522ca697b6
fix #9: disable workaround for adjustResize when it is not needed 2024-08-28 01:00:26 +02:00
496dc17c2e
Merge pull request #11 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2024-08-27 23:39:58 +02:00
toby
bd52784ce8 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/
2024-08-27 18:58:46 +00:00
493af82004
Merge pull request #3 from toolatebot/weblate-jrpie-launcher-launcher
Translations update from Toolate
2024-08-27 13:04:16 +02:00
79b63b6f5c
Remove non-translatable strings from chinese translation 2024-08-27 12:54:52 +02:00
Symphonic5855
33137a5bff Translated using Weblate (Chinese (Simplified))
Currently translated at 100.0% (3 of 3 strings)

Co-authored-by: Symphonic5855 <Symphonic5855@users.noreply.toolate.othing.xyz>
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/metadata/zh_Hans/
Translation: jrpie-Launcher/metadata
2024-08-24 00:53:56 +00:00
toolatebot
35296db832 Update translation files
Updated by "Remove blank strings" add-on in Weblate.

Co-authored-by: toolatebot <toolate@othing.xyz>
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/
Translation: jrpie-Launcher/Launcher
2024-08-24 00:53:56 +00:00
yzqzss
fb4d3b5f17 Translated using Weblate (Chinese (Simplified))
Currently translated at 98.9% (98 of 99 strings)

Translated using Weblate (Chinese (Simplified))

Currently translated at 33.3% (1 of 3 strings)

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (99 of 99 strings)

Co-authored-by: yzqzss <yzqzss@yandex.com>
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/metadata/zh_Hans/
Translation: jrpie-Launcher/Launcher
Translation: jrpie-Launcher/metadata
2024-08-24 00:53:56 +00:00
toolatebot
25c4472398 Update translation files
Updated by "Remove blank strings" add-on in Weblate.

Co-authored-by: toolatebot <toolate@othing.xyz>
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/
Translation: jrpie-Launcher/Launcher
2024-08-24 00:53:56 +00:00
Weblate
ef71215676 Translated using Weblate (Chinese (Simplified))
Currently translated at 10.1% (10 of 99 strings)

Co-authored-by: Weblate <noreply-mt-weblate@weblate.org>
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/
Translation: jrpie-Launcher/Launcher
2024-08-24 00:53:56 +00:00
Weblate Translation Memory
7dc6d1cf35 Translated using Weblate (Chinese (Simplified))
Currently translated at 10.1% (10 of 99 strings)

Co-authored-by: Weblate Translation Memory <noreply-mt-weblate-translation-memory@weblate.org>
Translate-URL: https://toolate.othing.xyz/projects/jrpie-launcher/launcher/zh_Hans/
Translation: jrpie-Launcher/Launcher
2024-08-24 00:53:56 +00:00
yzqzss
f54b4494e2 Added translation using Weblate (Chinese (Simplified))
Co-authored-by: yzqzss <yzqzss@yandex.com>
2024-08-24 00:53:56 +00:00
31727d63c4
Merge pull request #4 from Poussinou/patch-1
Update README.md
2024-08-23 19:21:40 +02:00
Poussinou
6be67336a3
Update README.md 2024-08-22 19:12:35 -04:00
25c0205015
updated featureGraphic.png 2024-08-22 22:33:29 +02:00
3b90b3f837
updated metadata 2024-08-08 17:20:03 +02:00
037b632a63
version j-0.0.8 2024-08-08 16:21:06 +02:00
c6fe8dc405
use Intent.CATEGORY_APP_MAIN instead of hardcoded reference to play store 2024-08-05 15:47:12 +02:00
0553d5eb4c
chore: some refactoring 2024-08-05 15:30:39 +02:00
888dc032c1
chore: code cleanup 2024-08-05 15:10:37 +02:00
5e841a9106
fix: popup menu for work profile apps 2024-08-05 15:08:41 +02:00
bf4298ea58
fix: sort apps alphabetically 2024-08-03 00:22:25 +02:00
311 changed files with 11707 additions and 4307 deletions

4
.github/FUNDING.yml vendored
View file

@ -1,3 +1,3 @@
# How you can support finnmglas/Launcher
# How you can support jrpie/Launcher
custom: sponsor.finnmglas.com
custom: https://s.jrpie.de/launcher-donate

View file

@ -1,31 +0,0 @@
---
name: Bug report
about: Create a report to help improve this app
title: ''
labels: bug
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Smartphone (please complete the following information):**
- Device: [e.g. Samsung A7]
- Android Version: [e.g. Marshmallow, 6.0 or API 23]
**Additional info**
Add any other info or comments about the problem here.

50
.github/ISSUE_TEMPLATE/bug_report.yaml vendored Normal file
View file

@ -0,0 +1,50 @@
name: Bug report
description: Create a report to help improve this app
title: '[bug] '
labels: bug
body:
- type: markdown
attributes:
value: |
Thank you for helping to improve µLauncher!
- type: textarea
id: bug
attributes:
label: Describe the Bug
description: What happened?
placeholder: A clear and concise description of what the bug is.
render: markdown
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected Behavior
description: What did you expect to happen instead?
render: markdown
validations:
required: false
- type: textarea
id: reproduce
attributes:
label: To Reproduce
description: What steps are required to reproduce the bug?
render: markdown
placeholder: |
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
validations:
required: false
- type: textarea
id: device
attributes:
label: Your Device
description: |
What device are you using? Adding this information helps to reproduce the bug.
You can copy this from µLauncher > Settings > Meta > Report Bug.
render: markdown
validations:
required: false

View file

@ -1,20 +1,24 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
title: '[feature] '
labels: enhancement
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
# <!--MANDATORY--> Please describe the problem to be solved
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
<!-- Add a clear and concise description of the addressed problem. Don't say "add a button such that ... " but **why** this button should be added. This is very important as it allows to discuss alternative solutions. -->
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
# <!--OPTIONAL--> Describe the solution you would suggest
**Additional info**
Add any other info, comments or screenshots about the feature request here.
<!-- A description of the solution, e.g. "add a button to the settings activity. When clicking that button ..." -->
# <!--OPTIONAL--> Describe alternative solutions you've considered
<!-- A description of any alternative solutions or features you've considered. -->
# <!--OPTIONAL--> Additional info
<!-- Add any other info, comments or screenshots about the feature request here. -->

32
.github/workflows/android.yml vendored Normal file
View file

@ -0,0 +1,32 @@
name: Android CI
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: gradle
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: upload apk
uses: actions/upload-artifact@v4
with:
name: launcher-debug-${{ github.sha }}.apk
path: app/build/outputs/apk/default/debug/app-default-debug.apk

3
.gitignore vendored
View file

@ -40,12 +40,15 @@ captures/
# IntelliJ
*.iml
.idea/*
.idea/workspace.xml
.idea/tasks.xml
.idea/other.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/deploymentTargetSelector.xml
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml

View file

@ -1,138 +0,0 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>
<package name="java.util" alias="false" withSubpackages="false" />
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
<package name="io.ktor" alias="false" withSubpackages="true" />
</value>
</option>
<option name="PACKAGES_IMPORT_LAYOUT">
<value>
<package name="" alias="false" withSubpackages="true" />
<package name="java" alias="false" withSubpackages="true" />
<package name="javax" alias="false" withSubpackages="true" />
<package name="kotlin" alias="false" withSubpackages="true" />
<package name="" alias="true" withSubpackages="true" />
</value>
</option>
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</JetCodeStyleSettings>
<codeStyleSettings language="XML">
<indentOptions>
<option name="CONTINUATION_INDENT_SIZE" value="4" />
</indentOptions>
<arrangement>
<rules>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:android</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>xmlns:.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:id</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*:name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>name</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>style</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>^$</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>http://schemas.android.com/apk/res/android</XML_NAMESPACE>
</AND>
</match>
<order>ANDROID_ATTRIBUTE_ORDER</order>
</rule>
</section>
<section>
<rule>
<match>
<AND>
<NAME>.*</NAME>
<XML_ATTRIBUTE />
<XML_NAMESPACE>.*</XML_NAMESPACE>
</AND>
</match>
<order>BY_NAME</order>
</rule>
</section>
</rules>
</arrangement>
</codeStyleSettings>
<codeStyleSettings language="kotlin">
<option name="CODE_STYLE_DEFAULTS" value="KOTLIN_OFFICIAL" />
</codeStyleSettings>
</code_scheme>
</component>

View file

@ -1,5 +0,0 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
</state>
</component>

6
.idea/compiler.xml generated
View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="17" />
</component>
</project>

View file

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetSelector">
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
</selectionStates>
</component>
</project>

View file

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DeviceTable">
<option name="columnSorters">
<list>
<ColumnSorterState>
<option name="column" value="Name" />
<option name="order" value="ASCENDING" />
</ColumnSorterState>
</list>
</option>
</component>
</project>

View file

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
<remote-repository>
<option name="id" value="BintrayJCenter" />
<option name="name" value="BintrayJCenter" />
<option name="url" value="https://jcenter.bintray.com/" />
</remote-repository>
<remote-repository>
<option name="id" value="Google" />
<option name="name" value="Google" />
<option name="url" value="https://dl.google.com/dl/android/maven2/" />
</remote-repository>
</component>
</project>

6
.idea/kotlinc.xml generated
View file

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KotlinJpsPluginSettings">
<option name="version" value="2.0.0" />
</component>
</project>

10
.idea/migrations.xml generated
View file

@ -1,10 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectMigrations">
<option name="MigrateToGradleLocalJavaHome">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</component>
</project>

18
.idea/misc.xml generated
View file

@ -1,18 +0,0 @@
<project version="4">
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
<entry key="app/src/main/res/layout/list.xml" value="0.21331521739130435" />
<entry key="app/src/main/res/layout/list_apps.xml" value="0.1757852077001013" />
<entry key="app/src/main/res/layout/settings.xml" value="0.21331521739130435" />
</map>
</option>
</component>
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>

252
.idea/other.xml generated
View file

@ -1,252 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="direct_access_persist.xml">
<option name="deviceSelectionList">
<list>
<PersistentDeviceSelectionData>
<option name="api" value="27" />
<option name="brand" value="DOCOMO" />
<option name="codename" value="F01L" />
<option name="id" value="F01L" />
<option name="manufacturer" value="FUJITSU" />
<option name="name" value="F-01L" />
<option name="screenDensity" value="360" />
<option name="screenX" value="720" />
<option name="screenY" value="1280" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="28" />
<option name="brand" value="DOCOMO" />
<option name="codename" value="SH-01L" />
<option name="id" value="SH-01L" />
<option name="manufacturer" value="SHARP" />
<option name="name" value="AQUOS sense2 SH-01L" />
<option name="screenDensity" value="480" />
<option name="screenX" value="1080" />
<option name="screenY" value="2160" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="31" />
<option name="brand" value="samsung" />
<option name="codename" value="a51" />
<option name="id" value="a51" />
<option name="manufacturer" value="Samsung" />
<option name="name" value="Galaxy A51" />
<option name="screenDensity" value="420" />
<option name="screenX" value="1080" />
<option name="screenY" value="2400" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="34" />
<option name="brand" value="google" />
<option name="codename" value="akita" />
<option name="id" value="akita" />
<option name="manufacturer" value="Google" />
<option name="name" value="Pixel 8a" />
<option name="screenDensity" value="420" />
<option name="screenX" value="1080" />
<option name="screenY" value="2400" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="33" />
<option name="brand" value="samsung" />
<option name="codename" value="b0q" />
<option name="id" value="b0q" />
<option name="manufacturer" value="Samsung" />
<option name="name" value="Galaxy S22 Ultra" />
<option name="screenDensity" value="600" />
<option name="screenX" value="1440" />
<option name="screenY" value="3088" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="32" />
<option name="brand" value="google" />
<option name="codename" value="bluejay" />
<option name="id" value="bluejay" />
<option name="manufacturer" value="Google" />
<option name="name" value="Pixel 6a" />
<option name="screenDensity" value="420" />
<option name="screenX" value="1080" />
<option name="screenY" value="2400" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="29" />
<option name="brand" value="samsung" />
<option name="codename" value="crownqlteue" />
<option name="id" value="crownqlteue" />
<option name="manufacturer" value="Samsung" />
<option name="name" value="Galaxy Note9" />
<option name="screenDensity" value="420" />
<option name="screenX" value="2220" />
<option name="screenY" value="1080" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="34" />
<option name="brand" value="samsung" />
<option name="codename" value="dm3q" />
<option name="id" value="dm3q" />
<option name="manufacturer" value="Samsung" />
<option name="name" value="Galaxy S23 Ultra" />
<option name="screenDensity" value="600" />
<option name="screenX" value="1440" />
<option name="screenY" value="3088" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="33" />
<option name="brand" value="google" />
<option name="codename" value="felix" />
<option name="id" value="felix" />
<option name="manufacturer" value="Google" />
<option name="name" value="Pixel Fold" />
<option name="screenDensity" value="420" />
<option name="screenX" value="2208" />
<option name="screenY" value="1840" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="33" />
<option name="brand" value="google" />
<option name="codename" value="felix_camera" />
<option name="id" value="felix_camera" />
<option name="manufacturer" value="Google" />
<option name="name" value="Pixel Fold (Camera-enabled)" />
<option name="screenDensity" value="420" />
<option name="screenX" value="2208" />
<option name="screenY" value="1840" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="33" />
<option name="brand" value="samsung" />
<option name="codename" value="gts8uwifi" />
<option name="id" value="gts8uwifi" />
<option name="manufacturer" value="Samsung" />
<option name="name" value="Galaxy Tab S8 Ultra" />
<option name="screenDensity" value="320" />
<option name="screenX" value="1848" />
<option name="screenY" value="2960" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="34" />
<option name="brand" value="google" />
<option name="codename" value="husky" />
<option name="id" value="husky" />
<option name="manufacturer" value="Google" />
<option name="name" value="Pixel 8 Pro" />
<option name="screenDensity" value="390" />
<option name="screenX" value="1008" />
<option name="screenY" value="2244" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="30" />
<option name="brand" value="motorola" />
<option name="codename" value="java" />
<option name="id" value="java" />
<option name="manufacturer" value="Motorola" />
<option name="name" value="G20" />
<option name="screenDensity" value="280" />
<option name="screenX" value="720" />
<option name="screenY" value="1600" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="33" />
<option name="brand" value="google" />
<option name="codename" value="lynx" />
<option name="id" value="lynx" />
<option name="manufacturer" value="Google" />
<option name="name" value="Pixel 7a" />
<option name="screenDensity" value="420" />
<option name="screenX" value="1080" />
<option name="screenY" value="2400" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="31" />
<option name="brand" value="google" />
<option name="codename" value="oriole" />
<option name="id" value="oriole" />
<option name="manufacturer" value="Google" />
<option name="name" value="Pixel 6" />
<option name="screenDensity" value="420" />
<option name="screenX" value="1080" />
<option name="screenY" value="2400" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="33" />
<option name="brand" value="google" />
<option name="codename" value="panther" />
<option name="id" value="panther" />
<option name="manufacturer" value="Google" />
<option name="name" value="Pixel 7" />
<option name="screenDensity" value="420" />
<option name="screenX" value="1080" />
<option name="screenY" value="2400" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="34" />
<option name="brand" value="samsung" />
<option name="codename" value="q5q" />
<option name="id" value="q5q" />
<option name="manufacturer" value="Samsung" />
<option name="name" value="Galaxy Z Fold5" />
<option name="screenDensity" value="420" />
<option name="screenX" value="1812" />
<option name="screenY" value="2176" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="30" />
<option name="brand" value="google" />
<option name="codename" value="r11" />
<option name="id" value="r11" />
<option name="manufacturer" value="Google" />
<option name="name" value="Pixel Watch" />
<option name="screenDensity" value="320" />
<option name="screenX" value="384" />
<option name="screenY" value="384" />
<option name="type" value="WEAR_OS" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="30" />
<option name="brand" value="google" />
<option name="codename" value="redfin" />
<option name="id" value="redfin" />
<option name="manufacturer" value="Google" />
<option name="name" value="Pixel 5" />
<option name="screenDensity" value="440" />
<option name="screenX" value="1080" />
<option name="screenY" value="2340" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="34" />
<option name="brand" value="google" />
<option name="codename" value="shiba" />
<option name="id" value="shiba" />
<option name="manufacturer" value="Google" />
<option name="name" value="Pixel 8" />
<option name="screenDensity" value="420" />
<option name="screenX" value="1080" />
<option name="screenY" value="2400" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="33" />
<option name="brand" value="google" />
<option name="codename" value="tangorpro" />
<option name="id" value="tangorpro" />
<option name="manufacturer" value="Google" />
<option name="name" value="Pixel Tablet" />
<option name="screenDensity" value="320" />
<option name="screenX" value="1600" />
<option name="screenY" value="2560" />
</PersistentDeviceSelectionData>
<PersistentDeviceSelectionData>
<option name="api" value="29" />
<option name="brand" value="samsung" />
<option name="codename" value="x1q" />
<option name="id" value="x1q" />
<option name="manufacturer" value="Samsung" />
<option name="name" value="Galaxy S20" />
<option name="screenDensity" value="480" />
<option name="screenX" value="1440" />
<option name="screenY" value="3200" />
</PersistentDeviceSelectionData>
</list>
</option>
</component>
</project>

76
.scripts/release.sh Executable file
View file

@ -0,0 +1,76 @@
#!/bin/bash
export JAVA_HOME="/usr/lib/jvm/java-21-openjdk/"
OUTPUT_DIR="$HOME/launcher-release"
BUILD_TOOLS_DIR="$HOME/Android/Sdk/build-tools/35.0.0"
KEYSTORE="$HOME/data/keys/launcher_jrpie.jks"
KEYSTORE_ACCRESCENT="$HOME/data/keys/launcher_jrpie_accrescent.jks"
KEYSTORE_PASS=$(keepassxc-password "android_keys/launcher")
KEYSTORE_ACCRESCENT_PASS=$(keepassxc-password "android_keys/launcher-accrescent")
if [[ $(git status --porcelain) ]]; then
echo "There are uncommitted changes."
read -p "Continue anyway? (y/n) " -n 1 -r
echo # (optional) move to a new line
if ! [[ $REPLY =~ ^[Yy]$ ]]
then
exit 1
fi
fi
rm -rf "$OUTPUT_DIR"
mkdir "$OUTPUT_DIR"
echo
echo "======================="
echo " Default Release (apk) "
echo "======================="
./gradlew clean
./gradlew assembleDefaultRelease
mv app/build/outputs/apk/default/release/app-default-release-unsigned.apk "$OUTPUT_DIR/app-release.apk"
"$BUILD_TOOLS_DIR/apksigner" sign --ks "$KEYSTORE" \
--ks-key-alias key0 \
--ks-pass="pass:$KEYSTORE_PASS" \
--key-pass="pass:$KEYSTORE_PASS" \
--alignment-preserved \
--v1-signing-enabled=true \
--v2-signing-enabled=true \
--v3-signing-enabled=true \
--v4-signing-enabled=true \
"$OUTPUT_DIR/app-release.apk"
echo
echo "======================="
echo " Default Release (aab) "
echo "======================="
./gradlew clean
./gradlew bundleDefaultRelease
mv app/build/outputs/bundle/defaultRelease/app-default-release.aab "$OUTPUT_DIR/app-release.aab"
"$BUILD_TOOLS_DIR/apksigner" sign --ks "$KEYSTORE" \
--ks-key-alias key0 \
--ks-pass="pass:$KEYSTORE_PASS" \
--key-pass="pass:$KEYSTORE_PASS" \
--v1-signing-enabled=true --v2-signing-enabled=true --v3-signing-enabled=true --v4-signing-enabled=true \
--min-sdk-version=21 \
"$OUTPUT_DIR/app-release.aab"
echo
echo "======================="
echo " Accrescent (apks) "
echo "======================="
./gradlew clean
./gradlew bundleAccrescentRelease
mv app/build/outputs/bundle/accrescentRelease/app-accrescent-release.aab "$OUTPUT_DIR/app-accrescent-release.aab"
# build apks using bundletool from https://github.com/google/bundletool/releases
"$JAVA_HOME/bin/java" -jar /opt/android/bundletool.jar build-apks \
--bundle="$OUTPUT_DIR/app-accrescent-release.aab" --output="$OUTPUT_DIR/launcher-accrescent.apks" \
--ks="$KEYSTORE_ACCRESCENT" \
--ks-pass="pass:$KEYSTORE_ACCRESCENT_PASS" \
--ks-key-alias="key0" \
--key-pass="pass:$KEYSTORE_ACCRESCENT_PASS"

View file

@ -1,7 +1,7 @@
MIT License
Original Code Copyright (c) 2020 Finn Glas (https://github.com/finnmglas/Launcher)
Modifications Copyright (c) 2023 Josia Pietsch
Modifications Copyright (c) 2025 Josia Pietsch
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

125
README.md
View file

@ -1,37 +1,112 @@
<!-- Shields from shields.io -->
<!--[![][shield-release]][latest-release] -->
[![][shield-release]][latest-release]
[![Android CI](https://github.com/jrpie/Launcher/actions/workflows/android.yml/badge.svg)](https://github.com/jrpie/Launcher/actions/workflows/android.yml)
[![][shield-license]][license]
[![Chat on Matrix](https://matrix.to/img/matrix-badge.svg)][matrix]
[![Chat on Discord](https://img.shields.io/badge/discord-join%20chat-007ec6.svg?style=flat)][discord]
# μLauncher
This is a fork of [finnmglas's app Launcher][original-repo].
## Notable changes:
* Edge gestures: There is a setting to allow distinguishing swiping at the edges of the screen from swiping in the center.
* Compatible with [work profile](https://www.android.com/enterprise/work-profile/), so apps like [Shelter](https://gitea.angry.im/PeterCxy/Shelter) can be used.
### Visual
* This app uses the system wallpaper instead of a custom solution.
* The font has been changed to [Hack][hack-font].
* Font Awesome Icons were replaced by Material icons.
* The gear button on the home screen was removed. Instead pressing back opens the list of applications and the app settings are accessible from there.
µLauncher is an Android home screen that lets you launch apps using swipe gestures and button presses.
It is *minimal, efficient and free of distraction*.
### Search
* The search algorithm was modified to prefer matches at the beginning of the app name, i.e. when searching for `"te"`, `"termux"` is sorted before `"notes"`.
* The search bar was moved to the bottom of the screen.
<a href="https://f-droid.org/packages/de.jrpie.android.launcher/"><img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png" alt="Get it on F-Droid" height="80"></a>
<a href="https://accrescent.app/app/de.jrpie.android.launcher.accrescent"><img alt="Get it on Accrescent" src="https://accrescent.app/badges/get-it-on.png" height="80"></a>
<a href="https://apps.obtainium.imranr.dev/redirect?r=obtainium://app/{%22id%22:%22de.jrpie.android.launcher%22,%22url%22:%22https://github.com/jrpie/Launcher%22,%22author%22:%22jrpie%22,%22name%22:%22%c2%b5Launcher%22,%22additionalSettings%22:%22{\%22apkFilterRegEx\%22:\%22release\%22,\%22invertAPKFilter\%22:false,\%22about\%22:\%22%c2%b5Launcher%20is%20a%20minimal%20home%20screen.\%22}%22}"><img src="https://raw.githubusercontent.com/ImranR98/Obtainium/b1c8ac6f2ab08497189721a788a5763e28ff64cd/assets/graphics/badge_obtainium.png" alt="Get it on Obtainium" height="80"></a>
<a href="https://github.com/jrpie/launcher/releases/latest"><img src="https://raw.githubusercontent.com/NeoApplications/Neo-Backup/034b226cea5c1b30eb4f6a6f313e4dadcbb0ece4/badge_github.png" alt="Get it on GitHub" height="80"></a>
You can also [get it on Google Play](https://play.google.com/store/apps/details?id=de.jrpie.android.launcher), but I don't recommend that.
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/1.jpg"
alt="screenshot"
height="400">
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/2.jpg"
alt="screenshot"
height="400">
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/3.jpg"
alt="screenshot"
height="400">
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/4.jpg"
alt="screenshot"
height="400">
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/5.jpg"
alt="screenshot"
height="400">
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/7.jpg"
alt="screenshot"
height="400">
<img src="fastlane/metadata/android/en-US/images/phoneScreenshots/8.jpg"
alt="screenshot"
height="400">
µLauncher is a fork of [finnmglas's app Launcher][original-repo].
An incomplete list of changes can be found [here](docs/launcher.md).
## Features
µLauncher only displays the date, time and a wallpaper.
Pressing back or swiping up (this can be configured) opens a list
of all installed apps, which can be searched efficiently.
The following gestures are available:
- volume up / down,
- swipe up / down / left / right,
- swipe with two fingers,
- swipe on the left / right resp. top / bottom edge,
- tap, then swipe up / down / left / right,
- draw < / > / V / Λ
- click on date / time,
- double click,
- long click,
- back button.
To every gesture you can bind one of the following actions:
- launch an app,
- open a list of all / favorite / private apps,
- open µLauncher settings,
- toggle private space lock,
- lock the screen,
- toggle the torch,
- volume up / down,
- go to previous / next audio track.
µLauncher is compatible with [work profile](https://www.android.com/enterprise/work-profile/),
so apps like [Shelter](https://gitea.angry.im/PeterCxy/Shelter) can be used.
By default the font is set to [Hack][hack-font], but other fonts can be selected.
## Contributing
There are several ways to contribute to this app:
* You can add or improve [translations][toolate].
<br><img src="https://toolate.othing.xyz/widget/jrpie-launcher/launcher/horizontal-auto.svg" alt="translation status">
* If you find a bug or have an idea for a new feature you can [join the chat][chat] or open an [issue][issues]. Please note that I work on this project in my free time. Thus I might not respond immediately and not all ideas will be implemented.
* You can implement a new feature yourself:
- Create a fork of this repository: [![][shield-gh-fork]][fork]
- Create a new branch named `feature/<your feature>` or `fix/<your fix>` and commit your changes.
- Open a new pull request.
See [build.md](docs/build.md) for instructions how to build this project.
The [CI pipeline](https://github.com/jrpie/Launcher/actions) automatically creates debug builds.
Note that those are not signed.
### Technical
* Small improvements to the gesture detection.
* Different apps set as default.
* Package name was changed to `de.jrpie.android.launcher` to avoid clashing with the original app.
* Dropped support for API < 21 (i.e. pre Lollypop)
* Some refactoring
---
---
[hack-font]: https://sourcefoundry.org/hack/
[original-repo]: https://github.com/finnmglas/Launcher
[toolate]: https://toolate.othing.xyz/projects/jrpie-launcher/
[issues]: https://github.com/jrpie/Launcher/issues/
[fork]: https://github.com/jrpie/Launcher/fork/
<!-- Download links / stores -->
@ -43,14 +118,16 @@ This is a fork of [finnmglas's app Launcher][original-repo].
<!-- Shields and Badges -->
[shield-release]: https://img.shields.io/github/v/release/jrpie/Launcher?style=flat
[latest-release]: https://github.com/jrpie/Launcher/releases/latest
[shield-contribute]: https://img.shields.io/badge/contributions-welcome-007ec6.svg?style=flat
[shield-license]: https://img.shields.io/badge/license-MIT-007ec6?style=flat
[shield-gh-watch]: https://img.shields.io/github/watchers/jrpie/Launcher?label=Watch&style=social
[shield-gh-star]: https://img.shields.io/github/stars/jrpie/Launcher?label=Star&style=social
[shield-gh-fork]: https://img.shields.io/github/forks/jrpie/Launcher?label=Fork&style=social
[matrix]: https://s.jrpie.de/launcher-matrix
[discord]: https://s.jrpie.de/launcher-discord
[chat]: https://s.jrpie.de/launcher-chat
<!-- Helpful resources -->

5
SECURITY.md Normal file
View file

@ -0,0 +1,5 @@
# Reporting Security Issues
For security related issues, please use the contact information
from the [security.txt](https://jrpie.de/.well-known/security.txt) on my website
or [report a vulnerability](https://github.com/jrpie/Launcher/security/advisories/new) on github.

View file

@ -1,10 +1,9 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlinx-serialization'
android {
compileSdkVersion 34
buildToolsVersion "34.0.0"
dataBinding {
enabled = true
}
@ -23,8 +22,9 @@ android {
applicationId "de.jrpie.android.launcher"
minSdkVersion 21
targetSdkVersion 35
versionCode 19
versionName "j-0.0.7"
compileSdk 35
versionCode 44
versionName "0.1.4"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
@ -41,34 +41,75 @@ android {
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix = ".debug"
versionNameSuffix = "-debug"
}
}
flavorDimensions += "distribution"
productFlavors {
create("default") {
dimension = "distribution"
getIsDefault().set(true)
buildConfigField "boolean", "USE_ACCESSIBILITY_SERVICE", "true"
}
create("accrescent") {
dimension = "distribution"
applicationIdSuffix = ".accrescent"
versionNameSuffix = "+accrescent"
buildConfigField "boolean", "USE_ACCESSIBILITY_SERVICE", "false"
}
}
sourceSets {
accrescent {
manifest.srcFile 'src/accrescent/AndroidManifest.xml'
}
}
namespace 'de.jrpie.android.launcher'
buildFeatures {
buildConfig true
}
dependenciesInfo {
// Disables dependency metadata when building APKs.
includeInApk = false
// Disables dependency metadata when building Android App Bundles.
includeInBundle = false
}
lint {
abortOnError false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.activity:activity-ktx:1.8.0'
implementation 'androidx.appcompat:appcompat:1.7.0'
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'
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.core:core-ktx:1.15.0'
implementation 'androidx.constraintlayout:constraintlayout:2.2.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.palette:palette-ktx:1.0.0'
implementation "com.android.databinding:compiler:$android_plugin_version"
implementation 'androidx.recyclerview:recyclerview:1.4.0'
implementation 'androidx.preference:preference-ktx:1.2.1'
implementation 'com.google.android.material:material:1.12.0'
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3")
implementation "eu.jonahbauer:android-preference-annotations:1.1.2"
annotationProcessor "eu.jonahbauer:android-preference-annotations:1.1.2"
annotationProcessor "com.android.databinding:compiler:$android_plugin_version"
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.2.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
}

View file

@ -1,4 +1,6 @@
# Add project specific ProGuard rules here.
-dontobfuscate
-dontoptimize
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
@ -25,3 +27,4 @@
# This is generated automatically by the Android Gradle plugin.
-dontwarn javax.annotation.processing.AbstractProcessor
-dontwarn javax.annotation.processing.SupportedAnnotationTypes
-dontwarn javax.annotation.processing.SupportedSourceVersion

View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:node="merge">
<application
android:name=".Application"
tools:node="merge">
<service
android:name=".actions.lock.LauncherAccessibilityService"
tools:strict="true"
tools:node="remove" />
</application>
</manifest>

View file

@ -0,0 +1,3 @@
<resources>
<string name="app_name" translatable="false">μLauncher [debug]</string>
</resources>

View file

@ -3,45 +3,98 @@
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
<uses-permission
android:name="android.permission.QUERY_ALL_PACKAGES"
tools:ignore="QueryAllPackagesPermission" />
<uses-permission android:name="android.permission.ACCESS_HIDDEN_PROFILES" />
<uses-permission android:name="android.permission.EXPAND_STATUS_BAR" />
<application
android:name=".Application"
android:allowBackup="true"
android:enableOnBackInvokedCallback="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/launcherBaseTheme">
<activity android:name=".HomeActivity"
android:theme="@style/launcherBaseTheme"
tools:ignore="UnusedAttribute">
<activity
android:name=".ui.PinShortcutActivity"
android:autoRemoveFromRecents="true"
android:excludeFromRecents="true"
android:exported="false">
<intent-filter>
<action android:name="android.content.pm.action.CONFIRM_PIN_SHORTCUT" />
<action android:name="android.content.pm.action.CONFIRM_PIN_APPWIDGET" />
</intent-filter>
</activity>
<activity
android:name=".ui.HomeActivity"
android:clearTaskOnLaunch="true"
android:configChanges="orientation|screenSize"
android:excludeFromRecents="true"
android:exported="true"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity">
android:launchMode="singleTask"
android:theme="@style/launcherHomeTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".tutorial.TutorialActivity"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity">
</activity>
<activity android:name=".list.ListActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"
tools:ignore="LockedOrientationActivity">
</activity>
<activity android:name=".settings.SettingsActivity"
android:screenOrientation="portrait"
tools:ignore="LockedOrientationActivity">
</activity>
<activity
android:name=".ui.tutorial.TutorialActivity"
android:configChanges="orientation|screenSize" />
<activity
android:name=".ui.list.ListActivity"
android:configChanges="orientation|screenSize"
android:windowSoftInputMode="adjustResize" />
<activity
android:name=".ui.settings.SettingsActivity"
android:configChanges="orientation|screenSize"
android:exported="true"
android:windowSoftInputMode="adjustNothing">
<intent-filter>
<action android:name="android.intent.action.APPLICATION_PREFERENCES" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".ui.LegalInfoActivity"
android:exported="false" />
<receiver
android:name=".actions.lock.LauncherDeviceAdmin"
android:description="@string/device_admin_description"
android:exported="true"
android:label="@string/app_name"
android:permission="android.permission.BIND_DEVICE_ADMIN">
<meta-data
android:name="android.app.device_admin"
android:resource="@xml/device_admin_config" />
<intent-filter>
<action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
</intent-filter>
</receiver>
<service
android:name=".actions.lock.LauncherAccessibilityService"
android:exported="true"
android:label="@string/app_name"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/accessibility_service_config" />
</service>
</application>
</manifest>
</manifest>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Before After
Before After

View file

@ -0,0 +1,160 @@
package de.jrpie.android.launcher
import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.IntentFilter
import android.content.SharedPreferences
import android.content.pm.LauncherApps
import android.content.pm.ShortcutInfo
import android.os.Build
import android.os.Build.VERSION_CODES
import android.os.UserHandle
import androidx.core.content.ContextCompat
import androidx.lifecycle.MutableLiveData
import androidx.preference.PreferenceManager
import de.jrpie.android.launcher.actions.TorchManager
import de.jrpie.android.launcher.apps.AbstractAppInfo
import de.jrpie.android.launcher.apps.AbstractDetailedAppInfo
import de.jrpie.android.launcher.apps.isPrivateSpaceLocked
import de.jrpie.android.launcher.preferences.LauncherPreferences
import de.jrpie.android.launcher.preferences.migratePreferencesToNewVersion
import de.jrpie.android.launcher.preferences.resetPreferences
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
class Application : android.app.Application() {
val apps = MutableLiveData<List<AbstractDetailedAppInfo>>()
val privateSpaceLocked = MutableLiveData<Boolean>()
private val profileAvailabilityBroadcastReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
// TODO: only update specific apps
// use Intent.EXTRA_USER
loadApps()
}
}
// TODO: only update specific apps
private val launcherAppsCallback = object : LauncherApps.Callback() {
override fun onPackageRemoved(p0: String?, p1: UserHandle?) {
loadApps()
}
override fun onPackageAdded(p0: String?, p1: UserHandle?) {
loadApps()
}
override fun onPackageChanged(p0: String?, p1: UserHandle?) {
loadApps()
}
override fun onPackagesAvailable(p0: Array<out String>?, p1: UserHandle?, p2: Boolean) {
// TODO
}
override fun onPackagesSuspended(packageNames: Array<out String>?, user: UserHandle?) {
// TODO
}
override fun onPackagesUnsuspended(packageNames: Array<out String>?, user: UserHandle?) {
// TODO
}
override fun onPackagesUnavailable(p0: Array<out String>?, p1: UserHandle?, p2: Boolean) {
// TODO
}
override fun onPackageLoadingProgressChanged(
packageName: String,
user: UserHandle,
progress: Float
) {
// TODO
}
override fun onShortcutsChanged(
packageName: String,
shortcuts: MutableList<ShortcutInfo>,
user: UserHandle
) {
// TODO
}
}
var torchManager: TorchManager? = null
private var customAppNames: HashMap<AbstractAppInfo, String>? = null
private val listener = SharedPreferences.OnSharedPreferenceChangeListener { _, pref ->
if (pref == getString(R.string.settings_apps_custom_names_key)) {
customAppNames = LauncherPreferences.apps().customNames()
} else if (pref == LauncherPreferences.apps().keys().pinnedShortcuts()) {
loadApps()
}
}
override fun onCreate() {
super.onCreate()
// TODO Error: Invalid resource ID 0x00000000.
// DynamicColors.applyToActivitiesIfAvailable(this)
if (Build.VERSION.SDK_INT >= VERSION_CODES.M) {
torchManager = TorchManager(this)
}
val preferences = PreferenceManager.getDefaultSharedPreferences(this)
LauncherPreferences.init(preferences, this.resources)
// Try to restore old preferences
migratePreferencesToNewVersion(this)
// First time opening the app: set defaults
// The tutorial is started from HomeActivity#onStart, as starting it here is blocked by android
if (!LauncherPreferences.internal().started()) {
resetPreferences(this)
}
LauncherPreferences.getSharedPreferences()
.registerOnSharedPreferenceChangeListener(listener)
val launcherApps = getSystemService(LAUNCHER_APPS_SERVICE) as LauncherApps
launcherApps.registerCallback(launcherAppsCallback)
if (Build.VERSION.SDK_INT >= VERSION_CODES.N) {
val filter = IntentFilter().also {
if (Build.VERSION.SDK_INT >= VERSION_CODES.VANILLA_ICE_CREAM) {
it.addAction(Intent.ACTION_PROFILE_AVAILABLE)
it.addAction(Intent.ACTION_PROFILE_UNAVAILABLE)
} else {
it.addAction(Intent.ACTION_MANAGED_PROFILE_AVAILABLE)
it.addAction(Intent.ACTION_MANAGED_PROFILE_UNAVAILABLE)
}
}
ContextCompat.registerReceiver(
this, profileAvailabilityBroadcastReceiver, filter,
ContextCompat.RECEIVER_EXPORTED
)
}
if (Build.VERSION.SDK_INT >= VERSION_CODES.N_MR1) {
removeUnusedShortcuts(this)
}
loadApps()
}
fun getCustomAppNames(): HashMap<AbstractAppInfo, String> {
return (customAppNames ?: LauncherPreferences.apps().customNames() ?: HashMap())
.also { customAppNames = it }
}
private fun loadApps() {
privateSpaceLocked.postValue(isPrivateSpaceLocked(this))
CoroutineScope(Dispatchers.Default).launch {
apps.postValue(getApps(packageManager, applicationContext))
}
}
}

View file

@ -1,502 +1,226 @@
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.ActivityNotFoundException
import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import android.content.pm.LauncherApps
import android.content.pm.LauncherApps.ShortcutQuery
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.drawable.Drawable
import android.media.AudioManager
import android.net.Uri
import android.content.pm.ShortcutInfo
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 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.settings.intendedSettingsPause
import de.jrpie.android.launcher.tutorial.TutorialActivity
import androidx.annotation.RequiresApi
import de.jrpie.android.launcher.actions.Action
import de.jrpie.android.launcher.actions.Gesture
import de.jrpie.android.launcher.actions.ShortcutAction
import de.jrpie.android.launcher.apps.AbstractAppInfo.Companion.INVALID_USER
import de.jrpie.android.launcher.apps.AbstractDetailedAppInfo
import de.jrpie.android.launcher.apps.AppInfo
import de.jrpie.android.launcher.apps.DetailedAppInfo
import de.jrpie.android.launcher.apps.DetailedPinnedShortcutInfo
import de.jrpie.android.launcher.apps.PinnedShortcutInfo
import de.jrpie.android.launcher.apps.getPrivateSpaceUser
import de.jrpie.android.launcher.apps.isPrivateSpaceSupported
import de.jrpie.android.launcher.preferences.LauncherPreferences
import de.jrpie.android.launcher.ui.tutorial.TutorialActivity
import androidx.core.net.toUri
/* Preference Key Constants */
const val PREF_DOMINANT = "custom_dominant"
const val PREF_VIBRANT = "custom_vibrant"
const val PREF_THEME = "theme"
const val PREF_SCREEN_TIMEOUT_DISABLED = "disableTimeout"
const val PREF_SCREEN_FULLSCREEN = "useFullScreen"
const val PREF_DATE_FORMAT = "dateFormat"
const val PREF_DOUBLE_ACTIONS_ENABLED = "enableDoubleActions"
const val PREF_EDGE_ACTIONS_ENABLED = "enableEdgeActions"
const val PREF_SEARCH_AUTO_LAUNCH = "searchAutoLaunch"
const val PREF_SEARCH_AUTO_KEYBOARD = "searchAutoKeyboard"
const val PREF_SLIDE_SENSITIVITY = "slideSensitivity"
const val PREF_STARTED = "startedBefore"
const val PREF_STARTED_TIME = "firstStartup"
const val PREF_VERSION = "version"
const val INVALID_USER = -1
/* Objects used by multiple activities */
val appsList: MutableList<AppInfo> = ArrayList()
/* Variables containing settings */
val displayMetrics = DisplayMetrics()
var dominantColor = 0
var vibrantColor = 0
/* REQUEST CODES */
const val REQUEST_CHOOSE_APP = 1
const val REQUEST_UNINSTALL = 2
const val LOG_TAG = "Launcher"
const val REQUEST_SET_DEFAULT_HOME = 42
/* Animate */
// Taken from https://stackoverflow.com/questions/47293269
fun View.blink(
times: Int = Animation.INFINITE,
duration: Long = 1000L,
offset: Long = 20L,
minAlpha: Float = 0.2f,
maxAlpha: Float = 1.0f,
repeatMode: Int = Animation.REVERSE
) {
startAnimation(AlphaAnimation(minAlpha, maxAlpha).also {
it.duration = duration
it.startOffset = offset
it.repeatMode = repeatMode
it.repeatCount = times
})
}
fun getPreferences(context: Context): SharedPreferences{
return context.getSharedPreferences(
context.getString(R.string.preference_file_key),
Context.MODE_PRIVATE
)
}
fun setDefaultHomeScreen(context: Context, checkDefault: Boolean = false) {
if (checkDefault
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
&& context is Activity) {
fun isDefaultHomeScreen(context: Context): Boolean {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
val roleManager = context.getSystemService(RoleManager::class.java)
if(!roleManager.isRoleHeld(RoleManager.ROLE_HOME)) {
context.startActivityForResult(roleManager.createRequestRoleIntent(RoleManager.ROLE_HOME), REQUEST_SET_DEFAULT_HOME)
}
return
}
if(checkDefault) {
return roleManager.isRoleHeld(RoleManager.ROLE_HOME)
} else {
val testIntent = Intent(Intent.ACTION_MAIN)
testIntent.addCategory(Intent.CATEGORY_HOME)
val defaultHome = testIntent.resolveActivity(context.packageManager)?.packageName
if(defaultHome == context.packageName){
// Launcher is already the default home app
return
}
return defaultHome == context.packageName
}
}
fun setDefaultHomeScreen(context: Context, checkDefault: Boolean = false) {
val isDefault = isDefaultHomeScreen(context)
if (checkDefault && isDefault) {
// Launcher is already the default home app
return
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
&& context is Activity
&& checkDefault // using role manager only works when µLauncher is not already the default.
) {
val roleManager = context.getSystemService(RoleManager::class.java)
context.startActivityForResult(
roleManager.createRequestRoleIntent(RoleManager.ROLE_HOME),
REQUEST_SET_DEFAULT_HOME
)
return
}
val intent = Intent(Settings.ACTION_HOME_SETTINGS)
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
fun getUserFromId(userId: Int?, context: Context): UserHandle {
/* TODO: this is an ugly hack.
Use userManager#getUserForSerialNumber instead (breaking change to SharedPreferences!)
*/
val userManager = context.getSystemService(Service.USER_SERVICE) as UserManager
val profiles = userManager.userProfiles
return profiles.firstOrNull { it.hashCode() == userId } ?: profiles[0]
}
private 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 launchApp(packageName: String, user: Int?, context: Context) {
Log.i("Launcher", "Starting: " + packageName + " (user " +user.toString()+ ")")
if (user != null) {
val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps
val userManager = context.getSystemService(Service.USER_SERVICE) as UserManager
userManager.userProfiles.firstOrNull { it.hashCode() == user }?.let {
userHandle -> launcherApps.getActivityList(packageName, userHandle).firstOrNull()?.let {
app -> launcherApps.startMainActivity(app.componentName, userHandle, null, null)
return
}
}
}
val intent = getIntent(packageName, context)
if (intent != null) {
context.startActivity(intent)
} else {
if (isInstalled(packageName, context)){
AlertDialog.Builder(
context,
R.style.AlertDialogCustom
@RequiresApi(Build.VERSION_CODES.N_MR1)
fun removeUnusedShortcuts(context: Context) {
val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps
fun getShortcuts(profile: UserHandle): List<ShortcutInfo>? {
return try {
launcherApps.getShortcuts(
ShortcutQuery().apply {
setQueryFlags(ShortcutQuery.FLAG_MATCH_PINNED)
},
profile
)
.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,
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()
} catch (e: Exception) {
// https://github.com/jrpie/launcher/issues/116
return null
}
}
}
fun openNewTabWindow(urls: String, context: Context) {
val uris = Uri.parse(urls)
val intents = Intent(Intent.ACTION_VIEW, uris)
val b = Bundle()
b.putBoolean("new_window", true)
intents.putExtras(b)
context.startActivity(intents)
}
/* Settings related functions */
fun getSavedTheme(context: Context) : String {
return getPreferences(context).getString(PREF_THEME, "finn").toString()
}
fun saveTheme(context: Context, themeName: String) : String {
getPreferences(context).edit()
.putString(PREF_THEME, themeName)
.apply()
return themeName
}
fun resetToDefaultTheme(activity: Activity) {
dominantColor = activity.resources.getColor(R.color.finnmglasTheme_background_color)
vibrantColor = activity.resources.getColor(R.color.finnmglasTheme_accent_color)
getPreferences(activity).edit()
.putInt(PREF_DOMINANT, dominantColor)
.putInt(PREF_VIBRANT, vibrantColor)
.apply()
saveTheme(activity,"finn")
loadSettings(activity)
intendedSettingsPause = true
activity.recreate()
}
fun resetToDarkTheme(activity: Activity) {
dominantColor = activity.resources.getColor(R.color.darkTheme_background_color)
vibrantColor = activity.resources.getColor(R.color.darkTheme_accent_color)
getPreferences(activity).edit()
.putInt(PREF_DOMINANT, dominantColor)
.putInt(PREF_VIBRANT, vibrantColor)
.apply()
saveTheme(activity,"dark")
intendedSettingsPause = true
activity.recreate()
}
fun openAppSettings(pkg: String, context: Context) {
val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
intent.data = Uri.parse("package:$pkg")
context.startActivity(intent)
}
fun openSettings(activity: Activity) {
activity.startActivity(Intent(activity, SettingsActivity::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())
intendedSettingsPause = true
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
val userManager = context.getSystemService(Service.USER_SERVICE) as UserManager
userManager.userProfiles.firstOrNull { it.hashCode() == user }?.let {
userHandle -> launcherApps.getActivityList(packageName, userHandle).firstOrNull()?.let {
app -> return app.getBadgedIcon(0)
val userManager = context.getSystemService(Service.USER_SERVICE) as UserManager
val boundActions: MutableSet<PinnedShortcutInfo> =
Gesture.entries.mapNotNull { Action.forGesture(it) as? ShortcutAction }.map { it.shortcut }
.toMutableSet()
LauncherPreferences.apps().pinnedShortcuts()?.let { boundActions.addAll(it) }
try {
userManager.userProfiles.filter { !userManager.isQuietModeEnabled(it) }.forEach { profile ->
getShortcuts(profile)?.groupBy { it.`package` }?.forEach { (p, shortcuts) ->
launcherApps.pinShortcuts(p,
shortcuts.filter { boundActions.contains(PinnedShortcutInfo(it)) }
.map { it.id }.toList(),
profile
)
}
}
}
return context.packageManager.getApplicationIcon(packageName)
} catch (_: SecurityException) { }
}
fun openInBrowser(url: String, context: Context) {
val intent = Intent(Intent.ACTION_VIEW, url.toUri())
intent.putExtras(Bundle().apply { putBoolean("new_window", true) })
try {
context.startActivity(intent)
} catch (_: ActivityNotFoundException) {
Toast.makeText(context, R.string.toast_activity_not_found_browser, Toast.LENGTH_LONG).show()
}
}
fun openTutorial(context: Context) {
context.startActivity(Intent(context, TutorialActivity::class.java))
}
/**
* [loadApps] is used to speed up the [AppsRecyclerAdapter] loading time,
* as it caches all the apps and allows for fast access to the data.
* Load all apps.
*/
fun loadApps(packageManager: PackageManager, context: Context) {
val loadList = mutableListOf<AppInfo>()
fun getApps(
packageManager: PackageManager,
context: Context
): MutableList<AbstractDetailedAppInfo> {
var start = System.currentTimeMillis()
val loadList = mutableListOf<AbstractDetailedAppInfo>()
val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps
val userManager = context.getSystemService(Service.USER_SERVICE) as UserManager
val privateSpaceUser = getPrivateSpaceUser(context)
// TODO: shortcuts - launcherApps.getShortcuts()
val users = userManager.userProfiles
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()
loadList.add(app)
for (user in users) {
// don't load apps from a user profile that has quiet mode enabled
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
if (userManager.isQuietModeEnabled(user)) {
// hide paused apps
if (LauncherPreferences.apps().hidePausedApps()) {
continue
}
// hide apps from private space
if (isPrivateSpaceSupported() &&
launcherApps.getLauncherUserInfo(user)?.userType == UserManager.USER_TYPE_PROFILE_PRIVATE
) {
continue
}
}
}
launcherApps.getActivityList(null, user).forEach {
loadList.add(DetailedAppInfo(it, it.user == privateSpaceUser))
}
}
// fallback option
if(loadList.isEmpty()){
Log.i("Launcher", "using fallback option to load packages")
if (loadList.isEmpty()) {
Log.w(LOG_TAG, "using fallback option to load packages")
val i = Intent(Intent.ACTION_MAIN, null)
i.addCategory(Intent.CATEGORY_LAUNCHER)
val allApps = packageManager.queryIntentActivities(i, 0)
for (ri in allApps) {
val app = AppInfo()
app.label = ri.loadLabel(packageManager)
app.packageName = ri.activityInfo.packageName
app.icon = ri.activityInfo.loadIcon(packageManager)
loadList.add(app)
val app = AppInfo(ri.activityInfo.packageName, null, INVALID_USER)
val detailedAppInfo = DetailedAppInfo(
app,
ri.loadLabel(packageManager),
ri.activityInfo.loadIcon(packageManager),
false
)
loadList.add(detailedAppInfo)
}
}
appsList.clear()
appsList.addAll(loadList)
}
loadList.sortBy { it.getCustomLabel(context) }
fun loadSettings(context: Context) {
val preferences = getPreferences(context)
dominantColor = preferences.getInt(PREF_DOMINANT, 0)
vibrantColor = preferences.getInt(PREF_VIBRANT, 0)
}
fun resetSettings(context: Context) {
val editor = getPreferences(context).edit()
// set default theme
dominantColor = context.resources.getColor(R.color.finnmglasTheme_background_color)
vibrantColor = context.resources.getColor(R.color.finnmglasTheme_accent_color)
editor
.putInt(PREF_DOMINANT, dominantColor)
.putInt(PREF_VIBRANT, vibrantColor)
.putString(PREF_THEME, "finn")
.putBoolean(PREF_SCREEN_TIMEOUT_DISABLED, false)
.putBoolean(PREF_SEARCH_AUTO_LAUNCH, false)
.putInt(PREF_DATE_FORMAT, 0)
.putBoolean(PREF_SCREEN_FULLSCREEN, true)
.putBoolean(PREF_DOUBLE_ACTIONS_ENABLED, false)
.putInt(PREF_SLIDE_SENSITIVITY, 50)
Gesture.values().forEach { editor.putString(it.id, it.pickDefaultApp(context)) }
editor.apply()
}
fun setWindowFlags(window: Window) {
window.setFlags(0, 0) // clear flags
val preferences = getPreferences(window.context)
// Display notification bar
if (preferences.getBoolean(PREF_SCREEN_FULLSCREEN, true))
window.setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
)
else window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
// Screen Timeout
if (preferences.getBoolean(PREF_SCREEN_TIMEOUT_DISABLED, false))
window.setFlags(
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
)
else window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
}
// 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 }
val forGesture = data?.getStringExtra("forGesture") ?: return
Gesture.byId(forGesture)?.setApp(context, value.toString(), user)
loadSettings(context)
}
// Taken from https://stackoverflow.com/a/50743764/12787264
fun openSoftKeyboard(context: Context, view: View) {
view.requestFocus()
// open the soft keyboard
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT)
}
/* Bitmaps */
fun setButtonColor(btn: Button, color: Int) {
if (Build.VERSION.SDK_INT >= 29)
btn.background.colorFilter = BlendModeColorFilter(color, BlendMode.MULTIPLY)
else {
// tested with API 17 (Android 4.4.2 on S4 mini) -> fails
// tested with API 28 (Android 9 on S8) -> necessary
btn.background.colorFilter = PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP)
var end = System.currentTimeMillis()
Log.i(LOG_TAG, "${loadList.size} apps loaded (${end - start}ms)")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
start = System.currentTimeMillis()
LauncherPreferences.apps().pinnedShortcuts()
?.mapNotNull { DetailedPinnedShortcutInfo.fromPinnedShortcutInfo(it, context) }
?.let {
end = System.currentTimeMillis()
Log.i(LOG_TAG, "${it.size} shortcuts loaded (${end - start}ms)")
loadList.addAll(it)
}
}
// not setting it in any other case (yet), unable to find a good solution
return loadList
}
fun setSwitchColor(sw: Switch, trackColor: Int) {
if (Build.VERSION.SDK_INT >= 29) {
sw.trackDrawable.colorFilter = BlendModeColorFilter(trackColor, BlendMode.MULTIPLY)
}
else {
sw.trackDrawable.colorFilter = PorterDuffColorFilter(trackColor, PorterDuff.Mode.SRC_ATOP)
}
// used for the bug report button
fun getDeviceInfo(): String {
return """
µLauncher version: ${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})
Android version: ${Build.VERSION.RELEASE} (sdk ${Build.VERSION.SDK_INT})
Model: ${Build.MODEL}
Device: ${Build.DEVICE}
Brand: ${Build.BRAND}
Manufacturer: ${Build.MANUFACTURER}
""".trimIndent()
}
// Taken from: https://stackoverflow.com/a/30340794/12787264
fun transformGrayscale(imageView: ImageView){
val matrix = ColorMatrix()
matrix.setSaturation(0f)
val filter = ColorMatrixColorFilter(matrix)
imageView.colorFilter = filter
}
fun copyToClipboard(context: Context, text: String) {
val clipboardManager = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
val clipData = ClipData.newPlainText("Debug Info", text)
clipboardManager.setPrimaryClip(clipData)
}

View file

@ -1,154 +0,0 @@
package de.jrpie.android.launcher
import android.app.Activity
import android.content.Context
/**
* @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_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 Edge{
TOP, BOTTOM, LEFT, RIGHT
}
fun getApp(context: Context): Pair<String, Int?> {
val preferences = getPreferences(context)
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)
}
fun removeApp(context: Context) {
getPreferences(context).edit()
.putString(this.id, "") // clear it
.apply()
}
fun setApp(context: Context, app: String, user: Int?) {
getPreferences(context).edit()
.putString(this.id, app)
.apply()
val u = user?: INVALID_USER
getPreferences(context).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 }
}
}
}

View file

@ -1,258 +0,0 @@
package de.jrpie.android.launcher
import android.content.Intent
import android.os.AsyncTask
import android.os.Bundle
import android.view.GestureDetector
import android.view.KeyEvent
import android.view.MotionEvent
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.GestureDetectorCompat
import de.jrpie.android.launcher.BuildConfig.VERSION_NAME
import de.jrpie.android.launcher.list.other.LauncherAction
import de.jrpie.android.launcher.tutorial.TutorialActivity
import de.jrpie.android.launcher.databinding.HomeBinding
import java.text.SimpleDateFormat
import java.util.*
import kotlin.concurrent.fixedRateTimer
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
/**
* [HomeActivity] is the actual application Launcher,
* what makes this application special / unique.
*
* In this activity we display the date and time,
* and we listen for actions like tapping, swiping or button presses.
*
* As it also is the first thing that is started when someone opens Launcher,
* it also contains some logic related to the overall application:
* - Setting global variables (preferences etc.)
* - Opening the [TutorialActivity] on new installations
*/
class HomeActivity: UIObject, AppCompatActivity(),
GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {
private lateinit var binding: HomeBinding
private var bufferedPointerCount = 1 // how many fingers on screen
private var pointerBufferTimer = Timer()
private lateinit var mDetector: GestureDetectorCompat
// timers
private var clockTimer = Timer()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val preferences = getPreferences(this)
windowManager.defaultDisplay.getMetrics(displayMetrics)
loadSettings(this)
// First time opening the app: show Tutorial, else: check versions
if (!preferences.getBoolean(PREF_STARTED, false))
startActivity(Intent(this, TutorialActivity::class.java))
else when (preferences.getString(PREF_VERSION, "")) {
// Check versions, make sure transitions between versions go well
VERSION_NAME -> { /* the version installed and used previously are the same */ }
"" -> { /* The version used before was pre- v1.3.0,
as version tracking started then */
/*
* 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 (getSavedTheme(this)) {
"finn" -> resetToDefaultTheme(this)
"dark" -> resetToDarkTheme(this)
}
preferences.edit()
.putString(PREF_VERSION, VERSION_NAME) // save new version
.apply()
// show the new tutorial
startActivity(Intent(this, TutorialActivity::class.java))
}
}
// Preload apps to speed up the Apps Recycler
AsyncTask.execute { loadApps(packageManager, applicationContext) }
// Initialise layout
binding = HomeBinding.inflate(layoutInflater)
setContentView(binding.root)
}
override fun onStart(){
super<AppCompatActivity>.onStart()
mDetector = GestureDetectorCompat(this, this)
mDetector.setOnDoubleTapListener(this)
// for if the settings changed
loadSettings(this)
super<UIObject>.onStart()
}
override fun onResume() {
super.onResume()
// Applying the date / time format (changeable in settings)
val dFormat = getPreferences(this).getInt(PREF_DATE_FORMAT, 0)
val upperFMT = resources.getStringArray(R.array.settings_launcher_time_formats_upper)
val lowerFMT = resources.getStringArray(R.array.settings_launcher_time_formats_lower)
val dateFormat = SimpleDateFormat(upperFMT[dFormat], Locale.getDefault())
val timeFormat = SimpleDateFormat(lowerFMT[dFormat], Locale.getDefault())
clockTimer = fixedRateTimer("clockTimer", true, 0L, 100) {
this@HomeActivity.runOnUiThread {
val t = timeFormat.format(Date())
if (binding.homeLowerView.text != t)
binding.homeLowerView.setText(t)
val d = dateFormat.format(Date())
if (binding.homeUpperView.text != d)
binding.homeUpperView.setText(d)
}
}
}
override fun onPause() {
super.onPause()
clockTimer.cancel()
}
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
when (keyCode) {
KeyEvent.KEYCODE_BACK -> LauncherAction.CHOOSE.launch(this)
KeyEvent.KEYCODE_VOLUME_UP -> Gesture.VOLUME_UP(this)
KeyEvent.KEYCODE_VOLUME_DOWN -> Gesture.VOLUME_DOWN(this)
}
return true
}
override fun onFling(e1: MotionEvent?, e2: MotionEvent, dX: Float, dY: Float): Boolean {
if (e1 == null) return false;
val width = displayMetrics.widthPixels
val height = displayMetrics.heightPixels
val diffX = e1.x - e2.x
val diffY = e1.y - e2.y
val preferences = getPreferences(this)
val doubleActions = preferences.getBoolean(PREF_DOUBLE_ACTIONS_ENABLED, false)
val edgeActions = preferences.getBoolean(PREF_EDGE_ACTIONS_ENABLED, false)
val edgeStrictness = 0.15
// how distinguished the swipe has to be to launch something
// strictness = opposite of sensitivity. TODO - May have to be adjusted
val strictness = (4 / bufferedPointerCount) * ((100 - preferences.getInt(PREF_SLIDE_SENSITIVITY, 50)) / 50)
var gesture = if(abs(diffX) > abs(diffY)) { // horizontal swipe
if (diffX > width / 4 && abs(diffX) > strictness * abs(diffY))
Gesture.SWIPE_LEFT
else if (diffX < -width / 4 && abs(diffX) > strictness * abs(diffY))
Gesture.SWIPE_RIGHT
else null
} else { // vertical swipe
// Only open if the swipe was not from the phones top edge
if (diffY < -height / 8 && abs(diffY) > strictness * abs(diffX) && e1.y > 100)
Gesture.SWIPE_DOWN
else if (diffY > height / 8 && abs(diffY) > strictness * abs(diffX))
Gesture.SWIPE_UP
else null
}
if (doubleActions && bufferedPointerCount > 1) {
gesture = gesture?.let(Gesture::getDoubleVariant)
}
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.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)
return true
}
override fun onLongPress(event: MotionEvent) {
Gesture.LONG_CLICK(this)
}
override fun onDoubleTap(event: MotionEvent): Boolean {
Gesture.DOUBLE_CLICK(this)
return false
}
// Tooltip
override fun onSingleTapConfirmed(event: MotionEvent): Boolean {
return false
}
override fun onTouchEvent(event: MotionEvent): Boolean {
// Buffer / Debounce the pointer count
if (event.pointerCount > bufferedPointerCount) {
bufferedPointerCount = event.pointerCount
pointerBufferTimer = fixedRateTimer("pointerBufferTimer", true, 300, 1000) {
bufferedPointerCount = 1
this.cancel() // a non-recurring timer
}
}
return if (mDetector.onTouchEvent(event)) { false } else { super.onTouchEvent(event) }
}
override fun setOnClicks() {
val preferences = getPreferences(this)
binding.homeUpperView.setOnClickListener {
when (preferences.getInt(PREF_DATE_FORMAT, 0)) {
0 -> Gesture.DATE(this)
else -> Gesture.TIME(this)
}
}
binding.homeLowerView.setOnClickListener {
when (preferences.getInt(PREF_DATE_FORMAT, 0)) {
0 -> Gesture.TIME(this)
else -> Gesture.DATE(this)
}
}
}
/* 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 onShowPress(event: MotionEvent) {}
override fun onSingleTapUp(event: MotionEvent): Boolean { return false }
}

View file

@ -1,22 +0,0 @@
package de.jrpie.android.launcher
import android.app.Activity
/**
* An interface implemented by every [Activity], Fragment etc. in Launcher.
* It handles themes and window flags - a useful abstraction as it is the same everywhere.
*/
interface UIObject {
fun onStart() {
if (this is Activity) setWindowFlags(window)
applyTheme()
setOnClicks()
adjustLayout()
}
// Don't use actual themes, rather create them on the fly for faster theme-switching
fun applyTheme() { }
fun setOnClicks() { }
fun adjustLayout() { }
}

View file

@ -0,0 +1,100 @@
package de.jrpie.android.launcher.actions
import android.app.Activity
import android.content.Context
import android.content.SharedPreferences.Editor
import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.widget.Toast
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.preferences.LauncherPreferences
import kotlinx.serialization.Serializable
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import androidx.core.content.edit
@Serializable
sealed interface Action {
fun invoke(context: Context, rect: Rect? = null): Boolean
fun label(context: Context): String
fun getIcon(context: Context): Drawable?
fun isAvailable(context: Context): Boolean
// Can the action be used to reach µLauncher settings?
fun canReachSettings(): Boolean
fun bindToGesture(prefEditor: Editor, id: String) {
prefEditor.putString(id, Json.encodeToString(this))
}
companion object {
fun forGesture(gesture: Gesture): Action? {
val id = gesture.id
val preferences = LauncherPreferences.getSharedPreferences()
val json = preferences.getString(id, "null")!!
return Json.decodeFromString(json)
}
fun resetToDefaultActions(context: Context) {
LauncherPreferences.getSharedPreferences().edit {
val boundActions = HashSet<String>()
Gesture.entries.forEach { gesture ->
context.resources
.getStringArray(gesture.defaultsResource)
.filterNot { boundActions.contains(it) }
.map { Pair(it, Json.decodeFromString<Action>(it)) }
.firstOrNull { it.second.isAvailable(context) }
?.apply {
// allow to bind CHOOSE to multiple gestures
if (second != LauncherAction.CHOOSE) {
boundActions.add(first)
}
second.bindToGesture(this@edit, gesture.id)
}
}
}
}
fun setActionForGesture(gesture: Gesture, action: Action?) {
if (action == null) {
clearActionForGesture(gesture)
return
}
LauncherPreferences.getSharedPreferences().edit {
action.bindToGesture(this, gesture.id)
}
}
fun clearActionForGesture(gesture: Gesture) {
LauncherPreferences.getSharedPreferences().edit {
remove(gesture.id)
}
}
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) {
// There does not seem to be a good alternative to overridePendingTransition.
// Note that we can't use overrideActivityTransition here.
@Suppress("deprecation")
context.overridePendingTransition(animationIn, animationOut)
}
} else {
Toast.makeText(
context,
context.getString(R.string.toast_cant_open_message),
Toast.LENGTH_SHORT
).show()
}
}
}
}

View file

@ -0,0 +1,81 @@
package de.jrpie.android.launcher.actions
import android.app.AlertDialog
import android.app.Service
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.content.pm.LauncherApps
import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.util.Log
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.apps.AppInfo
import de.jrpie.android.launcher.apps.AbstractAppInfo.Companion.INVALID_USER
import de.jrpie.android.launcher.apps.DetailedAppInfo
import de.jrpie.android.launcher.ui.list.apps.openSettings
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
@SerialName("action:app")
class AppAction(val app: AppInfo) : Action {
override fun invoke(context: Context, rect: Rect?): Boolean {
val packageName = app.packageName
if (app.user != INVALID_USER) {
val launcherApps =
context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps
app.getLauncherActivityInfo(context)?.let { app ->
Log.i("Launcher", "Starting ${this.app}")
launcherApps.startMainActivity(app.componentName, app.user, rect, null)
return true
}
}
context.packageManager.getLaunchIntentForPackage(packageName)?.let {
it.addCategory(Intent.CATEGORY_LAUNCHER)
try {
context.startActivity(it)
} catch (_: ActivityNotFoundException) {
return false
}
return true
}
/* check if app is installed */
if (isAvailable(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) { _, _ ->
app.openSettings(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 DetailedAppInfo.fromAppInfo(app, context)?.getCustomLabel(context).toString()
}
override fun getIcon(context: Context): Drawable? {
return DetailedAppInfo.fromAppInfo(app, context)?.getIcon(context)
}
override fun isAvailable(context: Context): Boolean {
// check if app is installed
return DetailedAppInfo.fromAppInfo(app, context) != null
}
override fun canReachSettings(): Boolean {
return false
}
}

View file

@ -0,0 +1,369 @@
package de.jrpie.android.launcher.actions
import android.content.Context
import android.util.Log
import de.jrpie.android.launcher.R
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 descriptionResource: 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.string.settings_gesture_description_vol_up,
R.array.default_volume_up,
0,
0
),
VOLUME_DOWN(
"action.volume_down",
R.string.settings_gesture_vol_down,
R.string.settings_gesture_description_vol_down,
R.array.default_volume_down, 0, 0
),
TIME(
"action.time",
R.string.settings_gesture_time,
R.string.settings_gesture_description_time,
R.array.default_time
),
DATE(
"action.date",
R.string.settings_gesture_date,
R.string.settings_gesture_description_date,
R.array.default_date
),
LONG_CLICK(
"action.long_click",
R.string.settings_gesture_long_click,
R.string.settings_gesture_description_long_click,
R.array.default_long_click, 0, 0
),
DOUBLE_CLICK(
"action.double_click",
R.string.settings_gesture_double_click,
R.string.settings_gesture_description_double_click,
R.array.default_double_click, 0, 0
),
SWIPE_UP(
"action.up",
R.string.settings_gesture_up,
R.string.settings_gesture_description_up,
R.array.default_up,
R.anim.bottom_up
),
SWIPE_UP_LEFT_EDGE(
"action.up_left",
R.string.settings_gesture_up_left_edge,
R.string.settings_gesture_description_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.string.settings_gesture_description_up_right_edge,
R.array.default_up_right,
R.anim.bottom_up
),
TAP_AND_SWIPE_UP(
"action.tap_up",
R.string.settings_gesture_tap_up,
R.string.settings_gesture_description_tap_up,
R.array.default_up,
R.anim.bottom_up
),
SWIPE_UP_DOUBLE(
"action.double_up",
R.string.settings_gesture_double_up,
R.string.settings_gesture_description_double_up,
R.array.default_double_up,
R.anim.bottom_up
),
SWIPE_DOWN(
"action.down",
R.string.settings_gesture_down,
R.string.settings_gesture_description_down,
R.array.default_down,
R.anim.top_down
),
SWIPE_DOWN_LEFT_EDGE(
"action.down_left",
R.string.settings_gesture_down_left_edge,
R.string.settings_gesture_description_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.string.settings_gesture_description_down_right_edge,
R.array.default_down_right,
R.anim.top_down
),
TAP_AND_SWIPE_DOWN(
"action.tap_down",
R.string.settings_gesture_tap_down,
R.string.settings_gesture_description_tap_down,
R.array.default_down,
R.anim.bottom_up
),
SWIPE_DOWN_DOUBLE(
"action.double_down",
R.string.settings_gesture_double_down,
R.string.settings_gesture_description_double_down,
R.array.default_double_down,
R.anim.top_down
),
SWIPE_LEFT(
"action.left",
R.string.settings_gesture_left,
R.string.settings_gesture_description_left,
R.array.default_messengers,
R.anim.right_left
),
SWIPE_LEFT_TOP_EDGE(
"action.left_top",
R.string.settings_gesture_left_top_edge,
R.string.settings_gesture_description_left_top_edge,
R.array.default_messengers,
R.anim.right_left
),
SWIPE_LEFT_BOTTOM_EDGE(
"action.left_bottom",
R.string.settings_gesture_left_bottom_edge,
R.string.settings_gesture_description_left_bottom_edge,
R.array.default_messengers,
R.anim.right_left
),
TAP_AND_SWIPE_LEFT(
"action.tap_left",
R.string.settings_gesture_tap_left,
R.string.settings_gesture_description_tap_left,
R.array.default_messengers,
R.anim.right_left
),
SWIPE_LEFT_DOUBLE(
"action.double_left",
R.string.settings_gesture_double_left,
R.string.settings_gesture_description_double_left,
R.array.default_messengers,
R.anim.right_left
),
SWIPE_RIGHT(
"action.right",
R.string.settings_gesture_right,
R.string.settings_gesture_description_right,
R.array.default_right,
R.anim.left_right
),
SWIPE_RIGHT_TOP_EDGE(
"action.right_top",
R.string.settings_gesture_right_top_edge,
R.string.settings_gesture_description_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.string.settings_gesture_description_right_bottom_edge,
R.array.default_right_bottom,
R.anim.left_right
),
TAP_AND_SWIPE_RIGHT(
"action.tap_right",
R.string.settings_gesture_tap_right,
R.string.settings_gesture_description_tap_right,
R.array.default_right,
R.anim.left_right
),
SWIPE_RIGHT_DOUBLE(
"action.double_right",
R.string.settings_gesture_double_right,
R.string.settings_gesture_description_double_right,
R.array.default_double_right,
R.anim.left_right
),
SWIPE_LARGER(
"action.larger",
R.string.settings_gesture_swipe_larger,
R.string.settings_gesture_description_swipe_larger,
R.array.no_default
),
SWIPE_LARGER_REVERSE(
"action.larger_reverse",
R.string.settings_gesture_swipe_larger_reverse,
R.string.settings_gesture_description_swipe_larger_reverse,
R.array.no_default
),
SWIPE_SMALLER(
"action.smaller",
R.string.settings_gesture_swipe_smaller,
R.string.settings_gesture_description_swipe_smaller,
R.array.no_default
),
SWIPE_SMALLER_REVERSE(
"action.smaller_reverse",
R.string.settings_gesture_swipe_smaller_reverse,
R.string.settings_gesture_description_swipe_smaller_reverse,
R.array.no_default
),
SWIPE_LAMBDA(
"action.lambda",
R.string.settings_gesture_swipe_lambda,
R.string.settings_gesture_description_swipe_lambda,
R.array.no_default
),
SWIPE_LAMBDA_REVERSE(
"action.lambda_reverse",
R.string.settings_gesture_swipe_lambda_reverse,
R.string.settings_gesture_description_swipe_lambda_reverse,
R.array.no_default
),
SWIPE_V(
"action.v",
R.string.settings_gesture_swipe_v,
R.string.settings_gesture_description_swipe_v,
R.array.no_default
),
SWIPE_V_REVERSE(
"action.v_reverse",
R.string.settings_gesture_swipe_v_reverse,
R.string.settings_gesture_description_swipe_v_reverse,
R.array.no_default
),
BACK(
"action.back",
R.string.settings_gesture_back,
R.string.settings_gesture_description_back,
R.array.default_back
);
enum class Edge {
TOP, BOTTOM, LEFT, RIGHT
}
fun getLabel(context: Context): String {
return context.resources.getString(this.labelResource)
}
fun getDescription(context: Context): String {
return context.resources.getString(this.descriptionResource)
}
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 getTapComboVariant(): Gesture {
return when (this) {
SWIPE_UP -> TAP_AND_SWIPE_UP
SWIPE_DOWN -> TAP_AND_SWIPE_DOWN
SWIPE_LEFT -> TAP_AND_SWIPE_LEFT
SWIPE_RIGHT -> TAP_AND_SWIPE_RIGHT
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
}
}
fun isEnabled(): Boolean {
if (isEdgeVariant()) {
return LauncherPreferences.enabled_gestures().edgeSwipe()
}
if (isDoubleVariant()) {
return LauncherPreferences.enabled_gestures().doubleSwipe()
}
return true
}
operator fun invoke(context: Context) {
Log.i("Launcher", "Detected gesture: $this")
val action = Action.forGesture(this)
Action.launch(action, context, this.animationIn, this.animationOut)
}
companion object {
fun byId(id: String): Gesture? {
return Gesture.entries.firstOrNull { it.id == id }
}
}
}

View file

@ -0,0 +1,341 @@
package de.jrpie.android.launcher.actions
import android.content.Context
import android.content.Intent
import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.media.AudioManager
import android.os.Build
import android.os.SystemClock
import android.view.KeyEvent
import android.widget.Toast
import androidx.appcompat.content.res.AppCompatResources
import de.jrpie.android.launcher.Application
import de.jrpie.android.launcher.BuildConfig
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.actions.lock.LauncherAccessibilityService
import de.jrpie.android.launcher.apps.AppFilter
import de.jrpie.android.launcher.apps.hidePrivateSpaceWhenLocked
import de.jrpie.android.launcher.apps.isPrivateSpaceSupported
import de.jrpie.android.launcher.apps.togglePrivateSpaceLock
import de.jrpie.android.launcher.preferences.LauncherPreferences
import de.jrpie.android.launcher.ui.list.ListActivity
import de.jrpie.android.launcher.ui.settings.SettingsActivity
import kotlinx.serialization.KSerializer
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.SerializationException
import kotlinx.serialization.builtins.serializer
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.descriptors.buildClassSerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder
import kotlinx.serialization.encoding.decodeStructure
import kotlinx.serialization.encoding.encodeStructure
@Serializable(with = LauncherActionSerializer::class)
@SerialName("action:launcher")
enum class LauncherAction(
val id: String,
val label: Int,
val icon: Int,
val launch: (Context) -> Unit,
private val canReachSettings: Boolean = false,
val available: (Context) -> Boolean = { true },
) : Action {
SETTINGS(
"settings",
R.string.list_other_settings,
R.drawable.baseline_settings_24,
::openSettings,
true
),
CHOOSE(
"choose",
R.string.list_other_list,
R.drawable.baseline_menu_24,
::openAppsList,
true
),
CHOOSE_FROM_FAVORITES(
"choose_from_favorites",
R.string.list_other_list_favorites,
R.drawable.baseline_favorite_24,
{ context -> openAppsList(context, favorite = true) },
true
),
CHOOSE_FROM_PRIVATE_SPACE(
"choose_from_private_space",
R.string.list_other_list_private_space,
R.drawable.baseline_security_24,
{ context ->
if ((context.applicationContext as Application).privateSpaceLocked.value != true
|| !hidePrivateSpaceWhenLocked(context)
) {
openAppsList(context, private = true)
}
},
available = { _ ->
isPrivateSpaceSupported()
}
),
TOGGLE_PRIVATE_SPACE_LOCK(
"toggle_private_space_lock",
R.string.list_other_toggle_private_space_lock,
R.drawable.baseline_security_24,
::togglePrivateSpaceLock,
available = { _ -> isPrivateSpaceSupported() }
),
VOLUME_UP(
"volume_up",
R.string.list_other_volume_up,
R.drawable.baseline_volume_up_24,
{ context -> audioVolumeAdjust(context, AudioManager.ADJUST_RAISE) }
),
VOLUME_DOWN(
"volume_down",
R.string.list_other_volume_down,
R.drawable.baseline_volume_down_24,
{ context -> audioVolumeAdjust(context, AudioManager.ADJUST_LOWER) }
),
VOLUME_ADJUST(
"volume_adjust",
R.string.list_other_volume_adjust,
R.drawable.baseline_volume_adjust_24,
{ context -> audioVolumeAdjust(context, AudioManager.ADJUST_SAME) }
),
TRACK_PLAY_PAUSE(
"play_pause_track",
R.string.list_other_track_play_pause,
R.drawable.baseline_play_arrow_24,
{ context -> audioManagerPressKey(context, KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) }
),
TRACK_NEXT(
"next_track",
R.string.list_other_track_next,
R.drawable.baseline_skip_next_24,
{ context -> audioManagerPressKey(context, KeyEvent.KEYCODE_MEDIA_NEXT) }
),
TRACK_PREV(
"previous_track",
R.string.list_other_track_previous,
R.drawable.baseline_skip_previous_24,
{ context -> audioManagerPressKey(context, KeyEvent.KEYCODE_MEDIA_PREVIOUS) }
),
EXPAND_NOTIFICATIONS_PANEL(
"expand_notifications_panel",
R.string.list_other_expand_notifications_panel,
R.drawable.baseline_notifications_24,
::expandNotificationsPanel
),
EXPAND_SETTINGS_PANEL(
"expand_settings_panel",
R.string.list_other_expand_settings_panel,
R.drawable.baseline_settings_applications_24,
::expandSettingsPanel
),
RECENT_APPS(
"recent_apps",
R.string.list_other_recent_apps,
R.drawable.baseline_apps_24,
LauncherAccessibilityService::openRecentApps,
false,
{ _ -> BuildConfig.USE_ACCESSIBILITY_SERVICE }
),
LOCK_SCREEN(
"lock_screen",
R.string.list_other_lock_screen,
R.drawable.baseline_lock_24,
{ c -> LauncherPreferences.actions().lockMethod().lockOrEnable(c) }
),
TORCH(
"toggle_torch",
R.string.list_other_torch,
R.drawable.baseline_flashlight_on_24,
::toggleTorch,
),
LAUNCH_OTHER_LAUNCHER(
"launcher_other_launcher",
R.string.list_other_launch_other_launcher,
R.drawable.baseline_home_24,
::launchOtherLauncher
),
NOP("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 AppCompatResources.getDrawable(context, icon)
}
override fun isAvailable(context: Context): Boolean {
return this.available(context)
}
override fun canReachSettings(): Boolean {
return this.canReachSettings
}
companion object {
fun byId(id: String): LauncherAction? {
return entries.singleOrNull { it.id == id }
}
}
}
/* Media player actions */
private fun audioManagerPressKey(context: Context, key: Int) {
val mAudioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
val eventTime: Long = SystemClock.uptimeMillis()
val downEvent =
KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, key, 0)
mAudioManager.dispatchMediaKeyEvent(downEvent)
val upEvent = KeyEvent(eventTime, eventTime, KeyEvent.ACTION_UP, key, 0)
mAudioManager.dispatchMediaKeyEvent(upEvent)
}
private fun audioVolumeAdjust(context: Context, direction: Int) {
val audioManager =
context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
audioManager.adjustStreamVolume(
AudioManager.STREAM_MUSIC,
direction,
AudioManager.FLAG_SHOW_UI
)
}
/* End media player actions */
private fun toggleTorch(context: Context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
Toast.makeText(
context,
context.getString(R.string.alert_requires_android_m),
Toast.LENGTH_LONG
).show()
return
}
(context.applicationContext as Application).torchManager?.toggleTorch(context)
}
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_status_bar_panel),
Toast.LENGTH_LONG
).show()
}
}
private fun expandSettingsPanel(context: Context) {
/* https://stackoverflow.com/a/31898506 */
try {
@Suppress("SpellCheckingInspection")
val statusBarService: Any? = context.getSystemService("statusbar")
val statusBarManager = Class.forName("android.app.StatusBarManager")
val showStatusBar = statusBarManager.getMethod("expandSettingsPanel")
showStatusBar.invoke(statusBarService)
} catch (e: Exception) {
Toast.makeText(
context,
context.getString(R.string.alert_cant_expand_status_bar_panel),
Toast.LENGTH_LONG
).show()
}
}
private fun launchOtherLauncher(context: Context) {
context.startActivity(
Intent.createChooser(
Intent(Intent.ACTION_MAIN).also { it.addCategory(Intent.CATEGORY_HOME) },
context.getString(R.string.list_other_launch_other_launcher)
)
)
}
private fun openSettings(context: Context) {
context.startActivity(Intent(context, SettingsActivity::class.java))
}
fun openAppsList(
context: Context,
favorite: Boolean = false,
hidden: Boolean = false,
private: Boolean = false
) {
val intent = Intent(context, ListActivity::class.java)
intent.putExtra("intention", ListActivity.ListActivityIntention.VIEW.toString())
intent.putExtra(
"favoritesVisibility",
if (favorite) {
AppFilter.Companion.AppSetVisibility.EXCLUSIVE
} else {
AppFilter.Companion.AppSetVisibility.VISIBLE
}
)
intent.putExtra(
"hiddenVisibility",
if (hidden) {
AppFilter.Companion.AppSetVisibility.EXCLUSIVE
} else {
AppFilter.Companion.AppSetVisibility.HIDDEN
}
)
intent.putExtra(
"privateSpaceVisibility",
if (private) {
AppFilter.Companion.AppSetVisibility.EXCLUSIVE
} else if (!hidden && LauncherPreferences.apps().hidePrivateSpaceApps()) {
AppFilter.Companion.AppSetVisibility.HIDDEN
} else {
AppFilter.Companion.AppSetVisibility.VISIBLE
}
)
context.startActivity(intent)
}
/* A custom serializer is required to store type information,
see https://github.com/Kotlin/kotlinx.serialization/issues/1486
*/
private class LauncherActionSerializer : KSerializer<LauncherAction> {
override val descriptor: SerialDescriptor = buildClassSerialDescriptor(
"action:launcher",
) {
element("value", String.serializer().descriptor)
}
override fun deserialize(decoder: Decoder): LauncherAction {
val s = decoder.decodeStructure(descriptor) {
decodeElementIndex(descriptor)
decodeSerializableElement(descriptor, 0, String.serializer())
}
return LauncherAction.byId(s) ?: throw SerializationException()
}
override fun serialize(encoder: Encoder, value: LauncherAction) {
encoder.encodeStructure(descriptor) {
encodeSerializableElement(descriptor, 0, String.serializer(), value.id)
}
}
}

View file

@ -0,0 +1,57 @@
package de.jrpie.android.launcher.actions
import android.app.Service
import android.content.Context
import android.content.pm.LauncherApps
import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.os.Build
import de.jrpie.android.launcher.apps.PinnedShortcutInfo
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@Serializable
@SerialName("action:shortcut")
class ShortcutAction(val shortcut: PinnedShortcutInfo) : Action {
override fun invoke(context: Context, rect: Rect?): Boolean {
val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
// TODO
return false
}
shortcut.getShortcutInfo(context)?.let {
launcherApps.startShortcut(it, rect, null)
}
// TODO: handle null
return true
}
override fun label(context: Context): String {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
return "?"
}
return shortcut.getShortcutInfo(context)?.longLabel?.toString() ?: "?"
}
override fun getIcon(context: Context): Drawable? {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
return null
}
val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps
return shortcut.getShortcutInfo(context)?.let { launcherApps.getShortcutBadgedIconDrawable(it, 0) }
}
override fun isAvailable(context: Context): Boolean {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
return false
}
return shortcut.getShortcutInfo(context) != null
}
override fun canReachSettings(): Boolean {
return false
}
}

View file

@ -0,0 +1,90 @@
package de.jrpie.android.launcher.actions
import android.content.Context
import android.hardware.camera2.CameraAccessException
import android.hardware.camera2.CameraCharacteristics
import android.hardware.camera2.CameraManager
import android.os.Build
import android.os.Build.VERSION_CODES
import android.os.Handler
import android.os.Looper
import android.widget.Toast
import androidx.annotation.RequiresApi
import de.jrpie.android.launcher.R
@RequiresApi(VERSION_CODES.M)
class TorchManager(context: Context) {
private val camera = getCameraId(context)
private var torchEnabled = false
private val torchCallback = object : CameraManager.TorchCallback() {
override fun onTorchModeChanged(cameraId: String, enabled: Boolean) {
synchronized(this@TorchManager) {
if (cameraId == camera) {
torchEnabled = enabled
}
}
}
}
init {
registerCallback(context)
}
private fun getCameraId(context: Context): String? {
val cameraManager =
context.getSystemService(Context.CAMERA_SERVICE) as CameraManager
return cameraManager.cameraIdList.firstOrNull { c ->
cameraManager
.getCameraCharacteristics(c)
.get(CameraCharacteristics.FLASH_INFO_AVAILABLE) ?: false
}
}
private fun registerCallback(context: Context) {
val cameraManager =
context.getSystemService(Context.CAMERA_SERVICE) as CameraManager
cameraManager.registerTorchCallback(
torchCallback,
Handler(Looper.getMainLooper())
)
}
fun toggleTorch(context: Context) {
synchronized(this) {
val cameraManager =
context.getSystemService(Context.CAMERA_SERVICE) as CameraManager
if (camera == null) {
Toast.makeText(
context,
context.getString(R.string.alert_no_torch_found),
Toast.LENGTH_LONG
).show()
return
}
try {
if (!torchEnabled && Build.VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) {
cameraManager.turnOnTorchWithStrengthLevel(
camera,
cameraManager.getCameraCharacteristics(camera)
.get(CameraCharacteristics.FLASH_INFO_STRENGTH_MAXIMUM_LEVEL) ?: 1
)
} else {
cameraManager.setTorchMode(camera, !torchEnabled)
}
} catch (e: CameraAccessException) {
Toast.makeText(
context,
context.getString(R.string.alert_torch_access_exception),
Toast.LENGTH_LONG
).show()
}
}
}
}

View file

@ -0,0 +1,151 @@
package de.jrpie.android.launcher.actions.lock
import android.accessibilityservice.AccessibilityService
import android.app.AlertDialog
import android.content.Context
import android.content.Intent
import android.os.Build
import android.provider.Settings
import android.util.Log
import android.view.accessibility.AccessibilityEvent
import android.widget.CheckBox
import android.widget.Toast
import de.jrpie.android.launcher.R
class LauncherAccessibilityService : AccessibilityService() {
override fun onInterrupt() {}
override fun onAccessibilityEvent(event: AccessibilityEvent?) {
// Intentionally left blank, we are not interested in any AccessibilityEvents.
// DO NOT ADD ANY CODE HERE!
}
companion object {
private const val TAG = "Launcher Accessibility"
private const val ACTION_REQUEST_ENABLE = "ACTION_REQUEST_ENABLE"
const val ACTION_LOCK_SCREEN = "ACTION_LOCK_SCREEN"
const val ACTION_RECENT_APPS = "ACTION_RECENT_APPS"
private fun invoke(context: Context, action: String, failureMessageRes: Int) {
try {
context.startService(
Intent(
context,
LauncherAccessibilityService::class.java
).apply {
this.action = action
})
} catch (_: Exception) {
Toast.makeText(
context,
context.getString(failureMessageRes),
Toast.LENGTH_LONG
).show()
}
}
fun lockScreen(context: Context) {
if (!isEnabled(context)) {
showEnableDialog(context)
} else {
invoke(context, ACTION_LOCK_SCREEN, R.string.alert_lock_screen_failed)
}
}
fun openRecentApps(context: Context) {
if (!isEnabled(context)) {
showEnableDialog(context)
} else {
invoke(context, ACTION_RECENT_APPS, R.string.alert_recent_apps_failed)
}
}
fun isEnabled(context: Context): Boolean {
val enabledServices = Settings.Secure.getString(
context.contentResolver,
Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES
) ?: return false
return enabledServices.split(":")
.contains("${context.packageName}/${LauncherAccessibilityService::class.java.name}")
.also { Log.d(TAG, "Accessibility Service enabled: $it") }
}
fun showEnableDialog(context: Context) {
AlertDialog.Builder(context, R.style.AlertDialogDanger).apply {
setView(R.layout.dialog_consent_accessibility)
setTitle(R.string.dialog_consent_accessibility_title)
setPositiveButton(R.string.dialog_consent_accessibility_ok) { _, _ ->
invoke(context, ACTION_REQUEST_ENABLE, R.string.alert_enable_accessibility_failed)
}
setNegativeButton(R.string.dialog_cancel) { _, _ -> }
}.create().also { it.show() }.apply {
val buttonOk = getButton(AlertDialog.BUTTON_POSITIVE)
val checkboxes = listOf(
findViewById<CheckBox>(R.id.dialog_consent_accessibility_checkbox_1),
findViewById(R.id.dialog_consent_accessibility_checkbox_2),
findViewById(R.id.dialog_consent_accessibility_checkbox_3),
findViewById(R.id.dialog_consent_accessibility_checkbox_4),
)
val update = {
buttonOk.isEnabled = checkboxes.map { b -> b?.isChecked == true }.all { it }
}
update()
checkboxes.forEach { c ->
c?.setOnClickListener { _ -> update() }
}
}
}
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
intent?.action?.let { action ->
if (!isEnabled(this)) {
Toast.makeText(
this,
getString(R.string.toast_accessibility_service_not_enabled),
Toast.LENGTH_LONG
).show()
requestEnable()
return START_NOT_STICKY
}
when (action) {
ACTION_REQUEST_ENABLE -> {} // do nothing
ACTION_LOCK_SCREEN -> handleLockScreen()
ACTION_RECENT_APPS -> performGlobalAction(GLOBAL_ACTION_RECENTS)
}
}
return super.onStartCommand(intent, flags, startId)
}
private fun requestEnable() {
startActivity(
Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS).addFlags(
Intent.FLAG_ACTIVITY_NEW_TASK
)
)
}
private fun handleLockScreen() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
Toast.makeText(
this,
getText(R.string.toast_lock_screen_not_supported),
Toast.LENGTH_SHORT
).show()
return
}
val success = performGlobalAction(GLOBAL_ACTION_LOCK_SCREEN)
if (!success) {
Toast.makeText(
this,
getText(R.string.alert_lock_screen_failed),
Toast.LENGTH_LONG
).show()
requestEnable()
}
}
}

View file

@ -0,0 +1,56 @@
package de.jrpie.android.launcher.actions.lock
import android.app.admin.DeviceAdminReceiver
import android.app.admin.DevicePolicyManager
import android.content.ComponentName
import android.content.Context
import android.content.Intent
import android.widget.Toast
import de.jrpie.android.launcher.R
class LauncherDeviceAdmin : DeviceAdminReceiver() {
companion object {
private fun getComponentName(context: Context): ComponentName {
return ComponentName(context, LauncherDeviceAdmin::class.java)
}
private fun requestDeviceAdmin(context: Context) {
val intent = Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN).apply {
putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, getComponentName(context))
putExtra(
DevicePolicyManager.EXTRA_ADD_EXPLANATION,
context.getString(R.string.device_admin_explanation)
)
}
context.startActivity(intent)
}
fun isDeviceAdmin(context: Context): Boolean {
val dpm = context.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
return dpm.isAdminActive(getComponentName(context))
}
private fun assertDeviceAdmin(context: Context): Boolean {
val dpm = context.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
if (!dpm.isAdminActive(getComponentName(context))) {
Toast.makeText(
context,
context.getString(R.string.toast_device_admin_not_enabled),
Toast.LENGTH_LONG
).show()
requestDeviceAdmin(context)
return false
}
return true
}
fun lockScreen(context: Context) {
assertDeviceAdmin(context) || return
val dpm = context.getSystemService(Context.DEVICE_POLICY_SERVICE) as DevicePolicyManager
dpm.lockNow()
}
}
}

View file

@ -0,0 +1,71 @@
package de.jrpie.android.launcher.actions.lock
import android.content.Context
import android.os.Build
import android.widget.Button
import androidx.appcompat.app.AlertDialog
import de.jrpie.android.launcher.BuildConfig
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.actions.lock.LauncherAccessibilityService
import de.jrpie.android.launcher.preferences.LauncherPreferences
enum class LockMethod(
private val lock: (Context) -> Unit,
private val isEnabled: (Context) -> Boolean,
private val enable: (Context) -> Unit
) {
DEVICE_ADMIN(
LauncherDeviceAdmin::lockScreen,
LauncherDeviceAdmin::isDeviceAdmin,
LauncherDeviceAdmin::lockScreen
),
ACCESSIBILITY_SERVICE(
LauncherAccessibilityService::lockScreen,
LauncherAccessibilityService::isEnabled,
LauncherAccessibilityService::showEnableDialog
),
;
fun lockOrEnable(context: Context) {
if (!this.isEnabled(context)) {
chooseMethod(context)
return
}
this.lock(context)
}
companion object {
fun chooseMethod(context: Context) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P ||
! BuildConfig.USE_ACCESSIBILITY_SERVICE) {
// only device admin is available
setMethod(context, DEVICE_ADMIN)
return
}
AlertDialog.Builder(context, R.style.AlertDialogCustom).apply {
setNegativeButton(R.string.dialog_cancel) { _, _ -> }
setView(R.layout.dialog_select_lock_method)
// setTitle()
}.create().also { it.show() }.apply {
findViewById<Button>(R.id.dialog_select_lock_method_button_accessibility)
?.setOnClickListener {
setMethod(context, ACCESSIBILITY_SERVICE)
cancel()
}
findViewById<Button>(R.id.dialog_select_lock_method_button_device_admin)
?.setOnClickListener {
setMethod(context, DEVICE_ADMIN)
cancel()
}
}
return
}
private fun setMethod(context: Context, m: LockMethod) {
LauncherPreferences.actions().lockMethod(m)
if (!m.isEnabled(context))
m.enable(context)
}
}
}

View file

@ -0,0 +1,22 @@
package de.jrpie.android.launcher.apps
import kotlinx.serialization.Serializable
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
/**
* This interface is implemented by [AppInfo] and [PinnedShortcutInfo].
*/
@Serializable
sealed interface AbstractAppInfo {
fun serialize(): String {
return Json.encodeToString(this)
}
companion object {
const val INVALID_USER = -1
fun deserialize(serialized: String): AbstractAppInfo {
return Json.decodeFromString(serialized)
}
}
}

View file

@ -0,0 +1,42 @@
package de.jrpie.android.launcher.apps
import android.content.Context
import android.graphics.drawable.Drawable
import android.os.UserHandle
import android.util.Log
import de.jrpie.android.launcher.Application
import de.jrpie.android.launcher.actions.Action
import de.jrpie.android.launcher.preferences.LauncherPreferences
/**
* This interface is implemented by [DetailedAppInfo] and [DetailedPinnedShortcutInfo]
*/
sealed interface AbstractDetailedAppInfo {
fun getRawInfo(): AbstractAppInfo
fun getLabel(): String
fun getIcon(context: Context): Drawable
fun getUser(context: Context): UserHandle
fun isPrivate(): Boolean
fun isRemovable(): Boolean
fun getAction(): Action
fun getCustomLabel(context: Context): String {
val map = (context.applicationContext as? Application)?.getCustomAppNames()
return map?.get(getRawInfo()) ?: getLabel()
}
fun setCustomLabel(label: CharSequence?) {
Log.i("Launcher", "Setting custom label for ${this.getRawInfo()} to ${label}.")
val map = LauncherPreferences.apps().customNames() ?: HashMap<AbstractAppInfo, String>()
if (label.isNullOrEmpty()) {
map.remove(getRawInfo())
} else {
map[getRawInfo()] = label.toString()
}
LauncherPreferences.apps().customNames(map)
}
}

View file

@ -0,0 +1,102 @@
package de.jrpie.android.launcher.apps
import android.content.Context
import android.icu.text.Normalizer2
import android.os.Build
import de.jrpie.android.launcher.actions.Action
import de.jrpie.android.launcher.actions.AppAction
import de.jrpie.android.launcher.actions.Gesture
import de.jrpie.android.launcher.actions.ShortcutAction
import de.jrpie.android.launcher.preferences.LauncherPreferences
import java.util.Locale
import kotlin.text.Regex.Companion.escape
class AppFilter(
var context: Context,
var query: String,
var favoritesVisibility: AppSetVisibility = AppSetVisibility.VISIBLE,
var hiddenVisibility: AppSetVisibility = AppSetVisibility.HIDDEN,
var privateSpaceVisibility: AppSetVisibility = AppSetVisibility.VISIBLE
) {
operator fun invoke(apps: List<AbstractDetailedAppInfo>): List<AbstractDetailedAppInfo> {
var apps =
apps.sortedBy { app -> app.getCustomLabel(context).lowercase(Locale.ROOT) }
val hidden = LauncherPreferences.apps().hidden() ?: setOf()
val favorites = LauncherPreferences.apps().favorites() ?: setOf()
val private = apps.filter { it.isPrivate() }
.map { it.getRawInfo() }.toSet()
apps = apps.filter { info ->
favoritesVisibility.predicate(favorites, info)
&& hiddenVisibility.predicate(hidden, info)
&& privateSpaceVisibility.predicate(private, info)
}
if (LauncherPreferences.apps().hideBoundApps()) {
val boundApps = Gesture.entries
.filter(Gesture::isEnabled)
.mapNotNull { g -> Action.forGesture(g) }
.mapNotNull {
(it as? AppAction)?.app
?: (it as? ShortcutAction)?.shortcut
}
.toSet()
apps = apps.filterNot { info -> boundApps.contains(info.getRawInfo()) }
}
// normalize text for search
val allowedSpecialCharacters = unicodeNormalize(query)
.lowercase(Locale.ROOT)
.toCharArray()
.distinct()
.filter { c -> !c.isLetter() }
.map { c -> escape(c.toString()) }
.fold("") { x, y -> x + y }
val disallowedCharsRegex = "[^\\p{L}$allowedSpecialCharacters]".toRegex()
fun normalize(text: String): String {
return unicodeNormalize(text).replace(disallowedCharsRegex, "")
}
if (query.isEmpty()) {
return apps
} else {
val r: MutableList<AbstractDetailedAppInfo> = ArrayList()
val appsSecondary: MutableList<AbstractDetailedAppInfo> = ArrayList()
val normalizedQuery: String = normalize(query)
for (item in apps) {
val itemLabel: String = normalize(item.getCustomLabel(context))
if (itemLabel.startsWith(normalizedQuery)) {
r.add(item)
} else if (itemLabel.contains(normalizedQuery)) {
appsSecondary.add(item)
}
}
r.addAll(appsSecondary)
return r
}
}
companion object {
enum class AppSetVisibility(
val predicate: (set: Set<AbstractAppInfo>, AbstractDetailedAppInfo) -> Boolean
) {
VISIBLE({ _, _ -> true }),
HIDDEN({ set, appInfo -> !set.contains(appInfo.getRawInfo()) }),
EXCLUSIVE({ set, appInfo -> set.contains(appInfo.getRawInfo()) }),
;
}
private fun unicodeNormalize(s: String): String {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
val normalizer = Normalizer2.getNFKDInstance()
return normalizer.normalize(s.lowercase(Locale.ROOT))
}
return s.lowercase(Locale.ROOT)
}
}
}

View file

@ -0,0 +1,29 @@
package de.jrpie.android.launcher.apps
import android.app.Service
import android.content.Context
import android.content.pm.LauncherActivityInfo
import android.content.pm.LauncherApps
import de.jrpie.android.launcher.apps.AbstractAppInfo.Companion.INVALID_USER
import de.jrpie.android.launcher.getUserFromId
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
/**
* Represents an app installed on the users device.
* Contains the minimal amount of data required to identify the app.
*/
@Serializable
@SerialName("app")
data class AppInfo(val packageName: String, val activityName: String?, val user: Int = INVALID_USER): AbstractAppInfo {
fun getLauncherActivityInfo(
context: Context
): LauncherActivityInfo? {
val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps
val userHandle = getUserFromId(user, context)
val activityList = launcherApps.getActivityList(packageName, userHandle)
return activityList.firstOrNull { app -> app.name == activityName }
?: activityList.firstOrNull()
}
}

View file

@ -0,0 +1,74 @@
package de.jrpie.android.launcher.apps
import android.content.Context
import android.content.pm.ApplicationInfo
import android.content.pm.LauncherActivityInfo
import android.graphics.drawable.Drawable
import android.os.UserHandle
import de.jrpie.android.launcher.actions.Action
import de.jrpie.android.launcher.actions.AppAction
import de.jrpie.android.launcher.getUserFromId
/**
* Stores information used to create [de.jrpie.android.launcher.ui.list.apps.AppsRecyclerAdapter] rows.
*/
class DetailedAppInfo(
private val app: AppInfo,
private val label: CharSequence,
private val icon: Drawable,
private val privateSpace: Boolean,
private val removable: Boolean = true,
): AbstractDetailedAppInfo {
constructor(activityInfo: LauncherActivityInfo, private: Boolean) : this(
AppInfo(
activityInfo.applicationInfo.packageName,
activityInfo.name,
activityInfo.user.hashCode()
),
activityInfo.label,
activityInfo.getBadgedIcon(0),
private,
// App can be uninstalled iff it is not a system app
activityInfo.applicationInfo.flags.and(ApplicationInfo.FLAG_SYSTEM) == 0
)
override fun getLabel(): String {
return label.toString()
}
override fun getIcon(context: Context): Drawable {
return icon
}
override fun getRawInfo(): AppInfo {
return app
}
override fun getUser(context: Context): UserHandle {
return getUserFromId(app.user, context)
}
override fun isPrivate(): Boolean {
return privateSpace
}
override fun isRemovable(): Boolean {
return removable
}
override fun getAction(): Action {
return AppAction(app)
}
companion object {
fun fromAppInfo(appInfo: AppInfo, context: Context): DetailedAppInfo? {
return appInfo.getLauncherActivityInfo(context)?.let {
DetailedAppInfo(it, it.user == getPrivateSpaceUser(context))
}
}
}
}

View file

@ -0,0 +1,66 @@
package de.jrpie.android.launcher.apps
import android.app.Service
import android.content.Context
import android.content.pm.LauncherApps
import android.content.pm.ShortcutInfo
import android.graphics.drawable.Drawable
import android.os.Build
import android.os.UserHandle
import androidx.annotation.RequiresApi
import de.jrpie.android.launcher.actions.Action
import de.jrpie.android.launcher.actions.ShortcutAction
import de.jrpie.android.launcher.getUserFromId
@RequiresApi(Build.VERSION_CODES.N_MR1)
class DetailedPinnedShortcutInfo(
private val shortcutInfo: PinnedShortcutInfo,
private val label: String,
private val icon: Drawable,
private val privateSpace: Boolean
) : AbstractDetailedAppInfo {
constructor(context: Context, shortcut: ShortcutInfo) : this(
PinnedShortcutInfo(shortcut),
shortcut.longLabel.toString(),
(context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps)
.getShortcutBadgedIconDrawable(shortcut, 0),
shortcut.userHandle == getPrivateSpaceUser(context)
)
override fun getRawInfo(): AbstractAppInfo {
return shortcutInfo
}
override fun getLabel(): String {
return label
}
override fun getIcon(context: Context): Drawable {
return icon
}
override fun getUser(context: Context): UserHandle {
return getUserFromId(shortcutInfo.user, context)
}
override fun isPrivate(): Boolean {
return privateSpace
}
override fun isRemovable(): Boolean {
return true
}
override fun getAction(): Action {
return ShortcutAction(shortcutInfo)
}
companion object {
fun fromPinnedShortcutInfo(shortcutInfo: PinnedShortcutInfo, context: Context): DetailedPinnedShortcutInfo? {
return shortcutInfo.getShortcutInfo(context)?.let {
DetailedPinnedShortcutInfo(context, it)
}
}
}
}

View file

@ -0,0 +1,46 @@
package de.jrpie.android.launcher.apps
import android.app.Service
import android.content.ComponentName
import android.content.Context
import android.content.pm.LauncherApps
import android.content.pm.LauncherApps.ShortcutQuery
import android.content.pm.ShortcutInfo
import android.os.Build
import androidx.annotation.RequiresApi
import de.jrpie.android.launcher.getUserFromId
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
@RequiresApi(Build.VERSION_CODES.N_MR1)
@Serializable
@SerialName("shortcut")
data class PinnedShortcutInfo(
val id: String,
val packageName: String,
val activityName: String,
val user: Int
): AbstractAppInfo {
constructor(info: ShortcutInfo) : this(info.id, info.`package`, info.activity?.className ?: "", info.userHandle.hashCode())
fun getShortcutInfo(context: Context): ShortcutInfo? {
val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps
return try {
launcherApps.getShortcuts(
ShortcutQuery().apply {
setQueryFlags(ShortcutQuery.FLAG_MATCH_PINNED)
setPackage(packageName)
setActivity(ComponentName(packageName, activityName))
setShortcutIds(listOf(id))
},
getUserFromId(user, context)
)?.firstOrNull()
} catch(_: Exception) {
// can throw SecurityException or IllegalStateException when profile is locked
null
}
}
}

View file

@ -0,0 +1,140 @@
package de.jrpie.android.launcher.apps
import android.content.ActivityNotFoundException
import android.content.Context
import android.content.Intent
import android.content.pm.LauncherApps
import android.os.Build
import android.os.UserHandle
import android.os.UserManager
import android.provider.Settings
import android.widget.Toast
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.isDefaultHomeScreen
import de.jrpie.android.launcher.setDefaultHomeScreen
/*
* Checks whether the device supports private space.
*/
fun isPrivateSpaceSupported(): Boolean {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM
}
fun getPrivateSpaceUser(context: Context): UserHandle? {
if (!isPrivateSpaceSupported()) {
return null
}
val userManager = context.getSystemService(Context.USER_SERVICE) as UserManager
val launcherApps = context.getSystemService(Context.LAUNCHER_APPS_SERVICE) as LauncherApps
return userManager.userProfiles.firstOrNull { u ->
launcherApps.getLauncherUserInfo(u)?.userType == UserManager.USER_TYPE_PROFILE_PRIVATE
}
}
/**
* Check whether the user has created a private space and whether µLauncher can access it.
*/
fun isPrivateSpaceSetUp(
context: Context,
showToast: Boolean = false,
launchSettings: Boolean = false
): Boolean {
if (!isPrivateSpaceSupported()) {
if (showToast) {
Toast.makeText(
context,
context.getString(R.string.alert_requires_android_v),
Toast.LENGTH_LONG
).show()
}
return false
}
val privateSpaceUser = getPrivateSpaceUser(context)
if (privateSpaceUser != null) {
return true
}
if (!isDefaultHomeScreen(context)) {
if (showToast) {
Toast.makeText(
context,
context.getString(R.string.toast_private_space_default_home_screen),
Toast.LENGTH_LONG
).show()
}
if (launchSettings) {
setDefaultHomeScreen(context)
}
} else {
if (showToast) {
Toast.makeText(
context,
context.getString(R.string.toast_private_space_not_available),
Toast.LENGTH_LONG
).show()
}
if (launchSettings) {
try {
context.startActivity(Intent(Settings.ACTION_PRIVACY_SETTINGS))
} catch (_: ActivityNotFoundException) {
}
}
}
return false
}
fun isPrivateSpaceLocked(context: Context): Boolean {
if (!isPrivateSpaceSupported()) {
return false
}
val userManager = context.getSystemService(Context.USER_SERVICE) as UserManager
val privateSpaceUser = getPrivateSpaceUser(context) ?: return false
return userManager.isQuietModeEnabled(privateSpaceUser)
}
fun lockPrivateSpace(context: Context, lock: Boolean) {
if (!isPrivateSpaceSupported()) {
return
}
// silently return when trying to unlock but hide when locked is set
if (!lock && hidePrivateSpaceWhenLocked(context)) {
return
}
val userManager = context.getSystemService(Context.USER_SERVICE) as UserManager
val privateSpaceUser = getPrivateSpaceUser(context) ?: return
userManager.requestQuietModeEnabled(lock, privateSpaceUser)
}
fun togglePrivateSpaceLock(context: Context) {
if (!isPrivateSpaceSetUp(context, showToast = true, launchSettings = true)) {
return
}
val lock = isPrivateSpaceLocked(context)
lockPrivateSpace(context, !lock)
if (!lock) {
Toast.makeText(
context,
context.getString(R.string.toast_private_space_locked),
Toast.LENGTH_LONG
).show()
}
}
@Suppress("SameReturnValue")
fun hidePrivateSpaceWhenLocked(context: Context): Boolean {
// Trying to access the setting as a 3rd party launcher raises a security exception.
// This is an Android bug: https://issuetracker.google.com/issues/352276244#comment5
// The logic for this is implemented.
// TODO: replace this once the Android bug is fixed
return false
// TODO: perhaps this should be cached
// https://cs.android.com/android/platform/superproject/main/+/main:packages/apps/Launcher3/src/com/android/launcher3/util/SettingsCache.java;l=61;drc=56bf7ad33bc9d5ed3c18e7abefeec5c177ec75d7
// val key = "hide_privatespace_entry_point"
// return Settings.Secure.getInt(context.contentResolver, key, 0) == 1
}

View file

@ -1,169 +0,0 @@
package de.jrpie.android.launcher.list
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.graphics.Rect
import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
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.PREF_SCREEN_FULLSCREEN
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.REQUEST_UNINSTALL
import de.jrpie.android.launcher.UIObject
import de.jrpie.android.launcher.getPreferences
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.vibrantColor
import de.jrpie.android.launcher.databinding.ListBinding
var intendedChoosePause = false // know when to close
// TODO: Better solution for this intercommunication functionality (used in list-fragments)
var intention = ListActivity.ListActivityIntention.VIEW
var forGesture: String? = null
/**
* The [ListActivity] is the most general purpose activity in Launcher:
* - used to view all apps and edit their settings
* - used to choose an app / intent to be launched
*
* The activity itself can also be chosen to be launched as an action.
*/
class ListActivity : AppCompatActivity(), UIObject {
private lateinit var binding: ListBinding
enum class ListActivityIntention(val titleResource: Int) {
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)
// Initialise layout
binding = ListBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.listSettings.setOnClickListener {
LauncherAction.SETTINGS.launch(this@ListActivity)
}
// android:windowSoftInputMode="adjustResize" doesn't work in full screen.
// workaround from https://stackoverflow.com/a/57623505
this.window.decorView.viewTreeObserver.addOnGlobalLayoutListener {
val r = Rect()
window.decorView.getWindowVisibleDisplayFrame(r)
val height: Int =
binding.listContainer.context.resources.displayMetrics.heightPixels
val diff = height - r.bottom
if (diff != 0 && getPreferences(this).getBoolean(PREF_SCREEN_FULLSCREEN, false)) {
if (binding.listContainer.paddingBottom !== diff) {
binding.listContainer.setPadding(0, 0, 0, diff)
}
} else {
if (binding.listContainer.paddingBottom !== 0) {
binding.listContainer.setPadding(0, 0, 0, 0)
}
}
}
}
override fun onStart(){
super<AppCompatActivity>.onStart()
super<UIObject>.onStart()
}
override fun onPause() {
super.onPause()
finish()
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode == REQUEST_UNINSTALL) {
if (resultCode == Activity.RESULT_OK) {
Toast.makeText(this, getString(R.string.list_removed), Toast.LENGTH_LONG).show()
finish()
} else if (resultCode == Activity.RESULT_FIRST_USER) {
Toast.makeText(this, getString(R.string.list_not_removed), Toast.LENGTH_LONG).show()
finish()
}
}
}
override fun applyTheme() {
// list_close.setTextColor(vibrantColor)
binding.listTabs.setSelectedTabIndicatorColor(vibrantColor)
}
override fun setOnClicks() {
binding.listClose.setOnClickListener { finish() }
}
override fun adjustLayout() {
// get info about which action this activity is open for
intent.extras?.let { bundle ->
intention = bundle.getString("intention")
?.let { ListActivityIntention.valueOf(it) }
?: ListActivityIntention.VIEW
if (intention != ListActivityIntention.VIEW)
forGesture = bundle.getString("forGesture")
}
// Hide tabs for the "view" action
if (intention == ListActivityIntention.VIEW) {
binding.listTabs.visibility = View.GONE
}
binding.listHeading.text = getString(intention.titleResource)
val sectionsPagerAdapter = ListSectionsPagerAdapter(this, supportFragmentManager)
val viewPager: ViewPager = findViewById(R.id.list_viewpager)
viewPager.adapter = sectionsPagerAdapter
val tabs: TabLayout = findViewById(R.id.list_tabs)
tabs.setupWithViewPager(viewPager)
}
}
private val TAB_TITLES = arrayOf(
R.string.list_tab_app,
R.string.list_tab_other
)
/**
* 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) {
override fun getItem(position: Int): Fragment {
return when (position){
0 -> ListFragmentApps()
1 -> ListFragmentOther()
else -> Fragment()
}
}
override fun getPageTitle(position: Int): CharSequence {
return context.resources.getString(TAB_TITLES[position])
}
override fun getCount(): Int {
return when (intention) {
ListActivity.ListActivityIntention.VIEW -> 1
else -> 2
}
}
}

View file

@ -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
}

View file

@ -1,207 +0,0 @@
package de.jrpie.android.launcher.list.apps
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.AsyncTask
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import android.widget.ImageView
import android.widget.PopupMenu
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import de.jrpie.android.launcher.PREF_SEARCH_AUTO_LAUNCH
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.REQUEST_CHOOSE_APP
import de.jrpie.android.launcher.REQUEST_UNINSTALL
import de.jrpie.android.launcher.appsList
import de.jrpie.android.launcher.getPreferences
import de.jrpie.android.launcher.getSavedTheme
import de.jrpie.android.launcher.launch
import de.jrpie.android.launcher.launchApp
import de.jrpie.android.launcher.list.ListActivity
import de.jrpie.android.launcher.list.intendedChoosePause
import de.jrpie.android.launcher.loadApps
import de.jrpie.android.launcher.openAppSettings
import de.jrpie.android.launcher.transformGrayscale
import java.util.*
/**
* A [RecyclerView] (efficient scrollable list) containing all apps on the users device.
* The apps details are represented by [AppInfo].
*
* @param activity - the activity this is in
* @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,
val intention: ListActivity.ListActivityIntention
= ListActivity.ListActivityIntention.VIEW,
val forGesture: String? = ""):
RecyclerView.Adapter<AppsRecyclerAdapter.ViewHolder>() {
private val appsListDisplayed: MutableList<AppInfo>
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView),
View.OnClickListener {
var textView: TextView = itemView.findViewById(R.id.list_apps_row_name)
var img: ImageView = itemView.findViewById(R.id.list_apps_row_icon)
var menuDots: ImageView = itemView.findViewById(R.id.list_apps_row_menu)
override fun onClick(v: View) {
val pos = adapterPosition
val context: Context = v.context
val appPackageName = appsListDisplayed[pos].packageName.toString()
val appUser = appsListDisplayed[pos].user
when (intention){
ListActivity.ListActivityIntention.VIEW -> {
launchApp(appPackageName, appUser, activity)
}
ListActivity.ListActivityIntention.PICK -> {
val returnIntent = Intent()
returnIntent.putExtra("value", appPackageName)
appUser?.let{ returnIntent.putExtra("user", it) }
returnIntent.putExtra("forGesture", forGesture)
activity.setResult(REQUEST_CHOOSE_APP, returnIntent)
activity.finish()
}
}
}
init { itemView.setOnClickListener(this) }
}
override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) {
val appLabel = appsListDisplayed[i].label.toString()
val appPackageName = appsListDisplayed[i].packageName.toString()
val appIcon = appsListDisplayed[i].icon
val isSystemApp = appsListDisplayed[i].isSystemApp
viewHolder.textView.text = appLabel
viewHolder.img.setImageDrawable(appIcon)
if (getSavedTheme(activity) == "dark") transformGrayscale(
viewHolder.img
)
// decide when to show the options popup menu about
if (isSystemApp || intention == ListActivity.ListActivityIntention.PICK) {
viewHolder.menuDots.visibility = View.INVISIBLE
}
else {
viewHolder.menuDots.visibility = View.VISIBLE
viewHolder.menuDots.setOnClickListener{ showOptionsPopup(viewHolder, appPackageName) }
viewHolder.menuDots.setOnLongClickListener{ showOptionsPopup(viewHolder, appPackageName) }
viewHolder.textView.setOnLongClickListener{ showOptionsPopup(viewHolder, appPackageName) }
viewHolder.img.setOnLongClickListener{ showOptionsPopup(viewHolder, appPackageName) }
// ensure onClicks are actually caught
viewHolder.textView.setOnClickListener{ viewHolder.onClick(viewHolder.textView) }
viewHolder.img.setOnClickListener{ viewHolder.onClick(viewHolder.img) }
}
}
// TODO fixme: handle work profile apps
@Suppress("SameReturnValue")
private fun showOptionsPopup(viewHolder: ViewHolder, appPackageName: String): Boolean {
//create the popup menu
val popup = PopupMenu(activity, viewHolder.menuDots)
popup.inflate(R.menu.menu_app)
popup.setOnMenuItemClickListener {
when (it.itemId) {
R.id.app_menu_delete -> { // delete
intendedChoosePause = true
val intent = Intent(Intent.ACTION_UNINSTALL_PACKAGE)
intent.data = Uri.parse("package:$appPackageName")
intent.putExtra(Intent.EXTRA_RETURN_RESULT, true)
activity.startActivityForResult(intent,
REQUEST_UNINSTALL
)
true
}
R.id.app_menu_info -> { // open app settings
intendedChoosePause = true
openAppSettings(
appPackageName,
activity
)
true
}
else -> false
}
}
popup.show()
return true
}
override fun getItemCount(): Int { return appsListDisplayed.size }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val inflater = LayoutInflater.from(parent.context)
val view: View = inflater.inflate(R.layout.list_apps_row, parent, false)
return ViewHolder(view)
}
init {
// Load the apps
if (appsList.size == 0)
loadApps(activity.packageManager, activity)
else {
AsyncTask.execute { loadApps(activity.packageManager, activity) }
notifyDataSetChanged()
}
appsListDisplayed = ArrayList()
appsListDisplayed.addAll(appsList)
}
/**
* The function [filter] is used to search elements within this [RecyclerView].
*/
fun filter(text: String) {
// normalize text for search
fun normalize(text: String): String{
return text.lowercase(Locale.ROOT).replace("[^a-z0-9]".toRegex(), "")
}
appsListDisplayed.clear()
if (text.isEmpty()) {
appsListDisplayed.addAll(appsList)
} else {
val appsSecondary: MutableList<AppInfo> = ArrayList()
val normalizedText: String = normalize(text)
for (item in appsList) {
val itemLabel: String = normalize(item.label.toString())
if (itemLabel.startsWith(normalizedText)) {
appsListDisplayed.add(item)
}else if(itemLabel.contains(normalizedText)){
appsSecondary.add(item)
}
}
appsListDisplayed.addAll(appsSecondary)
}
// Launch apps automatically if only one result is found and the user wants it
// Disabled at the moment. The Setting 'PREF_SEARCH_AUTO_LAUNCH' may be
// modifiable at some later point.
if (appsListDisplayed.size == 1 && intention == ListActivity.ListActivityIntention.VIEW
&& getPreferences(activity).getBoolean(PREF_SEARCH_AUTO_LAUNCH, false)) {
val info = appsListDisplayed[0]
launch(info.packageName.toString(), info.user, activity)
val inputMethodManager = activity.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.hideSoftInputFromWindow(View(activity).windowToken, 0)
}
notifyDataSetChanged()
}
}

View file

@ -1,77 +0,0 @@
package de.jrpie.android.launcher.list.apps
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.PREF_SEARCH_AUTO_KEYBOARD
import de.jrpie.android.launcher.UIObject
import de.jrpie.android.launcher.databinding.ListAppsBinding
import de.jrpie.android.launcher.getPreferences
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
/**
* The [ListFragmentApps] is used as a tab in ListActivity.
*
* It is a list of all installed applications that are can be launched.
*/
class ListFragmentApps : Fragment(), UIObject {
private lateinit var binding: ListAppsBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = ListAppsBinding.inflate(inflater)
return binding.root
}
override fun onStart() {
super<Fragment>.onStart()
super<UIObject>.onStart()
}
override fun applyTheme() {
}
override fun setOnClicks() { }
override fun adjustLayout() {
val appsRViewAdapter = AppsRecyclerAdapter(activity!!, intention, forGesture)
// set up the list / recycler
binding.listAppsRview.apply {
// improve performance (since content changes don't change the layout size)
setHasFixedSize(true)
layoutManager = LinearLayoutManager(context)
adapter = appsRViewAdapter
}
binding.listAppsSearchview.setOnQueryTextListener(object :
androidx.appcompat.widget.SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String): Boolean {
appsRViewAdapter.filter(query)
return false
}
override fun onQueryTextChange(newText: String): Boolean {
appsRViewAdapter.filter(newText)
return false
}
})
if (intention == ListActivity.ListActivityIntention.VIEW
&& getPreferences(requireContext())
.getBoolean(PREF_SEARCH_AUTO_KEYBOARD, true)) {
openSoftKeyboard(requireContext(), binding.listAppsSearchview)
}
}
}

View file

@ -1,38 +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.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),
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")
}
}
}

View file

@ -0,0 +1,166 @@
package de.jrpie.android.launcher.preferences
import android.content.Context
import android.content.res.TypedArray
import android.graphics.Color
import android.text.Editable
import android.text.TextWatcher
import android.util.AttributeSet
import android.widget.EditText
import android.widget.SeekBar
import android.widget.TextView
import androidx.annotation.ColorInt
import androidx.appcompat.app.AlertDialog
import androidx.core.graphics.alpha
import androidx.core.graphics.blue
import androidx.core.graphics.green
import androidx.core.graphics.red
import androidx.preference.Preference
import de.jrpie.android.launcher.R
import androidx.core.graphics.toColorInt
class ColorPreference(context: Context, attrs: AttributeSet?) :
Preference(context, attrs) {
@Suppress("unused")
constructor(context: Context) : this(context, null)
private var selectedColor = Color.WHITE
init {
isPersistent = true
selectedColor = getPersistedInt(selectedColor)
summary = selectedColor.getHex()
}
override fun onClick() {
showDialog()
}
@ColorInt
override fun onGetDefaultValue(a: TypedArray, index: Int): Int {
return a.getInt(index, selectedColor)
}
override fun onSetInitialValue(defaultValue: Any?) {
selectedColor = getPersistedInt(selectedColor)
summary = selectedColor.getHex()
}
private fun showDialog() {
var currentColor = getPersistedInt(selectedColor)
AlertDialog.Builder(context, R.style.AlertDialogCustom).apply {
setView(R.layout.dialog_choose_color)
setTitle(R.string.dialog_choose_color_title)
setPositiveButton(android.R.string.ok) { _, _ ->
persistInt(currentColor)
summary = currentColor.getHex()
}
setNegativeButton(R.string.dialog_cancel) { _, _ -> }
}.create().also { it.show() }.apply {
val preview = findViewById<EditText>(R.id.dialog_select_color_preview)
val red = findViewById<SeekBar>(R.id.dialog_select_color_seekbar_red)
val green = findViewById<SeekBar>(R.id.dialog_select_color_seekbar_green)
val blue = findViewById<SeekBar>(R.id.dialog_select_color_seekbar_blue)
val alpha = findViewById<SeekBar>(R.id.dialog_select_color_seekbar_alpha)
val updateColor = { updateText: Boolean ->
preview?.setTextColor(currentColor.foregroundTextColor())
preview?.setBackgroundColor(currentColor)
if (updateText) {
preview?.setText(currentColor.getHex(), TextView.BufferType.EDITABLE)
}
red?.progress = currentColor.red
green?.progress = currentColor.green
blue?.progress = currentColor.blue
alpha?.progress = currentColor.alpha
}
updateColor(true)
preview?.addTextChangedListener(object : TextWatcher {
override fun beforeTextChanged(text: CharSequence?, p1: Int, p2: Int, p3: Int) {}
override fun onTextChanged(text: CharSequence?, p1: Int, p2: Int, p3: Int) {}
override fun afterTextChanged(editable: Editable?) {
preview.hasFocus() || return
val newText = editable?.toString() ?: return
newText.isBlank() && return
try {
val newColor = newText.toColorInt()
currentColor = newColor
updateColor(false)
} catch (_: IllegalArgumentException) {
}
}
})
red?.setOnSeekBarChangeListener(SeekBarChangeListener {
currentColor = currentColor.updateRed(it)
updateColor(true)
})
green?.setOnSeekBarChangeListener(SeekBarChangeListener {
currentColor = currentColor.updateGreen(it)
updateColor(true)
})
blue?.setOnSeekBarChangeListener(SeekBarChangeListener {
currentColor = currentColor.updateBlue(it)
updateColor(true)
})
alpha?.setOnSeekBarChangeListener(SeekBarChangeListener {
currentColor = currentColor.updateAlpha(it)
updateColor(true)
})
}
}
private class SeekBarChangeListener(val update: (Int) -> Unit) :
SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(seekBar: SeekBar?, v: Int, fromUser: Boolean) {
fromUser || return
update(v)
}
override fun onStartTrackingTouch(p0: SeekBar?) {}
override fun onStopTrackingTouch(p0: SeekBar?) {}
}
companion object {
fun @receiver:ColorInt Int.getHex(): String {
return "#%08X".format(this)
}
@ColorInt
fun @receiver:ColorInt Int.updateRed(red: Int): Int {
return Color.argb(this.alpha, red, this.green, this.blue)
}
@ColorInt
fun @receiver:ColorInt Int.updateGreen(green: Int): Int {
return Color.argb(this.alpha, this.red, green, this.blue)
}
@ColorInt
fun @receiver:ColorInt Int.updateBlue(blue: Int): Int {
return Color.argb(this.alpha, this.red, this.green, blue)
}
@ColorInt
fun @receiver:ColorInt Int.updateAlpha(alpha: Int): Int {
return Color.argb(alpha, this.red, this.green, this.blue)
}
@ColorInt
fun @receiver:ColorInt Int.foregroundTextColor(): Int {
// https://stackoverflow.com/a/3943023
return if (
this.red * 0.299 + this.green * 0.587 + this.blue * 0.114
> this.alpha / 256f * 150
) {
Color.BLACK
} else {
Color.WHITE
}
}
}
}

View file

@ -0,0 +1,85 @@
package de.jrpie.android.launcher.preferences;
import java.util.HashMap;
import java.util.Set;
import de.jrpie.android.launcher.R;
import de.jrpie.android.launcher.actions.lock.LockMethod;
import de.jrpie.android.launcher.preferences.serialization.MapAbstractAppInfoStringPreferenceSerializer;
import de.jrpie.android.launcher.preferences.serialization.SetAbstractAppInfoPreferenceSerializer;
import de.jrpie.android.launcher.preferences.serialization.SetPinnedShortcutInfoPreferenceSerializer;
import de.jrpie.android.launcher.preferences.theme.Background;
import de.jrpie.android.launcher.preferences.theme.ColorTheme;
import de.jrpie.android.launcher.preferences.theme.Font;
import eu.jonahbauer.android.preference.annotations.Preference;
import eu.jonahbauer.android.preference.annotations.PreferenceGroup;
import eu.jonahbauer.android.preference.annotations.Preferences;
@Preferences(
name = "de.jrpie.android.launcher.preferences.LauncherPreferences",
makeFile = true,
r = R.class,
value = {
@PreferenceGroup(name = "internal", prefix = "settings_internal_", suffix = "_key", value = {
// set after the user finished the tutorial
@Preference(name = "started", type = boolean.class, defaultValue = "false"),
@Preference(name = "started_time", type = long.class),
// see PREFERENCE_VERSION in de.jrpie.android.launcher.preferences.Preferences.kt
@Preference(name = "version_code", type = int.class, defaultValue = "-1"),
}),
@PreferenceGroup(name = "apps", prefix = "settings_apps_", suffix = "_key", value = {
@Preference(name = "favorites", type = Set.class, serializer = SetAbstractAppInfoPreferenceSerializer.class),
@Preference(name = "hidden", type = Set.class, serializer = SetAbstractAppInfoPreferenceSerializer.class),
@Preference(name = "pinned_shortcuts", type = Set.class, serializer = SetPinnedShortcutInfoPreferenceSerializer.class),
@Preference(name = "custom_names", type = HashMap.class, serializer = MapAbstractAppInfoStringPreferenceSerializer.class),
@Preference(name = "hide_bound_apps", type = boolean.class, defaultValue = "false"),
@Preference(name = "hide_paused_apps", type = boolean.class, defaultValue = "false"),
@Preference(name = "hide_private_space_apps", type = boolean.class, defaultValue = "false"),
}),
@PreferenceGroup(name = "list", prefix = "settings_list_", suffix = "_key", value = {
@Preference(name = "layout", type = ListLayout.class, defaultValue = "DEFAULT"),
@Preference(name = "reverse_layout", type = boolean.class, defaultValue = "false")
}),
@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 = "DIM"),
@Preference(name = "font", type = Font.class, defaultValue = "HACK"),
@Preference(name = "text_shadow", type = boolean.class, defaultValue = "false"),
@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 = "color", type = int.class, defaultValue = "0xffffffff"),
@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 = "hide_status_bar", type = boolean.class, defaultValue = "true"),
@Preference(name = "hide_navigation_bar", type = boolean.class, defaultValue = "false"),
@Preference(name = "rotate_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_web", type = boolean.class, description = "false"),
@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"),
@Preference(name = "edge_swipe_edge_width", type = int.class, defaultValue = "15"),
}),
@PreferenceGroup(name = "actions", prefix = "settings_actions_", suffix = "_key", value = {
@Preference(name = "lock_method", type = LockMethod.class, defaultValue = "DEVICE_ADMIN"),
}),
})
public final class LauncherPreferences$Config {}

View file

@ -0,0 +1,39 @@
package de.jrpie.android.launcher.preferences
import android.content.Context
import android.util.TypedValue
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import de.jrpie.android.launcher.R
// TODO: move this to de.jrpie.android.launcher.ui.list.apps ?
@Suppress("unused")
enum class ListLayout(
val layoutManager: (context: Context) -> RecyclerView.LayoutManager,
val layoutResource: Int,
val useBadgedText: Boolean,
) {
DEFAULT(
{ c -> LinearLayoutManager(c) },
R.layout.list_apps_row,
false
),
TEXT(
{ c -> LinearLayoutManager(c) },
R.layout.list_apps_row_variant_text,
true
),
GRID(
{ c ->
val displayMetrics = c.resources.displayMetrics
val widthColumnPx =
TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 90f, displayMetrics)
val numColumns = (displayMetrics.widthPixels / widthColumnPx).toInt()
GridLayoutManager(c, numColumns)
},
R.layout.list_apps_row_variant_grid,
false
),
}

View file

@ -0,0 +1,89 @@
package de.jrpie.android.launcher.preferences
import android.content.Context
import android.util.Log
import de.jrpie.android.launcher.BuildConfig
import de.jrpie.android.launcher.actions.Action
import de.jrpie.android.launcher.apps.AppInfo
import de.jrpie.android.launcher.apps.AbstractAppInfo
import de.jrpie.android.launcher.apps.AbstractAppInfo.Companion.INVALID_USER
import de.jrpie.android.launcher.apps.DetailedAppInfo
import de.jrpie.android.launcher.preferences.legacy.migratePreferencesFromVersion1
import de.jrpie.android.launcher.preferences.legacy.migratePreferencesFromVersion2
import de.jrpie.android.launcher.preferences.legacy.migratePreferencesFromVersion3
import de.jrpie.android.launcher.preferences.legacy.migratePreferencesFromVersionUnknown
import de.jrpie.android.launcher.ui.HomeActivity
/* Current version of the structure of preferences.
* Increase when breaking changes are introduced and write an appropriate case in
* `migratePreferencesToNewVersion`
*/
const val PREFERENCE_VERSION = 4
const val UNKNOWN_PREFERENCE_VERSION = -1
private const val TAG = "Launcher - Preferences"
/*
* Tries to detect preferences written by older versions of the app
* and migrate them to the current format.
*/
fun migratePreferencesToNewVersion(context: Context) {
try {
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 */
migratePreferencesFromVersionUnknown(context)
Log.i(TAG, "migration of preferences complete (${UNKNOWN_PREFERENCE_VERSION} -> ${PREFERENCE_VERSION}).")
}
1 -> {
migratePreferencesFromVersion1()
Log.i(TAG, "migration of preferences complete (1 -> ${PREFERENCE_VERSION}).")
}
2 -> {
migratePreferencesFromVersion2()
Log.i(TAG, "migration of preferences complete (2 -> ${PREFERENCE_VERSION}).")
}
3 -> {
migratePreferencesFromVersion3()
Log.i(TAG, "migration of preferences complete (3 -> ${PREFERENCE_VERSION}).")
}
else -> {
Log.w(
TAG,
"Shared preferences were written by a newer version of the app (${
LauncherPreferences.internal().versionCode()
})!"
)
}
}
} catch (e: Exception) {
Log.e(TAG, "Unable to restore preferences:\n${e.stackTrace}")
resetPreferences(context)
}
}
fun resetPreferences(context: Context) {
Log.i(TAG, "Resetting preferences")
LauncherPreferences.clear()
LauncherPreferences.internal().versionCode(PREFERENCE_VERSION)
val hidden: MutableSet<AbstractAppInfo> = mutableSetOf()
val launcher = DetailedAppInfo.fromAppInfo(
AppInfo(
BuildConfig.APPLICATION_ID,
HomeActivity::class.java.name,
INVALID_USER
), context
)
launcher?.getRawInfo()?.let { hidden.add(it) }
Log.i(TAG,"Hiding ${launcher?.getRawInfo()}")
LauncherPreferences.apps().hidden(hidden)
Action.resetToDefaultActions(context)
}

View file

@ -0,0 +1,141 @@
package de.jrpie.android.launcher.preferences.legacy
import de.jrpie.android.launcher.actions.Action
import de.jrpie.android.launcher.actions.AppAction
import de.jrpie.android.launcher.actions.Gesture
import de.jrpie.android.launcher.actions.LauncherAction
import de.jrpie.android.launcher.apps.AppInfo
import de.jrpie.android.launcher.apps.AbstractAppInfo.Companion.INVALID_USER
import de.jrpie.android.launcher.preferences.LauncherPreferences
import de.jrpie.android.launcher.preferences.PREFERENCE_VERSION
import kotlinx.serialization.Serializable
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import org.json.JSONException
import org.json.JSONObject
import androidx.core.content.edit
@Serializable
@Suppress("unused")
private class LegacyMapEntry(val key: AppInfo, val value: String)
private fun serializeMapAppInfo(value: Map<AppInfo, String>?): Set<String>? {
return value?.map { (key, value) ->
Json.encodeToString(LegacyMapEntry(key, value))
}?.toSet()
}
val oldLauncherActionIds: Map<String, LauncherAction> =
mapOf(
Pair("launcher:settings", LauncherAction.SETTINGS),
Pair("launcher:choose", LauncherAction.CHOOSE),
Pair("launcher:chooseFromFavorites", LauncherAction.CHOOSE_FROM_FAVORITES),
Pair("launcher:volumeUp", LauncherAction.VOLUME_UP),
Pair("launcher:volumeDown", LauncherAction.VOLUME_DOWN),
Pair("launcher:nextTrack", LauncherAction.TRACK_NEXT),
Pair("launcher:previousTrack", LauncherAction.TRACK_PREV),
Pair("launcher:expandNotificationsPanel", LauncherAction.EXPAND_NOTIFICATIONS_PANEL),
Pair("launcher:expandSettingsPanel", LauncherAction.EXPAND_SETTINGS_PANEL),
Pair("launcher:lockScreen", LauncherAction.LOCK_SCREEN),
Pair("launcher:toggleTorch", LauncherAction.TORCH),
Pair("launcher:nop", LauncherAction.NOP),
)
private fun AppInfo.Companion.legacyDeserialize(serialized: String): AppInfo {
val values = serialized.split(";")
val packageName = values[0]
val user = Integer.valueOf(values[1])
val activityName = values.getOrNull(2) ?: "" // TODO
return AppInfo(packageName, activityName, user)
}
/**
* Get an action for a specific id.
* An id is of the form:
* - "launcher:${launcher_action_name}", see [LauncherAction]
* - "${package_name}", see [AppAction]
* - "${package_name}:${activity_name}", see [AppAction]
*
* @param id
* @param user a user id, ignored if the action is a [LauncherAction].
*/
private fun Action.Companion.legacyFromId(id: String, user: Int?): Action? {
if (id.isEmpty()) {
return null
}
oldLauncherActionIds[id]?.let { return it }
val values = id.split(";")
return AppAction(
AppInfo(
values[0], values.getOrNull(1) ?: "", user ?: INVALID_USER
)
)
}
private fun Action.Companion.legacyFromPreference(id: String): Action? {
val preferences = LauncherPreferences.getSharedPreferences()
val actionId = preferences.getString("$id.app", "")!!
var u: Int? = preferences.getInt(
"$id.user",
INVALID_USER
)
u = if (u == INVALID_USER) null else u
return Action.legacyFromId(actionId, u)
}
private fun migrateAppInfoStringMap(key: String) {
val preferences = LauncherPreferences.getSharedPreferences()
serializeMapAppInfo(
preferences.getStringSet(key, setOf())?.mapNotNull { entry ->
try {
val obj = JSONObject(entry)
val info = AppInfo.legacyDeserialize(obj.getString("key"))
val value = obj.getString("value")
Pair(info, value)
} catch (_: JSONException) {
null
}
}?.toMap(HashMap())
)?.let {
preferences.edit { putStringSet(key, it) }
}
}
private fun migrateAppInfoSet(key: String) {
(LauncherPreferences.getSharedPreferences().getStringSet(key, setOf()) ?: return)
.map(AppInfo.Companion::legacyDeserialize)
.map(AppInfo::serialize)
.toSet()
.let { LauncherPreferences.getSharedPreferences().edit { putStringSet(key, it) } }
}
private fun migrateAction(key: String) {
Action.legacyFromPreference(key)?.let { action ->
LauncherPreferences.getSharedPreferences().edit {
putString(key, Json.encodeToString(action))
.remove("$key.app")
.remove("$key.user")
}
}
}
/**
* Migrate preferences from version 1 (used until version j-0.0.18) to the current format
* (see [PREFERENCE_VERSION])
*/
fun migratePreferencesFromVersion1() {
assert(LauncherPreferences.internal().versionCode() == 1)
Gesture.entries.forEach { g -> migrateAction(g.id) }
migrateAppInfoSet(LauncherPreferences.apps().keys().hidden())
migrateAppInfoSet(LauncherPreferences.apps().keys().favorites())
migrateAppInfoStringMap(LauncherPreferences.apps().keys().customNames())
LauncherPreferences.internal().versionCode(2)
migratePreferencesFromVersion2()
}

View file

@ -0,0 +1,20 @@
package de.jrpie.android.launcher.preferences.legacy
import de.jrpie.android.launcher.actions.Action
import de.jrpie.android.launcher.actions.Gesture
import de.jrpie.android.launcher.actions.LauncherAction
import de.jrpie.android.launcher.preferences.LauncherPreferences
import de.jrpie.android.launcher.preferences.PREFERENCE_VERSION
/**
* Migrate preferences from version 2 (used until version 0.0.21) to the current format
* (see [PREFERENCE_VERSION])
*/
fun migratePreferencesFromVersion2() {
assert(LauncherPreferences.internal().versionCode() == 2)
// previously there was no setting for this
Action.setActionForGesture(Gesture.BACK, LauncherAction.CHOOSE)
LauncherPreferences.internal().versionCode(3)
migratePreferencesFromVersion3()
}

View file

@ -0,0 +1,85 @@
package de.jrpie.android.launcher.preferences.legacy
import android.content.SharedPreferences
import android.content.SharedPreferences.Editor
import de.jrpie.android.launcher.apps.AppInfo
import de.jrpie.android.launcher.apps.AbstractAppInfo
import de.jrpie.android.launcher.preferences.LauncherPreferences
import de.jrpie.android.launcher.preferences.PREFERENCE_VERSION
import de.jrpie.android.launcher.preferences.serialization.MapAbstractAppInfoStringPreferenceSerializer
import de.jrpie.android.launcher.preferences.serialization.SetAbstractAppInfoPreferenceSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import java.util.HashSet
import androidx.core.content.edit
/**
* Migrate preferences from version 3 (used until version 0.0.23) to the current format
* (see [PREFERENCE_VERSION])
*/
fun deserializeSet(value: Set<String>?): Set<AppInfo>? {
return value?.map {
Json.decodeFromString<AppInfo>(it)
}?.toHashSet()
}
fun deserializeMap(value: Set<String>?): HashMap<AppInfo, String>? {
return value?.associateTo(HashMap()) {
val entry = Json.decodeFromString<MapEntry>(it)
Pair(entry.key, entry.value)
}
}
@Serializable
private class MapEntry(val key: AppInfo, val value: String)
private fun migrateSetAppInfo(key: String, preferences: SharedPreferences, editor: Editor) {
try {
val serializer = SetAbstractAppInfoPreferenceSerializer()
val set = HashSet<AbstractAppInfo>()
deserializeSet(preferences.getStringSet(key, null))?.let {
set.addAll(it)
}
@Suppress("UNCHECKED_CAST")
editor.putStringSet(
key,
serializer.serialize(set as java.util.Set<AbstractAppInfo>) as Set<String>?
)
} catch (e: Exception) {
e.printStackTrace()
editor.putStringSet(key, null)
}
}
private fun migrateMapAppInfoString(key: String, preferences: SharedPreferences, editor: Editor ) {
try {
val serializer = MapAbstractAppInfoStringPreferenceSerializer()
val map = HashMap<AbstractAppInfo, String>()
deserializeMap(preferences.getStringSet(key, null))?.let {
map.putAll(it)
}
@Suppress("UNCHECKED_CAST")
editor.putStringSet(key, serializer.serialize(map) as Set<String>?)
} catch (e: Exception) {
e.printStackTrace()
editor.putStringSet(key, null)
}
}
fun migratePreferencesFromVersion3() {
assert(PREFERENCE_VERSION == 4)
assert(LauncherPreferences.internal().versionCode() == 3)
val preferences = LauncherPreferences.getSharedPreferences()
preferences.edit {
migrateSetAppInfo(LauncherPreferences.apps().keys().favorites(), preferences, this)
migrateSetAppInfo(LauncherPreferences.apps().keys().hidden(), preferences, this)
migrateMapAppInfoString(LauncherPreferences.apps().keys().customNames(), preferences, this)
}
LauncherPreferences.internal().versionCode(4)
}

View file

@ -0,0 +1,396 @@
package de.jrpie.android.launcher.preferences.legacy
import android.content.Context
import android.content.SharedPreferences
import android.util.Log
import de.jrpie.android.launcher.preferences.LauncherPreferences
import de.jrpie.android.launcher.preferences.theme.Background
import de.jrpie.android.launcher.preferences.theme.ColorTheme
import androidx.core.content.edit
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)
}
private const val TAG = "Preferences ? -> 1"
/**
* Try to migrate from a very old preference version, where no version number was stored
* and a different file was used.
*/
fun migratePreferencesFromVersionUnknown(context: Context) {
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")) {
Log.i(TAG, "No old preferences found. Probably this is a fresh installation.")
return
}
LauncherPreferences.getSharedPreferences().edit {
migrateBooleanPreference(
oldPrefs,
this,
"startedBefore",
"internal.started_before",
false
)
migrateStringPreference(
oldPrefs,
this,
"action_volumeUpApp",
"action.volume_up.app",
""
)
migrateIntPreference(
oldPrefs,
this,
"action_volumeUpApp_user",
"action.volume_up.user",
-1
)
migrateStringPreference(
oldPrefs,
this,
"action_volumeDownApp",
"action.volume_down.app",
""
)
migrateIntPreference(
oldPrefs,
this,
"action_volumeDownApp_user",
"action.volume_down.user",
-1
)
migrateStringPreference(oldPrefs, this, "action_timeApp", "action.time.app", "")
migrateIntPreference(oldPrefs, this, "action_timeApp_user", "action.time.user", -1)
migrateStringPreference(oldPrefs, this, "action_dateApp", "action.date.app", "")
migrateIntPreference(oldPrefs, this, "action_dateApp_user", "action.date.user", -1)
migrateStringPreference(
oldPrefs,
this,
"action_longClickApp",
"action.long_click.app",
""
)
migrateIntPreference(
oldPrefs,
this,
"action_longClickApp_user",
"action.long_click.user",
-1
)
migrateStringPreference(
oldPrefs,
this,
"action_doubleClickApp",
"action.double_click.app",
""
)
migrateIntPreference(
oldPrefs,
this,
"action_doubleClickApp_user",
"action.double_click.user",
-1
)
migrateStringPreference(oldPrefs, this, "action_upApp", "action.up.app", "")
migrateIntPreference(oldPrefs, this, "action_upApp_user", "action.up.user", -1)
migrateStringPreference(
oldPrefs,
this,
"action_up_leftApp",
"action.up_left.app",
""
)
migrateIntPreference(
oldPrefs,
this,
"action_up_leftApp_user",
"action.up_left.user",
-1
)
migrateStringPreference(
oldPrefs,
this,
"action_up_rightApp",
"action.up_right.app",
""
)
migrateIntPreference(
oldPrefs,
this,
"action_up_rightApp_user",
"action.up_right.user",
-1
)
migrateStringPreference(
oldPrefs,
this,
"action_doubleUpApp",
"action.double_up.app",
""
)
migrateIntPreference(
oldPrefs,
this,
"action_doubleUpApp_user",
"action.double_up.user",
-1
)
migrateStringPreference(oldPrefs, this, "action_downApp", "action.down.app", "")
migrateIntPreference(oldPrefs, this, "action_downApp_user", "action.down.user", -1)
migrateStringPreference(
oldPrefs,
this,
"action_down_leftApp",
"action.down_left.app",
""
)
migrateIntPreference(
oldPrefs,
this,
"action_down_leftApp_user",
"action.down_left.user",
-1
)
migrateStringPreference(
oldPrefs,
this,
"action_down_rightApp",
"action.down_right.app",
""
)
migrateIntPreference(
oldPrefs,
this,
"action_down_rightApp_user",
"action.down_right.user",
-1
)
migrateStringPreference(
oldPrefs,
this,
"action_doubleDownApp",
"action.double_down.app",
""
)
migrateIntPreference(
oldPrefs,
this,
"action_doubleDownApp_user",
"action.double_down.user",
-1
)
migrateStringPreference(oldPrefs, this, "action_leftApp", "action.left.app", "")
migrateIntPreference(oldPrefs, this, "action_leftApp_user", "action.left.user", -1)
migrateStringPreference(
oldPrefs,
this,
"action_left_topApp",
"action.left_top.app",
""
)
migrateIntPreference(
oldPrefs,
this,
"action_left_topApp_user",
"action.left_top.user",
-1
)
migrateStringPreference(
oldPrefs,
this,
"action_left_bottomApp",
"action.left_bottom.app",
""
)
migrateIntPreference(
oldPrefs,
this,
"action_left_bottomApp_user",
"action.left_bottom.user",
-1
)
migrateStringPreference(
oldPrefs,
this,
"action_doubleLeftApp",
"action.double_left.app",
""
)
migrateIntPreference(
oldPrefs,
this,
"action_doubleLeftApp_user",
"action.double_left.user",
-1
)
migrateStringPreference(oldPrefs, this, "action_rightApp", "action.right.app", "")
migrateIntPreference(
oldPrefs,
this,
"action_rightApp_user",
"action.right.user",
-1
)
migrateStringPreference(
oldPrefs,
this,
"action_right_topApp",
"action.right_top.app",
""
)
migrateIntPreference(
oldPrefs,
this,
"action_right_topApp_user",
"action.right_top.user",
-1
)
migrateStringPreference(
oldPrefs,
this,
"action_right_bottomApp",
"action.right_bottom.app",
""
)
migrateIntPreference(
oldPrefs,
this,
"action_right_bottomApp_user",
"action.right_bottom.user",
-1
)
migrateStringPreference(
oldPrefs,
this,
"action_doubleRightApp",
"action.double_right.app",
""
)
migrateIntPreference(
oldPrefs,
this,
"action_doubleRightApp_user",
"action.double_right.user",
-1
)
migrateBooleanPreference(oldPrefs, this, "timeVisible", "clock.time_visible", true)
migrateBooleanPreference(oldPrefs, this, "dateVisible", "clock.date_visible", true)
migrateBooleanPreference(
oldPrefs,
this,
"dateLocalized",
"clock.date_localized",
false
)
migrateBooleanPreference(
oldPrefs,
this,
"dateTimeFlip",
"clock.date_time_flip",
false
)
migrateBooleanPreference(
oldPrefs,
this,
"disableTimeout",
"display.disable_timeout",
false
)
migrateBooleanPreference(
oldPrefs,
this,
"useFullScreen",
"display.use_full_screen",
true
)
migrateBooleanPreference(
oldPrefs,
this,
"enableDoubleActions",
"enabled_gestures.double_actions",
true
)
migrateBooleanPreference(
oldPrefs,
this,
"enableEdgeActions",
"enabled_gestures.edge_actions",
true
)
migrateBooleanPreference(
oldPrefs,
this,
"searchAutoLaunch",
"functionality.search_auto_launch",
true
)
migrateBooleanPreference(
oldPrefs,
this,
"searchAutoKeyboard",
"functionality.search_auto_keyboard",
true
)
}
when (oldPrefs.getString("theme", "finn")) {
"finn" -> {
LauncherPreferences.theme().colorTheme(ColorTheme.DEFAULT)
LauncherPreferences.theme().monochromeIcons(false)
LauncherPreferences.theme().background(Background.DIM)
}
"dark" -> {
LauncherPreferences.theme().colorTheme(ColorTheme.DARK)
LauncherPreferences.theme().monochromeIcons(true)
LauncherPreferences.theme().background(Background.DIM)
}
}
LauncherPreferences.internal().versionCode(1)
Log.i(TAG, "migrated preferences to version 1.")
migratePreferencesFromVersion1()
}

View file

@ -0,0 +1,71 @@
@file:Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
package de.jrpie.android.launcher.preferences.serialization
import de.jrpie.android.launcher.apps.AbstractAppInfo
import de.jrpie.android.launcher.apps.PinnedShortcutInfo
import eu.jonahbauer.android.preference.annotations.serializer.PreferenceSerializationException
import eu.jonahbauer.android.preference.annotations.serializer.PreferenceSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
@Suppress("UNCHECKED_CAST")
class SetAbstractAppInfoPreferenceSerializer :
PreferenceSerializer<java.util.Set<AbstractAppInfo>?, java.util.Set<java.lang.String>?> {
@Throws(PreferenceSerializationException::class)
override fun serialize(value: java.util.Set<AbstractAppInfo>?): java.util.Set<java.lang.String> {
return value?.map(AbstractAppInfo::serialize)
?.toHashSet() as java.util.Set<java.lang.String>
}
@Throws(PreferenceSerializationException::class)
override fun deserialize(value: java.util.Set<java.lang.String>?): java.util.Set<AbstractAppInfo>? {
return value?.map(java.lang.String::toString)?.map(AbstractAppInfo::deserialize)
?.toHashSet() as? java.util.Set<AbstractAppInfo>
}
}
@Suppress("UNCHECKED_CAST")
class SetPinnedShortcutInfoPreferenceSerializer :
PreferenceSerializer<java.util.Set<PinnedShortcutInfo>?, java.util.Set<java.lang.String>?> {
@Throws(PreferenceSerializationException::class)
override fun serialize(value: java.util.Set<PinnedShortcutInfo>?): java.util.Set<java.lang.String> {
return value?.map { Json.encodeToString<PinnedShortcutInfo>(it) }
?.toHashSet() as java.util.Set<java.lang.String>
}
@Throws(PreferenceSerializationException::class)
override fun deserialize(value: java.util.Set<java.lang.String>?): java.util.Set<PinnedShortcutInfo>? {
return value?.map(java.lang.String::toString)
?.map { Json.decodeFromString<PinnedShortcutInfo>(it) }
?.toHashSet() as? java.util.Set<PinnedShortcutInfo>
}
}
@Suppress("UNCHECKED_CAST")
class MapAbstractAppInfoStringPreferenceSerializer :
PreferenceSerializer<java.util.HashMap<AbstractAppInfo, String>?, java.util.Set<java.lang.String>?> {
@Serializable
private class MapEntry(val key: AbstractAppInfo, val value: String)
@Throws(PreferenceSerializationException::class)
override fun serialize(value: java.util.HashMap<AbstractAppInfo, String>?): java.util.Set<java.lang.String>? {
return value?.map { (key, value) ->
Json.encodeToString(MapEntry(key, value))
}?.toHashSet() as? java.util.Set<java.lang.String>
}
@Throws(PreferenceSerializationException::class)
override fun deserialize(value: java.util.Set<java.lang.String>?): java.util.HashMap<AbstractAppInfo, String>? {
return value?.associateTo(HashMap()) {
val entry = Json.decodeFromString<MapEntry>(it.toString())
Pair(entry.key, entry.value)
}
}
}

View file

@ -0,0 +1,64 @@
package de.jrpie.android.launcher.preferences.theme
import android.content.res.Resources
import android.os.Build
import android.view.Window
import android.view.WindowManager
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.preferences.LauncherPreferences
@Suppress("unused")
enum class Background(val id: Int, val dim: Boolean = false, val blur: Boolean = false) {
TRANSPARENT(R.style.backgroundWallpaper),
DIM(R.style.backgroundWallpaper, dim = true),
BLUR(R.style.backgroundWallpaper, dim = true, blur = true),
SOLID(R.style.backgroundSolid),
;
fun applyToTheme(theme: Resources.Theme) {
var background = this
// force a solid background when using the light theme
if (LauncherPreferences.theme().colorTheme() == ColorTheme.LIGHT) {
background = SOLID
}
theme.applyStyle(background.id, true)
}
fun applyToWindow(window: Window) {
val layoutParams: WindowManager.LayoutParams = window.attributes
// TODO: add a setting to change this?
var dimAmount = 0.7f
val dim = this.dim
var blur = this.blur
// replace blur by more intense dim on old devices
if (blur && Build.VERSION.SDK_INT < Build.VERSION_CODES.S) {
blur = false
dimAmount += 0.1f
}
if (LauncherPreferences.theme().colorTheme() == ColorTheme.LIGHT) {
dimAmount = 0f
}
if (dim) {
layoutParams.dimAmount = dimAmount
window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
} else {
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
if (blur) {
window.addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND)
layoutParams.blurBehindRadius = 10
} else {
window.clearFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND)
layoutParams.blurBehindRadius = 0
}
}
window.attributes = layoutParams
}
}

View file

@ -0,0 +1,48 @@
package de.jrpie.android.launcher.preferences.theme
import android.content.Context
import android.content.res.Resources
import com.google.android.material.color.DynamicColors
import de.jrpie.android.launcher.R
enum class ColorTheme(
private val id: Int,
private val labelResource: Int,
private val shadowId: Int,
val isAvailable: () -> Boolean
) {
DEFAULT(
R.style.colorThemeDefault,
R.string.settings_theme_color_theme_item_default,
R.style.textShadow,
{ true }),
DARK(
R.style.colorThemeDark,
R.string.settings_theme_color_theme_item_dark,
R.style.textShadow,
{ true }),
LIGHT(
R.style.colorThemeLight,
R.string.settings_theme_color_theme_item_light,
R.style.textShadowLight,
{ true }),
DYNAMIC(
R.style.colorThemeDynamic,
R.string.settings_theme_color_theme_item_dynamic,
R.style.textShadow,
{ DynamicColors.isDynamicColorAvailable() }),
;
fun applyToTheme(theme: Resources.Theme, shadow: Boolean) {
val colorTheme = if (this.isAvailable()) this else DEFAULT
theme.applyStyle(colorTheme.id, true)
if (shadow) {
theme.applyStyle(colorTheme.shadowId, true)
}
}
fun getLabel(context: Context): String {
return context.getString(labelResource)
}
}

View file

@ -0,0 +1,23 @@
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
*/
@Suppress("unused")
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) {
theme.applyStyle(id, true)
}
}

View file

@ -1,111 +0,0 @@
package de.jrpie.android.launcher.settings
import android.content.Context
import android.content.Intent
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 de.jrpie.android.launcher.settings.actions.SettingsFragmentActions
import de.jrpie.android.launcher.settings.launcher.SettingsFragmentLauncher
import de.jrpie.android.launcher.settings.meta.SettingsFragmentMeta
var intendedSettingsPause = false // know when to close
/**
* The [SettingsActivity] is a tabbed activity:
*
* | Actions | Choose apps or intents to be launched | [SettingsFragmentActions] |
* | Theme | Select a theme / Customize | [SettingsFragmentLauncher] |
* | Meta | About Launcher / Contact etc. | [SettingsFragmentMeta] |
*
* Settings are closed automatically if the activity goes `onPause` unexpectedly.
*/
class SettingsActivity: AppCompatActivity(), UIObject {
private lateinit var binding: SettingsBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Initialise layout
binding = SettingsBinding.inflate(layoutInflater)
setContentView(binding.root)
// set up tabs and swiping in settings
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)
}
override fun onStart() {
super<AppCompatActivity>.onStart()
super<UIObject>.onStart()
}
override fun onResume() {
super.onResume()
intendedSettingsPause = false
}
override fun onPause() {
super.onPause()
if (!intendedSettingsPause) finish()
}
override fun applyTheme() {
//settings_system.setTextColor(vibrantColor)
//settings_close.setTextColor(vibrantColor)
binding.settingsTabs.setSelectedTabIndicatorColor(vibrantColor)
}
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)
binding.settingsSystem.setOnClickListener {
intendedSettingsPause = true
startActivity(Intent(Settings.ACTION_SETTINGS))
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
when (requestCode) {
REQUEST_CHOOSE_APP -> saveListActivityChoice(this, data)
else -> super.onActivityResult(requestCode, resultCode, data)
}
}
}
private val TAB_TITLES = arrayOf(
R.string.settings_tab_app,
R.string.settings_tab_launcher,
R.string.settings_tab_meta
)
class SettingsSectionsPagerAdapter(private val context: Context, fm: FragmentManager)
: FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
override fun getItem(position: Int): Fragment {
return when (position){
0 -> SettingsFragmentActions()
1 -> SettingsFragmentLauncher()
2 -> SettingsFragmentMeta()
else -> Fragment()
}
}
override fun getPageTitle(position: Int): CharSequence {
return context.resources.getString(TAB_TITLES[position])
}
override fun getCount(): Int { return 3 }
}

View file

@ -1,84 +0,0 @@
package de.jrpie.android.launcher.settings.actions
import android.content.ActivityNotFoundException
import android.content.Intent
import android.content.SharedPreferences
import android.content.SharedPreferences.OnSharedPreferenceChangeListener
import android.net.Uri
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.fragment.app.Fragment
import de.jrpie.android.launcher.*
import de.jrpie.android.launcher.databinding.SettingsActionsBinding
import de.jrpie.android.launcher.list.ListActivity
import de.jrpie.android.launcher.settings.intendedSettingsPause
/**
* The [SettingsFragmentActions] is a used as a tab in the SettingsActivity.
*
* It is used to change Apps / Intents to be launched when a specific action
* is triggered.
* It also allows the user to view all apps ([ListActivity]) or install new ones.
*/
class SettingsFragmentActions : Fragment(), UIObject {
private var binding: SettingsActionsBinding? = null
private val sharedPreferencesListener =
OnSharedPreferenceChangeListener { _, _ ->
binding?.let { it.settingsActionsRviewFragment.getFragment<SettingsFragmentActionsRecycler>().actionViewAdapter?.updateActions() }
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
getPreferences(requireContext()).registerOnSharedPreferenceChangeListener(sharedPreferencesListener)
binding = SettingsActionsBinding.inflate(inflater, container, false)
return binding!!.root
}
override fun onStart() {
super<Fragment>.onStart()
super<UIObject>.onStart()
}
override fun applyTheme() {
setButtonColor(binding!!.settingsActionsButtonViewApps, vibrantColor)
setButtonColor(binding!!.settingsActionsButtonInstallApps, vibrantColor)
}
override fun setOnClicks() {
// App management buttons
binding!!.settingsActionsButtonViewApps.setOnClickListener{
val intent = Intent(this.context, ListActivity::class.java)
intent.putExtra("intention", ListActivity.ListActivityIntention.VIEW.toString())
intendedSettingsPause = true
startActivity(intent)
}
binding!!.settingsActionsButtonInstallApps.setOnClickListener{
try {
val rateIntent = Intent(
Intent.ACTION_VIEW,
Uri.parse("https://play.google.com/store/apps/"))
intendedSettingsPause = true
startActivity(rateIntent)
} catch (e: ActivityNotFoundException) {
Toast.makeText(this.context, getString(R.string.settings_apps_toast_store_not_found), Toast.LENGTH_SHORT)
.show()
}
}
}
override fun onDestroy() {
super.onDestroy()
getPreferences(requireContext()).unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener)
}
}

View file

@ -1,152 +0,0 @@
package de.jrpie.android.launcher.settings.actions
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.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import de.jrpie.android.launcher.list.other.LauncherAction
import de.jrpie.android.launcher.settings.intendedSettingsPause
import de.jrpie.android.launcher.databinding.SettingsActionsRecyclerBinding
import java.lang.Exception
/**
* The [SettingsFragmentActionsRecycler] is a fragment containing the [ActionsRecyclerAdapter],
* which displays all selected actions / apps.
*
* It is used in the Tutorial and in Settings
*/
class SettingsFragmentActionsRecycler : Fragment(), UIObject {
private lateinit var binding: SettingsActionsRecyclerBinding
public var actionViewAdapter: ActionsRecyclerAdapter? = null
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = SettingsActionsRecyclerBinding.inflate(inflater, container, false)
return binding.root
}
override fun onStart() {
super<Fragment>.onStart()
// set up the list / recycler
val actionViewManager = LinearLayoutManager(context)
actionViewAdapter = ActionsRecyclerAdapter( requireActivity() )
binding.settingsActionsRview.apply {
// improve performance (since content changes don't change the layout size)
setHasFixedSize(true)
layoutManager = actionViewManager
adapter = actionViewAdapter
}
super<UIObject>.onStart()
}
}
class ActionsRecyclerAdapter(val activity: Activity):
RecyclerView.Adapter<ActionsRecyclerAdapter.ViewHolder>() {
private val gesturesList: ArrayList<Gesture>
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView),
View.OnClickListener {
var textView: TextView = itemView.findViewById(R.id.settings_actions_row_name)
var img: ImageView = itemView.findViewById(R.id.settings_actions_row_icon_img)
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) { }
init { itemView.setOnClickListener(this) }
}
override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) {
val gesture = gesturesList[i]
viewHolder.textView.text = gesture.getLabel(activity)
setButtonColor(viewHolder.chooseButton, vibrantColor)
if (getSavedTheme(activity) == "dark") transformGrayscale(
viewHolder.img
)
fun updateViewHolder() {
val app = gesture.getApp(activity)
val content = app.first
if (content == ""){
viewHolder.img.visibility = View.INVISIBLE
viewHolder.removeAction.visibility = View.GONE
viewHolder.chooseButton.visibility = View.VISIBLE
}
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) {
// 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
}
}
}
updateViewHolder()
viewHolder.img.setOnClickListener{ chooseApp(gesture) }
viewHolder.chooseButton.setOnClickListener{ chooseApp(gesture) }
viewHolder.removeAction.setOnClickListener{
gesture.removeApp(activity)
updateViewHolder()
}
}
override fun getItemCount(): Int { return gesturesList.size }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val inflater = LayoutInflater.from(parent.context)
val view: View = inflater.inflate(R.layout.settings_actions_row, parent, false)
return ViewHolder(view)
}
init {
val doubleActions = getPreferences(activity).getBoolean(PREF_DOUBLE_ACTIONS_ENABLED, false)
val edgeActions = getPreferences(activity).getBoolean(PREF_EDGE_ACTIONS_ENABLED, false)
gesturesList = Gesture.values().filter {
(doubleActions || !it.isDoubleVariant())
&& (edgeActions || !it.isEdgeVariant())} as ArrayList<Gesture>
}
public fun updateActions() {
val doubleActions = getPreferences(activity).getBoolean(PREF_DOUBLE_ACTIONS_ENABLED, false)
val edgeActions = getPreferences(activity).getBoolean(PREF_EDGE_ACTIONS_ENABLED, false)
this.gesturesList.clear()
gesturesList.addAll(Gesture.values().filter {
(doubleActions || !it.isDoubleVariant())
&& (edgeActions || !it.isEdgeVariant())})
notifyDataSetChanged()
}
/* */
private fun chooseApp(gesture: Gesture) {
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
intendedSettingsPause = true
activity.startActivityForResult(intent,
REQUEST_CHOOSE_APP
)
}
}

View file

@ -1,178 +0,0 @@
package de.jrpie.android.launcher.settings.launcher
import android.content.Intent
import android.graphics.PorterDuff
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.AdapterView
import android.widget.ArrayAdapter
import android.widget.SeekBar
import android.widget.Switch
import androidx.fragment.app.Fragment
import de.jrpie.android.launcher.PREF_DATE_FORMAT
import de.jrpie.android.launcher.PREF_DOUBLE_ACTIONS_ENABLED
import de.jrpie.android.launcher.PREF_EDGE_ACTIONS_ENABLED
import de.jrpie.android.launcher.PREF_SCREEN_FULLSCREEN
import de.jrpie.android.launcher.PREF_SCREEN_TIMEOUT_DISABLED
import de.jrpie.android.launcher.PREF_SEARCH_AUTO_KEYBOARD
import de.jrpie.android.launcher.PREF_SEARCH_AUTO_LAUNCH
import de.jrpie.android.launcher.PREF_SLIDE_SENSITIVITY
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.UIObject
import de.jrpie.android.launcher.getPreferences
import de.jrpie.android.launcher.getSavedTheme
import de.jrpie.android.launcher.resetToDarkTheme
import de.jrpie.android.launcher.resetToDefaultTheme
import de.jrpie.android.launcher.setButtonColor
import de.jrpie.android.launcher.setSwitchColor
import de.jrpie.android.launcher.setWindowFlags
import de.jrpie.android.launcher.settings.intendedSettingsPause
import de.jrpie.android.launcher.vibrantColor
import de.jrpie.android.launcher.databinding.SettingsLauncherBinding
import de.jrpie.android.launcher.setDefaultHomeScreen
/**
* The [SettingsFragmentLauncher] is a used as a tab in the SettingsActivity.
*
* It is used to change themes, select wallpapers ... theme related stuff
*/
class SettingsFragmentLauncher : Fragment(), UIObject {
private lateinit var binding: SettingsLauncherBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = SettingsLauncherBinding.inflate(inflater, container, false)
return binding.root
}
override fun onStart(){
super<Fragment>.onStart()
super<UIObject>.onStart()
}
override fun applyTheme() {
setButtonColor(binding.settingsLauncherButtonChooseHomescreen, vibrantColor)
setSwitchColor(binding.settingsLauncherSwitchScreenTimeout, vibrantColor)
setSwitchColor(binding.settingsLauncherSwitchScreenFull, vibrantColor)
setSwitchColor(binding.settingsLauncherSwitchAutoLaunch, vibrantColor)
setSwitchColor(binding.settingsLauncherSwitchAutoKeyboard, vibrantColor)
setSwitchColor(binding.settingsLauncherSwitchEnableDouble, vibrantColor)
setSwitchColor(binding.settingsLauncherSwitchEnableEdge, vibrantColor)
setButtonColor(binding.settingsLauncherButtonChooseWallpaper, vibrantColor)
binding.settingsSeekbarSensitivity.progressDrawable.setColorFilter(vibrantColor, PorterDuff.Mode.SRC_IN)
}
override fun setOnClicks() {
val preferences = getPreferences(requireActivity())
fun bindSwitchToPref(switch: Switch, pref: String, default: Boolean, onChange: (Boolean) -> Unit){
switch.isChecked = preferences.getBoolean(pref, default)
switch.setOnCheckedChangeListener { _, isChecked -> // Toggle double actions
preferences.edit()
.putBoolean(pref, isChecked)
.apply()
onChange(isChecked);
}
}
binding.settingsLauncherButtonChooseHomescreen.setOnClickListener {
setDefaultHomeScreen(requireContext(), checkDefault = false)
}
binding.settingsLauncherButtonChooseWallpaper.setOnClickListener {
// 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)
//.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
.putExtra("com.android.wallpaper.LAUNCH_SOURCE", "app_launched_launcher")
.putExtra("com.android.launcher3.WALLPAPER_FLAVOR", "focus_wallpaper")
startActivity(intent)
}
bindSwitchToPref(binding.settingsLauncherSwitchScreenTimeout, PREF_SCREEN_TIMEOUT_DISABLED, false) {
activity?.let{setWindowFlags(it.window)}
}
bindSwitchToPref(binding.settingsLauncherSwitchScreenFull, PREF_SCREEN_FULLSCREEN, true) {
activity?.let{setWindowFlags(it.window)}
}
bindSwitchToPref(binding.settingsLauncherSwitchAutoLaunch, PREF_SEARCH_AUTO_LAUNCH, false) {}
bindSwitchToPref(binding.settingsLauncherSwitchAutoKeyboard, PREF_SEARCH_AUTO_KEYBOARD, true) {}
bindSwitchToPref(binding.settingsLauncherSwitchEnableDouble, PREF_DOUBLE_ACTIONS_ENABLED, false) {}
bindSwitchToPref(binding.settingsLauncherSwitchEnableEdge, PREF_EDGE_ACTIONS_ENABLED, false) {}
binding.settingsSeekbarSensitivity.setOnSeekBarChangeListener(
object : SeekBar.OnSeekBarChangeListener {
override fun onProgressChanged(p0: SeekBar?, p1: Int, p2: Boolean) {}
override fun onStartTrackingTouch(p0: SeekBar?) {}
override fun onStopTrackingTouch(p0: SeekBar?) {
preferences.edit()
.putInt(PREF_SLIDE_SENSITIVITY, p0!!.progress * 100 / 4) // scale to %
.apply()
}
}
)
}
override fun adjustLayout() {
val preferences = getPreferences(requireActivity())
// Load values into the date-format spinner
val staticAdapter = ArrayAdapter.createFromResource(
requireActivity(), R.array.settings_launcher_time_format_spinner_items,
android.R.layout.simple_spinner_item )
staticAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
binding.settingsLauncherFormatSpinner.adapter = staticAdapter
binding.settingsLauncherFormatSpinner.setSelection(preferences.getInt(PREF_DATE_FORMAT, 0))
binding.settingsLauncherFormatSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
preferences.edit()
.putInt(PREF_DATE_FORMAT, position)
.apply()
}
override fun onNothingSelected(parent: AdapterView<*>?) { }
}
// Load values into the theme spinner
val staticThemeAdapter = ArrayAdapter.createFromResource(
requireActivity(), R.array.settings_launcher_theme_spinner_items,
android.R.layout.simple_spinner_item )
staticThemeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item)
binding.settingsLauncherThemeSpinner.adapter = staticThemeAdapter
val themeInt = when (getSavedTheme(requireActivity())) {
"finn" -> 0
"dark" -> 1
else -> 0
}
binding.settingsLauncherThemeSpinner.setSelection(themeInt)
binding.settingsLauncherThemeSpinner.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
override fun onItemSelected(parent: AdapterView<*>, view: View, position: Int, id: Long) {
when (position) {
0 -> if (getSavedTheme(activity!!) != "finn") resetToDefaultTheme(activity!!)
1 -> if (getSavedTheme(activity!!) != "dark") resetToDarkTheme(activity!!)
}
}
override fun onNothingSelected(parent: AdapterView<*>?) { }
}
binding.settingsSeekbarSensitivity.progress = preferences.getInt(PREF_SLIDE_SENSITIVITY, 2) * 4 / 100
}
}

View file

@ -1,139 +0,0 @@
package de.jrpie.android.launcher.settings.meta
import android.app.AlertDialog
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.provider.Settings
import android.view.LayoutInflater
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.resetSettings
import de.jrpie.android.launcher.setButtonColor
import de.jrpie.android.launcher.settings.intendedSettingsPause
import de.jrpie.android.launcher.tutorial.TutorialActivity
import de.jrpie.android.launcher.vibrantColor
import de.jrpie.android.launcher.databinding.SettingsMetaBinding
/**
* The [SettingsFragmentMeta] is a used as a tab in the SettingsActivity.
*
* It is used to change settings and access resources about Launcher,
* that are not directly related to the behaviour of the app itself.
*
* (greek `meta` = above, next level)
*/
class SettingsFragmentMeta : Fragment(), UIObject {
private lateinit var binding: SettingsMetaBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = SettingsMetaBinding.inflate(inflater, container, false)
return binding.root
}
override fun onStart() {
super<Fragment>.onStart()
super<UIObject>.onStart()
}
// Rate App
// Just copied code from https://stackoverflow.com/q/10816757/12787264
// that is how we write good software ^^
private fun rateIntentForUrl(url: String): Intent {
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse(String.format("%s?id=%s", url, this.context!!.packageName))
)
var flags = Intent.FLAG_ACTIVITY_NO_HISTORY or Intent.FLAG_ACTIVITY_MULTIPLE_TASK
flags = flags or Intent.FLAG_ACTIVITY_NEW_DOCUMENT
intent.addFlags(flags)
return intent
}
override fun applyTheme() {
setButtonColor(binding.settingsMetaButtonSelectLauncher, vibrantColor)
setButtonColor(binding.settingsMetaButtonViewTutorial, vibrantColor)
setButtonColor(binding.settingsMetaButtonResetSettings, vibrantColor)
setButtonColor(binding.settingsMetaButtonReportBug, vibrantColor)
setButtonColor(binding.settingsMetaButtonContact, vibrantColor)
setButtonColor(binding.settingsMetaButtonForkContact, vibrantColor)
setButtonColor(binding.settingsMetaButtonPrivacy, vibrantColor)
}
override fun setOnClicks() {
binding.settingsMetaButtonSelectLauncher.setOnClickListener {
intendedSettingsPause = true
val callHomeSettingIntent = Intent(Settings.ACTION_HOME_SETTINGS)
startActivity(callHomeSettingIntent)
}
binding.settingsMetaButtonViewTutorial.setOnClickListener {
intendedSettingsPause = true
startActivity(Intent(this.context, TutorialActivity::class.java))
}
// prompting for settings-reset confirmation
binding.settingsMetaButtonResetSettings.setOnClickListener {
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
) { _, _ ->
resetSettings(this.requireContext())
requireActivity().finish()
}
.setNegativeButton(android.R.string.cancel, null)
.setIcon(android.R.drawable.ic_dialog_alert)
.show()
}
// report a bug
binding.settingsMetaButtonReportBug.setOnClickListener {
intendedSettingsPause = true
openNewTabWindow(
getString(R.string.settings_meta_report_bug_link),
context!!
)
}
// contact developer
binding.settingsMetaButtonContact.setOnClickListener {
intendedSettingsPause = true
openNewTabWindow(
getString(R.string.settings_meta_contact_url),
context!!
)
}
// contact fork developer
binding.settingsMetaButtonForkContact.setOnClickListener {
intendedSettingsPause = true
openNewTabWindow(
getString(R.string.settings_meta_fork_contact_url),
context!!
)
}
// privacy policy
binding.settingsMetaButtonPrivacy.setOnClickListener {
intendedSettingsPause = true
openNewTabWindow(
getString(R.string.settings_meta_privacy_url),
context!!
)
}
}
}

View file

@ -1,98 +0,0 @@
package de.jrpie.android.launcher.tutorial
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
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.PREF_STARTED
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.getPreferences
import de.jrpie.android.launcher.loadSettings
import de.jrpie.android.launcher.resetSettings
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
/**
* The [TutorialActivity] is displayed automatically on new installations.
* It can also be opened from Settings.
*
* It tells the user about the concept behind launcher
* and helps with the setup process (on new installations)
*/
class TutorialActivity: AppCompatActivity(), UIObject {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// Initialise layout
setContentView(R.layout.tutorial)
val preferences = getPreferences(this)
// Check if the app was started before
if (!preferences.getBoolean(PREF_STARTED, false))
resetSettings(this)
loadSettings(this)
// set up tabs and swiping in settings
val sectionsPagerAdapter = TutorialSectionsPagerAdapter(supportFragmentManager)
val viewPager: ViewPager = findViewById(R.id.tutorial_viewpager)
viewPager.adapter = sectionsPagerAdapter
val tabs: TabLayout = findViewById(R.id.tutorial_tabs)
tabs.setupWithViewPager(viewPager)
}
override fun onStart() {
super<AppCompatActivity>.onStart()
super<UIObject>.onStart()
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
when (requestCode) {
REQUEST_CHOOSE_APP -> saveListActivityChoice(this,data)
else -> super.onActivityResult(requestCode, resultCode, data)
}
}
// Default: prevent going back, allow if viewed again later
override fun onBackPressed() {
if (getPreferences(this).getBoolean(PREF_STARTED, false))
super.onBackPressed()
}
}
/**
* The [TutorialSectionsPagerAdapter] defines which fragments are shown when,
* in the [TutorialActivity].
*
* Tabs: (Start | Concept | Usage | Setup | Finish)
*/
class TutorialSectionsPagerAdapter(fm: FragmentManager)
: FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) {
override fun getItem(position: Int): Fragment {
return when (position){
0 -> TutorialFragmentStart()
1 -> TutorialFragmentConcept()
2 -> TutorialFragmentUsage()
3 -> TutorialFragmentSetup()
4 -> TutorialFragmentFinish()
else -> Fragment()
}
}
/* We don't use titles here, as we have the dots */
override fun getPageTitle(position: Int): CharSequence { return "" }
override fun getCount(): Int { return 5 }
}

View file

@ -1,61 +0,0 @@
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 de.jrpie.android.launcher.*
import de.jrpie.android.launcher.BuildConfig.VERSION_NAME
import de.jrpie.android.launcher.databinding.TutorialFinishBinding
/**
* The [TutorialFragmentFinish] is a used as a tab in the TutorialActivity.
*
* It is used to display further resources and let the user start Launcher
*/
class TutorialFragmentFinish : Fragment(), UIObject {
private lateinit var binding: TutorialFinishBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = TutorialFinishBinding.inflate(inflater, container, false)
return binding.root
}
override fun onStart() {
super<Fragment>.onStart()
super<UIObject>.onStart()
}
override fun applyTheme() {
setButtonColor(binding.tutorialFinishButtonStart, vibrantColor)
binding.tutorialFinishButtonStart.blink()
}
override fun setOnClicks() {
super.setOnClicks()
binding.tutorialFinishButtonStart.setOnClickListener{ finishTutorial() }
}
private fun finishTutorial() {
context?.let { getPreferences(it) }?.let {
if (!it.getBoolean(PREF_STARTED, false)) {
it.edit()
.putBoolean(PREF_STARTED, true) // never auto run this again
.putLong(
PREF_STARTED_TIME,
System.currentTimeMillis() / 1000L
) // record first startup timestamp
.putString(PREF_VERSION, VERSION_NAME) // save current launcher version
.apply()
}
}
context?.let { setDefaultHomeScreen(it, checkDefault = true) }
activity?.finish()
}
}

View file

@ -1,38 +0,0 @@
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 de.jrpie.android.launcher.*
import de.jrpie.android.launcher.databinding.TutorialStartBinding
/**
* The [TutorialFragmentStart] is a used as a tab in the TutorialActivity.
*
* It displays info about the app and gets the user into the tutorial
*/
class TutorialFragmentStart : Fragment(), UIObject {
private lateinit var binding: TutorialStartBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
binding = TutorialStartBinding.inflate(inflater, container, false)
return binding.root
}
override fun onStart(){
super<Fragment>.onStart()
super<UIObject>.onStart()
}
override fun applyTheme() {
binding.tutorialStartIconRight.setTextColor(vibrantColor)
binding.tutorialStartIconRight.blink()
}
}

View file

@ -0,0 +1,47 @@
package de.jrpie.android.launcher.ui
import android.content.Context
import android.graphics.ColorMatrix
import android.graphics.ColorMatrixColorFilter
import android.view.View
import android.view.animation.AlphaAnimation
import android.view.animation.Animation
import android.view.inputmethod.InputMethodManager
import android.widget.ImageView
// Taken from https://stackoverflow.com/questions/47293269
fun View.blink(
times: Int = Animation.INFINITE,
duration: Long = 1000L,
offset: Long = 20L,
minAlpha: Float = 0.2f,
maxAlpha: Float = 1.0f,
repeatMode: Int = Animation.REVERSE
) {
startAnimation(AlphaAnimation(minAlpha, maxAlpha).also {
it.duration = duration
it.startOffset = offset
it.repeatMode = repeatMode
it.repeatCount = times
})
}
// Taken from: https://stackoverflow.com/a/30340794/12787264
fun ImageView.transformGrayscale(grayscale: Boolean) {
this.colorFilter = if (grayscale) {
ColorMatrixColorFilter(ColorMatrix().apply {
setSaturation(0f)
})
} else {
null
}
}
// Taken from https://stackoverflow.com/a/50743764/12787264
fun View.openSoftKeyboard(context: Context) {
this.requestFocus()
// open the soft keyboard
val imm = context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
imm.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT)
}

View file

@ -0,0 +1,267 @@
package de.jrpie.android.launcher.ui
import android.annotation.SuppressLint
import android.content.SharedPreferences
import android.content.res.Configuration
import android.content.res.Resources
import android.os.Build
import android.os.Bundle
import android.view.KeyEvent
import android.view.MotionEvent
import android.view.View
import android.window.OnBackInvokedDispatcher
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.isVisible
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.actions.Action
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.openTutorial
import de.jrpie.android.launcher.preferences.LauncherPreferences
import de.jrpie.android.launcher.ui.tutorial.TutorialActivity
import java.util.Locale
/**
* [HomeActivity] is the actual application Launcher,
* what makes this application special / unique.
*
* In this activity we display the date and time,
* and we listen for actions like tapping, swiping or button presses.
*
* As it also is the first thing that is started when someone opens Launcher,
* it also contains some logic related to the overall application:
* - Setting global variables (preferences etc.)
* - Opening the [TutorialActivity] on new installations
*/
class HomeActivity : UIObject, AppCompatActivity() {
private lateinit var binding: HomeBinding
private var touchGestureDetector: TouchGestureDetector? = null
private var sharedPreferencesListener =
SharedPreferences.OnSharedPreferenceChangeListener { _, prefKey ->
if (prefKey?.startsWith("clock.") == true ||
prefKey?.startsWith("display.") == true
) {
recreate()
}
if (prefKey?.startsWith("action.") == true) {
updateSettingsFallbackButtonVisibility()
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super<AppCompatActivity>.onCreate(savedInstanceState)
super<UIObject>.onCreate()
// Initialise layout
binding = HomeBinding.inflate(layoutInflater)
setContentView(binding.root)
// Handle back key / gesture on Android 13+, cf. onKeyDown()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
onBackInvokedDispatcher.registerOnBackInvokedCallback(
OnBackInvokedDispatcher.PRIORITY_OVERLAY
) {
handleBack()
}
}
binding.buttonFallbackSettings.setOnClickListener {
LauncherAction.SETTINGS.invoke(this)
}
}
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
touchGestureDetector?.updateScreenSize(windowManager)
}
override fun onStart() {
super<AppCompatActivity>.onStart()
super<UIObject>.onStart()
// If the tutorial was not finished, start it
if (!LauncherPreferences.internal().started()) {
openTutorial(this)
}
LauncherPreferences.getSharedPreferences()
.registerOnSharedPreferenceChangeListener(sharedPreferencesListener)
}
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
if (hasFocus && LauncherPreferences.display().hideNavigationBar()) {
hideNavigationBar()
}
}
private fun updateSettingsFallbackButtonVisibility() {
// If µLauncher settings can not be reached from any action bound to an enabled gesture,
// show the fallback button.
binding.buttonFallbackSettings.visibility = if (
!Gesture.entries.any { g ->
g.isEnabled() && Action.forGesture(g)?.canReachSettings() == true
}
) {
View.VISIBLE
} else {
View.GONE
}
}
private fun initClock() {
val locale = Locale.getDefault()
val dateVisible = LauncherPreferences.clock().dateVisible()
val timeVisible = LauncherPreferences.clock().timeVisible()
var dateFMT = "yyyy-MM-dd"
var timeFMT = "HH:mm"
if (LauncherPreferences.clock().showSeconds()) {
timeFMT += ":ss"
}
if (LauncherPreferences.clock().localized()) {
dateFMT = android.text.format.DateFormat.getBestDateTimePattern(locale, dateFMT)
timeFMT = android.text.format.DateFormat.getBestDateTimePattern(locale, timeFMT)
}
var upperFormat = dateFMT
var lowerFormat = timeFMT
var upperVisible = dateVisible
var lowerVisible = timeVisible
if (LauncherPreferences.clock().flipDateTime()) {
upperFormat = lowerFormat.also { lowerFormat = upperFormat }
upperVisible = lowerVisible.also { lowerVisible = upperVisible }
}
binding.homeUpperView.isVisible = upperVisible
binding.homeLowerView.isVisible = lowerVisible
binding.homeUpperView.setTextColor(LauncherPreferences.clock().color())
binding.homeLowerView.setTextColor(LauncherPreferences.clock().color())
binding.homeLowerView.format24Hour = lowerFormat
binding.homeUpperView.format24Hour = upperFormat
binding.homeLowerView.format12Hour = lowerFormat
binding.homeUpperView.format12Hour = upperFormat
}
override fun getTheme(): Resources.Theme {
val mTheme = modifyTheme(super.getTheme())
mTheme.applyStyle(R.style.backgroundWallpaper, true)
LauncherPreferences.clock().font().applyToTheme(mTheme)
LauncherPreferences.theme().colorTheme().applyToTheme(
mTheme,
LauncherPreferences.theme().textShadow()
)
return mTheme
}
override fun onResume() {
super.onResume()
/* This should be initialized in onCreate()
However on some devices there seems to be a bug where the touchGestureDetector
is not working properly after resuming the app.
Reinitializing the touchGestureDetector every time the app is resumed might help to fix that.
(see issue #138)
*/
touchGestureDetector = TouchGestureDetector(
this, 0, 0,
LauncherPreferences.enabled_gestures().edgeSwipeEdgeWidth() / 100f
).also {
it.updateScreenSize(windowManager)
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
binding.root.setOnApplyWindowInsetsListener { _, windowInsets ->
@Suppress("deprecation") // required to support API 29
val insets = windowInsets.systemGestureInsets
touchGestureDetector?.setSystemGestureInsets(insets)
windowInsets
}
}
initClock()
updateSettingsFallbackButtonVisibility()
}
override fun onDestroy() {
LauncherPreferences.getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener)
super.onDestroy()
}
@SuppressLint("GestureBackNavigation")
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
when (keyCode) {
KeyEvent.KEYCODE_BACK -> {
// Only used pre Android 13, cf. onBackInvokedDispatcher
handleBack()
}
KeyEvent.KEYCODE_VOLUME_UP -> {
if (Action.forGesture(Gesture.VOLUME_UP) == LauncherAction.VOLUME_UP) {
// Let the OS handle the key event. This works better with some custom ROMs
// and apps like Samsung Sound Assistant.
return false
}
Gesture.VOLUME_UP(this)
}
KeyEvent.KEYCODE_VOLUME_DOWN -> {
if (Action.forGesture(Gesture.VOLUME_DOWN) == LauncherAction.VOLUME_DOWN) {
// see above
return false
}
Gesture.VOLUME_DOWN(this)
}
}
return true
}
override fun onTouchEvent(event: MotionEvent): Boolean {
touchGestureDetector?.onTouchEvent(event)
return true
}
override fun setOnClicks() {
binding.homeUpperView.setOnClickListener {
if (LauncherPreferences.clock().flipDateTime()) {
Gesture.TIME(this)
} else {
Gesture.DATE(this)
}
}
binding.homeLowerView.setOnClickListener {
if (LauncherPreferences.clock().flipDateTime()) {
Gesture.DATE(this)
} else {
Gesture.TIME(this)
}
}
}
private fun handleBack() {
Gesture.BACK(this)
}
override fun isHomeScreen(): Boolean {
return true
}
}

View file

@ -0,0 +1,46 @@
package de.jrpie.android.launcher.ui
import android.content.res.Resources
import android.os.Bundle
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.databinding.LegalInfoBinding
class LegalInfoActivity : AppCompatActivity(), UIObject {
private lateinit var binding: LegalInfoBinding
override fun onCreate(savedInstanceState: Bundle?) {
super<AppCompatActivity>.onCreate(savedInstanceState)
super<UIObject>.onCreate()
// Initialise layout
binding = LegalInfoBinding.inflate(layoutInflater)
setContentView(binding.root)
setTitle(R.string.legal_info_title)
setSupportActionBar(binding.legalInfoAppbar)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
}
override fun onStart() {
super<AppCompatActivity>.onStart()
super<UIObject>.onStart()
}
override fun getTheme(): Resources.Theme {
return modifyTheme(super.getTheme())
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
android.R.id.home -> {
finish()
return true
}
else -> {
return super.onOptionsItemSelected(item)
}
}
}
}

View file

@ -0,0 +1,154 @@
package de.jrpie.android.launcher.ui
import android.app.AlertDialog
import android.app.Service
import android.content.Context
import android.content.pm.LauncherApps
import android.content.pm.LauncherApps.PinItemRequest
import android.content.res.Resources
import android.os.Build
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.actions.Action
import de.jrpie.android.launcher.actions.Gesture
import de.jrpie.android.launcher.actions.ShortcutAction
import de.jrpie.android.launcher.apps.PinnedShortcutInfo
import de.jrpie.android.launcher.databinding.ActivityPinShortcutBinding
import de.jrpie.android.launcher.preferences.LauncherPreferences
import androidx.core.content.edit
class PinShortcutActivity : AppCompatActivity(), UIObject {
private lateinit var binding: ActivityPinShortcutBinding
private var isBound = false
private var request: PinItemRequest? = null
override fun onCreate(savedInstanceState: Bundle?) {
super<AppCompatActivity>.onCreate(savedInstanceState)
super<UIObject>.onCreate()
enableEdgeToEdge()
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
finish()
return
}
binding = ActivityPinShortcutBinding.inflate(layoutInflater)
setContentView(binding.root)
val launcherApps = getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps
val request = launcherApps.getPinItemRequest(intent)
this.request = request
if (request == null || request.requestType != PinItemRequest.REQUEST_TYPE_SHORTCUT) {
finish()
return
}
binding.pinShortcutLabel.text = request.shortcutInfo!!.shortLabel ?: "?"
binding.pinShortcutLabel.setCompoundDrawables(
launcherApps.getShortcutBadgedIconDrawable(request.shortcutInfo, 0).also {
val size = (40 * resources.displayMetrics.density).toInt()
it.setBounds(0,0, size, size)
}, null, null, null)
binding.pinShortcutButtonBind.setOnClickListener {
AlertDialog.Builder(this, R.style.AlertDialogCustom)
.setTitle(getString(R.string.pin_shortcut_button_bind))
.setView(R.layout.dialog_select_gesture)
.setNegativeButton(android.R.string.cancel, null)
.create().also { it.show() }.let { dialog ->
val viewManager = LinearLayoutManager(dialog.context)
val viewAdapter = GestureRecyclerAdapter (dialog.context) { gesture ->
if (!isBound) {
isBound = true
request.accept()
}
LauncherPreferences.getSharedPreferences().edit {
ShortcutAction(PinnedShortcutInfo(request.shortcutInfo!!)).bindToGesture(
this,
gesture.id
)
}
dialog.dismiss()
}
dialog.findViewById<RecyclerView>(R.id.dialog_select_gesture_recycler).apply {
setHasFixedSize(true)
layoutManager = viewManager
adapter = viewAdapter
}
}
}
binding.pinShortcutClose.setOnClickListener { finish() }
binding.pinShortcutButtonOk.setOnClickListener { finish() }
}
override fun onStart() {
super<AppCompatActivity>.onStart()
super<UIObject>.onStart()
}
override fun onDestroy() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
super.onDestroy()
return
}
if(binding.pinShortcutSwitchVisible.isChecked) {
if(!isBound) {
request?.accept()
}
request?.shortcutInfo?.let {
val set = LauncherPreferences.apps().pinnedShortcuts() ?: mutableSetOf()
set.add(PinnedShortcutInfo(it))
LauncherPreferences.apps().pinnedShortcuts(set)
}
}
super.onDestroy()
}
override fun getTheme(): Resources.Theme {
return modifyTheme(super.getTheme())
}
inner class GestureRecyclerAdapter(val context: Context, val onClick: (Gesture) -> Unit): RecyclerView.Adapter<GestureRecyclerAdapter.ViewHolder>() {
private val gestures = Gesture.entries.filter { it.isEnabled() }.toList()
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val label: TextView = itemView.findViewById(R.id.dialog_select_gesture_row_name)
val description: TextView = itemView.findViewById(R.id.dialog_select_gesture_row_description)
val icon: ImageView = itemView.findViewById(R.id.dialog_select_gesture_row_icon)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val inflater = LayoutInflater.from(parent.context)
val view: View = inflater.inflate(R.layout.dialog_select_gesture_row, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val gesture = gestures[position]
holder.label.text = gesture.getLabel(context)
holder.description.text = gesture.getDescription(context)
holder.icon.setImageDrawable(
Action.forGesture(gesture)?.getIcon(context)
)
holder.itemView.setOnClickListener {
onClick(gesture)
}
}
override fun getItemCount(): Int {
return gestures.size
}
}
}

View file

@ -0,0 +1,339 @@
package de.jrpie.android.launcher.ui
import android.content.Context
import android.graphics.Insets
import android.os.Build
import android.os.Handler
import android.os.Looper
import android.util.DisplayMetrics
import android.view.MotionEvent
import android.view.ViewConfiguration
import android.view.WindowManager
import androidx.annotation.RequiresApi
import de.jrpie.android.launcher.actions.Gesture
import de.jrpie.android.launcher.preferences.LauncherPreferences
import kotlin.math.abs
import kotlin.math.max
import kotlin.math.min
import kotlin.math.tan
class TouchGestureDetector(
private val context: Context,
var width: Int,
var height: Int,
var edgeWidth: Float
) {
private val ANGULAR_THRESHOLD = tan(Math.PI / 6)
private val TOUCH_SLOP: Int
private val TOUCH_SLOP_SQUARE: Int
private val DOUBLE_TAP_SLOP: Int
private val DOUBLE_TAP_SLOP_SQUARE: Int
private val LONG_PRESS_TIMEOUT: Int
private val TAP_TIMEOUT: Int
private val DOUBLE_TAP_TIMEOUT: Int
private val MIN_TRIANGLE_HEIGHT = 250
private val longPressHandler = Handler(Looper.getMainLooper())
private var systemGestureInsetTop = 100
private var systemGestureInsetBottom = 0
private var systemGestureInsetLeft = 0
private var systemGestureInsetRight = 0
data class Vector(val x: Float, val y: Float) {
fun absSquared(): Float {
return this.x * this.x + this.y * this.y
}
fun plus(vector: Vector): Vector {
return Vector(this.x + vector.x, this.y + vector.y)
}
fun max(other: Vector): Vector {
return Vector(max(this.x, other.x), max(this.y, other.y))
}
fun min(other: Vector): Vector {
return Vector(min(this.x, other.x), min(this.y, other.y))
}
operator fun minus(vector: Vector): Vector {
return Vector(this.x - vector.x, this.y - vector.y)
}
}
class PointerPath(
val number: Int,
val start: Vector,
var last: Vector = start
) {
var min = Vector(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY)
var max = Vector(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY)
fun sizeSquared(): Float {
return (max - min).absSquared()
}
fun getDirection(): Vector {
return last - start
}
fun update(vector: Vector) {
min = min.min(vector)
max = max.max(vector)
last = vector
}
}
private fun PointerPath.startIntersectsSystemGestureInsets(): Boolean {
// ignore x, since this makes edge swipes very hard to execute
return start.y < systemGestureInsetTop
|| start.y > height - systemGestureInsetBottom
}
private fun PointerPath.intersectsSystemGestureInsets(): Boolean {
return min.x < systemGestureInsetLeft
|| min.y < systemGestureInsetTop
|| max.x > width - systemGestureInsetRight
|| max.y > height - systemGestureInsetBottom
}
private fun PointerPath.isTap(): Boolean {
if (intersectsSystemGestureInsets()) {
return false
}
return sizeSquared() < TOUCH_SLOP_SQUARE
}
init {
val configuration = ViewConfiguration.get(context)
TOUCH_SLOP = configuration.scaledTouchSlop
TOUCH_SLOP_SQUARE = TOUCH_SLOP * TOUCH_SLOP
DOUBLE_TAP_SLOP = configuration.scaledDoubleTapSlop
DOUBLE_TAP_SLOP_SQUARE = DOUBLE_TAP_SLOP * DOUBLE_TAP_SLOP
LONG_PRESS_TIMEOUT = ViewConfiguration.getLongPressTimeout()
TAP_TIMEOUT = ViewConfiguration.getTapTimeout()
DOUBLE_TAP_TIMEOUT = ViewConfiguration.getDoubleTapTimeout()
}
private var paths = HashMap<Int, PointerPath>()
/* Set when
* - the longPressHandler has detected this gesture as a long press
* - the gesture was cancelled by MotionEvent.ACTION_CANCEL
* In any case, the current gesture should be ignored by further detection logic.
*/
private var cancelled = false
private var lastTappedTime = 0L
private var lastTappedLocation: Vector? = null
fun onTouchEvent(event: MotionEvent) {
if (event.actionMasked == MotionEvent.ACTION_CANCEL) {
synchronized(this@TouchGestureDetector) {
cancelled = true
}
}
val pointerIdToIndex =
(0..<event.pointerCount).associateBy { event.getPointerId(it) }
if (event.actionMasked == MotionEvent.ACTION_DOWN) {
synchronized(this@TouchGestureDetector) {
paths = HashMap()
cancelled = false
}
longPressHandler.postDelayed({
synchronized(this@TouchGestureDetector) {
if (cancelled) {
return@postDelayed
}
if (paths.entries.size == 1 && paths.entries.firstOrNull()?.value?.isTap() == true) {
cancelled = true
Gesture.LONG_CLICK.invoke(context)
}
}
}, LONG_PRESS_TIMEOUT.toLong())
}
// add new pointers
for (i in 0..<event.pointerCount) {
if (paths.containsKey(event.getPointerId(i))) {
continue
}
val index = pointerIdToIndex[i] ?: continue
paths[i] = PointerPath(
paths.entries.size,
Vector(event.getX(index), event.getY(index))
)
}
for (i in 0..<event.pointerCount) {
val index = pointerIdToIndex[i] ?: continue
for (j in 0..<event.historySize) {
paths[i]?.update(
Vector(
event.getHistoricalX(index, j),
event.getHistoricalY(index, j)
)
)
}
paths[i]?.update(Vector(event.getX(index), event.getY(index)))
}
if (event.actionMasked == MotionEvent.ACTION_UP) {
synchronized(this@TouchGestureDetector) {
// if the long press handler is still running, kill it
longPressHandler.removeCallbacksAndMessages(null)
// if the gesture was already detected as a long click, there is nothing to do
if (cancelled) {
return
}
}
classifyPaths(paths, event.downTime, event.eventTime)
}
return
}
private fun getGestureForDirection(direction: Vector): Gesture? {
return if (ANGULAR_THRESHOLD * abs(direction.x) > abs(direction.y)) { // horizontal swipe
if (direction.x > TOUCH_SLOP)
Gesture.SWIPE_RIGHT
else if (direction.x < -TOUCH_SLOP)
Gesture.SWIPE_LEFT
else null
} else if (ANGULAR_THRESHOLD * abs(direction.y) > abs(direction.x)) { // vertical swipe
if (direction.y < -TOUCH_SLOP)
Gesture.SWIPE_UP
else if (direction.y > TOUCH_SLOP)
Gesture.SWIPE_DOWN
else null
} else null
}
private fun classifyPaths(paths: Map<Int, PointerPath>, timeStart: Long, timeEnd: Long) {
val duration = timeEnd - timeStart
val pointerCount = paths.entries.size
if (paths.entries.isEmpty()) {
return
}
val mainPointerPath = paths.entries.firstOrNull { it.value.number == 0 }?.value ?: return
// Ignore swipes starting at the very top and the very bottom
if (paths.entries.any { it.value.startIntersectsSystemGestureInsets() }) {
return
}
if (pointerCount == 1 && mainPointerPath.isTap()) {
// detect taps
if (duration in 0..TAP_TIMEOUT) {
if (timeStart - lastTappedTime < DOUBLE_TAP_TIMEOUT &&
lastTappedLocation?.let {
(mainPointerPath.last - it).absSquared() < DOUBLE_TAP_SLOP_SQUARE
} == true
) {
Gesture.DOUBLE_CLICK.invoke(context)
} else {
lastTappedTime = timeEnd
lastTappedLocation = mainPointerPath.last
}
}
} else {
// detect swipes
val doubleActions = LauncherPreferences.enabled_gestures().doubleSwipe()
val edgeActions = LauncherPreferences.enabled_gestures().edgeSwipe()
var gesture = getGestureForDirection(mainPointerPath.getDirection())
if (doubleActions && pointerCount > 1) {
if (paths.entries.any { getGestureForDirection(it.value.getDirection()) != gesture }) {
// the directions of the pointers don't match
return
}
gesture = gesture?.let(Gesture::getDoubleVariant)
}
// detect triangles
val startEndMin = mainPointerPath.start.min(mainPointerPath.last)
val startEndMax = mainPointerPath.start.max(mainPointerPath.last)
when (gesture) {
Gesture.SWIPE_DOWN -> {
if (startEndMax.x + MIN_TRIANGLE_HEIGHT < mainPointerPath.max.x) {
gesture = Gesture.SWIPE_LARGER
} else if (startEndMin.x - MIN_TRIANGLE_HEIGHT > mainPointerPath.min.x) {
gesture = Gesture.SWIPE_SMALLER
}
}
Gesture.SWIPE_UP -> {
if (startEndMax.x + MIN_TRIANGLE_HEIGHT < mainPointerPath.max.x) {
gesture = Gesture.SWIPE_LARGER_REVERSE
} else if (startEndMin.x - MIN_TRIANGLE_HEIGHT > mainPointerPath.min.x) {
gesture = Gesture.SWIPE_SMALLER_REVERSE
}
}
Gesture.SWIPE_RIGHT -> {
if (startEndMax.y + MIN_TRIANGLE_HEIGHT < mainPointerPath.max.y) {
gesture = Gesture.SWIPE_V
} else if (startEndMin.y - MIN_TRIANGLE_HEIGHT > mainPointerPath.min.y) {
gesture = Gesture.SWIPE_LAMBDA
}
}
Gesture.SWIPE_LEFT -> {
if (startEndMax.y + MIN_TRIANGLE_HEIGHT < mainPointerPath.max.y) {
gesture = Gesture.SWIPE_V_REVERSE
} else if (startEndMin.y - MIN_TRIANGLE_HEIGHT > mainPointerPath.min.y) {
gesture = Gesture.SWIPE_LAMBDA_REVERSE
}
}
else -> {}
}
if (edgeActions) {
if (mainPointerPath.max.x < edgeWidth * width) {
gesture = gesture?.getEdgeVariant(Gesture.Edge.LEFT)
} else if (mainPointerPath.min.x > (1 - edgeWidth) * width) {
gesture = gesture?.getEdgeVariant(Gesture.Edge.RIGHT)
}
if (mainPointerPath.max.y < edgeWidth * height) {
gesture = gesture?.getEdgeVariant(Gesture.Edge.TOP)
} else if (mainPointerPath.min.y > (1 - edgeWidth) * height) {
gesture = gesture?.getEdgeVariant(Gesture.Edge.BOTTOM)
}
}
if (timeStart - lastTappedTime < 2 * DOUBLE_TAP_TIMEOUT) {
gesture = gesture?.getTapComboVariant()
}
gesture?.invoke(context)
}
}
fun updateScreenSize(windowManager: WindowManager) {
val displayMetrics = DisplayMetrics()
@Suppress("deprecation") // required to support API < 30
windowManager.defaultDisplay.getMetrics(displayMetrics)
width = displayMetrics.widthPixels
height = displayMetrics.heightPixels
}
@RequiresApi(Build.VERSION_CODES.Q)
fun setSystemGestureInsets(insets: Insets) {
systemGestureInsetTop = insets.top
systemGestureInsetBottom = insets.bottom
systemGestureInsetLeft = insets.left
systemGestureInsetRight = insets.right
}
}

View file

@ -0,0 +1,103 @@
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.View
import android.view.Window
import android.view.WindowInsets
import android.view.WindowInsetsController
import android.view.WindowManager
import de.jrpie.android.launcher.preferences.LauncherPreferences
/**
* An interface implemented by every [Activity], Fragment etc. in Launcher.
* It handles themes and window flags - a useful abstraction as it is the same everywhere.
*/
@Suppress("deprecation") // FLAG_FULLSCREEN is required to support API level < 30
fun setWindowFlags(window: Window, homeScreen: Boolean) {
window.setFlags(0, 0) // clear flags
// Display notification bar
if (LauncherPreferences.display().hideStatusBar())
window.setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN
)
else window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
// Screen Timeout
if (LauncherPreferences.display().screenTimeoutDisabled())
window.setFlags(
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON,
WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
)
else window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
if (!homeScreen) {
LauncherPreferences.theme().background().applyToWindow(window)
}
}
interface UIObject {
fun onCreate() {
if (this !is Activity) {
return
}
setWindowFlags(window, isHomeScreen())
if (!LauncherPreferences.display().rotateScreen()) {
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_NOSENSOR
}
}
fun onStart() {
setOnClicks()
adjustLayout()
}
fun modifyTheme(theme: Resources.Theme): Resources.Theme {
LauncherPreferences.theme().colorTheme().applyToTheme(
theme,
LauncherPreferences.theme().textShadow()
)
LauncherPreferences.theme().background().applyToTheme(theme)
LauncherPreferences.theme().font().applyToTheme(theme)
return theme
}
// fun applyTheme() { }
fun setOnClicks() {}
fun adjustLayout() {}
fun isHomeScreen(): Boolean {
return false
}
@Suppress("DEPRECATION")
fun hideNavigationBar() {
if (this !is Activity) {
return
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
window.insetsController?.apply {
hide(WindowInsets.Type.navigationBars())
systemBarsBehavior =
WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
}
} else {
// Try to hide the navigation bar but do not hide the status bar
window.decorView.systemUiVisibility = (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
or View.SYSTEM_UI_FLAG_IMMERSIVE
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE)
}
}
}

View file

@ -0,0 +1,270 @@
package de.jrpie.android.launcher.ui.list
import android.content.res.Resources
import android.graphics.Rect
import android.os.Build
import android.os.Bundle
import android.view.View
import android.window.OnBackInvokedDispatcher
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.content.res.AppCompatResources
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentPagerAdapter
import de.jrpie.android.launcher.Application
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.actions.LauncherAction
import de.jrpie.android.launcher.apps.AppFilter
import de.jrpie.android.launcher.apps.hidePrivateSpaceWhenLocked
import de.jrpie.android.launcher.apps.isPrivateSpaceLocked
import de.jrpie.android.launcher.apps.isPrivateSpaceSetUp
import de.jrpie.android.launcher.apps.togglePrivateSpaceLock
import de.jrpie.android.launcher.databinding.ListBinding
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
/**
* The [ListActivity] is the most general purpose activity in Launcher:
* - used to view all apps and edit their settings
* - used to choose an app / intent to be launched
*
* The activity itself can also be chosen to be launched as an action.
*/
class ListActivity : AppCompatActivity(), UIObject {
private lateinit var binding: ListBinding
var intention = ListActivityIntention.VIEW
var favoritesVisibility: AppFilter.Companion.AppSetVisibility =
AppFilter.Companion.AppSetVisibility.VISIBLE
var privateSpaceVisibility: AppFilter.Companion.AppSetVisibility =
AppFilter.Companion.AppSetVisibility.VISIBLE
var hiddenVisibility: AppFilter.Companion.AppSetVisibility =
AppFilter.Companion.AppSetVisibility.HIDDEN
var forGesture: String? = null
private fun updateLockIcon(locked: Boolean) {
if (
// only show lock for VIEW intention
(intention != ListActivityIntention.VIEW)
// hide lock when private space does not exist
|| !isPrivateSpaceSetUp(this)
// hide lock when private space apps are hidden from the main list and we are not in the private space list
|| (LauncherPreferences.apps().hidePrivateSpaceApps()
&& privateSpaceVisibility != AppFilter.Companion.AppSetVisibility.EXCLUSIVE)
// hide lock when private space is locked and the hidden when locked setting is set
|| (locked && hidePrivateSpaceWhenLocked(this))
) {
binding.listLock.visibility = View.GONE
return
}
binding.listLock.visibility = View.VISIBLE
binding.listLock.setImageDrawable(
AppCompatResources.getDrawable(
this,
if (locked) {
R.drawable.baseline_lock_24
} else {
R.drawable.baseline_lock_open_24
}
)
)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
binding.listLock.tooltipText = getString(
if (locked) {
R.string.tooltip_unlock_private_space
} else {
R.string.tooltip_lock_private_space
}
)
}
}
enum class ListActivityIntention(val titleResource: Int) {
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<AppCompatActivity>.onCreate(savedInstanceState)
super<UIObject>.onCreate()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU && intention == ListActivityIntention.VIEW) {
onBackInvokedDispatcher.registerOnBackInvokedCallback(
OnBackInvokedDispatcher.PRIORITY_OVERLAY
) {
finish()
}
}
// get info about which action this activity is open for
intent.extras?.let { bundle ->
intention = bundle.getString("intention")
?.let { ListActivityIntention.valueOf(it) }
?: ListActivityIntention.VIEW
@Suppress("deprecation") // required to support API level < 33
favoritesVisibility = bundle.getSerializable("favoritesVisibility")
as? AppFilter.Companion.AppSetVisibility ?: favoritesVisibility
@Suppress("deprecation") // required to support API level < 33
privateSpaceVisibility = bundle.getSerializable("privateSpaceVisibility")
as? AppFilter.Companion.AppSetVisibility ?: privateSpaceVisibility
@Suppress("deprecation") // required to support API level < 33
hiddenVisibility = bundle.getSerializable("hiddenVisibility")
as? AppFilter.Companion.AppSetVisibility ?: hiddenVisibility
if (intention != ListActivityIntention.VIEW)
forGesture = bundle.getString("forGesture")
}
// Initialise layout
binding = ListBinding.inflate(layoutInflater)
setContentView(binding.root)
binding.listSettings.setOnClickListener {
LauncherAction.SETTINGS.launch(this@ListActivity)
}
if (privateSpaceVisibility == AppFilter.Companion.AppSetVisibility.EXCLUSIVE) {
isPrivateSpaceSetUp(this, showToast = true, launchSettings = true)
if (isPrivateSpaceLocked(this)) {
togglePrivateSpaceLock(this)
}
}
updateLockIcon(isPrivateSpaceLocked(this))
val privateSpaceLocked = (this.applicationContext as Application).privateSpaceLocked
privateSpaceLocked.observe(this) { updateLockIcon(it) }
// android:windowSoftInputMode="adjustResize" doesn't work in full screen.
// workaround from https://stackoverflow.com/a/57623505
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) {
this.window.decorView.viewTreeObserver.addOnGlobalLayoutListener {
val r = Rect()
window.decorView.getWindowVisibleDisplayFrame(r)
val height: Int =
binding.listContainer.context.resources.displayMetrics.heightPixels
val diff = height - r.bottom
if (diff != 0 &&
LauncherPreferences.display().hideStatusBar()
) {
if (binding.listContainer.paddingBottom != diff) {
binding.listContainer.setPadding(0, 0, 0, diff)
}
} else {
if (binding.listContainer.paddingBottom != 0) {
binding.listContainer.setPadding(0, 0, 0, 0)
}
}
}
}
}
override fun onStart() {
super<AppCompatActivity>.onStart()
super<UIObject>.onStart()
}
override fun onPause() {
super.onPause()
// ensure that the activity closes then an app is launched
// and when the user navigates to recent apps
finish()
}
fun updateTitle() {
var titleResource = intention.titleResource
if (intention == ListActivityIntention.VIEW) {
titleResource =
if (hiddenVisibility == AppFilter.Companion.AppSetVisibility.EXCLUSIVE) {
R.string.list_title_hidden
} else if (privateSpaceVisibility == AppFilter.Companion.AppSetVisibility.EXCLUSIVE) {
R.string.list_title_private_space
} else if (favoritesVisibility == AppFilter.Companion.AppSetVisibility.EXCLUSIVE) {
R.string.list_title_favorite
} else {
R.string.list_title_view
}
}
binding.listHeading.text = getString(titleResource)
}
override fun getTheme(): Resources.Theme {
return modifyTheme(super.getTheme())
}
override fun setOnClicks() {
binding.listClose.setOnClickListener { finish() }
binding.listLock.setOnClickListener {
togglePrivateSpaceLock(this)
if (privateSpaceVisibility == AppFilter.Companion.AppSetVisibility.EXCLUSIVE) {
finish()
}
}
}
override fun adjustLayout() {
// Hide tabs for the "view" action
if (intention == ListActivityIntention.VIEW) {
binding.listTabs.visibility = View.GONE
}
updateTitle()
val sectionsPagerAdapter = ListSectionsPagerAdapter(this)
binding.listViewpager.let {
it.adapter = sectionsPagerAdapter
binding.listTabs.setupWithViewPager(it)
}
}
}
private val TAB_TITLES = arrayOf(
R.string.list_tab_app,
R.string.list_tab_other
)
/**
* The [ListSectionsPagerAdapter] returns the fragment,
* which corresponds to the selected tab in [ListActivity].
*
* This should eventually be replaced by a [FragmentStateAdapter]
* However this keyboard does not open when using [ViewPager2]
* so currently [ViewPager] is used here.
* https://github.com/jrpie/launcher/issues/130
*/
@Suppress("deprecation")
class ListSectionsPagerAdapter(private val activity: ListActivity) :
FragmentPagerAdapter(activity.supportFragmentManager) {
override fun getItem(position: Int): Fragment {
return when (position) {
0 -> ListFragmentApps()
1 -> ListFragmentOther()
else -> Fragment()
}
}
override fun getPageTitle(position: Int): CharSequence {
return activity.resources.getString(TAB_TITLES[position])
}
override fun getCount(): Int {
return when (activity.intention) {
ListActivity.ListActivityIntention.VIEW -> 1
else -> 2
}
}
}

View file

@ -0,0 +1,245 @@
package de.jrpie.android.launcher.ui.list.apps
import android.annotation.SuppressLint
import android.app.Activity
import android.graphics.Rect
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import android.widget.ImageView
import android.widget.PopupMenu
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.RecyclerView
import de.jrpie.android.launcher.Application
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.actions.Action
import de.jrpie.android.launcher.actions.Gesture
import de.jrpie.android.launcher.apps.AbstractDetailedAppInfo
import de.jrpie.android.launcher.apps.AppFilter
import de.jrpie.android.launcher.apps.AppInfo
import de.jrpie.android.launcher.apps.DetailedAppInfo
import de.jrpie.android.launcher.preferences.LauncherPreferences
import de.jrpie.android.launcher.preferences.ListLayout
import de.jrpie.android.launcher.ui.list.ListActivity
import de.jrpie.android.launcher.ui.transformGrayscale
/**
* A [RecyclerView] (efficient scrollable list) containing all apps on the users device.
* The apps details are represented by [AppInfo].
*
* @param activity - the activity this is in
* @param intention - why the list is displayed ("view", "pick")
* @param forGesture - the action which an app is chosen for (when the intention is "pick")
*/
@SuppressLint("NotifyDataSetChanged")
class AppsRecyclerAdapter(
val activity: Activity,
val root: View,
private val intention: ListActivity.ListActivityIntention
= ListActivity.ListActivityIntention.VIEW,
private val forGesture: String? = "",
private var appFilter: AppFilter = AppFilter(activity, ""),
private val layout: ListLayout
) :
RecyclerView.Adapter<AppsRecyclerAdapter.ViewHolder>() {
private val apps = (activity.applicationContext as Application).apps
private val appsListDisplayed: MutableList<AbstractDetailedAppInfo> = mutableListOf()
private val grayscale = LauncherPreferences.theme().monochromeIcons()
// temporarily disable auto launch
var disableAutoLaunch: Boolean = false
init {
apps.observe(this.activity as AppCompatActivity) {
updateAppsList()
}
updateAppsList()
}
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView),
View.OnClickListener {
var textView: TextView = itemView.findViewById(R.id.list_apps_row_name)
var img: ImageView = itemView.findViewById(R.id.list_apps_row_icon)
override fun onClick(v: View) {
val rect = Rect()
img.getGlobalVisibleRect(rect)
selectItem(bindingAdapterPosition, rect)
}
init {
itemView.setOnClickListener(this)
}
}
override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) {
var appLabel = appsListDisplayed[i].getCustomLabel(activity)
val appIcon = appsListDisplayed[i].getIcon(activity)
viewHolder.img.transformGrayscale(grayscale)
viewHolder.img.setImageDrawable(appIcon.constantState?.newDrawable() ?: appIcon)
if (layout.useBadgedText) {
appLabel = activity.packageManager.getUserBadgedLabel(
appLabel,
appsListDisplayed[i].getUser(activity)
).toString()
}
viewHolder.textView.text = appLabel
// decide when to show the options popup menu about
if (intention == ListActivity.ListActivityIntention.VIEW) {
viewHolder.textView.setOnLongClickListener {
showOptionsPopup(
viewHolder,
appsListDisplayed[i]
)
}
viewHolder.img.setOnLongClickListener {
showOptionsPopup(
viewHolder,
appsListDisplayed[i]
)
}
// ensure onClicks are actually caught
viewHolder.textView.setOnClickListener { viewHolder.onClick(viewHolder.textView) }
viewHolder.img.setOnClickListener { viewHolder.onClick(viewHolder.img) }
}
}
@Suppress("SameReturnValue")
private fun showOptionsPopup(
viewHolder: ViewHolder,
appInfo: AbstractDetailedAppInfo
): Boolean {
//create the popup menu
val popup = PopupMenu(activity, viewHolder.img)
popup.inflate(R.menu.menu_app)
if (!appInfo.isRemovable()) {
popup.menu.findItem(R.id.app_menu_delete).setVisible(false)
}
if (appInfo !is DetailedAppInfo) {
popup.menu.findItem(R.id.app_menu_info).setVisible(false)
}
if (LauncherPreferences.apps().hidden()?.contains(appInfo.getRawInfo()) == true) {
popup.menu.findItem(R.id.app_menu_hidden).setTitle(R.string.list_app_hidden_remove)
}
if (LauncherPreferences.apps().favorites()?.contains(appInfo.getRawInfo()) == true) {
popup.menu.findItem(R.id.app_menu_favorite).setTitle(R.string.list_app_favorite_remove)
}
popup.setOnMenuItemClickListener {
when (it.itemId) {
R.id.app_menu_delete -> {
appInfo.getRawInfo().uninstall(activity); true
}
R.id.app_menu_info -> {
(appInfo.getRawInfo() as? AppInfo)?.openSettings(activity); true
}
R.id.app_menu_favorite -> {
appInfo.getRawInfo().toggleFavorite(); true
}
R.id.app_menu_hidden -> {
appInfo.getRawInfo().toggleHidden(root); true
}
R.id.app_menu_rename -> {
appInfo.showRenameDialog(activity); true
}
else -> false
}
}
popup.show()
return true
}
override fun getItemCount(): Int {
return appsListDisplayed.size
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val layout = LauncherPreferences.list().layout()
val inflater = LayoutInflater.from(parent.context)
val view: View = inflater.inflate(layout.layoutResource, parent, false)
val viewHolder = ViewHolder(view)
return viewHolder
}
fun selectItem(pos: Int, rect: Rect = Rect()) {
if (pos >= appsListDisplayed.size) {
return
}
val appInfo = appsListDisplayed[pos]
when (intention) {
ListActivity.ListActivityIntention.VIEW -> {
appInfo.getAction().invoke(activity, rect)
}
ListActivity.ListActivityIntention.PICK -> {
activity.finish()
forGesture ?: return
val gesture = Gesture.byId(forGesture) ?: return
Action.setActionForGesture(gesture, appInfo.getAction())
}
}
}
fun updateAppsList(triggerAutoLaunch: Boolean = false) {
appsListDisplayed.clear()
apps.value?.let { appsListDisplayed.addAll(appFilter(it)) }
if (triggerAutoLaunch &&
appsListDisplayed.size == 1
&& intention == ListActivity.ListActivityIntention.VIEW
&& !disableAutoLaunch
&& LauncherPreferences.functionality().searchAutoLaunch()
) {
val app = appsListDisplayed[0]
app.getAction().invoke(activity)
val inputMethodManager =
activity.getSystemService(Activity.INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.hideSoftInputFromWindow(View(activity).windowToken, 0)
}
notifyDataSetChanged()
}
/**
* The function [setSearchString] is used to search elements within this [RecyclerView].
*/
fun setSearchString(search: String) {
appFilter.query = search
updateAppsList(true)
}
fun setFavoritesVisibility(v: AppFilter.Companion.AppSetVisibility) {
appFilter.favoritesVisibility = v
updateAppsList()
}
fun setHiddenAppsVisibility(v: AppFilter.Companion.AppSetVisibility) {
appFilter.hiddenVisibility = v
updateAppsList()
}
}

View file

@ -0,0 +1,113 @@
package de.jrpie.android.launcher.ui.list.apps
import android.app.Activity
import android.app.Service
import android.content.Context
import android.content.Intent
import android.content.pm.LauncherApps
import android.graphics.Rect
import android.os.Bundle
import android.util.Log
import android.view.View
import android.widget.EditText
import androidx.appcompat.app.AlertDialog
import com.google.android.material.snackbar.Snackbar
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.apps.AppInfo
import de.jrpie.android.launcher.apps.AbstractAppInfo
import de.jrpie.android.launcher.apps.AbstractDetailedAppInfo
import de.jrpie.android.launcher.apps.PinnedShortcutInfo
import de.jrpie.android.launcher.getUserFromId
import de.jrpie.android.launcher.preferences.LauncherPreferences
import androidx.core.net.toUri
private const val LOG_TAG = "AppContextMenu"
fun AppInfo.openSettings(
context: Context,
sourceBounds: Rect? = null,
opts: Bundle? = null
) {
val launcherApps = context.getSystemService(Service.LAUNCHER_APPS_SERVICE) as LauncherApps
this.getLauncherActivityInfo(context)?.let { app ->
launcherApps.startAppDetailsActivity(app.componentName, app.user, sourceBounds, opts)
}
}
fun AbstractAppInfo.uninstall(activity: Activity) {
if (this is AppInfo) {
val packageName = this.packageName
val userId = this.user
Log.i(LOG_TAG, "uninstalling $this")
val intent = Intent(Intent.ACTION_DELETE)
intent.data = "package:$packageName".toUri()
getUserFromId(userId, activity).let { user ->
intent.putExtra(Intent.EXTRA_USER, user)
}
activity.startActivity(intent)
} else if(this is PinnedShortcutInfo) {
val pinned = LauncherPreferences.apps().pinnedShortcuts() ?: mutableSetOf()
pinned.remove(this)
LauncherPreferences.apps().pinnedShortcuts(pinned)
}
}
fun AbstractAppInfo.toggleFavorite() {
val favorites: MutableSet<AbstractAppInfo> =
LauncherPreferences.apps().favorites() ?: mutableSetOf()
if (favorites.contains(this)) {
favorites.remove(this)
Log.i(LOG_TAG, "Removing $this from favorites.")
} else {
Log.i(LOG_TAG, "Adding $this to favorites.")
favorites.add(this)
}
LauncherPreferences.apps().favorites(favorites)
}
/**
* @param view: used to show a snackbar letting the user undo the action
*/
fun AbstractAppInfo.toggleHidden(view: View) {
val hidden: MutableSet<AbstractAppInfo> =
LauncherPreferences.apps().hidden() ?: mutableSetOf()
if (hidden.contains(this)) {
hidden.remove(this)
} else {
hidden.add(this)
Snackbar.make(view, R.string.snackbar_app_hidden, Snackbar.LENGTH_LONG)
.setAction(R.string.undo) {
LauncherPreferences.apps().hidden(
LauncherPreferences.apps().hidden().minus(this)
)
}.show()
}
LauncherPreferences.apps().hidden(hidden)
}
fun AbstractDetailedAppInfo.showRenameDialog(context: Context) {
AlertDialog.Builder(context, R.style.AlertDialogCustom).apply {
setTitle(context.getString(R.string.dialog_rename_title, getLabel()))
setView(R.layout.dialog_rename_app)
setNegativeButton(android.R.string.cancel) { d, _ -> d.cancel() }
setPositiveButton(android.R.string.ok) { d, _ ->
setCustomLabel(
(d as? AlertDialog)
?.findViewById<EditText>(R.id.dialog_rename_app_edit_text)
?.text.toString()
)
}
}.create().also { it.show() }.apply {
val input = findViewById<EditText>(R.id.dialog_rename_app_edit_text)
input?.setText(getCustomLabel(context))
input?.hint = getLabel()
}
}

View file

@ -0,0 +1,157 @@
package de.jrpie.android.launcher.ui.list.apps
import android.content.ActivityNotFoundException
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 android.widget.Toast
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.apps.AppFilter
import de.jrpie.android.launcher.databinding.ListAppsBinding
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.openSoftKeyboard
/**
* The [ListFragmentApps] is used as a tab in ListActivity.
*
* It is a list of all installed applications that are can be launched.
*/
class ListFragmentApps : Fragment(), UIObject {
private lateinit var binding: ListAppsBinding
private lateinit var appsRecyclerAdapter: AppsRecyclerAdapter
private var sharedPreferencesListener =
SharedPreferences.OnSharedPreferenceChangeListener { _, _ ->
appsRecyclerAdapter.updateAppsList()
}
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding = ListAppsBinding.inflate(inflater)
return binding.root
}
override fun onStart() {
super<Fragment>.onStart()
super<UIObject>.onStart()
LauncherPreferences.getSharedPreferences()
.registerOnSharedPreferenceChangeListener(sharedPreferencesListener)
binding.listAppsCheckBoxFavorites.isChecked =
((activity as? ListActivity)?.favoritesVisibility == AppFilter.Companion.AppSetVisibility.EXCLUSIVE)
}
override fun onStop() {
super.onStop()
LauncherPreferences.getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener)
}
override fun setOnClicks() {}
override fun adjustLayout() {
val listActivity = activity as? ListActivity ?: return
appsRecyclerAdapter =
AppsRecyclerAdapter(
listActivity, binding.root, listActivity.intention, listActivity.forGesture,
appFilter = AppFilter(
requireContext(),
"",
favoritesVisibility = listActivity.favoritesVisibility,
privateSpaceVisibility = listActivity.privateSpaceVisibility,
hiddenVisibility = listActivity.hiddenVisibility
),
layout = LauncherPreferences.list().layout()
)
// set up the list / recycler
binding.listAppsRview.apply {
// improve performance (since content changes don't change the layout size)
setHasFixedSize(true)
layoutManager = LauncherPreferences.list().layout().layoutManager(context)
.also {
if (LauncherPreferences.list().reverseLayout()) {
(it as? LinearLayoutManager)?.reverseLayout = true
(it as? GridLayoutManager)?.reverseLayout = true
}
}
adapter = appsRecyclerAdapter
}
binding.listAppsSearchview.setOnQueryTextListener(object :
androidx.appcompat.widget.SearchView.OnQueryTextListener {
override fun onQueryTextSubmit(query: String): Boolean {
appsRecyclerAdapter.setSearchString(query)
if (LauncherPreferences.functionality().searchWeb()) {
val i = Intent(Intent.ACTION_WEB_SEARCH).putExtra("query", query)
try {
activity?.startActivity(i)
} catch (_: ActivityNotFoundException) {
Toast.makeText(
requireContext(),
R.string.toast_activity_not_found_search_web,
Toast.LENGTH_LONG
).show()
}
} else {
appsRecyclerAdapter.selectItem(0)
}
return true
}
override fun onQueryTextChange(newText: String): Boolean {
if (newText == " " &&
!appsRecyclerAdapter.disableAutoLaunch &&
(activity as? ListActivity)?.intention
== ListActivity.ListActivityIntention.VIEW &&
LauncherPreferences.functionality().searchAutoLaunch()
) {
appsRecyclerAdapter.disableAutoLaunch = true
binding.listAppsSearchview.apply {
queryHint = context.getString(R.string.list_apps_search_hint_no_auto_launch)
setQuery("", false)
}
return false
}
appsRecyclerAdapter.setSearchString(newText)
return false
}
})
binding.listAppsCheckBoxFavorites.setOnClickListener {
listActivity.favoritesVisibility =
if (binding.listAppsCheckBoxFavorites.isChecked) {
AppFilter.Companion.AppSetVisibility.EXCLUSIVE
} else {
AppFilter.Companion.AppSetVisibility.VISIBLE
}
appsRecyclerAdapter.setFavoritesVisibility(listActivity.favoritesVisibility)
(activity as? ListActivity)?.updateTitle()
}
if (listActivity.intention == ListActivity.ListActivityIntention.VIEW
&& LauncherPreferences.functionality().searchAutoOpenKeyboard()
) {
binding.listAppsSearchview.openSoftKeyboard(requireContext())
}
}
}

View file

@ -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
/**
@ -22,7 +21,7 @@ class ListFragmentOther : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
): View {
binding = ListOtherBinding.inflate(inflater)
return binding.root
}

View file

@ -1,17 +1,17 @@
package de.jrpie.android.launcher.list.other
package de.jrpie.android.launcher.ui.list.other
import android.app.Activity
import android.content.Intent
import android.view.LayoutInflater
import android.view.View
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.Action
import de.jrpie.android.launcher.actions.Gesture
import de.jrpie.android.launcher.actions.LauncherAction
import de.jrpie.android.launcher.ui.list.ListActivity
/**
* The [OtherRecyclerAdapter] will only be displayed in the ListActivity,
@ -20,10 +20,11 @@ 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<OtherRecyclerAdapter.ViewHolder>() {
private val othersList: Array<LauncherAction> = LauncherAction.values()
private val othersList: Array<LauncherAction> =
LauncherAction.entries.filter { it.isAvailable(activity) }.toTypedArray()
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView),
View.OnClickListener {
@ -32,13 +33,18 @@ class OtherRecyclerAdapter(val activity: Activity):
override fun onClick(v: View) {
val pos = adapterPosition
val pos = bindingAdapterPosition
val content = othersList[pos]
forGesture?.let { returnChoiceIntent(it, content.id) }
activity.finish()
val gestureId = (activity as? ListActivity)?.forGesture ?: return
val gesture = Gesture.byId(gestureId) ?: return
Action.setActionForGesture(gesture, content)
}
init { itemView.setOnClickListener(this) }
init {
itemView.setOnClickListener(this)
}
}
override fun onBindViewHolder(viewHolder: ViewHolder, i: Int) {
@ -49,20 +55,13 @@ 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)
val view: View = inflater.inflate(R.layout.list_other_row, parent, false)
return ViewHolder(view)
}
private fun returnChoiceIntent(forGesture: String, value: String) {
val returnIntent = Intent()
returnIntent.putExtra("value", value)
returnIntent.putExtra("forGesture", forGesture)
returnIntent.putExtra("user", INVALID_USER)
activity.setResult(REQUEST_CHOOSE_APP, returnIntent)
activity.finish()
}
}

View file

@ -0,0 +1,83 @@
package de.jrpie.android.launcher.ui.settings
import android.content.Context
import android.content.SharedPreferences
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Rect
import android.util.AttributeSet
import android.view.View
import de.jrpie.android.launcher.preferences.LauncherPreferences
/*
* An overlay to indicate the areas where edge-gestures are detected
*/
class GestureAreaIndicatorOverlayView(context: Context?, attrs: AttributeSet?) : View(context, attrs) {
private var horizontalWidth = 0.1f
private var verticalWidth = 0.1f
private lateinit var edgeLeft: Rect
private lateinit var edgeRight: Rect
private lateinit var edgeTop: Rect
private lateinit var edgeBottom: Rect
private val hideTask = Runnable {
visibility = INVISIBLE
}
private var sharedPreferencesListener =
SharedPreferences.OnSharedPreferenceChangeListener { _, prefKey ->
if (prefKey == LauncherPreferences.enabled_gestures().keys().edgeSwipeEdgeWidth()) {
this.removeCallbacks(hideTask)
visibility = VISIBLE
update()
requestLayout()
invalidate()
this.postDelayed(hideTask, 3000)
}
}
constructor(context: Context) : this(context, null)
private val overlayPaint = Paint()
init {
overlayPaint.setARGB(50,255,0,0)
overlayPaint.strokeWidth = 10f
update()
}
private fun update() {
horizontalWidth = LauncherPreferences.enabled_gestures().edgeSwipeEdgeWidth() / 100f
verticalWidth = horizontalWidth
edgeTop = Rect(0,0,(width * horizontalWidth).toInt(), height)
edgeBottom = Rect((width * (1 - horizontalWidth)).toInt(),0,width, height)
edgeLeft = Rect(0,0, width, (height * verticalWidth).toInt())
edgeRight = Rect(0,(height * (1-verticalWidth)).toInt(), width, height)
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
LauncherPreferences.getSharedPreferences().registerOnSharedPreferenceChangeListener(sharedPreferencesListener)
}
override fun onDetachedFromWindow() {
LauncherPreferences.getSharedPreferences().unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener)
super.onDetachedFromWindow()
}
override fun onDraw(canvas: Canvas) {
arrayOf(edgeLeft,
edgeRight, edgeTop, edgeBottom).forEach { e ->
canvas.drawRect(e, overlayPaint)
}
}
}

View file

@ -0,0 +1,136 @@
package de.jrpie.android.launcher.ui.settings
import android.content.Intent
import android.content.SharedPreferences
import android.content.res.Resources
import android.os.Bundle
import android.provider.Settings
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
import com.google.android.material.tabs.TabLayoutMediator
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.databinding.SettingsBinding
import de.jrpie.android.launcher.preferences.LauncherPreferences
import de.jrpie.android.launcher.preferences.theme.Background
import de.jrpie.android.launcher.preferences.theme.ColorTheme
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:
*
* | Actions | Choose apps or intents to be launched | [SettingsFragmentActions] |
* | Theme | Select a theme / Customize | [SettingsFragmentLauncher] |
* | Meta | About Launcher / Contact etc. | [SettingsFragmentMeta] |
*
* Settings are closed automatically if the activity goes `onPause` unexpectedly.
*/
class SettingsActivity : AppCompatActivity(), UIObject {
private val solidBackground = LauncherPreferences.theme().background() == Background.SOLID
|| LauncherPreferences.theme().colorTheme() == ColorTheme.LIGHT
private val sharedPreferencesListener =
SharedPreferences.OnSharedPreferenceChangeListener { _, prefKey ->
if (solidBackground &&
(prefKey == LauncherPreferences.theme().keys().background() ||
prefKey == LauncherPreferences.theme().keys().colorTheme())
) {
// Switching from solid background to a transparent background using `recreate()`
// causes a very ugly glitch, making the settings unreadable.
// This ugly workaround causes a jump to the top of the list, but at least
// the text stays readable.
val i = Intent(this, SettingsActivity::class.java)
.also { it.putExtra(EXTRA_TAB, 1) }
finish()
startActivity(i)
} else
if (prefKey?.startsWith("theme.") == true ||
prefKey?.startsWith("display.") == true
) {
recreate()
}
}
private lateinit var binding: SettingsBinding
override fun onCreate(savedInstanceState: Bundle?) {
super<AppCompatActivity>.onCreate(savedInstanceState)
super<UIObject>.onCreate()
// Initialise layout
binding = SettingsBinding.inflate(layoutInflater)
setContentView(binding.root)
// set up tabs and swiping in settings
val sectionsPagerAdapter = SettingsSectionsPagerAdapter(this)
binding.settingsViewpager.apply {
adapter = sectionsPagerAdapter
setCurrentItem(intent.getIntExtra(EXTRA_TAB, 0), false)
}
TabLayoutMediator(binding.settingsTabs, binding.settingsViewpager) { tab, position ->
tab.text = sectionsPagerAdapter.getPageTitle(position)
}.attach()
}
override fun onStart() {
super<AppCompatActivity>.onStart()
super<UIObject>.onStart()
LauncherPreferences.getSharedPreferences()
.registerOnSharedPreferenceChangeListener(sharedPreferencesListener)
}
override fun onPause() {
LauncherPreferences.getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener)
super.onPause()
}
override fun getTheme(): Resources.Theme {
return modifyTheme(super.getTheme())
}
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)
binding.settingsSystem.setOnClickListener {
startActivity(Intent(Settings.ACTION_SETTINGS))
}
}
companion object {
private const val EXTRA_TAB = "tab"
}
}
private val TAB_TITLES = arrayOf(
R.string.settings_tab_actions,
R.string.settings_tab_launcher,
R.string.settings_tab_meta
)
class SettingsSectionsPagerAdapter(private val activity: FragmentActivity) :
FragmentStateAdapter(activity) {
override fun createFragment(position: Int): Fragment {
return when (position) {
0 -> SettingsFragmentActions()
1 -> SettingsFragmentLauncher()
2 -> SettingsFragmentMeta()
else -> Fragment()
}
}
fun getPageTitle(position: Int): CharSequence {
return activity.resources.getString(TAB_TITLES[position])
}
override fun getItemCount(): Int {
return 3
}
}

View file

@ -0,0 +1,73 @@
package de.jrpie.android.launcher.ui.settings.actions
import android.content.ActivityNotFoundException
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.fragment.app.Fragment
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.databinding.SettingsActionsBinding
import de.jrpie.android.launcher.ui.UIObject
import de.jrpie.android.launcher.ui.list.ListActivity
/**
* The [SettingsFragmentActions] is a used as a tab in the SettingsActivity.
*
* It is used to change Apps / Intents to be launched when a specific action
* is triggered.
* It also allows the user to view all apps ([ListActivity]) or install new ones.
*/
class
SettingsFragmentActions : Fragment(), UIObject {
private var binding: SettingsActionsBinding? = null
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding = SettingsActionsBinding.inflate(inflater, container, false)
binding?.root?.viewTreeObserver?.addOnGlobalLayoutListener {
val buttonHeight =
binding?.settingsActionsButtons?.height ?: return@addOnGlobalLayoutListener
val height = binding?.root?.height ?: return@addOnGlobalLayoutListener
if (buttonHeight > 0.2 * height) {
binding?.settingsActionsButtons?.visibility = View.GONE
} else {
binding?.settingsActionsButtons?.visibility = View.VISIBLE
}
}
return binding!!.root
}
override fun onStart() {
super<Fragment>.onStart()
super<UIObject>.onStart()
}
override fun setOnClicks() {
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()
}
}
}
}

View file

@ -0,0 +1,183 @@
package de.jrpie.android.launcher.ui.settings.actions
import android.annotation.SuppressLint
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 android.widget.Button
import android.widget.ImageView
import android.widget.TextView
import androidx.appcompat.content.res.AppCompatResources
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.actions.Action
import de.jrpie.android.launcher.actions.Gesture
import de.jrpie.android.launcher.apps.AppFilter
import de.jrpie.android.launcher.databinding.SettingsActionsRecyclerBinding
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.transformGrayscale
/**
* The [SettingsFragmentActionsRecycler] is a fragment containing the [ActionsRecyclerAdapter],
* which displays all selected actions / apps.
*
* It is used in the Tutorial and in Settings
*/
class SettingsFragmentActionsRecycler : Fragment(), UIObject {
private var savedScrollPosition = 0
private var sharedPreferencesListener =
SharedPreferences.OnSharedPreferenceChangeListener { _, _ ->
actionViewAdapter?.updateActions()
}
private lateinit var binding: SettingsActionsRecyclerBinding
private var actionViewAdapter: ActionsRecyclerAdapter? = null
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding = SettingsActionsRecyclerBinding.inflate(inflater, container, false)
return binding.root
}
override fun onStart() {
super<Fragment>.onStart()
// set up the list / recycler
val actionViewManager = LinearLayoutManager(context)
actionViewAdapter = ActionsRecyclerAdapter(requireActivity())
binding.settingsActionsRview.apply {
// improve performance (since content changes don't change the layout size)
setHasFixedSize(true)
layoutManager = actionViewManager
adapter = actionViewAdapter
}
LauncherPreferences.getSharedPreferences()
.registerOnSharedPreferenceChangeListener(sharedPreferencesListener)
super<UIObject>.onStart()
}
override fun onDestroy() {
LauncherPreferences.getSharedPreferences()
.unregisterOnSharedPreferenceChangeListener(sharedPreferencesListener)
super.onDestroy()
}
override fun onPause() {
savedScrollPosition =
(binding.settingsActionsRview.layoutManager as LinearLayoutManager)
.findFirstCompletelyVisibleItemPosition()
super.onPause()
}
override fun onResume() {
super.onResume()
(binding.settingsActionsRview.layoutManager)?.scrollToPosition(savedScrollPosition)
}
}
class ActionsRecyclerAdapter(val activity: Activity) :
RecyclerView.Adapter<ActionsRecyclerAdapter.ViewHolder>() {
private val drawableUnknown = AppCompatResources.getDrawable(activity, R.drawable.baseline_question_mark_24)
private val gesturesList: ArrayList<Gesture> =
Gesture.entries.filter(Gesture::isEnabled) as ArrayList<Gesture>
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView),
View.OnClickListener {
var textView: TextView = itemView.findViewById(R.id.settings_actions_row_name)
var descriptionTextView: TextView =
itemView.findViewById(R.id.settings_actions_row_description)
var img: ImageView = itemView.findViewById(R.id.settings_actions_row_icon_img)
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) {}
init {
itemView.setOnClickListener(this)
}
}
private fun updateViewHolder(gesture: Gesture, viewHolder: ViewHolder) {
val action = Action.forGesture(gesture)
if (action == null) {
viewHolder.img.visibility = View.INVISIBLE
viewHolder.removeAction.visibility = View.GONE
viewHolder.chooseButton.visibility = View.VISIBLE
return
}
// Use the unknown icon if there is an action, but we can't find its icon.
// Probably an app was uninstalled.
val drawable = action.getIcon(activity) ?: drawableUnknown
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)
val description = gesture.getDescription(activity)
viewHolder.descriptionTextView.text = description
viewHolder.img.transformGrayscale(LauncherPreferences.theme().monochromeIcons())
updateViewHolder(gesture, viewHolder)
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 onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val inflater = LayoutInflater.from(parent.context)
val view: View = inflater.inflate(R.layout.settings_actions_row, parent, false)
return ViewHolder(view)
}
@SuppressLint("NotifyDataSetChanged")
fun updateActions() {
val doubleActions = LauncherPreferences.enabled_gestures().doubleSwipe()
val edgeActions = LauncherPreferences.enabled_gestures().edgeSwipe()
this.gesturesList.clear()
gesturesList.addAll(Gesture.entries.filter {
(doubleActions || !it.isDoubleVariant())
&& (edgeActions || !it.isEdgeVariant())
})
notifyDataSetChanged()
}
private fun chooseApp(gesture: Gesture) {
val intent = Intent(activity, ListActivity::class.java)
intent.putExtra("intention", ListActivity.ListActivityIntention.PICK.toString())
intent.putExtra("hiddenVisibility", AppFilter.Companion.AppSetVisibility.VISIBLE)
intent.putExtra("forGesture", gesture.id) // for which action we choose the app
activity.startActivity(intent)
}
}

View file

@ -0,0 +1,117 @@
package de.jrpie.android.launcher.ui.settings.launcher
import android.content.Intent
import android.content.SharedPreferences
import android.os.Build
import android.os.Bundle
import androidx.preference.PreferenceFragmentCompat
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.actions.lock.LockMethod
import de.jrpie.android.launcher.actions.openAppsList
import de.jrpie.android.launcher.preferences.LauncherPreferences
import de.jrpie.android.launcher.preferences.theme.ColorTheme
import de.jrpie.android.launcher.setDefaultHomeScreen
/**
* The [SettingsFragmentLauncher] is a used as a tab in the SettingsActivity.
*
* It is used to change themes, select wallpapers ... theme related stuff
*/
class SettingsFragmentLauncher : PreferenceFragmentCompat() {
private var sharedPreferencesListener =
SharedPreferences.OnSharedPreferenceChangeListener { _, prefKey ->
if (prefKey?.startsWith("clock.") == true) {
updateVisibility()
}
}
private fun updateVisibility() {
val showSeconds = findPreference<androidx.preference.Preference>(
LauncherPreferences.clock().keys().showSeconds()
)
val timeVisible = LauncherPreferences.clock().timeVisible()
showSeconds?.isVisible = timeVisible
val background = findPreference<androidx.preference.Preference>(
LauncherPreferences.theme().keys().background()
)
val lightTheme = LauncherPreferences.theme().colorTheme() == ColorTheme.LIGHT
background?.isVisible = !lightTheme
val hidePausedApps = findPreference<androidx.preference.Preference>(
LauncherPreferences.apps().keys().hidePausedApps()
)
hidePausedApps?.isVisible = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
}
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<androidx.preference.Preference>(
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)
.putExtra("com.android.wallpaper.LAUNCH_SOURCE", "app_launched_launcher")
.putExtra("com.android.launcher3.WALLPAPER_FLAVOR", "focus_wallpaper")
startActivity(intent)
true
}
val chooseHomeScreen = findPreference<androidx.preference.Preference>(
LauncherPreferences.general().keys().chooseHomeScreen()
)
chooseHomeScreen?.setOnPreferenceClickListener {
setDefaultHomeScreen(requireContext(), checkDefault = false)
true
}
val hiddenApps = findPreference<androidx.preference.Preference>(
LauncherPreferences.apps().keys().hidden()
)
hiddenApps?.setOnPreferenceClickListener {
openAppsList(requireContext(), favorite = false, hidden = true)
true
}
val lockMethod = findPreference<androidx.preference.Preference>(
LauncherPreferences.actions().keys().lockMethod()
)
lockMethod?.setOnPreferenceClickListener {
LockMethod.chooseMethod(requireContext())
true
}
findPreference<androidx.preference.DropDownPreference>(
LauncherPreferences.theme().keys().colorTheme()
)?.apply {
entries = ColorTheme.entries.filter { x -> x.isAvailable() }
.map { x -> x.getLabel(requireContext()) }.toTypedArray()
entryValues = ColorTheme.entries.filter { x -> x.isAvailable() }
.map { x -> x.name }.toTypedArray()
}
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.P) {
lockMethod?.isVisible = false
}
updateVisibility()
}
}

View file

@ -0,0 +1,138 @@
package de.jrpie.android.launcher.ui.settings.meta
import android.app.AlertDialog
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.TextView
import androidx.fragment.app.Fragment
import de.jrpie.android.launcher.BuildConfig
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.copyToClipboard
import de.jrpie.android.launcher.databinding.SettingsMetaBinding
import de.jrpie.android.launcher.getDeviceInfo
import de.jrpie.android.launcher.openInBrowser
import de.jrpie.android.launcher.openTutorial
import de.jrpie.android.launcher.preferences.resetPreferences
import de.jrpie.android.launcher.ui.LegalInfoActivity
import de.jrpie.android.launcher.ui.UIObject
/**
* The [SettingsFragmentMeta] is a used as a tab in the SettingsActivity.
*
* It is used to change settings and access resources about Launcher,
* that are not directly related to the behaviour of the app itself.
*
* (greek `meta` = above, next level)
*/
class SettingsFragmentMeta : Fragment(), UIObject {
private lateinit var binding: SettingsMetaBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding = SettingsMetaBinding.inflate(inflater, container, false)
return binding.root
}
override fun onStart() {
super<Fragment>.onStart()
super<UIObject>.onStart()
}
override fun setOnClicks() {
fun bindURL(view: View, urlRes: Int) {
view.setOnClickListener {
openInBrowser(
getString(urlRes),
requireContext()
)
}
}
binding.settingsMetaButtonViewTutorial.setOnClickListener {
openTutorial(requireContext())
}
// prompting for settings-reset confirmation
binding.settingsMetaButtonResetSettings.setOnClickListener {
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
) { _, _ ->
resetPreferences(this.requireContext())
requireActivity().finish()
}
.setNegativeButton(android.R.string.cancel, null)
.setIcon(android.R.drawable.ic_dialog_alert)
.show()
}
// view code
bindURL(binding.settingsMetaButtonViewCode, R.string.settings_meta_link_github)
// report a bug
binding.settingsMetaButtonReportBug.setOnClickListener {
val deviceInfo = getDeviceInfo()
AlertDialog.Builder(context, R.style.AlertDialogCustom).apply {
setView(R.layout.dialog_report_bug)
setTitle(R.string.dialog_report_bug_title)
setPositiveButton(R.string.dialog_report_bug_create_report) { _, _ ->
openInBrowser(
getString(R.string.settings_meta_report_bug_link),
requireContext()
)
}
setNegativeButton(R.string.dialog_cancel) { _, _ -> }
}.create().also { it.show() }.apply {
val info = findViewById<TextView>(R.id.dialog_report_bug_device_info)
val buttonClipboard = findViewById<Button>(R.id.dialog_report_bug_button_clipboard)
val buttonSecurity = findViewById<Button>(R.id.dialog_report_bug_button_security)
info.text = deviceInfo
buttonClipboard.setOnClickListener {
copyToClipboard(requireContext(), deviceInfo)
}
info.setOnClickListener {
copyToClipboard(requireContext(), deviceInfo)
}
buttonSecurity.setOnClickListener {
openInBrowser(
getString(R.string.settings_meta_report_vulnerability_link),
requireContext()
)
}
}
}
// join chat
bindURL(binding.settingsMetaButtonJoinChat, R.string.settings_meta_chat_url)
// contact developer
// bindURL(binding.settingsMetaButtonContact, R.string.settings_meta_contact_url)
// contact fork developer
bindURL(binding.settingsMetaButtonForkContact, R.string.settings_meta_fork_contact_url)
// donate
bindURL(binding.settingsMetaButtonDonate, R.string.settings_meta_donate_url)
// privacy policy
bindURL(binding.settingsMetaButtonPrivacy, R.string.settings_meta_privacy_url)
// legal info
binding.settingsMetaButtonLicenses.setOnClickListener {
startActivity(Intent(this.context, LegalInfoActivity::class.java))
}
binding.settingsMetaTextVersion.text = BuildConfig.VERSION_NAME
}
}

View file

@ -0,0 +1,148 @@
package de.jrpie.android.launcher.ui.tutorial
import android.content.res.Resources
import android.os.Build
import android.os.Bundle
import android.view.View
import android.window.OnBackInvokedDispatcher
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.tabs.TabLayoutMediator
import de.jrpie.android.launcher.databinding.TutorialBinding
import de.jrpie.android.launcher.preferences.LauncherPreferences
import de.jrpie.android.launcher.ui.UIObject
import de.jrpie.android.launcher.ui.blink
import de.jrpie.android.launcher.ui.tutorial.tabs.TutorialFragment0Start
import de.jrpie.android.launcher.ui.tutorial.tabs.TutorialFragment1Concept
import de.jrpie.android.launcher.ui.tutorial.tabs.TutorialFragment2Usage
import de.jrpie.android.launcher.ui.tutorial.tabs.TutorialFragment3AppList
import de.jrpie.android.launcher.ui.tutorial.tabs.TutorialFragment4Setup
import de.jrpie.android.launcher.ui.tutorial.tabs.TutorialFragment5Finish
/**
* The [TutorialActivity] is displayed automatically on new installations.
* It can also be opened from Settings.
*
* It tells the user about the concept behind launcher
* and helps with the setup process (on new installations)
*/
class TutorialActivity : AppCompatActivity(), UIObject {
private lateinit var binding: TutorialBinding
override fun onCreate(savedInstanceState: Bundle?) {
super<AppCompatActivity>.onCreate(savedInstanceState)
super<UIObject>.onCreate()
// Initialise layout
binding = TutorialBinding.inflate(layoutInflater)
setContentView(binding.root)
// Handle back key / gesture on Android 13+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
onBackInvokedDispatcher.registerOnBackInvokedCallback(
OnBackInvokedDispatcher.PRIORITY_OVERLAY
) {
// prevent going back when the tutorial is shown for the first time
if (!LauncherPreferences.internal().started()) {
return@registerOnBackInvokedCallback
}
finish()
}
}
// set up tabs and swiping in settings
val sectionsPagerAdapter = TutorialSectionsPagerAdapter(this)
binding.tutorialViewpager.apply {
adapter = sectionsPagerAdapter
currentItem = 0
registerOnPageChangeCallback(object : ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) {
binding.tutorialButtonNext.apply {
val lastItem = sectionsPagerAdapter.itemCount - 1
visibility = if (position == lastItem) {
View.INVISIBLE
} else {
View.VISIBLE
}
if (position == 0) {
blink()
} else {
clearAnimation()
}
}
binding.tutorialButtonBack.apply {
visibility = if (position == 0) {
View.INVISIBLE
} else {
View.VISIBLE
}
}
}
})
}
TabLayoutMediator(binding.tutorialTabs, binding.tutorialViewpager) { _, _ -> }.attach()
binding.tutorialButtonNext.setOnClickListener {
binding.tutorialViewpager.apply {
setCurrentItem(
(currentItem + 1).coerceAtMost(sectionsPagerAdapter.itemCount - 1),
true
)
}
}
binding.tutorialButtonBack.setOnClickListener {
binding.tutorialViewpager.apply {
setCurrentItem((currentItem - 1).coerceAtLeast(0), true)
}
}
}
override fun getTheme(): Resources.Theme {
return modifyTheme(super.getTheme())
}
override fun onStart() {
super<AppCompatActivity>.onStart()
super<UIObject>.onStart()
}
// prevent going back when the tutorial is shown for the first time
@Deprecated("Deprecated in Java", ReplaceWith("use anyway"))
@Suppress("deprecation") // support API level < 33
override fun onBackPressed() {
if (LauncherPreferences.internal().started())
super.onBackPressed()
}
}
/**
* The [TutorialSectionsPagerAdapter] defines which fragments are shown when,
* in the [TutorialActivity].
*
* Tabs: (Start | Concept | Usage | Setup | Finish)
*/
class TutorialSectionsPagerAdapter(activity: FragmentActivity) :
FragmentStateAdapter(activity) {
override fun getItemCount(): Int {
return 6
}
override fun createFragment(position: Int): Fragment {
return when (position) {
0 -> TutorialFragment0Start()
1 -> TutorialFragment1Concept()
2 -> TutorialFragment2Usage()
3 -> TutorialFragment3AppList()
4 -> TutorialFragment4Setup()
5 -> TutorialFragment5Finish()
else -> Fragment()
}
}
}

View file

@ -0,0 +1,31 @@
package de.jrpie.android.launcher.ui.tutorial.tabs
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import de.jrpie.android.launcher.databinding.Tutorial0StartBinding
import de.jrpie.android.launcher.ui.UIObject
/**
* The [TutorialFragment0Start] is a used as a tab in the TutorialActivity.
*
* It displays info about the app and gets the user into the tutorial
*/
class TutorialFragment0Start : Fragment(), UIObject {
private lateinit var binding: Tutorial0StartBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding = Tutorial0StartBinding.inflate(inflater, container, false)
return binding.root
}
override fun onStart() {
super<Fragment>.onStart()
super<UIObject>.onStart()
}
}

View file

@ -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,27 +6,27 @@ import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import de.jrpie.android.launcher.BuildConfig
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.UIObject
import de.jrpie.android.launcher.databinding.TutorialConceptBinding
import de.jrpie.android.launcher.databinding.Tutorial1ConceptBinding
import de.jrpie.android.launcher.ui.UIObject
/**
* The [TutorialFragmentConcept] is a used as a tab in the TutorialActivity.
* The [TutorialFragment1Concept] is a used as a tab in the TutorialActivity.
*
* It is used to display info about Launchers concept (open source, efficiency ...)
*/
class TutorialFragmentConcept : Fragment(), UIObject {
private lateinit var binding: TutorialConceptBinding
class TutorialFragment1Concept : Fragment(), UIObject {
private lateinit var binding: Tutorial1ConceptBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val binding = TutorialConceptBinding.inflate(inflater, container, false)
): View {
binding = Tutorial1ConceptBinding.inflate(inflater, container, false)
binding.tutorialConceptBadgeVersion.text = BuildConfig.VERSION_NAME
return binding.root
}
override fun onStart(){
override fun onStart() {
super<Fragment>.onStart()
super<UIObject>.onStart()
}

View file

@ -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,23 +6,23 @@ 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.
* The [TutorialFragment2Usage] is a used as a tab in the TutorialActivity.
*
* Tells the user how his screen will look and how the app can be used
*/
class TutorialFragmentUsage : Fragment(), UIObject {
class TutorialFragment2Usage : Fragment(), UIObject {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.tutorial_usage, container, false)
return inflater.inflate(R.layout.tutorial_2_usage, container, false)
}
override fun onStart(){
override fun onStart() {
super<Fragment>.onStart()
super<UIObject>.onStart()
}

View file

@ -0,0 +1,30 @@
package de.jrpie.android.launcher.ui.tutorial.tabs
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import de.jrpie.android.launcher.R
import de.jrpie.android.launcher.ui.UIObject
/**
* The [TutorialFragment3AppList] is a used as a tab in the TutorialActivity.
*
* Tells the user how his screen will look and how the app can be used
*/
class TutorialFragment3AppList : Fragment(), UIObject {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.tutorial_3_app_list, container, false)
}
override fun onStart() {
super<Fragment>.onStart()
super<UIObject>.onStart()
}
}

View file

@ -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,23 +6,23 @@ 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.
* The [TutorialFragment4Setup] is a used as a tab in the TutorialActivity.
*
* It is used to display info in the tutorial
*/
class TutorialFragmentSetup : Fragment(), UIObject {
class TutorialFragment4Setup : Fragment(), UIObject {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.tutorial_setup, container, false)
return inflater.inflate(R.layout.tutorial_4_setup, container, false)
}
override fun onStart(){
override fun onStart() {
super<Fragment>.onStart()
super<UIObject>.onStart()
}

View file

@ -0,0 +1,50 @@
package de.jrpie.android.launcher.ui.tutorial.tabs
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import de.jrpie.android.launcher.BuildConfig.VERSION_CODE
import de.jrpie.android.launcher.databinding.Tutorial5FinishBinding
import de.jrpie.android.launcher.preferences.LauncherPreferences
import de.jrpie.android.launcher.setDefaultHomeScreen
import de.jrpie.android.launcher.ui.UIObject
/**
* The [TutorialFragment5Finish] is a used as a tab in the TutorialActivity.
*
* It is used to display further resources and let the user start Launcher
*/
class TutorialFragment5Finish : Fragment(), UIObject {
private lateinit var binding: Tutorial5FinishBinding
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
savedInstanceState: Bundle?
): View {
binding = Tutorial5FinishBinding.inflate(inflater, container, false)
return binding.root
}
override fun onStart() {
super<Fragment>.onStart()
super<UIObject>.onStart()
}
override fun setOnClicks() {
super.setOnClicks()
binding.tutorialFinishButtonStart.setOnClickListener { finishTutorial() }
}
private fun finishTutorial() {
if (!LauncherPreferences.internal().started()) {
LauncherPreferences.internal().started(true)
LauncherPreferences.internal().startedTime(System.currentTimeMillis() / 1000L)
LauncherPreferences.internal().versionCode(VERSION_CODE)
}
context?.let { setDefaultHomeScreen(it, checkDefault = true) }
activity?.finish()
}
}

View file

@ -0,0 +1,19 @@
package de.jrpie.android.launcher.ui.util
import android.content.Context
import android.text.Html
import android.text.method.LinkMovementMethod
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatTextView
class HtmlTextView(context: Context, attr: AttributeSet?, int: Int) :
AppCompatTextView(context, attr, int) {
constructor(context: Context, attr: AttributeSet?) : this(context, attr, 0)
constructor(context: Context) : this(context, null, 0)
init {
@Suppress("deprecation") // required to support API level < 24
text = Html.fromHtml(text.toString())
movementMethod = LinkMovementMethod.getInstance()
}
}

View file

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_enabled="false" android:alpha="0.2" android:color="?android:color" />
<item android:color="?android:color" />
</selector>

Some files were not shown because too many files have changed in this diff Show more