add Simple Launchers settings as an icon

This commit is contained in:
tibbi 2022-09-25 18:45:50 +02:00
parent 012e0bdfc4
commit d86d35aa96
2 changed files with 13 additions and 0 deletions

View File

@ -364,6 +364,12 @@ class MainActivity : SimpleActivity(), FlingListener {
allApps.add(AppLauncher(null, label, packageName, 0, placeholderColor, drawable)) allApps.add(AppLauncher(null, label, packageName, 0, placeholderColor, drawable))
} }
// add Simple Launchers settings as an app
val drawable = getDrawableForPackageName(packageName)
val placeholderColor = calculateAverageColor(drawable!!.toBitmap())
val launcherSettings = AppLauncher(null, getString(R.string.launcher_settings), packageName, 0, placeholderColor, drawable)
allApps.add(launcherSettings)
val launchers = allApps.distinctBy { it.packageName } as ArrayList<AppLauncher> val launchers = allApps.distinctBy { it.packageName } as ArrayList<AppLauncher>
launchersDB.insertAll(launchers) launchersDB.insertAll(launchers)
return launchers return launchers

View File

@ -5,9 +5,16 @@ import android.content.Intent
import android.net.Uri import android.net.Uri
import android.provider.Settings import android.provider.Settings
import com.simplemobiletools.commons.extensions.showErrorToast import com.simplemobiletools.commons.extensions.showErrorToast
import com.simplemobiletools.launcher.activities.SettingsActivity
import com.simplemobiletools.launcher.helpers.UNINSTALL_APP_REQUEST_CODE import com.simplemobiletools.launcher.helpers.UNINSTALL_APP_REQUEST_CODE
fun Activity.launchApp(packageName: String) { fun Activity.launchApp(packageName: String) {
// if this is true, launch the app settings
if (packageName == this.packageName) {
startActivity(Intent(applicationContext, SettingsActivity::class.java))
return
}
val launchIntent = packageManager.getLaunchIntentForPackage(packageName) val launchIntent = packageManager.getLaunchIntentForPackage(packageName)
try { try {
startActivity(launchIntent) startActivity(launchIntent)