diff --git a/res/drawable/fod_icon_default.xml b/res/drawable/fod_icon_default.xml new file mode 100644 index 0000000..693917b --- /dev/null +++ b/res/drawable/fod_icon_default.xml @@ -0,0 +1,26 @@ + + + + + diff --git a/res/drawable/fod_icon_default_1.xml b/res/drawable/fod_icon_default_1.xml new file mode 100644 index 0000000..ffeafd7 --- /dev/null +++ b/res/drawable/fod_icon_default_1.xml @@ -0,0 +1,28 @@ + + + + + diff --git a/res/drawable/fod_icon_default_2.png b/res/drawable/fod_icon_default_2.png new file mode 100755 index 0000000..f83a70c Binary files /dev/null and b/res/drawable/fod_icon_default_2.png differ diff --git a/res/drawable/fod_icon_default_3.png b/res/drawable/fod_icon_default_3.png new file mode 100644 index 0000000..bd9ca2a Binary files /dev/null and b/res/drawable/fod_icon_default_3.png differ diff --git a/res/drawable/fod_picker_item_background.xml b/res/drawable/fod_picker_item_background.xml new file mode 100644 index 0000000..eb037ff --- /dev/null +++ b/res/drawable/fod_picker_item_background.xml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/res/drawable/ic_fingerprint.xml b/res/drawable/ic_fingerprint.xml index 20fbc04..ef20812 100644 --- a/res/drawable/ic_fingerprint.xml +++ b/res/drawable/ic_fingerprint.xml @@ -1,8 +1,23 @@ - - - - - - + + + + diff --git a/res/drawable/ic_fod_item.xml b/res/drawable/ic_fod_item.xml new file mode 100644 index 0000000..b6ab9c1 --- /dev/null +++ b/res/drawable/ic_fod_item.xml @@ -0,0 +1,21 @@ + + + + + + + diff --git a/res/layout/fod_picker_preference.xml b/res/layout/fod_picker_preference.xml new file mode 100644 index 0000000..46f34e8 --- /dev/null +++ b/res/layout/fod_picker_preference.xml @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/res/values-night/cherish_colors.xml b/res/values-night/cherish_colors.xml new file mode 100644 index 0000000..b9e96cb --- /dev/null +++ b/res/values-night/cherish_colors.xml @@ -0,0 +1,19 @@ + + + + + #555555 + diff --git a/res/values-vi/cherish_strings.xml b/res/values-vi/cherish_strings.xml index 9b4ed80..a53ae31 100644 --- a/res/values-vi/cherish_strings.xml +++ b/res/values-vi/cherish_strings.xml @@ -454,4 +454,8 @@ Ít nhàm chán heads up Chỉ hiển thị các ứng dụng quay số, ứng dụng nhắn tin và báo thức + + Chọn biểu tượng FOD + Chọn biểu thượng yêu thích vân tay của bạn + Để thêm biểu tượng của riêng bạn, hãy chọn biểu tượng trên cùng bên trái và sử dụng ứng dụng Tùy chỉnh OnePlus 6T FP để chọn biểu tượng bạn muốn. diff --git a/res/values/cherish_colors.xml b/res/values/cherish_colors.xml new file mode 100644 index 0000000..377f4d5 --- /dev/null +++ b/res/values/cherish_colors.xml @@ -0,0 +1,19 @@ + + + + + #d6d6d6 + diff --git a/res/values/cherish_dimens.xml b/res/values/cherish_dimens.xml index 9f71214..e82bf09 100644 --- a/res/values/cherish_dimens.xml +++ b/res/values/cherish_dimens.xml @@ -18,4 +18,8 @@ 26dp 20dp + + 20dp + 100dp + 20dp diff --git a/res/values/cherish_strings.xml b/res/values/cherish_strings.xml index 5d5cf2d..07dc8af 100644 --- a/res/values/cherish_strings.xml +++ b/res/values/cherish_strings.xml @@ -510,5 +510,11 @@ Less boring heads up Show heads up only for dialer, messaging and alarm app + + + FOD + FOD icon picker + Choose your favorite fingerprint icon + In order to add your own icon, select the top left icon and use the OnePlus 6T FP Customizer app to select the icon you want. diff --git a/res/xml/cherish_settings_fod_picker.xml b/res/xml/cherish_settings_fod_picker.xml new file mode 100644 index 0000000..e648745 --- /dev/null +++ b/res/xml/cherish_settings_fod_picker.xml @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/res/xml/cherish_settings_lockscreen.xml b/res/xml/cherish_settings_lockscreen.xml index d335e54..15f78f5 100644 --- a/res/xml/cherish_settings_lockscreen.xml +++ b/res/xml/cherish_settings_lockscreen.xml @@ -93,6 +93,21 @@ settings:interval="5" android:defaultValue="100"/> + + + + + + + + - \ No newline at end of file + diff --git a/src/com/cherish/settings/fragments/FODIconPickerFragment.java b/src/com/cherish/settings/fragments/FODIconPickerFragment.java new file mode 100644 index 0000000..6705f56 --- /dev/null +++ b/src/com/cherish/settings/fragments/FODIconPickerFragment.java @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2020 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; + +import android.content.res.Resources; +import android.os.Bundle; +import android.provider.Settings; + +import androidx.preference.Preference; +import androidx.preference.PreferenceCategory; +import androidx.preference.PreferenceScreen; + +import com.android.internal.logging.nano.MetricsProto; + +import com.android.settings.R; +import com.android.settings.SettingsPreferenceFragment; + +public class FODIconPickerFragment extends SettingsPreferenceFragment { + + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + + addPreferencesFromResource(R.xml.cherish_settings_fod_picker); + + getActivity().getActionBar().setTitle(R.string.fod_icon_picker_title); + + mFooterPreferenceMixin.createFooterPreference().setTitle(R.string.fod_icon_picker_footer); + } + + @Override + public int getMetricsCategory() { + return MetricsProto.MetricsEvent.CHERISH_SETTINGS; + } +} diff --git a/src/com/cherish/settings/fragments/LockScreenSettings.java b/src/com/cherish/settings/fragments/LockScreenSettings.java index 310caa1..a6315ab 100644 --- a/src/com/cherish/settings/fragments/LockScreenSettings.java +++ b/src/com/cherish/settings/fragments/LockScreenSettings.java @@ -44,9 +44,11 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements Preference.OnPreferenceChangeListener { private static final String FINGERPRINT_VIB = "fingerprint_success_vib"; + private static final String FOD_ICON_PICKER_CATEGORY = "fod_icon_picker_category"; private FingerprintManager mFingerprintManager; private SwitchPreference mFingerprintVib; + private Preference mFODIconPicker; @Override public void onCreate(Bundle icicle) { @@ -56,6 +58,12 @@ public class LockScreenSettings extends SettingsPreferenceFragment implements ContentResolver resolver = getActivity().getContentResolver(); final PreferenceScreen prefScreen = getPreferenceScreen(); Resources resources = getResources(); + + mFODIconPicker = (Preference) findPreference(FOD_ICON_PICKER_CATEGORY); + if (mFODIconPicker != null + && !getResources().getBoolean(com.android.internal.R.bool.config_supportsInDisplayFingerprint)) { + prefScreen.removePreference(mFODIconPicker); + } mFingerprintManager = (FingerprintManager) getActivity().getSystemService(Context.FINGERPRINT_SERVICE); mFingerprintVib = (SwitchPreference) findPreference(FINGERPRINT_VIB); diff --git a/src/com/cherish/settings/preferences/FODIconPicker.java b/src/com/cherish/settings/preferences/FODIconPicker.java new file mode 100644 index 0000000..f3d50bd --- /dev/null +++ b/src/com/cherish/settings/preferences/FODIconPicker.java @@ -0,0 +1,151 @@ +/* + * Copyright (C) 2020 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.preferences; + +import android.content.Context; +import android.content.res.ColorStateList; +import android.content.res.TypedArray; +import android.graphics.Color; +import android.provider.Settings; +import android.util.AttributeSet; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.View; +import android.view.ViewGroup; +import android.widget.FrameLayout; +import android.widget.ImageButton; + +import androidx.core.content.res.TypedArrayUtils; +import androidx.preference.Preference; +import androidx.preference.PreferenceViewHolder; + +import com.android.settings.R; + +import com.android.settingslib.Utils; +import com.android.settingslib.widget.LayoutPreference; + +public class FODIconPicker extends LayoutPreference { + + private boolean mAllowDividerAbove; + private boolean mAllowDividerBelow; + + private View mRootView; + + private static ImageButton ButtonOne; + private static ImageButton ButtonTwo; + private static ImageButton ButtonThree; + private static ImageButton ButtonFour; + + private static final String TAG = "FODIconPicker"; + + public FODIconPicker(Context context, AttributeSet attrs) { + super(context, attrs); + init(context, attrs, 0 /* defStyleAttr */); + } + + public FODIconPicker(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + init(context, attrs, defStyleAttr); + } + + private void init(Context context, AttributeSet attrs, int defStyleAttr) { + TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Preference); + mAllowDividerAbove = TypedArrayUtils.getBoolean(a, R.styleable.Preference_allowDividerAbove, + R.styleable.Preference_allowDividerAbove, false); + mAllowDividerBelow = TypedArrayUtils.getBoolean(a, R.styleable.Preference_allowDividerBelow, + R.styleable.Preference_allowDividerBelow, false); + a.recycle(); + + a = context.obtainStyledAttributes( + attrs, R.styleable.Preference, defStyleAttr, 0); + int layoutResource = a.getResourceId(R.styleable.Preference_android_layout, 0); + if (layoutResource == 0) { + throw new IllegalArgumentException("LayoutPreference requires a layout to be defined"); + } + a.recycle(); + + // Need to create view now so that findViewById can be called immediately. + final View view = LayoutInflater.from(getContext()) + .inflate(layoutResource, null, false); + setView(view, context); + } + + private void setView(View view, Context context) { + setLayoutResource(R.layout.layout_preference_frame); + mRootView = view; + setShouldDisableView(false); + ButtonOne = findViewById(R.id.fodiconone_button); + ButtonTwo = findViewById(R.id.fodicontwo_button); + ButtonThree = findViewById(R.id.fodiconthree_button); + ButtonFour = findViewById(R.id.fodiconfour_button); + + int defaultfodicon = Settings.System.getInt( + context.getContentResolver(), Settings.System.FOD_ICON, 0); + if (defaultfodicon==0) { + updateHighlightedItem(ButtonOne, context); + } else if (defaultfodicon==1) { + updateHighlightedItem(ButtonTwo, context); + } else if (defaultfodicon==2) { + updateHighlightedItem(ButtonThree, context); + } else if (defaultfodicon==3) { + updateHighlightedItem(ButtonFour, context); + } + + ButtonOne.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + updateSettings(0, context); + updateHighlightedItem(ButtonOne, context); + } + }); + ButtonTwo.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + updateSettings(1, context); + updateHighlightedItem(ButtonTwo, context); + } + }); + ButtonThree.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + updateSettings(2, context); + updateHighlightedItem(ButtonThree, context); + } + }); + ButtonFour.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + updateSettings(3, context); + updateHighlightedItem(ButtonFour, context); + } + }); + } + + private void updateSettings(int fodicon, Context context) { + Settings.System.putInt(context.getContentResolver(), Settings.System.FOD_ICON, fodicon); + } + + private void updateHighlightedItem(ImageButton activebutton, Context context) { + int defaultcolor = context.getResources().getColor(R.color.fod_item_background_stroke_color); + ColorStateList defaulttint = ColorStateList.valueOf(defaultcolor); + ButtonOne.setBackgroundTintList(defaulttint); + ButtonTwo.setBackgroundTintList(defaulttint); + ButtonThree.setBackgroundTintList(defaulttint); + ButtonFour.setBackgroundTintList(defaulttint); + activebutton.setBackgroundTintList(Utils.getColorAttr(getContext(), android.R.attr.colorAccent)); + } +}