Add advanced settings ui
Change-Id: I8bfe4f8e18e9ece7bec243c0db795c49a12301e5
Signed-off-by: Joey <bevilacquajoey@gmail.com>
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index c4879ad..cdcb8dd 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -102,8 +102,6 @@
android:resource="@string/summary_empty" />
</activity-alias>
- <activity android:name=".gestures.KeyHandler" />
-
<!-- Status bar settings (System category) -->
<activity-alias
android:name=".statusbar.StatusBarSettings"
@@ -125,5 +123,27 @@
android:name="com.android.settings.summary"
android:resource="@string/summary_empty" />
</activity-alias>
+
+ <!-- Advanced settings (System category) -->
+ <activity-alias
+ android:name=".advanced.AdvancedSettings"
+ android:label="@string/advanced_title"
+ android:icon="@drawable/ic_settings_advanced"
+ android:targetActivity="PartsActivity">
+ <intent-filter>
+ <action android:name="com.android.settings.action.IA_SETTINGS" />
+ <action android:name="com.shiftos.shiftparts.ADVANCED_SETTINGS" />
+ <category android:name="android.intent.category.DEFAULT" />
+ </intent-filter>
+ <meta-data
+ android:name="com.android.settings.category"
+ android:value="com.android.settings.category.ia.system" />
+ <meta-data
+ android:name="com.android.settings.order"
+ android:value="299" />
+ <meta-data
+ android:name="com.android.settings.summary"
+ android:resource="@string/summary_empty" />
+ </activity-alias>
</application>
</manifest>
diff --git a/res/drawable/ic_settings_advanced.xml b/res/drawable/ic_settings_advanced.xml
new file mode 100644
index 0000000..64f2ac6
--- /dev/null
+++ b/res/drawable/ic_settings_advanced.xml
@@ -0,0 +1,31 @@
+<!-- Copyright (C) 2020 Shift GmbH
+
+ 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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24"
+ android:tint="?android:attr/colorControlNormal">
+
+ <path
+ android:fillColor="@android:color/white"
+ android:pathData="M22.61 18.99l-9.08-9.08c0.93-2.34 0.45 -5.1-1.44-7C9.79 0.61 6.21 0.4 3.66
+2.26L7.5 6.11 6.08 7.52 2.25 3.69C0.39 6.23 0.6 9.82 2.9 12.11c1.86 1.86 4.57
+2.35 6.89 1.48l9.11 9.11c0.39 0.39 1.02 0.39 1.41 0l2.3-2.3c0.4-0.38 0.4 -1.01
+0-1.41zm-3 1.6l-9.46-9.46c-0.61 0.45 -1.29 0.72 -2 0.82-1.36 0.2
+-2.79-0.21-3.83-1.25C3.37 9.76 2.93 8.5 3 7.26l3.09 3.09
+4.24-4.24-3.09-3.09c1.24-0.07 2.49 0.37 3.44 1.31 1.08 1.08 1.49 2.57 1.24
+3.96-0.12 0.71 -0.42 1.37-0.88 1.96l9.45 9.45-0.88 0.89 z" />
+</vector>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 408b640..a17406a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -178,4 +178,9 @@
<string name="display_rotation_90_title">90 degrees</string>
<string name="display_rotation_180_title">180 degrees</string>
<string name="display_rotation_270_title">270 degrees</string>
+
+ <!-- Advanced mode -->
+ <string name="advanced_title">Advanced</string>
+ <string name="advanced_mode_title">Show more features</string>
+ <string name="advanced_mode_description">Enable advanced features for power users to unlock more customization options and extra capabilities.</string>
</resources>
diff --git a/res/xml/advanced_settings.xml b/res/xml/advanced_settings.xml
new file mode 100644
index 0000000..4754dca
--- /dev/null
+++ b/res/xml/advanced_settings.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 Shift GmbH
+
+ 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.
+-->
+
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:shift="http://schemas.android.com/apk/res/shiftos.platform"
+ android:key="button_settings"
+ android:title="@string/button_pref_title">
+
+ <shiftos.preference.ShiftSecureSettingSwitchPreference
+ android:key="advanced_mode"
+ android:title="@string/advanced_mode_title"
+ android:defaultValue="false" />
+
+ <com.shiftos.shiftparts.widget.WallOfTextPreference
+ android:summary="@string/advanced_mode_description" />
+</PreferenceScreen>
diff --git a/res/xml/parts_catalog.xml b/res/xml/parts_catalog.xml
index 54db80b..c820ccf 100644
--- a/res/xml/parts_catalog.xml
+++ b/res/xml/parts_catalog.xml
@@ -49,4 +49,9 @@
android:title="@string/power_menu_title"
android:fragment="com.shiftos.shiftparts.input.PowerMenuActions"
shift:xmlRes="@xml/power_menu_settings" />
+
+ <part android:key="advanced_settings"
+ android:title="@string/advanced_title"
+ android:fragment="com.shiftos.shiftparts.advanced.AdvancedSettings"
+ shift:xmlRes="@xml/advanced_settings" />
</parts-catalog>
diff --git a/src/com/shiftos/shiftparts/advanced/AdvancedSettings.java b/src/com/shiftos/shiftparts/advanced/AdvancedSettings.java
new file mode 100644
index 0000000..12eddaa
--- /dev/null
+++ b/src/com/shiftos/shiftparts/advanced/AdvancedSettings.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2014-2015 The CyanogenMod Project
+ * 2017-2019 The LineageOS 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 com.shiftos.shiftparts.advanced;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.util.ArraySet;
+
+import com.shiftos.shiftparts.R;
+import com.shiftos.shiftparts.SettingsPreferenceFragment;
+import com.shiftos.shiftparts.search.BaseSearchIndexProvider;
+import com.shiftos.shiftparts.search.Searchable;
+
+import java.util.Set;
+
+public class AdvancedSettings extends SettingsPreferenceFragment implements Searchable {
+
+ private static final String ADVANCED_MODE = "advanced_mode";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.xml.advanced_settings);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ }
+
+ public static final Searchable.SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
+ new BaseSearchIndexProvider() {
+
+ @Override
+ public Set<String> getNonIndexableKeys(Context context) {
+ final Set<String> result = new ArraySet<String>();
+
+ result.add(ADVANCED_MODE);
+ return result;
+ }
+ };
+}