Cherish: Move FOD Related stuff to separate fragment

Signed-off-by: Jackeagle <jackeagle102@gmail.com>
Change-Id: I851a5d159b18f572e516ecb18b6e2bcb6ef285a2
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
Jackeagle
2021-05-15 03:29:07 -04:00
committed by Hưng Phan
parent 85920fef9c
commit fdb4b7a953
5 changed files with 183 additions and 48 deletions

View File

@@ -1135,6 +1135,7 @@
<!-- Screen off fod -->
<string name="lockscreen_fod_category">Fingerprint On Display</string>
<string name="fod_category_summary">Configure FOD View</string>
<string name="fod_gesture_title">Screen off FOD</string>
<string name="fod_gesture_summary">Allows unlocking the device without having to wake up the screen first</string>

View File

@@ -270,40 +270,13 @@
android:summary="@string/keyguard_show_battery_summary"
android:fragment="com.cherish.settings.fragments.KeygaurdBatteryBar" />
<PreferenceCategory
android:key="fod_category"
android:title="@string/lockscreen_fod_category">
<com.cherish.settings.preferences.SystemSettingSwitchPreference
android:key="fod_recognizing_animation"
android:title="@string/fod_recog_animation"
android:summary="@string/fod_recog_animation_summary"
android:defaultValue="false" />
<com.cherish.settings.preferences.SystemSettingListPreference
android:key="fod_anim"
android:title="@string/fod_recog_animation_effect_title"
android:summary="%s"
android:entries="@array/fod_recog_animation_entries"
android:entryValues="@array/fod_recog_animation_values"
android:defaultValue="0"
android:dependency="fod_recognizing_animation" />
<com.cherish.settings.preferences.SystemSettingListPreference
android:key="fod_color"
android:title="@string/fod_pressed_color_title"
android:summary="%s"
android:entries="@array/fod_pressed_color_entries"
android:entryValues="@array/fod_pressed_color_values"
android:defaultValue="0" />
<com.cherish.settings.preferences.SystemSettingSwitchPreference
android:key="fod_gesture"
android:title="@string/fod_gesture_title"
android:summary="@string/fod_gesture_summary"
android:defaultValue="false" />
</PreferenceCategory>
<!-- FOD Settings -->
<Preference
android:key="lockscreen_fod_category"
android:title="@string/lockscreen_fod_category"
android:icon="@drawable/ic_fingerprint"
android:summary="@string/fod_category_summary"
android:fragment="com.cherish.settings.fragments.lockscreen.FODSettings"/>
</PreferenceCategory>
</PreferenceScreen>

59
res/xml/fod_settings.xml Normal file
View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2020-2021 CherishOS 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"
xmlns:settings="http://schemas.android.com/apk/res/com.android.settings"
android:key="fod_category"
android:title="@string/lockscreen_fod_category">
<!-- FOD icon picker -->
<Preference
android:key="fod_icon_picker_category"
android:title="@string/fod_icon_picker_title"
android:summary="@string/fod_icon_picker_summary"
android:fragment="com.cherish.settings.fragments.lockscreen.FODIconPickerFragment" />
<com.cherish.settings.preferences.SystemSettingSwitchPreference
android:key="fod_recognizing_animation"
android:title="@string/fod_recog_animation"
android:summary="@string/fod_recog_animation_summary"
android:defaultValue="false" />
<com.cherish.settings.preferences.SystemSettingListPreference
android:key="fod_anim"
android:title="@string/fod_recog_animation_effect_title"
android:summary="%s"
android:entries="@array/fod_recog_animation_entries"
android:entryValues="@array/fod_recog_animation_values"
android:defaultValue="0"
android:dependency="fod_recognizing_animation" />
<com.cherish.settings.preferences.SystemSettingListPreference
android:key="fod_color"
android:title="@string/fod_pressed_color_title"
android:summary="%s"
android:entries="@array/fod_pressed_color_entries"
android:entryValues="@array/fod_pressed_color_values"
android:defaultValue="0" />
<com.cherish.settings.preferences.SystemSettingSwitchPreference
android:key="fod_gesture"
android:title="@string/fod_gesture_title"
android:summary="@string/fod_gesture_summary"
android:defaultValue="false" />
</PreferenceScreen>

View File

@@ -0,0 +1,111 @@
/*
* Copyright (C) 2021 The CherishOS 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.lockscreen;
import com.android.internal.logging.nano.MetricsProto;
import android.os.Bundle;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.os.UserHandle;
import android.provider.SearchIndexableResource;
import android.content.ContentResolver;
import android.content.res.Resources;
import android.provider.Settings;
import com.android.settings.R;
import android.os.SystemProperties;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceScreen;
import androidx.preference.PreferenceGroup;
import androidx.preference.PreferenceCategory;
import androidx.preference.Preference.OnPreferenceChangeListener;
import androidx.preference.SwitchPreference;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.Indexable;
import com.android.settingslib.search.SearchIndexable;
import java.util.Locale;
import android.text.TextUtils;
import android.view.View;
import com.android.settings.SettingsPreferenceFragment;
import com.cherish.settings.preferences.SystemSettingSwitchPreference;
import com.android.settings.Utils;
import android.util.Log;
import android.hardware.fingerprint.FingerprintManager;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.Collections;
@SearchIndexable
public class FODSettings extends SettingsPreferenceFragment implements
Preference.OnPreferenceChangeListener, Indexable {
private ContentResolver mResolver;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.fod_settings);
PreferenceScreen prefScreen = getPreferenceScreen();
boolean enableScreenOffFOD = getContext().getResources().
getBoolean(com.android.internal.R.bool.config_needCustomFODView);
Preference ScreenOffFODPref = (Preference) findPreference("fod_gesture");
if (!enableScreenOffFOD){
prefScreen.removePreference(ScreenOffFODPref);
}
}
public boolean onPreferenceChange(Preference preference, Object newValue) {
return false;
}
@Override
public int getMetricsCategory() {
return MetricsProto.MetricsEvent.CHERISH_SETTINGS;
}
public static final SearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider() {
@Override
public List<SearchIndexableResource> getXmlResourcesToIndex(Context context,
boolean enabled) {
final ArrayList<SearchIndexableResource> result = new ArrayList<>();
final SearchIndexableResource sir = new SearchIndexableResource(context);
sir.xmlResId = R.xml.fod_settings;
result.add(sir);
return result;
}
@Override
public List<String> getNonIndexableKeys(Context context) {
final List<String> keys = super.getNonIndexableKeys(context);
return keys;
}
};
}

View File

@@ -54,7 +54,9 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements
private static final String DATE_FONT_SIZE = "lockdate_font_size";
private static final String LOCKOWNER_FONT_SIZE = "lockowner_font_size";
private static final String AOD_SCHEDULE_KEY = "always_on_display_schedule";
private static final String LOCKSCREEN_FOD_CATEGORY = "lockscreen_fod_category";
private ContentResolver mResolver;
private Preference FODSettings;
static final int MODE_DISABLED = 0;
static final int MODE_NIGHT = 1;
@@ -77,20 +79,9 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements
final PreferenceScreen prefScreen = getPreferenceScreen();
Resources resources = getResources();
PreferenceCategory overallPreferences = (PreferenceCategory) findPreference("fod_category");
mResolver = getActivity().getContentResolver();
boolean enableScreenOffFOD = getContext().getResources().
getBoolean(com.android.internal.R.bool.config_supportsInDisplayFingerprint);
Preference ScreenOffFODPref = (Preference) findPreference("fod_gesture");
if (!enableScreenOffFOD){
overallPreferences.removePreference(ScreenOffFODPref);
}
if (!getResources().getBoolean(com.android.internal.R.bool.config_supportsInDisplayFingerprint)) {
prefScreen.removePreference(findPreference("fod_category"));
}
FODSettings = (Preference) findPreference(LOCKSCREEN_FOD_CATEGORY);
if (!getResources().getBoolean(com.android.internal.R.bool.config_needCustomFODView)) {
prefScreen.removePreference(FODSettings);
// Lock Clock Size
mClockFontSize = (CustomSeekBarPreference) findPreference(CLOCK_FONT_SIZE);