add Simple Clock on Android 10+

This commit is contained in:
tibbi 2022-06-19 17:49:07 +02:00
parent c6d692077a
commit df9f021b64
3 changed files with 34 additions and 19 deletions

View File

@ -1,5 +1,5 @@
package com.simplemobiletools.applauncher.extensions
import com.simplemobiletools.applauncher.helpers.predefinedPackageNames
import com.simplemobiletools.applauncher.helpers.getPredefinedPackageNames
fun String.isAPredefinedApp() = predefinedPackageNames.contains(this)
fun String.isAPredefinedApp() = getPredefinedPackageNames().contains(this)

View File

@ -1,24 +1,34 @@
package com.simplemobiletools.applauncher.helpers
import com.simplemobiletools.commons.helpers.isRPlus
const val WAS_REMOVE_INFO_SHOWN = "was_remove_info_shown"
const val CLOSE_APP = "close_app"
const val PORTRAIT_COLUMN_COUNT = "portrait_column_count"
const val LANDSCAPE_COLUMN_COUNT = "landscape_column_count"
const val SHOW_APP_NAME = "show_app_name"
val predefinedPackageNames = arrayListOf(
"com.simplemobiletools.calculator",
"com.simplemobiletools.calendar.pro",
"com.simplemobiletools.contacts.pro",
"com.simplemobiletools.dialer",
"com.simplemobiletools.draw.pro",
"com.simplemobiletools.filemanager.pro",
"com.simplemobiletools.flashlight",
"com.simplemobiletools.gallery.pro",
"com.simplemobiletools.keyboard",
"com.simplemobiletools.musicplayer",
"com.simplemobiletools.notes.pro",
"com.simplemobiletools.smsmessenger",
"com.simplemobiletools.thankyou",
"com.simplemobiletools.voicerecorder"
)
fun getPredefinedPackageNames(): ArrayList<String> {
val packages = arrayListOf(
"com.simplemobiletools.calculator",
"com.simplemobiletools.calendar.pro",
"com.simplemobiletools.contacts.pro",
"com.simplemobiletools.dialer",
"com.simplemobiletools.draw.pro",
"com.simplemobiletools.filemanager.pro",
"com.simplemobiletools.flashlight",
"com.simplemobiletools.gallery.pro",
"com.simplemobiletools.keyboard",
"com.simplemobiletools.musicplayer",
"com.simplemobiletools.notes.pro",
"com.simplemobiletools.smsmessenger",
"com.simplemobiletools.thankyou",
"com.simplemobiletools.voicerecorder"
)
if (isRPlus()) {
packages.add(2, "com.simplemobiletools.clock")
}
return packages
}

View File

@ -14,6 +14,7 @@ import com.simplemobiletools.applauncher.extensions.isAPredefinedApp
import com.simplemobiletools.applauncher.models.AppLauncher
import com.simplemobiletools.commons.extensions.getIntValue
import com.simplemobiletools.commons.extensions.getStringValue
import com.simplemobiletools.commons.helpers.isRPlus
class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_VERSION) {
private val MAIN_TABLE_NAME = "launchers"
@ -102,9 +103,13 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
R.string.voice_recorder_short
)
if (isRPlus()) {
titles.add(2, R.string.clock_short)
}
val cnt = titles.size
val resources = context.resources
val packages = predefinedPackageNames
val packages = getPredefinedPackageNames()
for (i in 0 until cnt) {
val appLauncher = AppLauncher(0, resources.getString(titles[i]), packages[i], 0)
addAppLauncher(appLauncher, db)