Skip to content

Commit

Permalink
For mozilla-mobile#12157: Don't show two search widget dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz committed Jul 2, 2020
1 parent ad8e28a commit ec6fde4
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion app/src/main/java/org/mozilla/fenix/cfr/SearchWidgetCFR.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ class SearchWidgetCFR(

fun displayIfNecessary() {
if (!context.settings().isInSearchWidgetExperiment ||
!context.settings().shouldDisplaySearchWidgetCFR()) { return }
!context.settings().shouldDisplaySearchWidgetCFR() ||
isShown
) { return }

isShown = true
showSearchWidgetCFR()
}

Expand All @@ -43,6 +47,7 @@ class SearchWidgetCFR(
context.settings().incrementSearchWidgetCFRDisplayed()

val searchWidgetCFRDialog = Dialog(context)

val layout = LayoutInflater.from(context)
.inflate(R.layout.search_widget_cfr, null)
val isBottomToolbar = Settings.getInstance(context).shouldUseBottomToolbar
Expand Down Expand Up @@ -85,14 +90,21 @@ class SearchWidgetCFR(
}

searchWidgetCFRDialog.setOnCancelListener {
isShown = false
context.components.analytics.metrics.track(Event.SearchWidgetCFRCanceled)
}

searchWidgetCFRDialog.setOnDismissListener {
isShown = false
context.settings().incrementSearchWidgetCFRDismissed()
}

searchWidgetCFRDialog.show()
context.components.analytics.metrics.track(Event.SearchWidgetCFRDisplayed)
}

companion object {
// Used to ensure multiple dialogs are not shown on top of each other
var isShown = false
}
}

0 comments on commit ec6fde4

Please sign in to comment.