mirror of
https://github.com/twofas/2fas-android.git
synced 2024-11-23 18:59:54 +01:00
Fix WidgetSettings activity launch mode
This commit is contained in:
parent
888dfcaa02
commit
2a0afb3350
@ -5,7 +5,8 @@
|
||||
<activity
|
||||
android:name=".ui.settings.WidgetSettingsActivity"
|
||||
android:exported="true"
|
||||
android:label="Widget Setup">
|
||||
android:label="Widget Setup"
|
||||
android:launchMode="singleInstance">
|
||||
<intent-filter>
|
||||
<action android:name="android.appwidget.action.APPWIDGET_CONFIGURE" />
|
||||
</intent-filter>
|
||||
|
@ -33,9 +33,6 @@ class WidgetSettingsActivity : ComponentActivity(), AuthAware {
|
||||
AppWidgetManager.INVALID_APPWIDGET_ID
|
||||
) ?: AppWidgetManager.INVALID_APPWIDGET_ID
|
||||
|
||||
val resultValue = Intent().putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId)
|
||||
setResult(Activity.RESULT_CANCELED, resultValue)
|
||||
|
||||
authTracker.onWidgetSettingsScreen()
|
||||
|
||||
lifecycle.addObserver(
|
||||
@ -52,7 +49,7 @@ class WidgetSettingsActivity : ComponentActivity(), AuthAware {
|
||||
appWidgetId = appWidgetId,
|
||||
) {
|
||||
setResult(Activity.RESULT_OK, Intent().putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId))
|
||||
finish()
|
||||
finishAndRemoveTask()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.twofasapp.feature.widget.ui.settings
|
||||
|
||||
import androidx.activity.compose.BackHandler
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
@ -26,6 +27,7 @@ import com.twofasapp.designsystem.common.TwCircularProgressIndicator
|
||||
import com.twofasapp.designsystem.common.TwSwitch
|
||||
import com.twofasapp.designsystem.common.TwTextButton
|
||||
import com.twofasapp.designsystem.common.TwTopAppBar
|
||||
import com.twofasapp.designsystem.ktx.currentActivity
|
||||
import com.twofasapp.designsystem.service.DsServiceSimple
|
||||
import com.twofasapp.designsystem.service.asState
|
||||
import com.twofasapp.feature.widget.GlanceWidget
|
||||
@ -40,9 +42,13 @@ internal fun WidgetSettingsScreen(
|
||||
onSuccess: () -> Unit,
|
||||
) {
|
||||
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
|
||||
val context = LocalContext.current
|
||||
val activity = LocalContext.currentActivity
|
||||
val scope = rememberCoroutineScope()
|
||||
|
||||
BackHandler {
|
||||
activity.finishAndRemoveTask()
|
||||
}
|
||||
|
||||
LaunchedEffect(Unit) {
|
||||
viewModel.updateAppWidgetId(appWidgetId)
|
||||
}
|
||||
@ -52,7 +58,7 @@ internal fun WidgetSettingsScreen(
|
||||
onToggleService = { viewModel.toggleService(it) },
|
||||
onSave = {
|
||||
scope.launch {
|
||||
GlanceWidget().updateAll(context)
|
||||
GlanceWidget().updateAll(activity)
|
||||
viewModel.save()
|
||||
onSuccess()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user