@@ -8,11 +8,14 @@ import androidx.appcompat.app.AppCompatDelegate
8
8
import androidx.core.content.edit
9
9
import androidx.core.view.WindowCompat
10
10
import androidx.fragment.app.Fragment
11
+ import androidx.fragment.app.FragmentManager
11
12
import androidx.fragment.app.commit
12
13
import androidx.lifecycle.lifecycleScope
13
14
import kotlinx.coroutines.delay
14
15
import kotlinx.coroutines.launch
15
16
import ru.queuejw.mpl.Application.Companion.PREFS
17
+ import ru.queuejw.mpl.Application.Companion.customBoldFont
18
+ import ru.queuejw.mpl.Application.Companion.customFont
16
19
import ru.queuejw.mpl.R
17
20
import ru.queuejw.mpl.content.settings.fragments.MainSettingsFragment
18
21
import ru.queuejw.mpl.content.settings.fragments.ThemeSettingsFragment
@@ -26,37 +29,45 @@ class SettingsActivity : AppCompatActivity() {
26
29
private var isTipActive = false
27
30
28
31
override fun onCreate (savedInstanceState : Bundle ? ) {
32
+ super .onCreate(savedInstanceState)
29
33
when (PREFS .appTheme) {
30
34
0 -> AppCompatDelegate .setDefaultNightMode(AppCompatDelegate .MODE_NIGHT_FOLLOW_SYSTEM )
31
35
1 -> AppCompatDelegate .setDefaultNightMode(AppCompatDelegate .MODE_NIGHT_YES )
32
36
2 -> AppCompatDelegate .setDefaultNightMode(AppCompatDelegate .MODE_NIGHT_NO )
33
37
}
34
- super .onCreate(savedInstanceState)
35
38
binding = LauncherSettingsMainBinding .inflate(layoutInflater)
39
+ binding.root.apply {
40
+ pivotX = 24f
41
+ pivotY = height.toFloat()
42
+ }
36
43
setContentView(binding.root)
37
44
WindowCompat .setDecorFitsSystemWindows(window, false )
38
45
Utils .applyWindowInsets(binding.root)
39
- }
40
-
41
- override fun onStart () {
42
- super .onStart()
43
- setupBackPressedDispatcher()
44
- supportFragmentManager.commit {
45
- replace(binding.fragmentContainerView.id, MainSettingsFragment ())
46
- }
46
+ setupFont()
47
47
if (PREFS .prefs.getBoolean(" themeChanged" , false )) {
48
+ supportFragmentManager.popBackStack(null , FragmentManager .POP_BACK_STACK_INCLUSIVE )
48
49
PREFS .prefs.edit { putBoolean(" themeChanged" , false ) }
49
- changeFragment(ThemeSettingsFragment (), " theme" )
50
+ changeFragmentFunction(ThemeSettingsFragment (), " theme" )
51
+ } else {
52
+ supportFragmentManager.commit {
53
+ replace(binding.fragmentContainerView.id, MainSettingsFragment ())
54
+ }
50
55
}
51
- prepareTip()
52
56
}
53
57
54
- override fun onResume () {
55
- super .onResume()
58
+ private fun setupFont () {
59
+ customFont?.let {
60
+ binding.settings.typeface = it
61
+ }
62
+ customBoldFont?.let {
63
+ binding.settings.typeface = it
64
+ }
56
65
}
57
66
58
- override fun onPause () {
59
- super .onPause()
67
+ override fun onStart () {
68
+ super .onStart()
69
+ setupBackPressedDispatcher()
70
+ prepareTip()
60
71
}
61
72
62
73
private fun prepareTip () {
@@ -90,17 +101,17 @@ class SettingsActivity : AppCompatActivity() {
90
101
if (! PREFS .isTransitionAnimEnabled) {
91
102
supportFragmentManager.popBackStackImmediate()
92
103
} else {
93
- binding.root.animate().rotationY(90f ).alpha(0.75f ).translationX(- 100f ).setDuration(150 ).setInterpolator(
104
+ binding.root.animate().rotationY(90f ).alpha(0.75f ).translationX(- 100f ).setDuration(125 ).setInterpolator(
94
105
DecelerateInterpolator ()
95
106
).withEndAction {
96
107
supportFragmentManager.popBackStack()
97
108
binding.root.apply {
98
- rotationY = - 45f
109
+ rotationY = - 90f
99
110
alpha = 0f
100
111
}
101
112
lifecycleScope.launch {
102
113
delay(25 )
103
- binding.root.animate().rotationY(0f ).alpha(1f ).translationX(0f ).setDuration(150 ).setInterpolator(
114
+ binding.root.animate().rotationY(0f ).alpha(1f ).translationX(0f ).setDuration(125 ).setInterpolator(
104
115
DecelerateInterpolator ()
105
116
).start()
106
117
}.start()
@@ -119,11 +130,7 @@ class SettingsActivity : AppCompatActivity() {
119
130
120
131
fun changeFragment (fragment : Fragment , name : String ) {
121
132
if (PREFS .isTransitionAnimEnabled) {
122
- lifecycleScope.launch {
123
- animateFragmentEnter()
124
- delay(80 )
125
- changeFragmentFunction(fragment, name)
126
- }
133
+ animateFragmentEnter(fragment, name)
127
134
} else {
128
135
changeFragmentFunction(fragment, name)
129
136
}
@@ -134,17 +141,20 @@ class SettingsActivity : AppCompatActivity() {
134
141
addToBackStack(name)
135
142
}
136
143
}
137
- private fun animateFragmentEnter () {
138
- binding.root.animate().rotationY(- 45f ).alpha(0.75f ).translationX(- 500f ).setDuration(75 )
144
+ private fun animateFragmentEnter (fragment : Fragment , name : String ) {
145
+ binding.root.animate().rotationY(- 90f ).alpha(0.75f ).translationX(- 250f ).setDuration(125 )
139
146
.setInterpolator(
140
147
DecelerateInterpolator ()
141
148
).withEndAction {
142
- binding.root.alpha = 0f
143
- binding.root.rotationY = 90f
149
+ binding.root.apply {
150
+ alpha = 0f
151
+ rotationY = 90f
152
+ }
153
+ changeFragmentFunction(fragment, name)
144
154
lifecycleScope.launch {
145
- delay(50 )
155
+ delay(25 )
146
156
binding.root.alpha = 0.5f
147
- binding.root.animate().rotationY(0f ).alpha(1f ).translationX(0f ).setDuration(150 )
157
+ binding.root.animate().rotationY(0f ).alpha(1f ).translationX(0f ).setDuration(125 )
148
158
.setInterpolator(
149
159
DecelerateInterpolator ()
150
160
).start()
0 commit comments