-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature] Support to configure whether to show video thumbnails
- Loading branch information
Showing
12 changed files
with
128 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...ain/java/com/skyd/anivu/model/preference/appearance/media/MediaShowThumbnailPreference.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.skyd.anivu.model.preference.appearance.media | ||
|
||
import android.content.Context | ||
import androidx.datastore.preferences.core.Preferences | ||
import androidx.datastore.preferences.core.booleanPreferencesKey | ||
import com.skyd.anivu.base.BasePreference | ||
import com.skyd.anivu.ext.dataStore | ||
import com.skyd.anivu.ext.put | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.launch | ||
|
||
object MediaShowThumbnailPreference : BasePreference<Boolean> { | ||
private const val MEDIA_SHOW_THUMBNAIL = "mediaShowThumbnail" | ||
override val default = true | ||
|
||
val key = booleanPreferencesKey(MEDIA_SHOW_THUMBNAIL) | ||
|
||
fun put(context: Context, scope: CoroutineScope, value: Boolean) { | ||
scope.launch(Dispatchers.IO) { | ||
context.dataStore.put(key, value) | ||
} | ||
} | ||
|
||
override fun fromPreferences(preferences: Preferences): Boolean = preferences[key] ?: default | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
app/src/main/java/com/skyd/anivu/ui/screen/settings/appearance/media/MediaStyleScreen.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package com.skyd.anivu.ui.screen.settings.appearance.media | ||
|
||
import androidx.compose.foundation.layout.fillMaxSize | ||
import androidx.compose.foundation.lazy.LazyColumn | ||
import androidx.compose.material.icons.Icons | ||
import androidx.compose.material.icons.outlined.HideImage | ||
import androidx.compose.material.icons.outlined.Image | ||
import androidx.compose.material3.Scaffold | ||
import androidx.compose.material3.Text | ||
import androidx.compose.material3.TopAppBarDefaults | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.rememberCoroutineScope | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.input.nestedscroll.nestedScroll | ||
import androidx.compose.ui.platform.LocalContext | ||
import androidx.compose.ui.res.stringResource | ||
import com.skyd.anivu.R | ||
import com.skyd.anivu.model.preference.appearance.media.MediaShowThumbnailPreference | ||
import com.skyd.anivu.ui.component.AniVuTopBar | ||
import com.skyd.anivu.ui.component.AniVuTopBarStyle | ||
import com.skyd.anivu.ui.component.CategorySettingsItem | ||
import com.skyd.anivu.ui.component.SwitchSettingsItem | ||
import com.skyd.anivu.ui.local.LocalMediaShowThumbnail | ||
|
||
|
||
const val MEDIA_STYLE_SCREEN_ROUTE = "mediaStyleScreen" | ||
|
||
@Composable | ||
fun MediaStyleScreen() { | ||
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior() | ||
val context = LocalContext.current | ||
val scope = rememberCoroutineScope() | ||
|
||
Scaffold( | ||
topBar = { | ||
AniVuTopBar( | ||
style = AniVuTopBarStyle.Large, | ||
scrollBehavior = scrollBehavior, | ||
title = { Text(text = stringResource(R.string.media_style_screen_name)) }, | ||
) | ||
} | ||
) { paddingValues -> | ||
LazyColumn( | ||
modifier = Modifier | ||
.fillMaxSize() | ||
.nestedScroll(scrollBehavior.nestedScrollConnection), | ||
contentPadding = paddingValues, | ||
) { | ||
item { | ||
CategorySettingsItem(text = stringResource(id = R.string.media_style_screen_media_list_category)) | ||
} | ||
item { | ||
val mediaShowThumbnail = LocalMediaShowThumbnail.current | ||
SwitchSettingsItem( | ||
imageVector = if (mediaShowThumbnail) Icons.Outlined.Image else Icons.Outlined.HideImage, | ||
text = stringResource(id = R.string.media_style_screen_media_list_show_thumbnail), | ||
checked = mediaShowThumbnail, | ||
onCheckedChange = { | ||
MediaShowThumbnailPreference.put( | ||
context = context, | ||
scope = scope, | ||
value = it, | ||
) | ||
} | ||
) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters