mirror of
https://github.com/jrpie/Launcher.git
synced 2025-02-23 14:31:30 +01:00
Improve default apps choice algorithm
- Add new apps (TikTok, Brave browser, Tor browser, S Memo, etc...) - By default, choose the apps list and settings - Now have browsers on down-swipe
This commit is contained in:
parent
7245834138
commit
f46c1a278c
3 changed files with 108 additions and 89 deletions
|
@ -132,6 +132,8 @@ fun View.fadeRotateOut(duration: Long = 500L) {
|
||||||
/* Activity related */
|
/* Activity related */
|
||||||
|
|
||||||
fun isInstalled(uri: String, context: Context): Boolean {
|
fun isInstalled(uri: String, context: Context): Boolean {
|
||||||
|
if (uri.startsWith("launcher:")) return true // All internal actions
|
||||||
|
|
||||||
try {
|
try {
|
||||||
context.packageManager.getPackageInfo(uri, PackageManager.GET_ACTIVITIES)
|
context.packageManager.getPackageInfo(uri, PackageManager.GET_ACTIVITIES)
|
||||||
return true
|
return true
|
||||||
|
@ -251,9 +253,7 @@ fun loadSettings(){
|
||||||
vibrantColor = launcherPreferences.getInt("custom_vibrant", 0)
|
vibrantColor = launcherPreferences.getInt("custom_vibrant", 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resetSettings(context: Context) : MutableList<String>{
|
fun resetSettings(context: Context) {
|
||||||
|
|
||||||
val defaultList :MutableList<String> = mutableListOf<String>()
|
|
||||||
|
|
||||||
val editor = launcherPreferences.edit()
|
val editor = launcherPreferences.edit()
|
||||||
|
|
||||||
|
@ -269,64 +269,60 @@ fun resetSettings(context: Context) : MutableList<String>{
|
||||||
|
|
||||||
saveTheme("finn")
|
saveTheme("finn")
|
||||||
|
|
||||||
val (chosenUpName, chosenUpPackage) = pickDefaultApp(
|
editor.putString(
|
||||||
"action_upApp",
|
"action_upApp",
|
||||||
context
|
pickDefaultApp("action_upApp", context)
|
||||||
)
|
)
|
||||||
editor.putString("action_upApp", chosenUpPackage)
|
|
||||||
defaultList.add(chosenUpName)
|
|
||||||
|
|
||||||
val (chosenDownName, chosenDownPackage) = pickDefaultApp(
|
editor.putString(
|
||||||
"action_downApp",
|
"action_downApp",
|
||||||
context
|
pickDefaultApp("action_downApp", context)
|
||||||
)
|
)
|
||||||
editor.putString("action_downApp", chosenDownPackage)
|
|
||||||
defaultList.add(chosenDownName)
|
|
||||||
|
|
||||||
val (chosenRightName, chosenRightPackage) = pickDefaultApp(
|
editor.putString(
|
||||||
"action_rightApp",
|
"action_rightApp",
|
||||||
context
|
pickDefaultApp("action_rightApp", context)
|
||||||
)
|
)
|
||||||
editor.putString("action_rightApp", chosenRightPackage)
|
|
||||||
defaultList.add(chosenRightName)
|
|
||||||
|
|
||||||
val (chosenLeftName, chosenLeftPackage) = pickDefaultApp(
|
editor.putString(
|
||||||
"action_leftApp",
|
"action_leftApp",
|
||||||
context
|
pickDefaultApp("action_leftApp", context)
|
||||||
)
|
)
|
||||||
editor.putString("action_leftApp", chosenLeftPackage)
|
|
||||||
editor.putString("action_calendarApp", chosenLeftPackage)
|
|
||||||
defaultList.add(chosenLeftName)
|
|
||||||
|
|
||||||
val (chosenVolumeUpName, chosenVolumeUpPackage) = pickDefaultApp(
|
editor.putString(
|
||||||
|
"action_calendarApp",
|
||||||
|
pickDefaultApp("action_leftApp", context)
|
||||||
|
)
|
||||||
|
|
||||||
|
editor.putString(
|
||||||
"action_volumeUpApp",
|
"action_volumeUpApp",
|
||||||
context
|
pickDefaultApp("action_volumeUpApp",context)
|
||||||
)
|
)
|
||||||
editor.putString("action_volumeUpApp", chosenVolumeUpPackage)
|
|
||||||
defaultList.add(chosenVolumeUpName)
|
|
||||||
|
|
||||||
val (chosenVolumeDownName, chosenVolumeDownPackage) = pickDefaultApp(
|
editor.putString(
|
||||||
"action_volumeDownApp",
|
"action_volumeDownApp",
|
||||||
context
|
pickDefaultApp("action_volumeDownApp",context)
|
||||||
)
|
)
|
||||||
editor.putString("action_volumeDownApp", chosenVolumeDownPackage)
|
|
||||||
defaultList.add(chosenVolumeDownName)
|
|
||||||
|
|
||||||
editor.putString("action_doubleClickApp", "")
|
editor.putString(
|
||||||
editor.putString("action_longClickApp", "")
|
"action_doubleClickApp",
|
||||||
|
pickDefaultApp("action_doubleClickApp", context)
|
||||||
|
)
|
||||||
|
|
||||||
val (_, chosenClockPackage) = pickDefaultApp(
|
editor.putString(
|
||||||
|
"action_longClickApp",
|
||||||
|
pickDefaultApp("action_longClickApp", context)
|
||||||
|
)
|
||||||
|
|
||||||
|
editor.putString(
|
||||||
"action_clockApp",
|
"action_clockApp",
|
||||||
context
|
pickDefaultApp("action_clockApp", context)
|
||||||
)
|
)
|
||||||
editor.putString("action_clockApp", chosenClockPackage)
|
|
||||||
|
|
||||||
editor.apply()
|
editor.apply()
|
||||||
|
|
||||||
return defaultList // UP, DOWN, RIGHT, LEFT, VOLUME_UP, VOLUME_DOWN
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun pickDefaultApp(action: String, context: Context) : Pair<String, String>{
|
fun pickDefaultApp(action: String, context: Context) : String {
|
||||||
val arrayResource = when (action) {
|
val arrayResource = when (action) {
|
||||||
"action_upApp" -> R.array.default_up
|
"action_upApp" -> R.array.default_up
|
||||||
"action_downApp" -> R.array.default_down
|
"action_downApp" -> R.array.default_down
|
||||||
|
@ -334,20 +330,16 @@ fun pickDefaultApp(action: String, context: Context) : Pair<String, String>{
|
||||||
"action_leftApp" -> R.array.default_left
|
"action_leftApp" -> R.array.default_left
|
||||||
"action_volumeUpApp" -> R.array.default_volume_up
|
"action_volumeUpApp" -> R.array.default_volume_up
|
||||||
"action_volumeDownApp" -> R.array.default_volume_down
|
"action_volumeDownApp" -> R.array.default_volume_down
|
||||||
|
"action_doubleClickApp" -> R.array.default_double_click
|
||||||
|
"action_longClickApp" -> R.array.default_long_click
|
||||||
"action_clockApp" -> R.array.default_clock
|
"action_clockApp" -> R.array.default_clock
|
||||||
else -> return Pair(context.getString(R.string.none_found), "") // just prevent crashing on unknown input
|
else -> return "" // just prevent crashing on unknown input
|
||||||
}
|
}
|
||||||
|
|
||||||
// Related question: https://stackoverflow.com/q/3013655/12787264 (Adjusted)
|
|
||||||
val list = context.resources.getStringArray(arrayResource)
|
val list = context.resources.getStringArray(arrayResource)
|
||||||
for (entry in list){
|
for (packageName in list)
|
||||||
val splitResult = entry.split("|").toTypedArray()
|
if (isInstalled(packageName, context)) return packageName
|
||||||
val pkgname = splitResult[0]
|
return ""
|
||||||
val name = splitResult[1]
|
|
||||||
|
|
||||||
if (isInstalled(pkgname, context)) return Pair(name, pkgname)
|
|
||||||
}
|
|
||||||
return Pair(context.getString(R.string.none_found), "")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Bitmaps */
|
/* Bitmaps */
|
||||||
|
|
70
app/src/main/res/values/defaults.xml
Normal file
70
app/src/main/res/values/defaults.xml
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<resources>
|
||||||
|
<!-- Default Apps for different actions (button-press, swipes ...) -->
|
||||||
|
|
||||||
|
<!-- Swipe up - Apps list -->
|
||||||
|
<string-array name="default_up">
|
||||||
|
<item>launcher:choose</item> <!-- The apps list -->
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Swipe down - Browser -->
|
||||||
|
<string-array name="default_down">
|
||||||
|
<item>org.torproject.torbrowser</item> <!-- Tor Browser -->
|
||||||
|
<item>org.mozilla.firefox</item> <!-- Firefox -->
|
||||||
|
<item>com.brave.browser</item> <!-- Brave Browser -->
|
||||||
|
<item>com.duckduckgo.mobile.android</item> <!-- DuckDuckGo Browser -->
|
||||||
|
<item>com.sec.android.app.sbrowser</item> <!-- Samsung Internet -->
|
||||||
|
<item>com.android.chrome</item> <!-- Chrome -->
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Swipe right - Mail -->
|
||||||
|
<string-array name="default_right">
|
||||||
|
<item>de.web.mobile.android.mail</item> <!-- WebMail -->
|
||||||
|
<item>com.samsung.android.email.provider</item> <!-- Samsung Mail -->
|
||||||
|
<item>com.google.android.gm</item> <!-- Google Mail -->
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Swipe left - Calendar -->
|
||||||
|
<string-array name="default_left">
|
||||||
|
<item>com.google.android.calendar</item> <!-- Google Calendar -->
|
||||||
|
<item>com.samsung.android.calendar</item> <!-- Samsung Calendar -->
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Volume up - Messaging -->
|
||||||
|
<string-array name="default_volume_up">
|
||||||
|
<item>com.whatsapp</item> <!-- WhatsApp -->
|
||||||
|
<item>com.facebook.orca</item> <!-- Facebook Messenger -->
|
||||||
|
<item>com.viber.voip</item> <!-- Viber -->
|
||||||
|
<item>com.skype.raider</item> <!-- Skype -->
|
||||||
|
<item>com.snapchat.android</item> <!-- Snapchat -->
|
||||||
|
<item>com.instagram.android</item> <!-- Instagram -->
|
||||||
|
<item>com.zhiliaoapp.musically</item> <!-- TikTok -->
|
||||||
|
<item>com.samsung.android.messaging</item> <!-- Samsung SMS -->
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Volume down - Utility -->
|
||||||
|
<string-array name="default_volume_down">
|
||||||
|
<item>com.sec.android.app.popupcalculator</item> <!-- Samsung Calculator -->
|
||||||
|
<item>com.github.android</item> <!-- GitHub Android -->
|
||||||
|
<item>com.soundbrenner.pulse</item> <!-- Soundbrenner Metronome -->
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Double click - Notes -->
|
||||||
|
<string-array name="default_double_click">
|
||||||
|
<item>com.samsung.android.app.notes</item> <!-- Samsung Notes -->
|
||||||
|
<item>com.sec.android.widgetapp.diotek.smemo</item> <!-- S Memo (older devices) -->
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Long click - Security -->
|
||||||
|
<string-array name="default_long_click">
|
||||||
|
<item>com.twofasapp</item> <!-- 2 Factor Authentication -->
|
||||||
|
<item>launcher:settings</item> <!-- Launcher Settings -->
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
<!-- Clock -->
|
||||||
|
<string-array name="default_clock">
|
||||||
|
<item>com.sec.android.app.clockpackage</item> <!-- Android Clock -->
|
||||||
|
</string-array>
|
||||||
|
|
||||||
|
</resources>
|
|
@ -94,47 +94,4 @@
|
||||||
<string name="tutorial_finish_text">You are ready to get started!\n\n I hope this provides great value to you!\n\n- Finn M Glas\n(the developer)</string>
|
<string name="tutorial_finish_text">You are ready to get started!\n\n I hope this provides great value to you!\n\n- Finn M Glas\n(the developer)</string>
|
||||||
<string name="tutorial_finish_button">Start Launcher</string>
|
<string name="tutorial_finish_button">Start Launcher</string>
|
||||||
|
|
||||||
<!-- Default Apps for different actions (button-press, swipes ...) -->
|
|
||||||
<string-array name="default_up">
|
|
||||||
<item>org.mozilla.firefox|Firefox</item>
|
|
||||||
<item>com.sec.android.app.sbrowser|Samsung Internet</item>
|
|
||||||
<item>com.android.chrome|Chrome</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="default_down">
|
|
||||||
<item>com.samsung.android.app.galaxyfinder|GalaxyFinder</item>
|
|
||||||
<item>com.prometheusinteractive.voice_launcher|VoiceSearch</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="default_right">
|
|
||||||
<item>de.web.mobile.android.mail|WebMail</item>
|
|
||||||
<item>com.samsung.android.email.provider|Samsung Mail</item>
|
|
||||||
<item>com.google.android.gm|Google Mail</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="default_left">
|
|
||||||
<item>com.google.android.calendar|Google Calendar</item>
|
|
||||||
<item>com.samsung.android.calendar|Samsung Calendar</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="default_volume_up">
|
|
||||||
<item>com.whatsapp|WhatsApp</item>
|
|
||||||
<item>com.facebook.orca|Facebook Messenger</item>
|
|
||||||
<item>com.viber.voip|Viber</item>
|
|
||||||
<item>com.skype.raider|Skype</item>
|
|
||||||
<item>com.snapchat.android|Snapchat</item>
|
|
||||||
<item>com.instagram.android|Instagram</item>
|
|
||||||
<item>com.samsung.android.messaging|Samsung SMS</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="default_volume_down">
|
|
||||||
<item>com.github.android|GitHub</item>
|
|
||||||
<item>com.soundbrenner.pulse|Soundbrenner Metronome</item>
|
|
||||||
<item>com.sec.android.app.popupcalculator|Calculator</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
<string-array name="default_clock">
|
|
||||||
<item>com.sec.android.app.clockpackage|Android Clock</item>
|
|
||||||
</string-array>
|
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Add table
Reference in a new issue