From d74783a3fd91d1be45ac95f6b99df0d71eb3ed71 Mon Sep 17 00:00:00 2001 From: Finn M Glas Date: Sat, 30 May 2020 01:23:05 +0200 Subject: [PATCH] A few related fixes + Prevent opening app when clicking close to 3 dots icon + Enable dark popup background on older APIs + Prevent closing `ChooseActivity` when app is uninstalled --- .../main/java/com/finnmglas/launcher/ChooseActivity.kt | 5 ++++- .../finnmglas/launcher/choose/AppsRecyclerAdapter.kt | 3 +++ app/src/main/res/layout/recycler_apps_row.xml | 4 ++-- app/src/main/res/values/styles.xml | 10 ++++++++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/finnmglas/launcher/ChooseActivity.kt b/app/src/main/java/com/finnmglas/launcher/ChooseActivity.kt index 3b9b2bd..7c1c533 100644 --- a/app/src/main/java/com/finnmglas/launcher/ChooseActivity.kt +++ b/app/src/main/java/com/finnmglas/launcher/ChooseActivity.kt @@ -12,6 +12,8 @@ import com.finnmglas.launcher.choose.AppsRecyclerAdapter import com.finnmglas.launcher.extern.* import kotlinx.android.synthetic.main.activity_choose.* +var intendedChoosePause = false // know when to close + class ChooseActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -63,11 +65,12 @@ class ChooseActivity : AppCompatActivity() { override fun onPause() { super.onPause() intendedSettingsPause = false - finish() + if(!intendedChoosePause) finish() } override fun onResume() { super.onResume() + intendedChoosePause = false } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { diff --git a/app/src/main/java/com/finnmglas/launcher/choose/AppsRecyclerAdapter.kt b/app/src/main/java/com/finnmglas/launcher/choose/AppsRecyclerAdapter.kt index c70f59a..df1ed41 100644 --- a/app/src/main/java/com/finnmglas/launcher/choose/AppsRecyclerAdapter.kt +++ b/app/src/main/java/com/finnmglas/launcher/choose/AppsRecyclerAdapter.kt @@ -17,6 +17,7 @@ import com.finnmglas.launcher.extern.FontAwesome import com.finnmglas.launcher.extern.REQUEST_CHOOSE_APP import com.finnmglas.launcher.extern.REQUEST_UNINSTALL import com.finnmglas.launcher.extern.openAppSettings +import com.finnmglas.launcher.intendedChoosePause class AppsRecyclerAdapter(val activity: Activity, val action: String?, val forApp: String?): RecyclerView.Adapter() { @@ -70,6 +71,7 @@ class AppsRecyclerAdapter(val activity: Activity, val action: String?, val forAp popup.setOnMenuItemClickListener { when (it.itemId) { R.id.app_menu_delete -> { // delete + intendedChoosePause = true val intent = Intent(Intent.ACTION_UNINSTALL_PACKAGE) intent.data = Uri.parse("package:$appPackageName") intent.putExtra(Intent.EXTRA_RETURN_RESULT, true) @@ -78,6 +80,7 @@ class AppsRecyclerAdapter(val activity: Activity, val action: String?, val forAp true } R.id.app_menu_info -> { // open app settings + intendedChoosePause = true openAppSettings(appPackageName, activity) true } diff --git a/app/src/main/res/layout/recycler_apps_row.xml b/app/src/main/res/layout/recycler_apps_row.xml index b5146df..80da072 100644 --- a/app/src/main/res/layout/recycler_apps_row.xml +++ b/app/src/main/res/layout/recycler_apps_row.xml @@ -33,8 +33,8 @@ @style/Widget.AppCompat.Button.Colored @color/finnmglasTheme_accent_color + @style/PopupMenuCustom + true @style/WindowFadeTransition @@ -27,6 +29,8 @@ @style/Widget.AppCompat.Button.Colored @color/darkTheme_accent_color + @style/PopupMenuCustom + true @style/WindowFadeTransition @@ -37,10 +41,16 @@ @style/Widget.AppCompat.Button.Colored #252827 + @style/PopupMenuCustom + true @style/WindowFadeTransition + +