From 07d283bddc7fdaa33ba566f2de49a058b71f6cc0 Mon Sep 17 00:00:00 2001 From: kik-btaski Date: Sun, 21 Jan 2024 19:18:10 +0530 Subject: [PATCH] fix: exit app after qs tile recording launch #186 Currently only works for screen recording --- .../com/bnyro/recorder/ui/MainActivity.kt | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/bnyro/recorder/ui/MainActivity.kt b/app/src/main/java/com/bnyro/recorder/ui/MainActivity.kt index 2ceaed60..5a8f95c6 100644 --- a/app/src/main/java/com/bnyro/recorder/ui/MainActivity.kt +++ b/app/src/main/java/com/bnyro/recorder/ui/MainActivity.kt @@ -16,12 +16,13 @@ import com.bnyro.recorder.ui.models.ThemeModel import com.bnyro.recorder.ui.theme.RecordYouTheme class MainActivity : ComponentActivity() { + private var initialRecorder = RecorderType.NONE + private var exit = false override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - val themeModel: ThemeModel by viewModels() - val initialRecorder = when (intent?.getStringExtra("action")) { + initialRecorder = when (intent?.getStringExtra("action")) { "audio" -> RecorderType.AUDIO "screen" -> RecorderType.VIDEO else -> RecorderType.NONE @@ -51,4 +52,20 @@ class MainActivity : ComponentActivity() { } } } + + override fun onPause() { + super.onPause() + if (initialRecorder != RecorderType.NONE) { + exit = true + initialRecorder = RecorderType.NONE + } + } + + override fun onResume() { + super.onResume() + if (exit) { + exit = false + finish() + } + } }