Updated on 2026-08-14
This commit is contained in:
parent
01c263e4e1
commit
3394ed1552
3 changed files with 10 additions and 19 deletions
|
|
@ -1,12 +1,15 @@
|
|||
package com.tangem.tap.common.finisher
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.tangem.core.navigation.finisher.AppFinisher
|
||||
import com.tangem.tap.MainActivity
|
||||
import com.tangem.tap.foregroundActivityObserver
|
||||
import com.tangem.tap.withForegroundActivity
|
||||
|
||||
internal class AndroidAppFinisher : AppFinisher {
|
||||
internal class AndroidAppFinisher(
|
||||
private val appContext: Context,
|
||||
) : AppFinisher {
|
||||
|
||||
override fun finish() {
|
||||
foregroundActivityObserver.withForegroundActivity { activity ->
|
||||
|
|
@ -15,14 +18,9 @@ internal class AndroidAppFinisher : AppFinisher {
|
|||
}
|
||||
|
||||
override fun restart() {
|
||||
foregroundActivityObserver.withForegroundActivity { activity ->
|
||||
activity.finish()
|
||||
|
||||
val intent = Intent(activity, MainActivity::class.java).apply {
|
||||
flags = Intent.FLAG_ACTIVITY_CLEAR_TOP
|
||||
}
|
||||
activity.startActivity(intent)
|
||||
Runtime.getRuntime().exit(0)
|
||||
val intent = Intent(appContext, MainActivity::class.java).apply {
|
||||
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
}
|
||||
appContext.startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package com.tangem.tap.di
|
||||
|
||||
import android.content.Context
|
||||
import com.tangem.core.navigation.feedback.FeedbackManager
|
||||
import com.tangem.core.navigation.finisher.AppFinisher
|
||||
import com.tangem.core.navigation.share.ShareManager
|
||||
|
|
@ -11,6 +12,7 @@ import com.tangem.tap.common.url.CustomTabsUrlOpener
|
|||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import javax.inject.Singleton
|
||||
|
||||
|
|
@ -32,5 +34,5 @@ internal object UtilsModule {
|
|||
|
||||
@Provides
|
||||
@Singleton
|
||||
fun provideAppFinisher(): AppFinisher = AndroidAppFinisher()
|
||||
fun provideAppFinisher(@ApplicationContext context: Context): AppFinisher = AndroidAppFinisher(context)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue