diff --git a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt
index 8718d87..55b02dd 100644
--- a/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt
+++ b/app/src/main/java/eu/ottop/yamlauncher/MainActivity.kt
@@ -283,7 +283,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
lifecycleScope.launch(Dispatchers.Default) {
showHidden = true
refreshAppMenu()
- runOnUiThread {
+ runOnUiThread {
toAppMenu() // This is intentionally slow to happen
}
}
@@ -1189,7 +1189,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
println(leftSwipeActivity)
if (leftSwipeActivity.first != null && leftSwipeActivity.second != null) {
canLaunchShortcut = false
- launcherApps.startMainActivity(leftSwipeActivity.first!!.componentName, launcherApps.profiles[leftSwipeActivity.second!!], null, null)
+ appUtils.launchApp(leftSwipeActivity.first!!.componentName, launcherApps.profiles[leftSwipeActivity.second!!])
} else {
Toast.makeText(this@MainActivity, getString(R.string.launch_error), Toast.LENGTH_SHORT).show()
}
@@ -1200,7 +1200,7 @@ class MainActivity : AppCompatActivity(), SharedPreferences.OnSharedPreferenceCh
else if (deltaX > 0 && abs(deltaX) > swipeThreshold && abs(velocityX) > swipeVelocityThreshold && sharedPreferenceManager.isGestureEnabled("right")) {
if (rightSwipeActivity.first != null && rightSwipeActivity.second != null) {
canLaunchShortcut = false
- launcherApps.startMainActivity(rightSwipeActivity.first!!.componentName, launcherApps.profiles[rightSwipeActivity.second!!], null, null)
+ appUtils.launchApp(rightSwipeActivity.first!!.componentName, launcherApps.profiles[rightSwipeActivity.second!!])
} else {
Toast.makeText(this@MainActivity, getString(R.string.launch_error), Toast.LENGTH_SHORT).show()
}
diff --git a/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt b/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt
index 2b999ef..7712f62 100644
--- a/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt
+++ b/app/src/main/java/eu/ottop/yamlauncher/settings/SharedPreferenceManager.kt
@@ -67,6 +67,10 @@ class SharedPreferenceManager (private val context: Context) {
return preferences.getString("swipeVelocity", "100")?.toInt() ?: 100
}
+ fun isConfirmationEnabled(): Boolean {
+ return preferences.getBoolean("enableConfirmation", false)
+ }
+
// Home Screen
fun isClockEnabled(): Boolean {
return preferences.getBoolean("clockEnabled", true)
diff --git a/app/src/main/java/eu/ottop/yamlauncher/utils/AppUtils.kt b/app/src/main/java/eu/ottop/yamlauncher/utils/AppUtils.kt
index acd2138..8e9644b 100644
--- a/app/src/main/java/eu/ottop/yamlauncher/utils/AppUtils.kt
+++ b/app/src/main/java/eu/ottop/yamlauncher/utils/AppUtils.kt
@@ -1,11 +1,14 @@
package eu.ottop.yamlauncher.utils
+import android.app.AlertDialog
import android.content.ComponentName
import android.content.Context
import android.content.pm.ApplicationInfo
import android.content.pm.LauncherActivityInfo
import android.content.pm.LauncherApps
import android.os.UserHandle
+import androidx.core.content.ContextCompat.getString
+import eu.ottop.yamlauncher.R
import eu.ottop.yamlauncher.settings.SharedPreferenceManager
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
@@ -83,7 +86,31 @@ class AppUtils(private val context: Context, private val launcherApps: LauncherA
}
}
- fun launchApp(componentName: ComponentName, userHandle: UserHandle) {
+ private fun startApp(componentName: ComponentName, userHandle: UserHandle) {
launcherApps.startMainActivity(componentName, userHandle, null, null)
}
+
+ fun launchApp(componentName: ComponentName, userHandle: UserHandle) {
+ if (sharedPreferenceManager.isConfirmationEnabled()) {
+ showConfirmationDialog(componentName, userHandle)
+ } else {
+ startApp(componentName, userHandle)
+ }
+ }
+
+ private fun showConfirmationDialog(componentName: ComponentName, userHandle: UserHandle) {
+ AlertDialog.Builder(context).apply {
+ setTitle(getString(context, R.string.confirm_title))
+ setMessage(getString(context, R.string.launch_confirmation_text))
+
+ setPositiveButton(getString(context, R.string.confirm_yes)) { _, _ ->
+ startApp(componentName, userHandle)
+ }
+
+ setNegativeButton(getString(context, R.string.confirm_no)) { _, _ ->
+ }
+
+ }.create().show()
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index ba38a69..d054254 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -71,6 +71,8 @@
Schwellenwert für Wischen
Schwellenwert für Wischgeschwindigkeit
Statusleiste anzeigen
+ App-Bestätigungsdialog
+ Sind Sie sicher, dass Sie diese Anwendung starten möchten?
Startbildschirmeinstellungen
Startbildschirm
diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml
index 8d3e049..2c08053 100644
--- a/app/src/main/res/values-fi/strings.xml
+++ b/app/src/main/res/values-fi/strings.xml
@@ -69,6 +69,8 @@
Pyyhkäisyn Kynnysarvo
Pyyhkäisyn Nopeuden Kynnysarvo
Näytä Tilapalkki
+ Vahvistus Sovellusta Avatessa
+ Oletko varma, että haluat avata tämän sovelluksen?
Kotinäytön Asetukset
Kotinäyttö
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 703d45a..457dc3d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -71,6 +71,8 @@
Swipe Threshold
Swipe Velocity Threshold
Show Status Bar
+ App Confirmation Dialog
+ Are you sure you want to launch this app?
Home Screen Settings
Home Screen
diff --git a/app/src/main/res/xml/ui_preferences.xml b/app/src/main/res/xml/ui_preferences.xml
index 9562f1b..8cb5a64 100644
--- a/app/src/main/res/xml/ui_preferences.xml
+++ b/app/src/main/res/xml/ui_preferences.xml
@@ -80,6 +80,12 @@
android:defaultValue="false"
android:title="@string/show_status_bar"
app:key="barVisibility" />
+
\ No newline at end of file