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:
@@ -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