[1/2] OmniGears: add more settings page

CPU info overlay and MatLog

Change-Id: Ie4223a95d65d620bbd0fc410f539bb53f1cae637
diff --git a/res/xml/more_settings.xml b/res/xml/more_settings.xml
new file mode 100644
index 0000000..805db6e
--- /dev/null
+++ b/res/xml/more_settings.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--  Copyright (C) 2017 The OmniROM Project
+
+  This program is free software: you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation, either version 2 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ -->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+    android:key="more_settings"
+    android:title="@string/more_settings_title">
+
+        <PreferenceCategory
+            android:key="category_system"
+            android:title="@string/system_category">
+
+            <org.omnirom.omnigears.preference.GlobalSettingSwitchPreference
+                android:key="show_cpu_overlay"
+                android:title="@string/show_cpu_title"
+                android:summary="@string/show_cpu_summary"
+                android:defaultValue="false" />
+
+            <PreferenceScreen
+                android:key="logcat_app"
+                android:title="@string/logcat_app_title"
+                android:summary="@string/logcat_app_summary"
+                android:persistent="false" >
+                <intent android:action="android.intent.action.MAIN"
+                        android:targetPackage="org.omnirom.logcat"
+                        android:targetClass="com.pluscubed.logcat.ui.LogcatActivity" />
+            </PreferenceScreen>
+        </PreferenceCategory>
+</PreferenceScreen>
diff --git a/src/org/omnirom/omnigears/moresettings/MoreSettings.java b/src/org/omnirom/omnigears/moresettings/MoreSettings.java
new file mode 100644
index 0000000..7db55d4
--- /dev/null
+++ b/src/org/omnirom/omnigears/moresettings/MoreSettings.java
@@ -0,0 +1,86 @@
+/*
+ *  Copyright (C) 2017 The OmniROM Project
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+*/
+
+package org.omnirom.omnigears.moresettings;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v7.preference.ListPreference;
+import android.support.v7.preference.Preference;
+import android.support.v7.preference.PreferenceCategory;
+import android.support.v7.preference.PreferenceScreen;
+import android.provider.SearchIndexableResource;
+import android.util.Log;
+
+import com.android.internal.util.omni.PackageUtils;
+
+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 org.omnirom.omnigears.OmniDashboardFragment;
+
+import java.util.List;
+import java.util.ArrayList;
+
+public class MoreSettings extends SettingsPreferenceFragment implements Indexable {
+    private static final String TAG = "MoreSettings";
+
+    @Override
+    public int getMetricsCategory() {
+        return OmniDashboardFragment.ACTION_SETTINGS_OMNI;
+    }
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        addPreferencesFromResource(R.xml.more_settings);
+        // check for disabled logcat app
+        Preference logcatApp = findPreference("logcat_app");
+        if (logcatApp != null) {
+            PreferenceCategory systemPrefs = (PreferenceCategory) findPreference("category_system");
+            if (systemPrefs != null && !PackageUtils.isAvailableApp("org.omnirom.logcat", getActivity())) {
+                systemPrefs.removePreference(logcatApp);
+            }
+        }
+    }
+
+    public static final Indexable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+            new BaseSearchIndexProvider() {
+                @Override
+                public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
+                        boolean enabled) {
+                    ArrayList<SearchIndexableResource> result =
+                            new ArrayList<SearchIndexableResource>();
+
+                    SearchIndexableResource sir = new SearchIndexableResource(context);
+                    sir.xmlResId = R.xml.more_settings;
+                    result.add(sir);
+
+                    return result;
+                }
+
+                @Override
+                public List<String> getNonIndexableKeys(Context context) {
+                    ArrayList<String> result = new ArrayList<String>();
+                    return result;
+                }
+    };
+}