Merge "Fix the build: Revert "Improve Search results highlighting""
This commit is contained in:
@@ -19,7 +19,6 @@
|
|||||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
||||||
|
|
||||||
<com.android.settings.BrightnessPreference
|
<com.android.settings.BrightnessPreference
|
||||||
android:key="brightness"
|
|
||||||
android:title="@string/brightness"
|
android:title="@string/brightness"
|
||||||
android:persistent="false"/>
|
android:persistent="false"/>
|
||||||
|
|
||||||
|
@@ -360,8 +360,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
|
|||||||
|
|
||||||
mDataEnabled = new Switch(inflater.getContext());
|
mDataEnabled = new Switch(inflater.getContext());
|
||||||
mDataEnabledView = inflatePreference(inflater, mNetworkSwitches, mDataEnabled);
|
mDataEnabledView = inflatePreference(inflater, mNetworkSwitches, mDataEnabled);
|
||||||
mDataEnabledView.setTag(R.id.preference_highlight_key,
|
mDataEnabledView.setTag(DATA_USAGE_ENABLE_MOBILE_KEY);
|
||||||
DATA_USAGE_ENABLE_MOBILE_KEY);
|
|
||||||
mDataEnabled.setOnCheckedChangeListener(mDataEnabledListener);
|
mDataEnabled.setOnCheckedChangeListener(mDataEnabledListener);
|
||||||
mNetworkSwitches.addView(mDataEnabledView);
|
mNetworkSwitches.addView(mDataEnabledView);
|
||||||
|
|
||||||
@@ -369,8 +368,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
|
|||||||
mDisableAtLimit.setClickable(false);
|
mDisableAtLimit.setClickable(false);
|
||||||
mDisableAtLimit.setFocusable(false);
|
mDisableAtLimit.setFocusable(false);
|
||||||
mDisableAtLimitView = inflatePreference(inflater, mNetworkSwitches, mDisableAtLimit);
|
mDisableAtLimitView = inflatePreference(inflater, mNetworkSwitches, mDisableAtLimit);
|
||||||
mDisableAtLimitView.setTag(R.id.preference_highlight_key,
|
mDisableAtLimitView.setTag(DATA_USAGE_DISABLE_MOBILE_LIMIT_KEY);
|
||||||
DATA_USAGE_DISABLE_MOBILE_LIMIT_KEY);
|
|
||||||
mDisableAtLimitView.setClickable(true);
|
mDisableAtLimitView.setClickable(true);
|
||||||
mDisableAtLimitView.setFocusable(true);
|
mDisableAtLimitView.setFocusable(true);
|
||||||
mDisableAtLimitView.setOnClickListener(mDisableAtLimitListener);
|
mDisableAtLimitView.setOnClickListener(mDisableAtLimitListener);
|
||||||
@@ -379,7 +377,7 @@ public class DataUsageSummary extends HighlightingFragment implements Indexable
|
|||||||
|
|
||||||
// bind cycle dropdown
|
// bind cycle dropdown
|
||||||
mCycleView = mHeader.findViewById(R.id.cycles);
|
mCycleView = mHeader.findViewById(R.id.cycles);
|
||||||
mCycleView.setTag(R.id.preference_highlight_key, DATA_USAGE_CYCLE_KEY);
|
mCycleView.setTag(DATA_USAGE_CYCLE_KEY);
|
||||||
mCycleSpinner = (Spinner) mCycleView.findViewById(R.id.cycles_spinner);
|
mCycleSpinner = (Spinner) mCycleView.findViewById(R.id.cycles_spinner);
|
||||||
mCycleAdapter = new CycleAdapter(context);
|
mCycleAdapter = new CycleAdapter(context);
|
||||||
mCycleSpinner.setAdapter(mCycleAdapter);
|
mCycleSpinner.setAdapter(mCycleAdapter);
|
||||||
|
@@ -116,7 +116,7 @@ public class HighlightingFragment extends Fragment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkTag(View view, String key) {
|
private boolean checkTag(View view, String key) {
|
||||||
final Object tag = view.getTag(R.id.preference_highlight_key);
|
final Object tag = view.getTag();
|
||||||
if (tag == null || !(tag instanceof String)) {
|
if (tag == null || !(tag instanceof String)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -204,6 +204,19 @@ public class SettingsPreferenceFragment extends PreferenceFragment implements Di
|
|||||||
}, DELAY_HIGHLIGHT_DURATION_MILLIS);
|
}, 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,6 +235,33 @@ public class SettingsPreferenceFragment extends PreferenceFragment implements Di
|
|||||||
return -1;
|
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) {
|
protected void removePreference(String key) {
|
||||||
Preference pref = findPreference(key);
|
Preference pref = findPreference(key);
|
||||||
if (pref != null) {
|
if (pref != null) {
|
||||||
|
Reference in New Issue
Block a user