Cherish: Custom Rounded Corner and Padding preferences [2/2] (WIP)
* Skipped statubar extra padding * Commented content padding Signed-off-by: spezi77 <spezi7713@gmx.net> Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
@@ -75,9 +75,6 @@
|
||||
|
||||
<!-- Power menu and dialogs opacity -->
|
||||
|
||||
<!-- Rounded corners -->
|
||||
<string name="corners_category_title">Rounded corners</string>
|
||||
|
||||
<!-- AOKP custom system animations -->
|
||||
|
||||
<!-- Power menu Animations -->
|
||||
@@ -1041,4 +1038,14 @@
|
||||
<!-- Allow fake signature -->
|
||||
<string name="allow_signature_fake">Allow signature spoofing</string>
|
||||
<string name="allow_signature_fake_summary">Allow apps to bypass security systems by pretending to be a different app.</string>
|
||||
|
||||
<!-- Rounded corners -->
|
||||
<string name="corners_category_title">Rounded corners (beta)</string>
|
||||
<string name="corners_category_summary">Adjust rounded corners and padding</string>
|
||||
<string name="corners_title">Customize rounded corners</string>
|
||||
<string name="corner_radius">Rounded corner radius</string>
|
||||
<string name="content_padding">Corner content padding</string>
|
||||
<string name="corner_fwvals">Use framework values</string>
|
||||
<string name="corner_fwvals_summary">Useful if the device actually has rounded corners</string>
|
||||
<string name="unit_pixels">dp</string>
|
||||
</resources>
|
||||
|
||||
@@ -77,4 +77,18 @@
|
||||
android:summary="@string/volume_steps_summary"
|
||||
android:icon="@drawable/ic_volume"
|
||||
android:fragment="com.cherish.settings.fragments.VolumeStepsFragment" />
|
||||
|
||||
<!-- Rounded Corners -->
|
||||
<PreferenceCategory
|
||||
android:key="rounded_corners_category"
|
||||
android:title="@string/corners_category_title">
|
||||
|
||||
<PreferenceScreen
|
||||
android:key="rounded_corners"
|
||||
android:title="@string/corners_title"
|
||||
android:icon="@drawable/ic_round"
|
||||
android:summary="@string/corners_category_summary"
|
||||
android:fragment="com.cherish.settings.fragments.RoundedCorners" />
|
||||
|
||||
</PreferenceCategory>
|
||||
</PreferenceScreen>
|
||||
|
||||
47
res/xml/rounded_corners.xml
Normal file
47
res/xml/rounded_corners.xml
Normal file
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2019 The PixelDust 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/corners_title"
|
||||
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings">
|
||||
|
||||
<com.cherish.settings.preferences.SecureSettingSwitchPreference
|
||||
android:key="sysui_rounded_fwvals"
|
||||
android:title="@string/corner_fwvals"
|
||||
android:icon="@drawable/ic_round"
|
||||
android:defaultValue="true"
|
||||
android:disableDependentsState="true" />
|
||||
|
||||
<com.cherish.settings.preferences.CustomSeekBarPreference
|
||||
android:key="sysui_rounded_size"
|
||||
android:title="@string/corner_radius"
|
||||
android:max="60"
|
||||
settings:min="0"
|
||||
settings:units="@string/unit_pixels"
|
||||
android:persistent="false"
|
||||
android:dependency="sysui_rounded_fwvals" />
|
||||
|
||||
<!--com.cherish.settings.preferences.CustomSeekBarPreference
|
||||
android:key="sysui_rounded_content_padding"
|
||||
android:title="@string/content_padding"
|
||||
android:max="30"
|
||||
settings:min="0"
|
||||
settings:units="@string/unit_pixels"
|
||||
android:persistent="false"
|
||||
android:dependency="sysui_rounded_fwvals" /-->
|
||||
|
||||
</PreferenceScreen>
|
||||
162
src/com/cherish/settings/fragments/RoundedCorners.java
Normal file
162
src/com/cherish/settings/fragments/RoundedCorners.java
Normal file
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The PixelDust 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.content.BroadcastReceiver;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.SystemProperties;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.preference.ListPreference;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.preference.Preference.OnPreferenceChangeListener;
|
||||
import androidx.preference.SwitchPreference;
|
||||
|
||||
import com.android.internal.logging.nano.MetricsProto;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.SettingsPreferenceFragment;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import com.cherish.settings.preferences.CustomSeekBarPreference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
public class RoundedCorners extends SettingsPreferenceFragment implements
|
||||
OnPreferenceChangeListener {
|
||||
|
||||
private static final String SYSUI_ROUNDED_SIZE = "sysui_rounded_size";
|
||||
//private static final String SYSUI_ROUNDED_CONTENT_PADDING = "sysui_rounded_content_padding";
|
||||
//private static final String SYSUI_STATUS_BAR_PADDING = "sysui_status_bar_padding";
|
||||
private static final String SYSUI_ROUNDED_FWVALS = "sysui_rounded_fwvals";
|
||||
|
||||
private CustomSeekBarPreference mCornerRadius;
|
||||
//private CustomSeekBarPreference mContentPadding;
|
||||
private SwitchPreference mRoundedFwvals;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
addPreferencesFromResource(R.xml.rounded_corners);
|
||||
|
||||
Resources res = null;
|
||||
Context ctx = getContext();
|
||||
float density = Resources.getSystem().getDisplayMetrics().density;
|
||||
|
||||
try {
|
||||
res = ctx.getPackageManager().getResourcesForApplication("com.android.systemui");
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Rounded Corner Radius
|
||||
mCornerRadius = (CustomSeekBarPreference) findPreference(SYSUI_ROUNDED_SIZE);
|
||||
int resourceIdRadius = (int) ctx.getResources().getDimension(com.android.internal.R.dimen.rounded_corner_radius);
|
||||
int cornerRadius = Settings.Secure.getIntForUser(ctx.getContentResolver(), Settings.Secure.SYSUI_ROUNDED_SIZE,
|
||||
((int) (resourceIdRadius / density)), UserHandle.USER_CURRENT);
|
||||
mCornerRadius.setValue(cornerRadius);
|
||||
mCornerRadius.setOnPreferenceChangeListener(this);
|
||||
|
||||
// Rounded Content Padding
|
||||
/*
|
||||
mContentPadding = (CustomSeekBarPreference) findPreference(SYSUI_ROUNDED_CONTENT_PADDING);
|
||||
int resourceIdPadding = res.getIdentifier("com.android.systemui:dimen/rounded_corner_content_padding", null,
|
||||
null);
|
||||
int contentPadding = Settings.Secure.getIntForUser(ctx.getContentResolver(),
|
||||
Settings.Secure.SYSUI_ROUNDED_CONTENT_PADDING,
|
||||
(int) (res.getDimension(resourceIdPadding) / density), UserHandle.USER_CURRENT);
|
||||
mContentPadding.setValue(contentPadding);
|
||||
mContentPadding.setOnPreferenceChangeListener(this);
|
||||
*/
|
||||
|
||||
// Rounded use Framework Values
|
||||
mRoundedFwvals = (SwitchPreference) findPreference(SYSUI_ROUNDED_FWVALS);
|
||||
mRoundedFwvals.setOnPreferenceChangeListener(this);
|
||||
}
|
||||
|
||||
private void restoreCorners() {
|
||||
Resources res = null;
|
||||
float density = Resources.getSystem().getDisplayMetrics().density;
|
||||
Context ctx = getContext();
|
||||
|
||||
try {
|
||||
res = ctx.getPackageManager().getResourcesForApplication("com.android.systemui");
|
||||
} catch (NameNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
int resourceIdRadius = (int) ctx.getResources().getDimension(com.android.internal.R.dimen.rounded_corner_radius);
|
||||
int cornerRadius = Settings.Secure.getIntForUser(ctx.getContentResolver(), Settings.Secure.SYSUI_ROUNDED_SIZE,
|
||||
((int) (resourceIdRadius / density)), UserHandle.USER_CURRENT);
|
||||
mCornerRadius.setValue(cornerRadius);
|
||||
//int resourceIdPadding = res.getIdentifier("com.android.systemui:dimen/rounded_corner_content_padding", null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onPreferenceChange(Preference preference, Object newValue) {
|
||||
if (preference == mCornerRadius) {
|
||||
Settings.Secure.putIntForUser(getContext().getContentResolver(), Settings.Secure.SYSUI_ROUNDED_SIZE,
|
||||
(int) newValue, UserHandle.USER_CURRENT);
|
||||
/*
|
||||
} else if (preference == mContentPadding) {
|
||||
Settings.Secure.putIntForUser(getContext().getContentResolver(), Settings.Secure.SYSUI_ROUNDED_CONTENT_PADDING,
|
||||
(int) newValue, UserHandle.USER_CURRENT);
|
||||
*/
|
||||
} else if (preference == mRoundedFwvals) {
|
||||
restoreCorners();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMetricsCategory() {
|
||||
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
|
||||
}
|
||||
|
||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider() {
|
||||
|
||||
@Override
|
||||
public List<SearchIndexableResource> getXmlResourcesToIndex(
|
||||
Context context, boolean enabled) {
|
||||
final SearchIndexableResource sir = new SearchIndexableResource(context);
|
||||
sir.xmlResId = R.xml.rounded_corners;
|
||||
return Arrays.asList(sir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getNonIndexableKeys(Context context) {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user