Fix: Fixed the appSelectionDialog from not closing right.
Signed-off-by: HeCodes2Much <wayne6324@gmail.com>
This commit is contained in:
5
.github/ISSUE_TEMPLATE/config.yml
vendored
5
.github/ISSUE_TEMPLATE/config.yml
vendored
@@ -4,11 +4,8 @@ contact_links:
|
|||||||
url: https://github.com/orgs/community/discussions
|
url: https://github.com/orgs/community/discussions
|
||||||
about: Please ask and answer questions here.
|
about: Please ask and answer questions here.
|
||||||
- name: Organization wide discussions
|
- name: Organization wide discussions
|
||||||
url: https://github.com/orgs/HeAndroids2Much/discussions
|
url: https://github.com/orgs/DroidWorksStudio/discussions
|
||||||
about: For any discussion within our community
|
about: For any discussion within our community
|
||||||
- name: GitHub Security Bug Bounty
|
- name: GitHub Security Bug Bounty
|
||||||
url: https://bounty.github.com/
|
url: https://bounty.github.com/
|
||||||
about: Please report security vulnerabilities here.
|
about: Please report security vulnerabilities here.
|
||||||
- name: Email Me
|
|
||||||
url: mailto://wayne6324@proton.me
|
|
||||||
about: Contact me via sending email
|
|
||||||
@@ -339,15 +339,14 @@ class SettingsFragment : Fragment(),
|
|||||||
launcherFontDialog?.show()
|
launcherFontDialog?.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add this function to dismiss the dialog if it's showing
|
private var appSelectionDialog: AlertDialog? = null
|
||||||
private fun dismissDialogs() {
|
|
||||||
launcherFontDialog?.dismiss()
|
|
||||||
searchEngineDialog?.dismiss()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun showAppSelectionDialog(swipeType: Constants.Swipe) {
|
private fun showAppSelectionDialog(swipeType: Constants.Swipe) {
|
||||||
// Make sure this method is called within a lifecycle owner scope
|
// Make sure this method is called within a lifecycle owner scope
|
||||||
lifecycleScope.launch(Dispatchers.Main) {
|
lifecycleScope.launch(Dispatchers.Main) {
|
||||||
|
// Dismiss any existing dialog to prevent multiple dialogs open simultaneously
|
||||||
|
appSelectionDialog?.dismiss()
|
||||||
|
|
||||||
// Collect the flow of installed apps
|
// Collect the flow of installed apps
|
||||||
appInfoRepository.getDrawApps().collect { installedApps ->
|
appInfoRepository.getDrawApps().collect { installedApps ->
|
||||||
// Extract app names and package names
|
// Extract app names and package names
|
||||||
@@ -355,9 +354,9 @@ class SettingsFragment : Fragment(),
|
|||||||
val packageNames = installedApps.map { it.packageName }
|
val packageNames = installedApps.map { it.packageName }
|
||||||
|
|
||||||
// Build and display the dialog
|
// Build and display the dialog
|
||||||
val builder = AlertDialog.Builder(binding.root.context)
|
val dialogBuilder = MaterialAlertDialogBuilder(context)
|
||||||
builder.setTitle("Select an App")
|
dialogBuilder.setTitle("Select an App")
|
||||||
builder.setItems(appNames) { _, which ->
|
dialogBuilder.setItems(appNames) { _, which ->
|
||||||
val selectedPackageName = packageNames[which]
|
val selectedPackageName = packageNames[which]
|
||||||
when (swipeType) {
|
when (swipeType) {
|
||||||
Constants.Swipe.DoubleTap,
|
Constants.Swipe.DoubleTap,
|
||||||
@@ -368,11 +367,21 @@ class SettingsFragment : Fragment(),
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
builder.show()
|
|
||||||
|
// Assign the created dialog to launcherFontDialog
|
||||||
|
appSelectionDialog = dialogBuilder.create()
|
||||||
|
appSelectionDialog?.show()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add this function to dismiss the dialog if it's showing
|
||||||
|
private fun dismissDialogs() {
|
||||||
|
launcherFontDialog?.dismiss()
|
||||||
|
searchEngineDialog?.dismiss()
|
||||||
|
appSelectionDialog?.dismiss()
|
||||||
|
}
|
||||||
|
|
||||||
private fun handleSwipeAction(swipeType: Constants.Swipe, selectedPackageName: String) {
|
private fun handleSwipeAction(swipeType: Constants.Swipe, selectedPackageName: String) {
|
||||||
val selectedApp = context.getAppNameFromPackageName(selectedPackageName)
|
val selectedApp = context.getAppNameFromPackageName(selectedPackageName)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user