Skip to content

Commit

Permalink
Remove category title when searching passwords
Browse files Browse the repository at this point in the history
The title of the (only displayed) category causes confusion with
Talkback because it was counted as search result entry.
As it also doesn't need to be shown according to the latest
mocks, removing it should be just fine.

Bug: 808260
Change-Id: I870bb02f9f936dbf4f41ad3edb9cf1b9f0617dec
Reviewed-on: https://chromium-review.googlesource.com/918621
Reviewed-by: Theresa <twellington@chromium.org>
Commit-Queue: Friedrich Horschig <fhorschig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#536701}
  • Loading branch information
FHorschig authored and Commit Bot committed Feb 14, 2018
1 parent b095c52 commit 8a88898
Showing 1 changed file with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.support.annotation.IntDef;
import android.support.annotation.Nullable;
Expand Down Expand Up @@ -652,11 +653,17 @@ public void passwordListAvailable(int count) {

displayManageAccountLink();

PreferenceCategory profileCategory = new PreferenceCategory(getActivity());
profileCategory.setKey(PREF_KEY_CATEGORY_SAVED_PASSWORDS);
profileCategory.setTitle(R.string.section_saved_passwords);
profileCategory.setOrder(ORDER_SAVED_PASSWORDS);
getPreferenceScreen().addPreference(profileCategory);
PreferenceGroup passwordParent;
if (mSearchQuery == null) {
PreferenceCategory profileCategory = new PreferenceCategory(getActivity());
profileCategory.setKey(PREF_KEY_CATEGORY_SAVED_PASSWORDS);
profileCategory.setTitle(R.string.section_saved_passwords);
profileCategory.setOrder(ORDER_SAVED_PASSWORDS);
getPreferenceScreen().addPreference(profileCategory);
passwordParent = profileCategory;
} else {
passwordParent = getPreferenceScreen();
}
for (int i = 0; i < count; i++) {
SavedPasswordEntry saved = PasswordManagerHandlerProvider.getInstance()
.getPasswordManagerHandler()
Expand All @@ -676,12 +683,15 @@ public void passwordListAvailable(int count) {
args.putString(PASSWORD_LIST_URL, url);
args.putString(PASSWORD_LIST_PASSWORD, password);
args.putInt(PASSWORD_LIST_ID, i);
profileCategory.addPreference(screen);
passwordParent.addPreference(screen);
}
mNoPasswords = profileCategory.getPreferenceCount() == 0;
mNoPasswords = passwordParent.getPreferenceCount() == 0;
if (mNoPasswords) {
if (count == 0) displayEmptyScreenMessage(); // Show if the list was already empty.
getPreferenceScreen().removePreference(profileCategory);
if (mSearchQuery == null) {
// If not searching, the category needs to be removed again.
getPreferenceScreen().removePreference(passwordParent);
}
}
}

Expand Down

0 comments on commit 8a88898

Please sign in to comment.