fix(app): actions crash
Signed-off-by: rhunk <101876869+rhunk@users.noreply.github.com>
This commit is contained in:
@@ -23,6 +23,8 @@ import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import me.rhunk.snapenhance.bridge.BridgeService
|
||||
import me.rhunk.snapenhance.common.BuildConfig
|
||||
import me.rhunk.snapenhance.common.Constants
|
||||
import me.rhunk.snapenhance.common.action.EnumAction
|
||||
import me.rhunk.snapenhance.common.bridge.wrapper.LocaleWrapper
|
||||
import me.rhunk.snapenhance.common.bridge.wrapper.LoggerWrapper
|
||||
import me.rhunk.snapenhance.common.bridge.wrapper.MappingsWrapper
|
||||
@@ -223,4 +225,16 @@ class RemoteSideContext(
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
fun launchActionIntent(action: EnumAction) {
|
||||
val intent = androidContext.packageManager.getLaunchIntentForPackage(
|
||||
Constants.SNAPCHAT_PACKAGE_NAME
|
||||
)
|
||||
if (intent == null) {
|
||||
shortToast("Can't execute action: Snapchat is not installed")
|
||||
return
|
||||
}
|
||||
intent.putExtra(EnumAction.ACTION_PARAMETER, action.key)
|
||||
androidContext.startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,13 +54,6 @@ class HomeRootSection : Routes.Route() {
|
||||
|
||||
private lateinit var activityLauncherHelper: ActivityLauncherHelper
|
||||
|
||||
private fun launchActionIntent(action: EnumAction) {
|
||||
val intent = context.androidContext.packageManager.getLaunchIntentForPackage(
|
||||
Constants.SNAPCHAT_PACKAGE_NAME
|
||||
)
|
||||
intent?.putExtra(EnumAction.ACTION_PARAMETER, action.key)
|
||||
context.androidContext.startActivity(intent)
|
||||
}
|
||||
|
||||
private val cards by lazy {
|
||||
EnumQuickActions.entries.map {
|
||||
@@ -70,7 +63,7 @@ class HomeRootSection : Routes.Route() {
|
||||
}.toMutableMap().apply {
|
||||
EnumAction.entries.forEach { action ->
|
||||
this[context.translation["actions.${action.key}.name"] to action.icon] = {
|
||||
launchActionIntent(action)
|
||||
context.launchActionIntent(action)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,12 +121,6 @@ class HomeSettings : Routes.Route() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun launchActionIntent(action: EnumAction) {
|
||||
val intent = context.androidContext.packageManager.getLaunchIntentForPackage(Constants.SNAPCHAT_PACKAGE_NAME)
|
||||
intent?.putExtra(EnumAction.ACTION_PARAMETER, action.key)
|
||||
context.androidContext.startActivity(intent)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun ShiftedRow(
|
||||
modifier: Modifier = Modifier,
|
||||
@@ -151,7 +145,7 @@ class HomeSettings : Routes.Route() {
|
||||
RowTitle(title = translation["actions_title"])
|
||||
EnumAction.entries.forEach { enumAction ->
|
||||
RowAction(key = enumAction.key) {
|
||||
launchActionIntent(enumAction)
|
||||
context.launchActionIntent(enumAction)
|
||||
}
|
||||
}
|
||||
RowAction(key = "regen_mappings") {
|
||||
|
||||
Reference in New Issue
Block a user