Cherish:Hide FOD if devices not supported

Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
Hưng Phan
2021-07-04 14:14:15 +07:00
parent 02e2156ffe
commit 2a8495d42f
5 changed files with 80 additions and 188 deletions

View File

@@ -1132,8 +1132,11 @@
<string name="oos_qsclock">Qs clock</string>
<string name="oos_qsclock_summary">Display an oos like clock on qs</string>
<!-- Screen off fod -->
<string name="lockscreen_fod_category">Fingerprint On Display</string>
<!-- FOD Icon Picker -->
<string name="fod_icon_picker_category_title">FOD settings</string>
<!-- FOD animations -->
<string name="fod_recog_animation_category">FOD animation</string>
<string name="fod_category_summary">Configure FOD View</string>
<!-- FOD animations -->

View File

@@ -269,13 +269,61 @@
android:entryValues="@array/lockscreen_albumart_filter_values"
android:dependency="lockscreen_media_metadata"
android:defaultValue="0" />
<!-- 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>
<!-- FOD-->
<PreferenceCategory
android:key="fod_icon_picker"
android:title="@string/fod_icon_picker_category_title">
<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" />
<!-- Animated FOD icon -->
<com.cherish.settings.preferences.SystemSettingSwitchPreference
android:key="fod_icon_animation"
android:title="@string/fod_icon_animation"
android:summary="@string/fod_icon_animation_summary"
android:defaultValue="false" />
<com.cherish.settings.preferences.SystemSettingListPreference
android:key="fod_icon_anim_type"
android:title="@string/fod_icon_animation_effect_title"
android:summary="%s"
android:entries="@array/fod_icon_animation_entries"
android:entryValues="@array/fod_icon_animation_values"
android:defaultValue="0"
android:dependency="fod_icon_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" />
</PreferenceCategory>
<PreferenceCategory
android:title="@string/fod_recog_animation_category"
android:key="fod_animations">
<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" />
</PreferenceCategory>
</PreferenceScreen>

View File

@@ -1,69 +0,0 @@
<?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" />
<!-- Animated FOD icon -->
<com.cherish.settings.preferences.SystemSettingSwitchPreference
android:key="fod_icon_animation"
android:title="@string/fod_icon_animation"
android:summary="@string/fod_icon_animation_summary"
android:defaultValue="false" />
<com.cherish.settings.preferences.SystemSettingListPreference
android:key="fod_icon_anim_type"
android:title="@string/fod_icon_animation_effect_title"
android:summary="%s"
android:entries="@array/fod_icon_animation_entries"
android:entryValues="@array/fod_icon_animation_values"
android:defaultValue="0"
android:dependency="fod_icon_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" />
</PreferenceScreen>

View File

@@ -1,103 +0,0 @@
/*
* 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();
}
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

@@ -39,6 +39,7 @@ import android.provider.Settings;
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.SystemSettingListPreference;
import com.cherish.settings.preferences.CustomSeekBarPreference;
import com.cherish.settings.preferences.SecureSettingListPreference;
@@ -61,7 +62,8 @@ 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 static final String FOD_ANIMATION_CATEGORY = "fod_animations";
private static final String FOD_ICON_PICKER_CATEGORY = "fod_icon_picker";
private ContentResolver mResolver;
private Preference FODSettings;
@@ -75,6 +77,7 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements
private CustomSeekBarPreference mDateFontSize;
private CustomSeekBarPreference mOwnerInfoFontSize;
private CustomSeekBarPreference mCustomTextClockFontSize;
private PreferenceCategory mFODIconPickerCategory;
private Preference mAODPref;
@Override
@@ -83,13 +86,20 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements
addPreferencesFromResource(R.xml.cherish_settings_lockscreen);
ContentResolver resolver = getActivity().getContentResolver();
final PreferenceScreen prefScreen = getPreferenceScreen();
PreferenceScreen prefScreen = getPreferenceScreen();
Resources resources = getResources();
FODSettings = (Preference) findPreference(LOCKSCREEN_FOD_CATEGORY);
if (FODSettings != null
&& !getResources().getBoolean(com.android.internal.R.bool.config_needCustomFODView)) {
prefScreen.removePreference(FODSettings);
mFODIconPickerCategory = findPreference(FOD_ICON_PICKER_CATEGORY);
if (mFODIconPickerCategory != null && !FodUtils.hasFodSupport(getContext())) {
prefScreen.removePreference(mFODIconPickerCategory);
}
final PreferenceCategory fodCat = (PreferenceCategory) prefScreen
.findPreference(FOD_ANIMATION_CATEGORY);
final boolean isFodAnimationResources = CherishUtils.isPackageInstalled(getContext(),
getResources().getString(com.android.internal.R.string.config_fodAnimationPackage));
if (!isFodAnimationResources) {
prefScreen.removePreference(fodCat);
}
// Lock Clock Size
@@ -197,6 +207,9 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements
@Override
public List<String> getNonIndexableKeys(Context context) {
List<String> keys = super.getNonIndexableKeys(context);
if (!FodUtils.hasFodSupport(context)) {
keys.add(FOD_ICON_PICKER_CATEGORY);
}
return keys;
}
};