Improve Search results highlighting
- remove unnecessary code - use keyed Tag with a well known App key for preventing collisions - fix missing Brightness Level preference key (used for highlight) Change-Id: I070e3b8c3cb43da7addd34be192aade21951f57c
This commit is contained in:
@@ -204,19 +204,6 @@ public class SettingsPreferenceFragment extends PreferenceFragment implements Di
|
||||
}, DELAY_HIGHLIGHT_DURATION_MILLIS);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// Try locating the Preference View thru its tag
|
||||
View preferenceView = findPreferenceViewForKey(getView(), key);
|
||||
if (preferenceView != null ) {
|
||||
mPreferenceHighlighted = true;
|
||||
|
||||
preferenceView.setBackground(highlight);
|
||||
final int centerX = preferenceView.getWidth() / 2;
|
||||
final int centerY = preferenceView.getHeight() / 2;
|
||||
highlight.setHotspot(centerX, centerY);
|
||||
preferenceView.setPressed(true);
|
||||
preferenceView.setPressed(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,33 +222,6 @@ public class SettingsPreferenceFragment extends PreferenceFragment implements Di
|
||||
return -1;
|
||||
}
|
||||
|
||||
private View findPreferenceViewForKey(View root, String key) {
|
||||
if (checkTag(root, key)) {
|
||||
return root;
|
||||
}
|
||||
if (root instanceof ViewGroup) {
|
||||
final ViewGroup group = (ViewGroup) root;
|
||||
final int count = group.getChildCount();
|
||||
for (int n = 0; n < count; n++) {
|
||||
final View child = group.getChildAt(n);
|
||||
final View view = findPreferenceViewForKey(child, key);
|
||||
if (view != null) {
|
||||
return view;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean checkTag(View view, String key) {
|
||||
final Object tag = view.getTag();
|
||||
if (tag == null || !(tag instanceof String)) {
|
||||
return false;
|
||||
}
|
||||
final String prefKey = (String) tag;
|
||||
return (!TextUtils.isEmpty(prefKey) && prefKey.equals(key));
|
||||
}
|
||||
|
||||
protected void removePreference(String key) {
|
||||
Preference pref = findPreference(key);
|
||||
if (pref != null) {
|
||||
|
||||
Reference in New Issue
Block a user