зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1207340 - Pref/Search Engine Suggestions UI can get out of sync. r=mcomella
This commit is contained in:
Родитель
5474338211
Коммит
bde80682bd
|
@ -635,9 +635,15 @@ public class BrowserSearch extends HomeFragment
|
||||||
|
|
||||||
// Show suggestions opt-in prompt only if suggestions are not enabled yet,
|
// 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.
|
// 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) {
|
if (!mSuggestionsEnabled && !suggestionsPrompted && mSuggestClient != null) {
|
||||||
showSuggestionsOptIn();
|
showSuggestionsOptIn();
|
||||||
|
} else {
|
||||||
|
removeSuggestionsOptIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
Log.e(LOGTAG, "Error getting search engine JSON", 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) {
|
private void maybeSetSuggestClient(final String suggestTemplate, final boolean isPrivate) {
|
||||||
if (mSuggestClient != null || isPrivate) {
|
if (isPrivate) {
|
||||||
|
mSuggestClient = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mSuggestClient != null) {
|
||||||
return;
|
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) {
|
private void setSuggestionsEnabled(final boolean enabled) {
|
||||||
// Clicking the yes/no buttons quickly can cause the click events be
|
// Clicking the yes/no buttons quickly can cause the click events be
|
||||||
// queued before the listeners are removed above, so it's possible
|
// queued before the listeners are removed above, so it's possible
|
||||||
|
|
Загрузка…
Ссылка в новой задаче