Launch app main activities with the correct action and category
Fix #15
This commit is contained in:
parent
48e358b4f3
commit
8c6b6c5e91
@ -3,11 +3,9 @@ package de.mm20.launcher2.search.data
|
|||||||
import android.content.ActivityNotFoundException
|
import android.content.ActivityNotFoundException
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
|
||||||
import android.content.pm.LauncherActivityInfo
|
import android.content.pm.LauncherActivityInfo
|
||||||
import android.content.pm.LauncherApps
|
import android.content.pm.LauncherApps
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.content.pm.ShortcutInfo
|
|
||||||
import android.graphics.drawable.AdaptiveIconDrawable
|
import android.graphics.drawable.AdaptiveIconDrawable
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Process
|
import android.os.Process
|
||||||
@ -15,7 +13,6 @@ import android.os.UserHandle
|
|||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import de.mm20.launcher2.icons.LauncherIcon
|
import de.mm20.launcher2.icons.LauncherIcon
|
||||||
import de.mm20.launcher2.ktx.getSerialNumber
|
import de.mm20.launcher2.ktx.getSerialNumber
|
||||||
import de.mm20.launcher2.ktx.tryStartActivity
|
|
||||||
import de.mm20.launcher2.preferences.Settings.IconSettings.LegacyIconBackground
|
import de.mm20.launcher2.preferences.Settings.IconSettings.LegacyIconBackground
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
@ -77,24 +74,17 @@ class LauncherApp(
|
|||||||
|
|
||||||
override fun launch(context: Context, options: Bundle?): Boolean {
|
override fun launch(context: Context, options: Bundle?): Boolean {
|
||||||
val launcherApps = context.getSystemService<LauncherApps>()!!
|
val launcherApps = context.getSystemService<LauncherApps>()!!
|
||||||
if (isMainProfile) {
|
try {
|
||||||
val intent = Intent()
|
launcherApps.startMainActivity(
|
||||||
intent.component = ComponentName(`package`, activity)
|
ComponentName(`package`, activity),
|
||||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
launcherActivityInfo.user,
|
||||||
return context.tryStartActivity(intent, options)
|
null,
|
||||||
} else {
|
options
|
||||||
try {
|
)
|
||||||
launcherApps.startMainActivity(
|
} catch (e: SecurityException) {
|
||||||
ComponentName(`package`, activity),
|
return false
|
||||||
launcherActivityInfo.user,
|
} catch (e: ActivityNotFoundException) {
|
||||||
null,
|
return false
|
||||||
options
|
|
||||||
)
|
|
||||||
} catch (e: SecurityException) {
|
|
||||||
return false
|
|
||||||
} catch (e: ActivityNotFoundException) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user