Skip to content

Commit

Permalink
Fix: Fixed the appSelectionDialog from not closing right.
Browse files Browse the repository at this point in the history
Signed-off-by: HeCodes2Much <wayne6324@gmail.com>
  • Loading branch information
CreativeCodeCat committed Jul 9, 2024
1 parent bb01d97 commit 3efe245
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
7 changes: 2 additions & 5 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ contact_links:
url: https://github.com/orgs/community/discussions
about: Please ask and answer questions here.
- 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
- name: GitHub Security Bug Bounty
url: https://bounty.github.com/
about: Please report security vulnerabilities here.
- name: Email Me
url: mailto://wayne6324@proton.me
about: Contact me via sending email
about: Please report security vulnerabilities here.
Original file line number Diff line number Diff line change
Expand Up @@ -339,25 +339,24 @@ class SettingsFragment : Fragment(),
launcherFontDialog?.show()
}

// Add this function to dismiss the dialog if it's showing
private fun dismissDialogs() {
launcherFontDialog?.dismiss()
searchEngineDialog?.dismiss()
}
private var appSelectionDialog: AlertDialog? = null

private fun showAppSelectionDialog(swipeType: Constants.Swipe) {
// Make sure this method is called within a lifecycle owner scope
lifecycleScope.launch(Dispatchers.Main) {
// Dismiss any existing dialog to prevent multiple dialogs open simultaneously
appSelectionDialog?.dismiss()

// Collect the flow of installed apps
appInfoRepository.getDrawApps().collect { installedApps ->
// Extract app names and package names
val appNames = installedApps.map { it.appName }.toTypedArray()
val packageNames = installedApps.map { it.packageName }

// Build and display the dialog
val builder = AlertDialog.Builder(binding.root.context)
builder.setTitle("Select an App")
builder.setItems(appNames) { _, which ->
val dialogBuilder = MaterialAlertDialogBuilder(context)
dialogBuilder.setTitle("Select an App")
dialogBuilder.setItems(appNames) { _, which ->
val selectedPackageName = packageNames[which]
when (swipeType) {
Constants.Swipe.DoubleTap,
Expand All @@ -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) {
val selectedApp = context.getAppNameFromPackageName(selectedPackageName)

Expand Down

0 comments on commit 3efe245

Please sign in to comment.