Skip to content

Commit 8839698

Browse files
committed
Merge branch 'release/1.9.2'
2 parents 392a3e1 + 4f28b49 commit 8839698

File tree

14 files changed

+230
-34
lines changed

14 files changed

+230
-34
lines changed

.idea/gradle.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ android {
2222
applicationId = "com.dede.android_eggs"
2323
minSdk = Versions.MIN_SDK
2424
targetSdk = Versions.TARGET_SDK
25-
versionCode = 24
26-
versionName = "1.9.1"
25+
versionCode = 25
26+
versionName = "1.9.2"
2727

2828
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2929
resourceConfigurations.addAll(listOf("zh", "en"))

app/src/main/java/com/dede/android_eggs/main/EasterEggsActivity.kt

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.dede.android_eggs.main
22

3+
import android.animation.ObjectAnimator
34
import android.content.res.Configuration
45
import android.os.Bundle
56
import android.view.Menu
@@ -29,10 +30,6 @@ class EasterEggsActivity : AppCompatActivity(), MenuProvider {
2930

3031
navigationViewController.setContentView()
3132

32-
if (savedInstanceState == null) {
33-
EasterEggsSplash(this).welcome()
34-
}
35-
3633
addMenuProvider(this, this)
3734
}
3835

@@ -53,7 +50,21 @@ class EasterEggsActivity : AppCompatActivity(), MenuProvider {
5350
}
5451

5552
override fun onMenuItemSelected(menuItem: MenuItem): Boolean {
56-
SettingsFragment().show(supportFragmentManager, "Settings")
53+
when (menuItem.itemId) {
54+
R.id.menu_settings -> {
55+
val icon = menuItem.icon as FontIconsDrawable
56+
SettingsFragment().apply {
57+
onSlide = {
58+
icon.setRotate(360f * it)
59+
}
60+
show(supportFragmentManager, "Settings")
61+
}
62+
ObjectAnimator.ofFloat(icon, "rotate", 0f, 360f)
63+
.setDuration(500)
64+
.start()
65+
}
66+
else -> return false
67+
}
5768
return true
5869
}
5970

app/src/main/java/com/dede/android_eggs/settings/SettingsFragment.kt

Lines changed: 47 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ package com.dede.android_eggs.settings
22

33
import android.app.Dialog
44
import android.app.LocaleManager
5+
import android.content.Context
56
import android.content.Intent
67
import android.graphics.drawable.Drawable
78
import android.net.Uri
89
import android.os.Build
910
import android.os.Bundle
11+
import android.view.View
1012
import androidx.annotation.RequiresApi
1113
import androidx.core.content.getSystemService
1214
import androidx.preference.ListPreference
@@ -21,15 +23,31 @@ import com.dede.android_eggs.util.NightModeManager
2123
import com.dede.android_eggs.util.WindowEdgeUtilsAccessor
2224
import com.dede.android_eggs.util.requirePreference
2325
import com.dede.basic.dp
26+
import com.google.android.material.bottomsheet.BottomSheetBehavior
2427
import com.google.android.material.bottomsheet.BottomSheetDialog
2528
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
2629

2730
class SettingsFragment : BottomSheetDialogFragment(R.layout.fragment_settings) {
2831

32+
var onSlide: Function1<Float, Unit>? = null
33+
34+
private var lastSlideOffset: Float = -1f
35+
private val callback = object : BottomSheetBehavior.BottomSheetCallback() {
36+
override fun onStateChanged(bottomSheet: View, newState: Int) {
37+
}
38+
39+
override fun onSlide(bottomSheet: View, slideOffset: Float) {
40+
if (lastSlideOffset == slideOffset) return
41+
onSlide?.invoke(slideOffset)
42+
lastSlideOffset = slideOffset
43+
}
44+
}
45+
2946
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
3047
val dialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
3148
WindowEdgeUtilsAccessor.applyEdgeToEdge(dialog.window!!, true)
3249
val bottomSheetBehavior = dialog.behavior
50+
bottomSheetBehavior.addBottomSheetCallback(callback)
3351
bottomSheetBehavior.isFitToContents = true
3452
bottomSheetBehavior.skipCollapsed = true
3553
dialog.dismissWithAnimation = true
@@ -58,7 +76,7 @@ class SettingsFragment : BottomSheetDialogFragment(R.layout.fragment_settings) {
5876

5977
requirePreference<ListPreference>(IconShapeOverride.KEY_PREFERENCE).apply {
6078
icon = createFontIcon("\ue920")
61-
//isEnabled = IconShapeOverride.isSupported()
79+
isEnabled = IconShapeOverride.isEnabled()
6280
IconShapeOverride.handlePreferenceUi(this)
6381
}
6482

@@ -77,28 +95,47 @@ class SettingsFragment : BottomSheetDialogFragment(R.layout.fragment_settings) {
7795
private fun configureChangeLanguagePreference() {
7896
requirePreference<Preference>(PREF_LANGUAGE).apply {
7997
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
80-
val localeManager = requireContext().getSystemService<LocaleManager>()
81-
if (localeManager != null) {
82-
val locales = localeManager.applicationLocales
83-
if (!locales.isEmpty) {
84-
summary = locales.get(0).displayName
85-
}
86-
}
8798
setOnPreferenceClickListener {
88-
startActivity(createActionAppLocaleSettingsIntent())
99+
runCatching {
100+
startActivity(createActionAppLocaleSettingsIntent())
101+
}
89102
return@setOnPreferenceClickListener true
90103
}
91104
}
105+
summary = getLocalDisplayName(requireContext())
92106
isEnabled = Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
93107
icon = createFontIcon("\ue894")
94108
}
95109
}
96110

111+
private fun getLocalDisplayName(context: Context): String? {
112+
var name: String? = null
113+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
114+
val localeManager = context.getSystemService<LocaleManager>()
115+
if (localeManager != null) {
116+
val locales = localeManager.applicationLocales
117+
if (!locales.isEmpty) {
118+
name = locales.get(0).displayName
119+
}
120+
}
121+
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
122+
val locales = context.resources.configuration.locales
123+
if (!locales.isEmpty) {
124+
name = locales.get(0).displayName
125+
}
126+
} else {
127+
@Suppress("DEPRECATION")
128+
val locale = context.resources.configuration.locale
129+
name = locale.displayName
130+
}
131+
return name
132+
}
133+
97134
@RequiresApi(Build.VERSION_CODES.TIRAMISU)
98135
private fun createActionAppLocaleSettingsIntent(): Intent = Intent(
99136
android.provider.Settings.ACTION_APP_LOCALE_SETTINGS,
100137
Uri.fromParts("package", requireActivity().packageName, null)
101-
)
138+
).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
102139

103140
private fun createFontIcon(unicode: String): Drawable {
104141
return FontIconsDrawable(requireContext(), unicode, 36f).apply {

app/src/main/java/com/dede/android_eggs/ui/EggPreference.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ open class EggPreference : Preference {
129129
val icon = holder.findViewById(android.R.id.icon) as? ImageView
130130
if (icon != null) {
131131
icon.dispose()
132-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O && supportAdaptiveIcon) {
132+
if (supportAdaptiveIcon && Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
133133
// support adaptive-icon
134134
icon.load(iconResId) {
135135
val shapePath = IconShapeOverride.getAppliedValue(context)

app/src/main/java/com/dede/android_eggs/ui/FontIconsDrawable.kt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import android.text.TextPaint
1010
import androidx.annotation.AttrRes
1111
import androidx.annotation.Dimension
1212
import androidx.annotation.FloatRange
13+
import androidx.annotation.Keep
1314
import androidx.core.graphics.component1
1415
import androidx.core.graphics.component2
1516
import androidx.core.graphics.component3
@@ -69,11 +70,18 @@ class FontIconsDrawable(
6970
}
7071
}
7172

72-
fun setRotate(@FloatRange(from = 0.0, to = 360.0) degree: Float) {
73-
this.degree = degree % 360
74-
invalidateSelf()
73+
@Keep
74+
fun setRotate(@FloatRange(from = -360.0, to = 360.0) degree: Float) {
75+
val newDegree = degree % 360f
76+
if (newDegree != this.degree) {
77+
this.degree = newDegree
78+
invalidateSelf()
79+
}
7580
}
7681

82+
@Keep
83+
fun getRotate(): Float = this.degree
84+
7785
fun setColor(color: Int) {
7886
if (color != paint.color) {
7987
paint.color = color

app/src/main/java/com/dede/android_eggs/util/IconShapeOverride.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,18 +132,31 @@ public Resources getResources() {
132132

133133
public static void apply(Context context) {
134134
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O &&
135-
Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
135+
Build.VERSION.SDK_INT < Build.VERSION_CODES.Q &&
136+
isEnabled()
137+
) {
136138
Api26Impl.apply(context);
137139
}
138140
}
139141

140142
public static Resources getOverrideResources(Context context, Resources parent) {
141-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
143+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && isEnabled()) {
142144
return Api29Impl.getOverrideResources(context, parent);
143145
}
144146
return parent;
145147
}
146148

149+
public static boolean isEnabled() {
150+
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
151+
// support adaptive-icon
152+
return true;
153+
}
154+
if (Utils.isXiaomi()) {
155+
return false;
156+
}
157+
return isSupported();
158+
}
159+
147160
public static boolean isSupported() {
148161
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
149162
return false;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@file:JvmName("Utils")
2+
package com.dede.android_eggs.util
3+
4+
import android.os.Build
5+
import java.util.*
6+
7+
8+
fun isXiaomi(): Boolean {
9+
return Build.MANUFACTURER.lowercase(Locale.ENGLISH) == "xiaomi"
10+
}
11+
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<animated-vector
2+
xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:aapt="http://schemas.android.com/aapt">
4+
<aapt:attr name="android:drawable">
5+
<vector
6+
android:name="vector"
7+
android:width="24dp"
8+
android:height="24dp"
9+
android:viewportWidth="24"
10+
android:viewportHeight="24">
11+
<group
12+
android:name="scale"
13+
android:translateX="6"
14+
android:translateY="6"
15+
android:scaleX="0.5"
16+
android:scaleY="0.5">
17+
<path
18+
android:name="bg"
19+
android:pathData="M 11 0.3 C 11.6 0 12.4 0 13 0.3 L 13.6 0.7 C 14.3 1.1 15 1.3 15.8 1.3 L 16.5 1.2 C 17.2 1.2 17.9 1.5 18.3 2.1 L 18.6 2.7 C 19 3.4 19.6 3.9 20.3 4.2 L 21 4.5 C 21.7 4.8 22.1 5.4 22.2 6.2 L 22.2 6.9 C 22.2 7.7 22.5 8.4 23 9 L 23.4 9.5 C 23.8 10.1 23.9 10.8 23.6 11.5 L 23.3 12.1 C 23 12.8 22.9 13.6 23 14.4 L 23.1 15.1 C 23.2 15.8 22.9 16.5 22.4 17 L 22 17.5 C 21.4 18 20.9 18.6 20.7 19.4 L 20.5 20 C 20.3 20.7 19.7 21.2 19 21.4 L 18.3 21.5 C 17.5 21.7 16.9 22 16.3 22.6 L 15.8 23.1 C 15.3 23.6 14.5 23.8 13.8 23.6 L 13.2 23.4 C 12.4 23.2 11.7 23.2 10.9 23.4 L 10.3 23.6 C 9.6 23.8 8.8 23.6 8.3 23.1 L 7.8 22.6 C 7.3 22.1 6.6 21.7 5.8 21.5 L 5 21.4 C 4.3 21.2 3.7 20.7 3.5 20 L 3.3 19.3 C 3.1 18.6 2.6 18 2 17.5 L 1.4 17.1 C 0.8 16.6 0.6 15.9 0.7 15.2 L 0.8 14.5 C 0.9 13.7 0.8 12.9 0.5 12.2 L 0.2 11.6 C -0.1 10.9 0 10.2 0.4 9.6 L 1 9 C 1.5 8.4 1.7 7.6 1.8 6.8 L 1.8 6.2 C 1.9 5.5 2.3 4.8 3 4.5 L 3.6 4.2 C 4.3 3.9 4.9 3.3 5.3 2.7 L 5.6 2.1 C 6 1.5 6.7 1.1 7.4 1.2 L 8.1 1.3 C 8.9 1.3 9.7 1.1 10.3 0.7 L 11 0.3 Z"
20+
android:fillColor="@color/t_system_accent1_400"/>
21+
<group android:name="group">
22+
<path
23+
android:name="1_bg"
24+
android:pathData="M 6.3 6.5 L 9.3 6.5 L 9.3 18.7"
25+
android:strokeColor="@color/t_system_accent3_800"
26+
android:strokeWidth="2.22"/>
27+
<path
28+
android:name="1"
29+
android:pathData="M 6.3 6.5 L 9.3 6.5 L 9.3 18.7 M 6.3 6.5 L 9.3 6.5 L 9.3 18.7"
30+
android:strokeColor="@color/t_system_neutral1_100"
31+
android:strokeWidth="0.56"/>
32+
<path
33+
android:name="3_bg"
34+
android:pathData="M 12.3 6.5 L 16.3 6.5 L 14.3 10.5 C 16.5 10.8 17.9 12.9 17.6 15 C 17.3 16.9 15.7 18.3 13.8 18.3 C 13.3 18.3 12.8 18.2 12.4 18"
35+
android:strokeColor="@color/t_system_accent3_800"
36+
android:strokeWidth="2.22"/>
37+
<path
38+
android:name="3"
39+
android:pathData="M 12.3 6.5 L 16.3 6.5 L 14.3 10.5 C 16.5 10.8 17.9 12.9 17.6 15 C 17.3 16.9 15.7 18.3 13.8 18.3 C 13.3 18.3 12.8 18.2 12.4 18"
40+
android:strokeColor="@color/t_system_neutral1_100"
41+
android:strokeWidth="0.56"/>
42+
</group>
43+
</group>
44+
</vector>
45+
</aapt:attr>
46+
<target android:name="group">
47+
<aapt:attr name="android:animation">
48+
<set>
49+
<objectAnimator
50+
android:propertyName="rotation"
51+
android:startOffset="400"
52+
android:duration="100"
53+
android:valueFrom="20"
54+
android:valueTo="0"
55+
android:valueType="floatType"
56+
android:interpolator="@android:anim/linear_interpolator"/>
57+
<objectAnimator
58+
android:propertyName="rotation"
59+
android:startOffset="100"
60+
android:duration="100"
61+
android:valueFrom="0"
62+
android:valueTo="-20"
63+
android:valueType="floatType"
64+
android:interpolator="@android:anim/linear_interpolator"/>
65+
<objectAnimator
66+
android:propertyName="rotation"
67+
android:startOffset="200"
68+
android:duration="100"
69+
android:valueFrom="-20"
70+
android:valueTo="0"
71+
android:valueType="floatType"
72+
android:interpolator="@android:anim/linear_interpolator"/>
73+
<objectAnimator
74+
android:propertyName="pivotX"
75+
android:startOffset="100"
76+
android:duration="401"
77+
android:valueFrom="12"
78+
android:valueTo="12"
79+
android:valueType="floatType"
80+
android:interpolator="@android:anim/linear_interpolator"/>
81+
<objectAnimator
82+
android:propertyName="pivotY"
83+
android:startOffset="100"
84+
android:duration="401"
85+
android:valueFrom="12"
86+
android:valueTo="12"
87+
android:valueType="floatType"
88+
android:interpolator="@android:anim/linear_interpolator"/>
89+
<objectAnimator
90+
android:propertyName="rotation"
91+
android:startOffset="300"
92+
android:duration="100"
93+
android:valueFrom="0"
94+
android:valueTo="20"
95+
android:valueType="floatType"
96+
android:interpolator="@android:anim/linear_interpolator"/>
97+
</set>
98+
</aapt:attr>
99+
</target>
100+
</animated-vector>

app/src/main/res/drawable/u_icon_fg.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
android:viewportWidth="512"
66
android:viewportHeight="512">
77
<group
8-
android:scaleX="0.75"
9-
android:scaleY="0.75"
10-
android:translateX="64"
11-
android:translateY="64">
8+
android:scaleX="0.74"
9+
android:scaleY="0.74"
10+
android:translateX="66.56"
11+
android:translateY="66.56">
1212

1313
<path android:pathData="M256,256m-200,0a200,200 0,1 1,400 0a200,200 0,1 1,-400 0">
1414
<aapt:attr name="android:fillColor">

0 commit comments

Comments
 (0)