Cherish: notch-city: Add 3 mode display cutout handler [3/3]
[AgentFabulous - POSP] - Add the respective control in here - Also add a little video illustration I made to go along with it :) Signed-off-by: Kshitij Gupta <kshitijgm@gmail.com> Signed-off-by: Arghya Chanda <arghyac35@gmail.com> Change-Id: I8fe68610a50e2a430363dc09f4a9adb8a4563ad0 Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
12
res/drawable/ic_cutout.xml
Normal file
12
res/drawable/ic_cutout.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="30dp"
|
||||
android:height="30dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?android:attr/colorAccent">
|
||||
|
||||
<path
|
||||
android:fillColor="?android:attr/colorPrimary"
|
||||
android:pathData="M17,1L7,1C5.9,1,5,1.9,5,3v18c0,1.1,0.9,2,2,2h10c1.1,0,2-0.9,2-2V3C19,1.9,18.1,1,17,1z M17,5v1.6h0V20c0,0.6-0.4,1-1,1H8 c-0.6,0-1-0.4-1-1V6.6V5l0-0.9c0-0.6,0.4-1,1-1h1.7v1.1c0,0.3,0.3,0.6,0.6,0.6h3.5c0.3,0,0.6-0.3,0.6-0.6V3.1H16c0.6,0,1,0.4,1,1 L17,5z" />
|
||||
</vector>
|
||||
@@ -1242,4 +1242,16 @@
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="display_cutout_style_entries" translatable="false">
|
||||
<item>@string/display_cutout_style_normal</item>
|
||||
<item>@string/display_cutout_style_immerse</item>
|
||||
<item>@string/display_cutout_style_hide</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="display_cutout_style_values" translatable="false">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
|
||||
@@ -1158,4 +1158,14 @@
|
||||
<!-- Status Bar Lyric -->
|
||||
<string name="status_bar_show_lyric_title">Status bar lyric</string>
|
||||
<string name="status_bar_show_lyric_summary">Show lyric in status bar (need App support)</string>
|
||||
|
||||
<!-- Display cutout options -->
|
||||
<string name="cutout_main">Display Cutout</string>
|
||||
<string name="cutout_main_summary">They really cut corners with this one</string>
|
||||
<string name="display_cutout_style_title">Cutout style</string>
|
||||
<string name="display_cutout_style_normal">Normal</string>
|
||||
<string name="display_cutout_style_immerse">Immerse</string>
|
||||
<string name="display_cutout_style_hide">Hide</string>
|
||||
<string name="stock_statusbar_in_hide">Stock statusbar height</string>
|
||||
<string name="stock_statusbar_in_hide_summary">Use default statusbar height in Hide</string>
|
||||
</resources>
|
||||
|
||||
@@ -83,6 +83,12 @@
|
||||
android:summary="@string/carrier_label_settings_summary"
|
||||
android:fragment="com.cherish.settings.fragments.CustomCarrierLabel" />
|
||||
|
||||
<Preference
|
||||
android:key="cutout_settings"
|
||||
android:icon="@drawable/ic_cutout"
|
||||
android:fragment="com.cherish.settings.fragments.CutoutFragment"
|
||||
android:title="@string/cutout_main" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingListPreference
|
||||
android:key="status_bar_show_ticker"
|
||||
android:title="@string/ticker_screen_title"
|
||||
|
||||
37
res/xml/cutout.xml
Normal file
37
res/xml/cutout.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2018 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.
|
||||
-->
|
||||
|
||||
<PreferenceScreen
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:title="@string/cutout_main"
|
||||
xmlns:settings="http://schemas.android.com/apk/res-auto"
|
||||
android:key="cutout_settings">
|
||||
|
||||
<ListPreference
|
||||
android:key="display_cutout_style"
|
||||
android:title="@string/display_cutout_style_title"
|
||||
android:persistent="false"
|
||||
android:entries="@array/display_cutout_style_entries"
|
||||
android:entryValues="@array/display_cutout_style_values" />
|
||||
|
||||
<com.cherish.settings.preferences.SystemSettingSwitchPreference
|
||||
android:key="stock_statusbar_in_hide"
|
||||
android:title="@string/stock_statusbar_in_hide"
|
||||
android:summary="@string/stock_statusbar_in_hide_summary"
|
||||
android:defaultValue="true" />
|
||||
|
||||
</PreferenceScreen>
|
||||
@@ -46,6 +46,8 @@ public class StatusBarSettings extends SettingsPreferenceFragment implements
|
||||
|
||||
private SystemSettingMasterSwitchPreference mStatusBarLogo;
|
||||
|
||||
private static final String PREF_KEY_CUTOUT = "cutout_settings";
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
super.onCreate(icicle);
|
||||
@@ -61,6 +63,7 @@ public class StatusBarSettings extends SettingsPreferenceFragment implements
|
||||
Settings.System.STATUS_BAR_LOGO, 0) == 1));
|
||||
mStatusBarLogo.setOnPreferenceChangeListener(this);
|
||||
|
||||
Preference mCutoutPref = (Preference) findPreference(PREF_KEY_CUTOUT);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The Potato Open Sauce 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.cherish.settings.fragments;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.content.Context;
|
||||
import android.preference.Preference.OnPreferenceChangeListener;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.provider.Settings;
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceCategory;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.PreferenceFragment;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.search.Indexable;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CutoutFragment extends SettingsPreferenceFragment
|
||||
implements Preference.OnPreferenceChangeListener, Indexable {
|
||||
|
||||
private static final String KEY_DISPLAY_CUTOUT_STYLE = "display_cutout_style";
|
||||
private ListPreference mCutoutStyle;
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (preference == mCutoutStyle) {
|
||||
String value = (String) newValue;
|
||||
Settings.System.putInt(getContentResolver(), Settings.System.DISPLAY_CUTOUT_MODE, Integer.valueOf(value));
|
||||
int valueIndex = mCutoutStyle.findIndexOfValue(value);
|
||||
mCutoutStyle.setValueIndex(valueIndex >= 0 ? valueIndex : 0);
|
||||
mCutoutStyle.setSummary(mCutoutStyle.getEntries()[valueIndex]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.cutout);
|
||||
mCutoutStyle = (ListPreference) findPreference(KEY_DISPLAY_CUTOUT_STYLE);
|
||||
int cutoutStyle = Settings.System.getInt(getContentResolver(),
|
||||
Settings.System.DISPLAY_CUTOUT_MODE, 0);
|
||||
int valueIndex = mCutoutStyle.findIndexOfValue(String.valueOf(cutoutStyle));
|
||||
mCutoutStyle.setValueIndex(valueIndex >= 0 ? valueIndex : 0);
|
||||
mCutoutStyle.setSummary(mCutoutStyle.getEntry());
|
||||
mCutoutStyle.setOnPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = new BaseSearchIndexProvider() {
|
||||
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context, boolean enabled) {
|
||||
List<SearchIndexableResource> indexables = new ArrayList<>();
|
||||
SearchIndexableResource indexable = new SearchIndexableResource(context);
|
||||
indexable.xmlResId = R.xml.cutout;
|
||||
indexables.add(indexable);
|
||||
return indexables;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
List<String> keys = super.getNonIndexableKeys(context);
|
||||
return keys;
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user