From 4b4b2ba49c623eee89d178e61f285771bbcc4caf Mon Sep 17 00:00:00 2001 From: spkal01 Date: Sun, 27 Mar 2022 14:27:38 +0300 Subject: [PATCH] Cherish: Add Udfps Settings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Hưng Phan --- res/values/cherish_strings.xml | 6 ++ res/xml/cherish_settings_lockscreen.xml | 13 ++++ res/xml/cherish_settings_udfps.xml | 17 ++++ .../fragments/LockScreenSettings.java | 8 ++ src/com/cherish/settings/fragments/Udfps.java | 78 +++++++++++++++++++ 5 files changed, 122 insertions(+) create mode 100644 res/xml/cherish_settings_udfps.xml create mode 100644 src/com/cherish/settings/fragments/Udfps.java diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml index 83c8f2d..676ea14 100644 --- a/res/values/cherish_strings.xml +++ b/res/values/cherish_strings.xml @@ -613,5 +613,11 @@ Clockertino Spark Spark Circle + + + UDFPS haptic feedback + Vibrate when touching UDFPS icon + UDFPS settings + Customizations for the UDFPS diff --git a/res/xml/cherish_settings_lockscreen.xml b/res/xml/cherish_settings_lockscreen.xml index 04b4b7b..c0e5522 100644 --- a/res/xml/cherish_settings_lockscreen.xml +++ b/res/xml/cherish_settings_lockscreen.xml @@ -68,6 +68,19 @@ android:entries="@array/lock_screen_custom_clock_face_entries" android:entryValues="@array/lock_screen_custom_clock_face_values" /> + + + + + + + + + + + + + diff --git a/src/com/cherish/settings/fragments/LockScreenSettings.java b/src/com/cherish/settings/fragments/LockScreenSettings.java index 6c66dbf..33976e3 100644 --- a/src/com/cherish/settings/fragments/LockScreenSettings.java +++ b/src/com/cherish/settings/fragments/LockScreenSettings.java @@ -41,6 +41,7 @@ import android.os.SystemProperties; import android.provider.Settings; import com.android.settings.R; import com.android.settings.SettingsPreferenceFragment; +import com.android.internal.util.cherish.udfps.UdfpsUtils; import com.android.internal.util.cherish.CherishUtils; import com.cherish.settings.preferences.SystemSettingListPreference; import com.cherish.settings.preferences.CustomSeekBarPreference; @@ -61,6 +62,7 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements private static final String AOD_SCHEDULE_KEY = "always_on_display_schedule"; private static final String CUSTOM_CLOCK_FACE = Settings.Secure.LOCK_SCREEN_CUSTOM_CLOCK_FACE; private static final String DEFAULT_CLOCK = "com.android.keyguard.clock.DefaultClockController"; + private static final String UDFPS_CATEGORY = "udfps_category"; static final int MODE_DISABLED = 0; static final int MODE_NIGHT = 1; @@ -69,6 +71,7 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements static final int MODE_MIXED_SUNRISE = 4; private ListPreference mLockClockStyles; + private PreferenceCategory mUdfpsCategory; private Context mContext; Preference mAODPref; @@ -92,6 +95,11 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements e.printStackTrace(); } + mUdfpsCategory = findPreference(UDFPS_CATEGORY); + if (!UdfpsUtils.hasUdfpsSupport(getContext())) { + prefSet.removePreference(mUdfpsCategory); + } + mAODPref = findPreference(AOD_SCHEDULE_KEY); updateAlwaysOnSummary(); diff --git a/src/com/cherish/settings/fragments/Udfps.java b/src/com/cherish/settings/fragments/Udfps.java new file mode 100644 index 0000000..ee373b4 --- /dev/null +++ b/src/com/cherish/settings/fragments/Udfps.java @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2019-2022 The CherishOS Projects + * + * 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.app.Activity; +import android.app.WallpaperManager; +import android.content.ContentResolver; +import android.content.Context; +import android.content.Intent; +import android.content.res.Resources; +import android.hardware.fingerprint.FingerprintManager; +import android.net.Uri; +import android.os.Bundle; +import android.os.UserHandle; +import android.provider.Settings; + +import androidx.preference.ListPreference; +import androidx.preference.Preference.OnPreferenceChangeListener; +import androidx.preference.Preference; +import androidx.preference.PreferenceCategory; +import androidx.preference.PreferenceFragment; +import androidx.preference.PreferenceManager; +import androidx.preference.PreferenceScreen; +import androidx.preference.SwitchPreference; + +import com.android.internal.logging.nano.MetricsProto; +import com.android.internal.util.cherish.CherishUtils; + +import com.android.settings.R; +import com.android.settings.SettingsPreferenceFragment; +import com.android.settings.search.BaseSearchIndexProvider; +import com.android.settingslib.search.SearchIndexable; + +@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC) +public class Udfps extends SettingsPreferenceFragment implements + Preference.OnPreferenceChangeListener { + + + @Override + public void onCreate(Bundle icicle) { + super.onCreate(icicle); + addPreferencesFromResource(R.xml.cherish_settings_udfps); + + final PreferenceScreen prefSet = getPreferenceScreen(); + Resources resources = getResources(); + + } + + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + ContentResolver resolver = getActivity().getContentResolver(); + return false; + } + + @Override + public int getMetricsCategory() { + return MetricsProto.MetricsEvent.CHERISH_SETTINGS; + } + + /** + * For Search. + */ + public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = + new BaseSearchIndexProvider(R.xml.cherish_settings_udfps); +}