From e08d03ef0197916479fd3e47c98608c6adbe43e4 Mon Sep 17 00:00:00 2001 From: Billy Brawner Date: Thu, 7 Nov 2019 17:20:40 -0600 Subject: [PATCH] Fix dialog dismissal when returning from settings --- .../simplemarkdown/view/activity/MainActivity.kt | 1 - .../simplemarkdown/view/fragment/MainMenuFragment.kt | 10 +++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.kt b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.kt index 8a6fcfd..f46f972 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.kt +++ b/app/src/main/java/com/wbrawner/simplemarkdown/view/activity/MainActivity.kt @@ -206,7 +206,6 @@ class MainActivity : AppCompatActivity(), ActivityCompat.OnRequestPermissionsRes viewModel.save(this@MainActivity, data.data) } } - REQUEST_DARK_MODE -> recreate() } super.onActivityResult(requestCode, resultCode, data) } diff --git a/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/MainMenuFragment.kt b/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/MainMenuFragment.kt index bedf810..77030e6 100644 --- a/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/MainMenuFragment.kt +++ b/app/src/main/java/com/wbrawner/simplemarkdown/view/fragment/MainMenuFragment.kt @@ -40,7 +40,6 @@ class MainMenuFragment : BottomSheetDialogFragment(), CoroutineScope { R.id.action_settings -> { val settingsIntent = Intent(context, SettingsActivity::class.java) startActivityForResult(settingsIntent, MainActivity.REQUEST_DARK_MODE) - dialog?.dismiss() } R.id.action_libraries -> showInfoActivity(context, R.id.action_libraries) R.id.action_privacy -> showInfoActivity(context, R.id.action_privacy) @@ -54,6 +53,15 @@ class MainMenuFragment : BottomSheetDialogFragment(), CoroutineScope { } } + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { + if (requestCode == MainActivity.REQUEST_DARK_MODE) { + activity?.recreate() + dialog?.dismiss() + return + } + super.onActivityResult(requestCode, resultCode, data) + } + private fun showInfoActivity(context: Context?, action: Int) { val infoIntent = Intent(context, MarkdownInfoActivity::class.java) var fileName = ""