Bug 1207340 - Pref/Search Engine Suggestions UI can get out of sync. r=mcomella

This commit is contained in:
Prabhjyot Singh Sodhi 2015-11-13 02:20:00 +01:00
Родитель 5474338211
Коммит bde80682bd
1 изменённых файлов: 20 добавлений и 1 удалений

Просмотреть файл

@ -635,9 +635,15 @@ public class BrowserSearch extends HomeFragment
// Show suggestions opt-in prompt only if suggestions are not enabled yet,
// user hasn't been prompted and we're not on a private browsing tab.
// The prompt might have been inflated already when this view was previously called.
// Remove the opt-in prompt if it has been inflated in the view and dealt with by the user,
// or if we're on a private browsing tab
if (!mSuggestionsEnabled && !suggestionsPrompted && mSuggestClient != null) {
showSuggestionsOptIn();
} else {
removeSuggestionsOptIn();
}
} catch (JSONException e) {
Log.e(LOGTAG, "Error getting search engine JSON", e);
}
@ -667,7 +673,12 @@ public class BrowserSearch extends HomeFragment
}
private void maybeSetSuggestClient(final String suggestTemplate, final boolean isPrivate) {
if (mSuggestClient != null || isPrivate) {
if (isPrivate) {
mSuggestClient = null;
return;
}
if (mSuggestClient != null) {
return;
}
@ -716,6 +727,14 @@ public class BrowserSearch extends HomeFragment
});
}
private void removeSuggestionsOptIn() {
if (mSuggestionsOptInPrompt == null) {
return;
}
mSuggestionsOptInPrompt.setVisibility(View.GONE);
}
private void setSuggestionsEnabled(final boolean enabled) {
// Clicking the yes/no buttons quickly can cause the click events be
// queued before the listeners are removed above, so it's possible