From 442b7b8712e81a8b7f4726bbfa852f45ed3e7baa Mon Sep 17 00:00:00 2001 From: Finn M Glas Date: Sat, 23 May 2020 11:57:52 +0200 Subject: [PATCH] Animate transition for openSettings() --- app/src/main/java/com/finnmglas/launcher/Functions.kt | 8 ++++---- .../main/java/com/finnmglas/launcher/MainActivity.kt | 1 + app/src/main/res/anim/bottom_up.xml | 10 ++++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 app/src/main/res/anim/bottom_up.xml diff --git a/app/src/main/java/com/finnmglas/launcher/Functions.kt b/app/src/main/java/com/finnmglas/launcher/Functions.kt index bb6bfa5..62845b4 100644 --- a/app/src/main/java/com/finnmglas/launcher/Functions.kt +++ b/app/src/main/java/com/finnmglas/launcher/Functions.kt @@ -128,10 +128,10 @@ private fun getIntent(packageName: String, context: Context): Intent? { } fun launchApp(packageName: String, context: Context) { - val intent1 = getIntent(packageName, context) + val intent = getIntent(packageName, context) - if (intent1 != null) { - context.startActivity(intent1) + if (intent != null) { + context.startActivity(intent) if (context is Activity) { context.overridePendingTransition(0, 0) @@ -139,7 +139,7 @@ fun launchApp(packageName: String, context: Context) { } else { if (isInstalled(packageName, context)){ - AlertDialog.Builder(context) + AlertDialog.Builder(context, R.style.AlertDialogCustom) .setTitle(context.getString(R.string.alert_cant_open_title)) .setMessage(context.getString(R.string.alert_cant_open_message)) .setPositiveButton(android.R.string.yes, diff --git a/app/src/main/java/com/finnmglas/launcher/MainActivity.kt b/app/src/main/java/com/finnmglas/launcher/MainActivity.kt index 1c93391..a7278ab 100644 --- a/app/src/main/java/com/finnmglas/launcher/MainActivity.kt +++ b/app/src/main/java/com/finnmglas/launcher/MainActivity.kt @@ -122,6 +122,7 @@ class MainActivity : AppCompatActivity(), private fun openSettings(){ startActivity(Intent(this, SettingsActivity::class.java)) + overridePendingTransition(R.anim.bottom_up, android.R.anim.fade_out) } /** Touch- and Key-related functions to start activities */ diff --git a/app/src/main/res/anim/bottom_up.xml b/app/src/main/res/anim/bottom_up.xml new file mode 100644 index 0000000..7832abf --- /dev/null +++ b/app/src/main/res/anim/bottom_up.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file