Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ac1c42f5 authored by John Spurlock's avatar John Spurlock
Browse files

Clean up search metadata for notification pages.

Remove custom providers for screens added purely via xml.
Add data keys for those that remain.

Change-Id: I28172a1937e40e853f929f3332e3640e63b65141
parent c9cf31ca
Loading
Loading
Loading
Loading
+2 −28
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@ import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.pm.Signature;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.os.Bundle;
@@ -54,9 +53,6 @@ import android.widget.SectionIndexer;
import android.widget.TextView;

import com.android.settings.R;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;

import java.text.Collator;
import java.util.ArrayList;
@@ -64,7 +60,8 @@ import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class AppNotificationSettings extends ListFragment implements Indexable {
/** Just a sectioned list of installed applications, nothing else to index **/
public class AppNotificationSettings extends ListFragment {
    private static final String TAG = "AppNotificationSettings";
    private static final boolean DEBUG = true;

@@ -586,27 +583,4 @@ public class AppNotificationSettings extends ListFragment implements Indexable {
            return true;
        }
    }

    // === Indexing ===

    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
        new BaseSearchIndexProvider() {
            @Override
            public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
                final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
                add(result, context, R.string.app_notifications_title);
                add(result, context, R.string.app_notifications_dialog_show);
                add(result, context, R.string.app_notifications_dialog_priority);
                add(result, context, R.string.app_notifications_dialog_visibility);
                return result;
            }

            private void add(List<SearchIndexableRaw> result, Context context, int title) {
                final Resources res = context.getResources();
                final SearchIndexableRaw data = new SearchIndexableRaw(context);
                data.title = res.getString(title);
                data.screenTitle = res.getString(R.string.app_notifications_title);
                result.add(data);
            }
        };
}
+1 −33
Original line number Diff line number Diff line
@@ -17,15 +17,12 @@
package com.android.settings.notification;

import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;
import android.preference.TwoStatePreference;
import android.provider.Settings;
@@ -33,14 +30,8 @@ import android.util.Log;

import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;

import java.util.ArrayList;
import java.util.List;

public class NotificationDisplaySettings extends SettingsPreferenceFragment implements Indexable {
public class NotificationDisplaySettings extends SettingsPreferenceFragment {
    private static final String TAG = "NotificationDisplaySettings";

    private static final String KEY_NOTIFICATION_PULSE = "notification_pulse";
@@ -183,29 +174,6 @@ public class NotificationDisplaySettings extends SettingsPreferenceFragment impl
                Settings.Secure.DISPLAY_INTERCEPTED_NOTIFICATIONS, 0));
    }

    // === Indexing ===

    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
        new BaseSearchIndexProvider() {
            @Override
            public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
                final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
                add(result, context, R.string.notification_display_settings);
                add(result, context, R.string.notification_pulse_title);
                add(result, context, R.string.lock_screen_notifications_title);
                add(result, context, R.string.zen_mode_notifications_title);
                return result;
            }

            private void add(List<SearchIndexableRaw> result, Context context, int title) {
                final Resources res = context.getResources();
                final SearchIndexableRaw data = new SearchIndexableRaw(context);
                data.title = res.getString(title);
                data.screenTitle = res.getString(R.string.notification_display_settings);
                result.add(data);
            }
        };

    // === Callbacks ===

    private final class SettingsObserver extends ContentObserver {
+1 −35
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.media.AudioManager;
import android.media.RingtoneManager;
@@ -42,14 +41,8 @@ import android.provider.Settings;
import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.SoundSettings;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;

import java.util.ArrayList;
import java.util.List;

public class NotificationSettings extends SettingsPreferenceFragment implements Indexable {
public class NotificationSettings extends SettingsPreferenceFragment {
    private static final String TAG = "NotificationSettings";

    private static final String KEY_MEDIA_VOLUME = "media_volume";
@@ -245,33 +238,6 @@ public class NotificationSettings extends SettingsPreferenceFragment implements
        }
    }

    // === Indexing ===

    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
        new BaseSearchIndexProvider() {
            @Override
            public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
                final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
                add(result, context, R.string.notification_settings);
                add(result, context, R.string.media_volume_option_title);
                add(result, context, R.string.alarm_volume_option_title);
                add(result, context, R.string.ring_volume_option_title);
                add(result, context, R.string.ringer_mode_title);
                add(result, context, R.string.ringtone_title);
                add(result, context, R.string.vibrate_when_ringing_title);
                add(result, context, R.string.manage_notification_access_title);
                return result;
            }

            private void add(List<SearchIndexableRaw> result, Context context, int title) {
                final Resources res = context.getResources();
                final SearchIndexableRaw data = new SearchIndexableRaw(context);
                data.title = res.getString(title);
                data.screenTitle = res.getString(R.string.notification_settings);
                result.add(data);
            }
        };

    // === Callbacks ===

    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
+1 −35
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.settings.notification;

import android.content.ContentResolver;
import android.content.Context;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.media.AudioManager;
import android.net.Uri;
@@ -27,23 +26,14 @@ import android.os.Handler;
import android.os.Vibrator;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceScreen;
import android.preference.TwoStatePreference;
import android.provider.Settings.System;
import android.util.Log;

import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
import com.android.settings.search.SearchIndexableRaw;

import java.util.ArrayList;
import java.util.List;

public class TouchSoundSettings extends SettingsPreferenceFragment implements Indexable {
public class TouchSoundSettings extends SettingsPreferenceFragment {
    private static final String TAG = "TouchSoundSettings";

    private static final String KEY_DIAL_PAD_TONES = "dial_pad_tones";
@@ -145,30 +135,6 @@ public class TouchSoundSettings extends SettingsPreferenceFragment implements In
        }
    }

    // === Indexing ===

    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
        new BaseSearchIndexProvider() {
            @Override
            public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
                final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
                add(result, context, R.string.touch_sound_settings);
                add(result, context, R.string.dial_pad_tones_title);
                add(result, context, R.string.screen_locking_sounds_title);
                add(result, context, R.string.other_touch_sounds_title);
                add(result, context, R.string.vibrate_on_touch_title);
                return result;
            }

            private void add(List<SearchIndexableRaw> result, Context context, int title) {
                final Resources res = context.getResources();
                final SearchIndexableRaw data = new SearchIndexableRaw(context);
                data.title = res.getString(title);
                data.screenTitle = res.getString(R.string.touch_sound_settings);
                result.add(data);
            }
        };

    // === Callbacks ===

    private final class SettingsObserver extends ContentObserver {
+31 −17
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.service.notification.Condition;
import android.service.notification.ZenModeConfig;
import android.text.format.DateFormat;
import android.util.Log;
import android.util.SparseArray;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Switch;
@@ -75,11 +76,29 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index

    private static final String KEY_AUTOMATIC = "automatic";
    private static final String KEY_WHEN = "when";
    private static final String KEY_START_TIME = "start_time";
    private static final String KEY_END_TIME = "end_time";

    private static final String KEY_AUTOMATION = "automation";
    private static final String KEY_ENTRY = "entry";
    private static final String KEY_CONDITION_PROVIDERS = "manage_condition_providers";

    private static final SparseArray<String> ALL_KEY_TITLES = allKeyTitles();

    private static SparseArray<String> allKeyTitles() {
        final SparseArray<String> rt = new SparseArray<String>();
        rt.put(R.string.zen_mode_general_category, KEY_GENERAL);
        rt.put(R.string.zen_mode_phone_calls, KEY_CALLS);
        rt.put(R.string.zen_mode_messages, KEY_MESSAGES);
        rt.put(R.string.zen_mode_automatic_category, KEY_AUTOMATIC);
        rt.put(R.string.zen_mode_when, KEY_WHEN);
        rt.put(R.string.zen_mode_start_time, KEY_START_TIME);
        rt.put(R.string.zen_mode_end_time, KEY_END_TIME);
        rt.put(R.string.zen_mode_automation_category, KEY_AUTOMATION);
        rt.put(R.string.manage_condition_providers, KEY_CONDITION_PROVIDERS);
        return rt;
    }

    private final Handler mHandler = new Handler();
    private final SettingsObserver mSettingsObserver = new SettingsObserver();

@@ -217,6 +236,7 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
        final FragmentManager mgr = getFragmentManager();

        mStart = new TimePickerPreference(mContext, mgr);
        mStart.setKey(KEY_START_TIME);
        mStart.setTitle(R.string.zen_mode_start_time);
        mStart.setCallback(new TimePickerPreference.Callback() {
            @Override
@@ -238,6 +258,7 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
        mStart.setDependency(mWhen.getKey());

        mEnd = new TimePickerPreference(mContext, mgr);
        mEnd.setKey(KEY_END_TIME);
        mEnd.setTitle(R.string.zen_mode_end_time);
        mEnd.setSummaryFormat(R.string.zen_mode_end_time_summary_format);
        mEnd.setCallback(new TimePickerPreference.Callback() {
@@ -449,25 +470,18 @@ public class ZenModeSettings extends SettingsPreferenceFragment implements Index
        new BaseSearchIndexProvider() {
            @Override
            public List<SearchIndexableRaw> getRawDataToIndex(Context context, boolean enabled) {
                final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>();
                add(result, context, R.string.zen_mode_settings_title);
                add(result, context, R.string.zen_mode_general_category);
                add(result, context, R.string.zen_mode_phone_calls);
                add(result, context, R.string.zen_mode_messages);
                add(result, context, R.string.zen_mode_automatic_category);
                add(result, context, R.string.zen_mode_when);
                add(result, context, R.string.zen_mode_start_time);
                add(result, context, R.string.zen_mode_end_time);
                return result;
            }

            private void add(List<SearchIndexableRaw> result, Context context, int title) {
                final int N = ALL_KEY_TITLES.size();
                final List<SearchIndexableRaw> result = new ArrayList<SearchIndexableRaw>(N);
                final Resources res = context.getResources();
                for (int i = 0; i < N; i++) {
                    final SearchIndexableRaw data = new SearchIndexableRaw(context);
                data.title = res.getString(title);
                    data.key = ALL_KEY_TITLES.valueAt(i);
                    data.title = res.getString(ALL_KEY_TITLES.keyAt(i));
                    data.screenTitle = res.getString(R.string.zen_mode_settings_title);
                    result.add(data);
                }
                return result;
            }
        };

    private final class SettingsObserver extends ContentObserver {
Loading