[2/3] OmniGears: setting search index fixes
for propper creating we must provide our dashboard entries
directly in the xml file and not via manifest contribution
and while we are here fix all the wrong ListPreferences
added for left clock - must have persistent = false
Change-Id: I6ef79883202c564c05891b39b5815496401e7df5
diff --git a/res/xml/bars_settings.xml b/res/xml/bars_settings.xml
index 5589644..803b958 100644
--- a/res/xml/bars_settings.xml
+++ b/res/xml/bars_settings.xml
@@ -15,7 +15,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+ android:key="bars_settings"
+ android:title="@string/bars_settings_title" >
<PreferenceCategory
android:key="category_statusbar"
diff --git a/res/xml/battery_light_settings.xml b/res/xml/battery_light_settings.xml
index c5ef473..ad962fb 100644
--- a/res/xml/battery_light_settings.xml
+++ b/res/xml/battery_light_settings.xml
@@ -15,7 +15,9 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+ android:key="led_settings"
+ android:title="@string/battery_light_settings_title" >
<org.omnirom.omnigears.preference.SystemSettingSwitchPreference
android:key="battery_light_enabled"
diff --git a/res/xml/button_brightness_settings.xml b/res/xml/button_brightness_settings.xml
index 27f7ae2..928a649 100644
--- a/res/xml/button_brightness_settings.xml
+++ b/res/xml/button_brightness_settings.xml
@@ -15,7 +15,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+ android:key="button_brightness"
+ android:title="@string/button_backlight_title" >
<org.omnirom.omnigears.preference.SystemSettingSwitchPreference
android:key="button_backlight_enable"
diff --git a/res/xml/button_settings.xml b/res/xml/button_settings.xml
index b83d291..95c38d5 100644
--- a/res/xml/button_settings.xml
+++ b/res/xml/button_settings.xml
@@ -15,7 +15,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+ android:key="button_settings"
+ android:title="@string/button_settings_title" >
<PreferenceCategory
android:key="button_volume_keys"
diff --git a/res/xml/display_rotation.xml b/res/xml/display_rotation.xml
index 6831c33..38f0fa4 100644
--- a/res/xml/display_rotation.xml
+++ b/res/xml/display_rotation.xml
@@ -15,8 +15,9 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- android:title="@string/display_rotation_title"
- xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+ android:key="rotation_settings"
+ android:title="@string/display_rotation_title" >
<SwitchPreference
android:key="accelerometer"
diff --git a/res/xml/global_actions.xml b/res/xml/global_actions.xml
index 2748338..a317a03 100644
--- a/res/xml/global_actions.xml
+++ b/res/xml/global_actions.xml
@@ -16,8 +16,9 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- android:key="global_actions"
- android:title="@string/global_actions_title">
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+ android:key="global_actions"
+ android:title="@string/global_actions_title">
<PreferenceCategory
android:key="global_actions_anim"
diff --git a/res/xml/omni_dashboard_fragment.xml b/res/xml/omni_dashboard_fragment.xml
index 78cd6c7..0802e18 100644
--- a/res/xml/omni_dashboard_fragment.xml
+++ b/res/xml/omni_dashboard_fragment.xml
@@ -17,4 +17,49 @@
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/header_category_omni">
+
+ <Preference
+ android:key="style_settings"
+ android:title="@string/style_settings_title"
+ android:summary="@string/style_settings_summary"
+ android:icon="@drawable/ic_settings_style"
+ android:fragment="org.omnirom.omnigears.interfacesettings.StyleSettings" />
+
+ <Preference
+ android:key="device_parts"
+ android:title="@string/omni_device_parts"
+ android:icon="@drawable/ic_settings_omnigears"
+ android:fragment="org.omnirom.device.DeviceParts" />
+
+ <Preference
+ android:key="button_settings"
+ android:title="@string/button_settings_title"
+ android:icon="@drawable/ic_settings_buttons"
+ android:fragment="org.omnirom.omnigears.ButtonSettings" />
+
+ <Preference
+ android:key="bars_settings"
+ android:title="@string/bars_settings_title"
+ android:icon="@drawable/ic_bars_tile"
+ android:fragment="org.omnirom.omnigears.interfacesettings.BarsSettings" />
+
+ <Preference
+ android:key="rotation_settings"
+ android:title="@string/display_rotation_title"
+ android:summary="@string/display_rotation_summary"
+ android:icon="@drawable/ic_display_rotation_tile"
+ android:fragment="org.omnirom.omnigears.DisplayRotation" />
+
+ <Preference
+ android:key="led_settings"
+ android:title="@string/battery_light_settings_title"
+ android:icon="@drawable/ic_settings_leds"
+ android:fragment="org.omnirom.omnigears.batterylight.BatteryLightSettings" />
+
+ <Preference
+ android:key="more_settings"
+ android:title="@string/more_settings_title"
+ android:icon="@drawable/ic_settings_more"
+ android:fragment="org.omnirom.omnigears.moresettings.MoreSettings"
+ android:order="10" />
</PreferenceScreen>
diff --git a/res/xml/statusbar_battery_settings.xml b/res/xml/statusbar_battery_settings.xml
index 4ecf0c6..103f10a 100644
--- a/res/xml/statusbar_battery_settings.xml
+++ b/res/xml/statusbar_battery_settings.xml
@@ -15,7 +15,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+ android:title="@string/battery_title"
+ android:key="statusbar_battery">
<ListPreference
android:key="statusbar_battery_style"
diff --git a/res/xml/statusbar_clock_settings.xml b/res/xml/statusbar_clock_settings.xml
index e345434..d2ae3c7 100644
--- a/res/xml/statusbar_clock_settings.xml
+++ b/res/xml/statusbar_clock_settings.xml
@@ -13,8 +13,10 @@
-->
<PreferenceScreen
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+ android:title="@string/clock_title"
+ android:key="statusbar_clock">
<org.omnirom.omnigears.preference.SystemSettingSwitchPreference
android:key="status_bar_clock"
@@ -32,7 +34,8 @@
android:entries="@array/clock_style_entries"
android:entryValues="@array/clock_style_values"
android:title="@string/clock_title_enable"
- android:dependency="status_bar_clock" />
+ android:dependency="status_bar_clock"
+ android:persistent="false" />
<ListPreference
android:key="status_bar_am_pm"
@@ -40,7 +43,8 @@
android:title="@string/status_bar_am_pm_title"
android:entries="@array/entries_status_bar_am_pm"
android:entryValues="@array/values_status_bar_am_pm"
- android:dependency="status_bar_clock" />
+ android:dependency="status_bar_clock"
+ android:persistent="false" />
<ListPreference
android:key="clock_date_display"
@@ -48,28 +52,32 @@
android:summary="@string/clock_date_display_summary"
android:entries="@array/clock_date_display_entries"
android:entryValues="@array/clock_date_display_values"
- android:dependency="status_bar_clock" />
+ android:dependency="status_bar_clock"
+ android:persistent="false" />
<ListPreference
android:key="clock_date_style"
android:title="@string/clock_date_style"
android:entries="@array/clock_date_style_entries"
android:entryValues="@array/clock_date_style_values"
- android:dependency="status_bar_clock" />
+ android:dependency="status_bar_clock"
+ android:persistent="false" />
<ListPreference
android:key="clock_date_position"
android:title="@string/clock_date_position"
android:entries="@array/clock_date_position_entries"
android:entryValues="@array/clock_date_position_values"
- android:dependency="status_bar_clock" />
+ android:dependency="status_bar_clock"
+ android:persistent="false" />
<ListPreference
android:key="clock_date_format"
android:title="@string/clock_date_format"
android:entries="@array/clock_date_format_entries_values"
android:entryValues="@array/clock_date_format_entries_values"
- android:dependency="status_bar_clock" />
+ android:dependency="status_bar_clock"
+ android:persistent="false" />
</PreferenceScreen>
diff --git a/res/xml/style_settings.xml b/res/xml/style_settings.xml
index 639a2ce..b03adb2 100644
--- a/res/xml/style_settings.xml
+++ b/res/xml/style_settings.xml
@@ -15,7 +15,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+ android:key="style_settings"
+ android:title="@string/style_settings_title" >
<PreferenceCategory
android:key="category_theming"
diff --git a/res/xml/volume_steps.xml b/res/xml/volume_steps.xml
index e495ee7..c025273 100644
--- a/res/xml/volume_steps.xml
+++ b/res/xml/volume_steps.xml
@@ -12,8 +12,9 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
- android:title="@string/volume_steps_title"
- xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
+ xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
+ android:title="@string/volume_steps_title"
+ android:key="volume_steps">
<ListPreference
android:key="volume_steps_music"
diff --git a/src/org/omnirom/omnigears/ButtonSettings.java b/src/org/omnirom/omnigears/ButtonSettings.java
index 0a89373..b08bc55 100644
--- a/src/org/omnirom/omnigears/ButtonSettings.java
+++ b/src/org/omnirom/omnigears/ButtonSettings.java
@@ -39,7 +39,6 @@
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.Utils;
import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.dashboard.SummaryLoader;
diff --git a/src/org/omnirom/omnigears/interfacesettings/OmniThemePreferenceController.java b/src/org/omnirom/omnigears/interfacesettings/OmniThemePreferenceController.java
deleted file mode 100644
index e0e0b09..0000000
--- a/src/org/omnirom/omnigears/interfacesettings/OmniThemePreferenceController.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Copyright (C) 2017 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-package org.omnirom.omnigears.interfacesettings;
-
-import android.content.Context;
-import android.content.om.IOverlayManager;
-import android.content.om.OverlayInfo;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.os.RemoteException;
-import android.os.ServiceManager;
-import android.os.UserHandle;
-import android.support.annotation.VisibleForTesting;
-import android.support.v7.preference.ListPreference;
-import android.support.v7.preference.Preference;
-import android.text.TextUtils;
-import android.util.Log;
-
-import com.android.settings.R;
-import com.android.settings.core.PreferenceControllerMixin;
-import com.android.settings.core.instrumentation.MetricsFeatureProvider;
-import com.android.settings.overlay.FeatureFactory;
-import com.android.settingslib.core.AbstractPreferenceController;
-
-import libcore.util.Objects;
-
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.List;
-
-import static com.android.internal.logging.nano.MetricsProto.MetricsEvent.ACTION_THEME;
-
-public class OmniThemePreferenceController extends AbstractPreferenceController implements
- PreferenceControllerMixin, Preference.OnPreferenceChangeListener {
-
- private static final String KEY_THEME = "omni_theme_select";
- private static final String KEY_THEMES_DISABLED = "default";
- private static final String OMNI_THEME_PREFIX = "org.omnirom.";
-
- private final MetricsFeatureProvider mMetricsFeatureProvider;
- private final OverlayManager mOverlayService;
- private final PackageManager mPackageManager;
-
- public OmniThemePreferenceController(Context context) {
- this(context, ServiceManager.getService(Context.OVERLAY_SERVICE) != null
- ? new OverlayManager() : null);
- }
-
- @VisibleForTesting
- OmniThemePreferenceController(Context context, OverlayManager overlayManager) {
- super(context);
- mOverlayService = overlayManager;
- mPackageManager = context.getPackageManager();
- mMetricsFeatureProvider = FeatureFactory.getFactory(context).getMetricsFeatureProvider();
- }
-
- @Override
- public String getPreferenceKey() {
- return KEY_THEME;
- }
-
- @Override
- public boolean handlePreferenceTreeClick(Preference preference) {
- if (KEY_THEME.equals(preference.getKey())) {
- mMetricsFeatureProvider.action(mContext, ACTION_THEME);
- }
- return false;
- }
-
- @Override
- public void updateState(Preference preference) {
- ListPreference pref = (ListPreference) preference;
- List<String> pkgs = new ArrayList<>(Arrays.asList(getAvailableThemes()));
- List<CharSequence> labels = new ArrayList<>(pkgs.size());
- for (String pkg : pkgs) {
- CharSequence label = null;
- try {
- label = mPackageManager.getApplicationInfo(pkg, 0).loadLabel(mPackageManager);
- } catch (NameNotFoundException e) {
- label = pkg;
- }
- labels.add(label);
- }
- labels.add(mContext.getString(R.string.omni_theme_select_none));
- pkgs.add(KEY_THEMES_DISABLED);
-
- pref.setEntries(labels.toArray(new CharSequence[labels.size()]));
- pref.setEntryValues(pkgs.toArray(new String[pkgs.size()]));
- String theme = getCurrentTheme();
- CharSequence themeLabel = null;
-
- if (theme != null) {
- int i = 0;
- for (String pkg : pkgs) {
- if (TextUtils.equals(pkg, theme)) {
- themeLabel = labels.get(i);
- break;
- }
- i++;
- }
- }
-
- if (TextUtils.isEmpty(themeLabel)) {
- themeLabel = mContext.getString(R.string.omni_theme_select_none);
- theme = KEY_THEMES_DISABLED;
- }
-
- pref.setSummary(themeLabel);
- pref.setValue(theme);
- }
-
- @Override
- public boolean onPreferenceChange(Preference preference, Object newValue) {
- String current = getTheme();
- if (Objects.equal(newValue, current)) {
- return true;
- }
- try {
- if (newValue.equals(KEY_THEMES_DISABLED)) {
- disableTheme();
- } else {
- mOverlayService.setEnabledExclusive((String) newValue, true, UserHandle.myUserId());
- }
- } catch (RemoteException e) {
- return false;
- }
- return true;
- }
-
- private boolean isChangeableOverlay(String packageName) {
- try {
- PackageInfo pi = mPackageManager.getPackageInfo(packageName, 0);
- return pi != null && (pi.overlayFlags & PackageInfo.FLAG_OVERLAY_STATIC) == 0;
- } catch (PackageManager.NameNotFoundException e) {
- return false;
- }
- }
-
- private String getTheme() {
- try {
- List<OverlayInfo> infos = mOverlayService.getOverlayInfosForTarget("android",
- UserHandle.myUserId());
- for (int i = 0, size = infos.size(); i < size; i++) {
- if (infos.get(i).isEnabled() &&
- isChangeableOverlay(infos.get(i).packageName)) {
- return infos.get(i).packageName;
- }
- }
- } catch (RemoteException e) {
- }
- return null;
- }
-
- private void disableTheme() {
- try {
- List<OverlayInfo> infos = mOverlayService.getOverlayInfosForTarget("android",
- UserHandle.myUserId());
- for (int i = 0, size = infos.size(); i < size; i++) {
- if (infos.get(i).isEnabled() &&
- infos.get(i).packageName.startsWith(OMNI_THEME_PREFIX) &&
- isChangeableOverlay(infos.get(i).packageName)) {
- mOverlayService.setEnabled(infos.get(i).packageName, false, UserHandle.myUserId());
- }
- }
- } catch (RemoteException e) {
- }
- }
-
- @Override
- public boolean isAvailable() {
- if (mOverlayService == null) return false;
- String[] themes = getAvailableThemes();
- return themes != null && themes.length >= 1;
- }
-
-
- @VisibleForTesting
- String getCurrentTheme() {
- return getTheme();
- }
-
- @VisibleForTesting
- String[] getAvailableThemes() {
- try {
- List<OverlayInfo> infos = mOverlayService.getOverlayInfosForTarget("android",
- UserHandle.myUserId());
- List<String> pkgs = new ArrayList(infos.size());
- for (int i = 0, size = infos.size(); i < size; i++) {
- if (infos.get(i).packageName.startsWith(OMNI_THEME_PREFIX) &&
- isChangeableOverlay(infos.get(i).packageName)) {
- pkgs.add(infos.get(i).packageName);
- }
- }
- return pkgs.toArray(new String[pkgs.size()]);
- } catch (RemoteException e) {
- }
- return new String[0];
- }
-
- public static class OverlayManager {
- private final IOverlayManager mService;
-
- public OverlayManager() {
- mService = IOverlayManager.Stub.asInterface(
- ServiceManager.getService(Context.OVERLAY_SERVICE));
- }
-
- public void setEnabledExclusive(String pkg, boolean enabled, int userId)
- throws RemoteException {
- mService.setEnabledExclusive(pkg, enabled, userId);
- }
-
- public void setEnabled(String pkg, boolean enabled, int userId)
- throws RemoteException {
- mService.setEnabled(pkg, enabled, userId);
- }
-
- public List<OverlayInfo> getOverlayInfosForTarget(String target, int userId)
- throws RemoteException {
- return mService.getOverlayInfosForTarget(target, userId);
- }
- }
-}
diff --git a/src/org/omnirom/omnigears/interfacesettings/StyleSettings.java b/src/org/omnirom/omnigears/interfacesettings/StyleSettings.java
index 9b4fd87..26e2c78 100644
--- a/src/org/omnirom/omnigears/interfacesettings/StyleSettings.java
+++ b/src/org/omnirom/omnigears/interfacesettings/StyleSettings.java
@@ -37,7 +37,7 @@
import com.android.settings.R;
import com.android.settings.Utils;
-import com.android.settings.dashboard.DashboardFragment;
+import com.android.settings.SettingsPreferenceFragment;
import com.android.settings.dashboard.SummaryLoader;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settings.search.Indexable;
@@ -52,7 +52,7 @@
import java.util.List;
import java.util.Map;
-public class StyleSettings extends DashboardFragment implements
+public class StyleSettings extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener, Indexable {
private static final String TAG = "StyleSettings";
private static final String CUSTOM_WALL_BROWSE = "custom_wall_browse";
@@ -91,18 +91,9 @@
}
@Override
- protected String getLogTag() {
- return TAG;
- }
-
- @Override
- protected int getPreferenceScreenResId() {
- return R.xml.style_settings;
- }
-
- @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.style_settings);
mDaylightHeaderProvider = getResources().getString(R.string.daylight_header_provider);
mFileHeaderProvider = getResources().getString(R.string.file_header_provider);
@@ -268,13 +259,6 @@
}
}
- @Override
- protected List<AbstractPreferenceController> getPreferenceControllers(Context context) {
- final List<AbstractPreferenceController> controllers = new ArrayList<>();
- //controllers.add(new OmniThemePreferenceController(context));
- return controllers;
- }
-
private void updateEnablement() {
String providerName = Settings.System.getString(getContentResolver(),
Settings.System.STATUS_BAR_CUSTOM_HEADER_PROVIDER);