Skip to content

Commit

Permalink
fix: Settings ModalDrawerSheet width
Browse files Browse the repository at this point in the history
ref: [#211](#211)
ref: [#212](#212)
  • Loading branch information
hushenghao committed Mar 14, 2024
1 parent 810560f commit ee97b8c
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 10 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
### v2.4.0
### v2.4.1

- New Settings UI 🎉
- Waiting Android Vanilla Ice Cream
- Fix Settings ModalDrawerSheet width [#211](https://github.com/hushenghao/AndroidEasterEggs/issues/211) [#212](https://github.com/hushenghao/AndroidEasterEggs/issues/212)

### v2.4.0 (2024-03-14)

- New Settings UI 🎉
- Waiting Android Vanilla Ice Cream
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG_zh.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
### v2.4.0
### v2.4.1

- 新的设置页面样式 🎉
- 等待 Android Vanilla Ice Cream
- 修复设置抽屉宽度 [#211](https://github.com/hushenghao/AndroidEasterEggs/issues/211) [#212](https://github.com/hushenghao/AndroidEasterEggs/issues/212)

### v2.4.0 (2024-03-14)

- 新的设置页面样式 🎉
- 等待 Android Vanilla Ice Cream
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {

defaultConfig {
applicationId = "com.dede.android_eggs"
versionCode = 38
versionName = "2.4.0"
versionCode = 39
versionName = "2.4.1"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

resourceConfigurations += listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material3.DrawerValue
Expand Down Expand Up @@ -86,10 +87,11 @@ class EasterEggsActivity : AppCompatActivity() {
drawerContent = {
ModalDrawerSheet(
drawerShape = shapes.extraLarge.end(0.dp),
modifier = Modifier.fillMaxWidth(0.85f),
windowInsets = WindowInsets(0, 0, 0, 0)
) {
SettingsScreen(drawerState)
Box(modifier = Modifier.fillMaxWidth(0.85f)) {
SettingsScreen(drawerState)
}
}
},
drawerState = drawerState
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ import com.dede.android_eggs.views.settings.compose.ContributeGroup
import com.dede.android_eggs.views.settings.compose.IconShapePref
import com.dede.android_eggs.views.settings.compose.IconVisualEffectsPref
import com.dede.android_eggs.views.settings.compose.LanguagePref
import com.dede.android_eggs.views.settings.compose.LanguagePrefUtil
import com.dede.android_eggs.views.settings.compose.RetainInRecentsPref
import com.dede.android_eggs.views.settings.compose.SettingDivider
import com.dede.android_eggs.views.settings.compose.SettingPrefUtil
import com.dede.android_eggs.views.settings.compose.ThemePref
import com.dede.android_eggs.views.settings.compose.TimelinePref
import kotlinx.coroutines.launch

@Preview
@Preview(widthDp = 360)
@Composable
fun SettingsScreen(drawerState: DrawerState = rememberDrawerState(DrawerValue.Closed)) {
val scope = rememberCoroutineScope()
Expand Down Expand Up @@ -110,7 +111,9 @@ fun SettingsScreen(drawerState: DrawerState = rememberDrawerState(DrawerValue.Cl

IconShapePref()

LanguagePref()
if (LanguagePrefUtil.isSupported()) {
LanguagePref()
}

IconVisualEffectsPref()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,17 @@ object DynamicColorPrefUtil {
const val KEY_DYNAMIC_COLOR = "pref_key_dynamic_color"
const val ACTION_DYNAMIC_COLOR_CHANGED = "ACTION_DYNAMIC_COLOR_CHANGED"

fun isSupported(): Boolean {
return DynamicColors.isDynamicColorAvailable()
}

fun isDynamicEnable(context: Context): Boolean {
return SettingPrefUtil.getValue(context, KEY_DYNAMIC_COLOR, DEFAULT) == SettingPrefUtil.ON
}

fun apply(context: Context) {
if (!isSupported()) return

val callback = Callback()
DynamicColors.applyToActivitiesIfAvailable(
context.applicationContext as Application,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ object LanguagePrefUtil {
)
// @formatter:on

fun isSupported(): Boolean {
// For API<24 the application does not have a localeList instead it has a single locale
// Unsupported region
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.N
}

fun checkLocaleConfig(context: Context) {
// check languageOptions count
val expected = languageOptions.size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,11 @@ fun ThemePref() {
onOptionClick = onOptionClick,
)

Spacer(modifier = Modifier.height(1.dp))
if (DynamicColorPrefUtil.isSupported()) {
Spacer(modifier = Modifier.height(1.dp))

DynamicColorPref()
DynamicColorPref()
}

}
}
3 changes: 3 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/39.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- New Settings UI 🎉
- Waiting Android Vanilla Ice Cream
- Fix Settings ModalDrawerSheet width
3 changes: 3 additions & 0 deletions fastlane/metadata/android/zh-CN/changelogs/39.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- 新的设置页面样式 🎉
- 等待 Android Vanilla Ice Cream
- 修复设置抽屉宽度

0 comments on commit ee97b8c

Please sign in to comment.