mirror of
https://github.com/SimpleMobileTools/Simple-App-Launcher.git
synced 2025-06-05 21:49:21 +02:00
show the dialog about removing launcher just once
This commit is contained in:
@ -6,6 +6,7 @@ import android.view.ViewGroup
|
|||||||
import com.simplemobiletools.applauncher.R
|
import com.simplemobiletools.applauncher.R
|
||||||
import com.simplemobiletools.applauncher.activities.SimpleActivity
|
import com.simplemobiletools.applauncher.activities.SimpleActivity
|
||||||
import com.simplemobiletools.applauncher.dialogs.EditDialog
|
import com.simplemobiletools.applauncher.dialogs.EditDialog
|
||||||
|
import com.simplemobiletools.applauncher.extensions.config
|
||||||
import com.simplemobiletools.applauncher.extensions.dbHelper
|
import com.simplemobiletools.applauncher.extensions.dbHelper
|
||||||
import com.simplemobiletools.applauncher.models.AppLauncher
|
import com.simplemobiletools.applauncher.models.AppLauncher
|
||||||
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
|
||||||
@ -55,7 +56,7 @@ class LaunchersAdapter(activity: SimpleActivity, val launchers: MutableList<AppL
|
|||||||
override fun actionItemPressed(id: Int) {
|
override fun actionItemPressed(id: Int) {
|
||||||
when (id) {
|
when (id) {
|
||||||
R.id.cab_edit -> showEditDialog()
|
R.id.cab_edit -> showEditDialog()
|
||||||
R.id.cab_remove -> askConfirmRemove()
|
R.id.cab_remove -> tryRemoveLauncher()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,8 +69,17 @@ class LaunchersAdapter(activity: SimpleActivity, val launchers: MutableList<AppL
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun tryRemoveLauncher() {
|
||||||
|
if (activity.config.wasRemoveInfoShown) {
|
||||||
|
removeItems()
|
||||||
|
} else {
|
||||||
|
askConfirmRemove()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun askConfirmRemove() {
|
private fun askConfirmRemove() {
|
||||||
ConfirmationDialog(activity, "", R.string.remove_explanation, R.string.ok, R.string.cancel) {
|
ConfirmationDialog(activity, "", R.string.remove_explanation, R.string.ok, R.string.cancel) {
|
||||||
|
activity.config.wasRemoveInfoShown = true
|
||||||
removeItems()
|
removeItems()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,4 +7,8 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
companion object {
|
companion object {
|
||||||
fun newInstance(context: Context) = Config(context)
|
fun newInstance(context: Context) = Config(context)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var wasRemoveInfoShown: Boolean
|
||||||
|
get() = prefs.getBoolean(WAS_REMOVE_INFO_SHOWN, false)
|
||||||
|
set(wasRemoveInfoShown) = prefs.edit().putBoolean(WAS_REMOVE_INFO_SHOWN, wasRemoveInfoShown).apply()
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.simplemobiletools.applauncher.helpers
|
package com.simplemobiletools.applauncher.helpers
|
||||||
|
|
||||||
|
const val WAS_REMOVE_INFO_SHOWN = "was_remove_info_shown"
|
||||||
|
|
||||||
val predefinedPackageNames = arrayListOf(
|
val predefinedPackageNames = arrayListOf(
|
||||||
"com.simplemobiletools.calculator",
|
"com.simplemobiletools.calculator",
|
||||||
"com.simplemobiletools.calendar",
|
"com.simplemobiletools.calendar",
|
||||||
|
Reference in New Issue
Block a user