Cherish: Add lockscreen background blur [2/2]

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
Pranav Vashi
2021-05-08 07:53:59 +05:30
committed by Hưng Phan
parent 76e0ea5f69
commit d979103998
4 changed files with 42 additions and 2 deletions

View File

@@ -1268,4 +1268,7 @@
<string name="theme_navbar_picker_nexus">Nexus</string>
<string name="theme_navbar_picker_old">Old</string>
<string name="theme_navbar_picker_sammy">Samsung</string>
<!-- Lockscreen blur -->
<string name="lockscreen_blur_title">Background blur</string>
</resources>

View File

@@ -66,6 +66,15 @@
android:icon="@drawable/ic_upset"
android:title="@string/always_on_display_schedule_title"
android:fragment="com.cherish.settings.fragments.AODSchedule" />
<com.cherish.settings.preferences.SystemSettingSeekBarPreference
android:key="lockscreen_blur"
android:title="@string/lockscreen_blur_title"
android:max="100"
settings:min="0"
settings:units="%"
settings:interval="5"
android:defaultValue="0" />
<com.cherish.settings.preferences.SystemSettingSwitchPreference
android:key="lockscreen_status_bar"

View File

@@ -40,6 +40,8 @@ import com.android.settings.R;
import com.android.settings.SettingsPreferenceFragment;
import com.android.internal.util.cherish.FodUtils;
import com.android.internal.util.cherish.CherishUtils;
import com.cherish.settings.preferences.SystemSettingSeekBarPreference;
import com.cherish.settings.utils.Utils;
import com.cherish.settings.preferences.SystemSettingListPreference;
import com.cherish.settings.preferences.CustomSeekBarPreference;
import com.cherish.settings.preferences.SecureSettingListPreference;
@@ -64,6 +66,8 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements
private static final String AOD_SCHEDULE_KEY = "always_on_display_schedule";
private static final String FOD_ANIMATION_CATEGORY = "fod_animations";
private static final String FOD_ICON_PICKER_CATEGORY = "fod_icon_picker";
private static final String KEY_LOCKSCREEN_BLUR = "lockscreen_blur";
private ContentResolver mResolver;
private Preference FODSettings;
@@ -73,10 +77,11 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements
static final int MODE_MIXED_SUNSET = 3;
static final int MODE_MIXED_SUNRISE = 4;
private SystemSettingSeekBarPreference mLockscreenBlur;
private CustomSeekBarPreference mClockFontSize;
private CustomSeekBarPreference mDateFontSize;
private CustomSeekBarPreference mOwnerInfoFontSize;
private CustomSeekBarPreference mCustomTextClockFontSize;
private CustomSeekBarPreference mCustomTextClockFontSize;
private PreferenceCategory mFODIconPickerCategory;
private Preference mAODPref;
@@ -88,6 +93,11 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements
ContentResolver resolver = getActivity().getContentResolver();
PreferenceScreen prefScreen = getPreferenceScreen();
Resources resources = getResources();
mLockscreenBlur = (SystemSettingSeekBarPreference) findPreference(KEY_LOCKSCREEN_BLUR);
if (!Utils.isBlurSupported()) {
prefScreen.removePreference(mLockscreenBlur);
}
mFODIconPickerCategory = findPreference(FOD_ICON_PICKER_CATEGORY);
if (mFODIconPickerCategory != null && !FodUtils.hasFodSupport(getContext())) {

View File

@@ -19,13 +19,23 @@ package com.cherish.settings.utils;
import static android.os.UserHandle.USER_SYSTEM;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.ActivityInfo;
import android.content.om.IOverlayManager;
import android.os.AsyncTask;
import android.os.RemoteException;
import android.widget.Toast;
import android.os.Build;
import android.os.SystemProperties;
import android.provider.Settings;
import com.android.settings.R;
import android.text.TextUtils;
import android.view.KeyCharacterMap;
import android.view.KeyEvent;
import android.view.Surface;
public class Utils {
@@ -36,5 +46,13 @@ public class Utils {
e.printStackTrace();
}
}
public static boolean isBlurSupported() {
boolean blurSupportedSysProp = SystemProperties
.getBoolean("ro.surface_flinger.supports_background_blur", false);
boolean blurDisabledSysProp = SystemProperties
.getBoolean("persist.sys.sf.disable_blurs", false);
return blurSupportedSysProp && !blurDisabledSysProp && ActivityManager.isHighEndGfx();
}
}