import android.content.Context;
import android.content.DialogInterface;
import android.content.pm.PackageManager;
+import android.database.DataSetObserver;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.preference.Preference;
private static final String TAG = "SettingsPreferenceFragment";
private static final int MENU_HELP = Menu.FIRST + 100;
- private static final int DELAY_HIGHLIGHT_DURATION_MILLIS = 300;
+ private static final int DELAY_HIGHLIGHT_DURATION_MILLIS = 400;
private static final String SAVE_HIGHLIGHTED_KEY = "android:preference_highlighted";
private String mPreferenceKey;
private boolean mPreferenceHighlighted = false;
+ private DataSetObserver mDataSetObserver = new DataSetObserver() {
+ @Override
+ public void onChanged() {
+ highlightPreferenceIfNeeded();
+ }
+
+ @Override
+ public void onInvalidated() {
+ highlightPreferenceIfNeeded();
+ }
+ };
+
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
@Override
protected void onBindPreferences() {
- highlightPreferenceIfNeeded();
+ getPreferenceScreen().getRootAdapter().registerDataSetObserver(mDataSetObserver);
+ }
+
+ @Override
+ public void onDestroy() {
+ super.onDestroy();
+
+ getPreferenceScreen().getRootAdapter().unregisterDataSetObserver(mDataSetObserver);
}
public void highlightPreferenceIfNeeded() {
- if (!mPreferenceHighlighted &&!TextUtils.isEmpty(mPreferenceKey)) {
+ if (isAdded() && !mPreferenceHighlighted &&!TextUtils.isEmpty(mPreferenceKey)) {
highlightPreference(mPreferenceKey);
}
}
final int serviceCount = services.size();
for (int i = 0; i < serviceCount; i++) {
PrintServiceInfo service = services.get(i);
+
+ ComponentName componentName = new ComponentName(
+ service.getResolveInfo().serviceInfo.packageName,
+ service.getResolveInfo().serviceInfo.name);
+
SearchIndexableRaw indexable = new SearchIndexableRaw(context);
+ indexable.key = componentName.flattenToString();
indexable.title = service.getResolveInfo().loadLabel(packageManager).toString();
indexable.summaryOn = context.getString(R.string.print_feature_state_on);
indexable.summaryOff = context.getString(R.string.print_feature_state_off);