Skip to content

Commit

Permalink
update: testTag & remove upscayl
Browse files Browse the repository at this point in the history
  • Loading branch information
muedsa committed Sep 9, 2024
1 parent f8c24b4 commit abd9617
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 71 deletions.
4 changes: 1 addition & 3 deletions app/src/main/kotlin/com/muedsa/agetv/Perfs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ val KEY_DANMAKU_SIZE_SCALE = intPreferencesKey("danmaku_size_scale")

val KEY_DANMAKU_ALPHA = intPreferencesKey("danmaku_alpha")

val KEY_DANMAKU_SCREEN_PART = intPreferencesKey("danmaku_size_part")

val KEY_UPSCAYL_COVER_IMAGE_ENABLE = booleanPreferencesKey("upscayl_cover_image_enable")
val KEY_DANMAKU_SCREEN_PART = intPreferencesKey("danmaku_size_part")
3 changes: 0 additions & 3 deletions app/src/main/kotlin/com/muedsa/agetv/model/AppSettingModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ import com.muedsa.agetv.KEY_DANMAKU_ENABLE
import com.muedsa.agetv.KEY_DANMAKU_MERGE_ENABLE
import com.muedsa.agetv.KEY_DANMAKU_SCREEN_PART
import com.muedsa.agetv.KEY_DANMAKU_SIZE_SCALE
import com.muedsa.agetv.KEY_UPSCAYL_COVER_IMAGE_ENABLE

data class AppSettingModel(
val danmakuEnable: Boolean,
val danmakuMergeEnable: Boolean,
val danmakuSizeScale: Int,
val danmakuAlpha: Int,
val danmakuScreenPart: Int,
val upscaylCoverImageEnable: Boolean
) {
companion object {

Expand All @@ -25,7 +23,6 @@ data class AppSettingModel(
danmakuSizeScale = prefs[KEY_DANMAKU_SIZE_SCALE] ?: 140,
danmakuAlpha = prefs[KEY_DANMAKU_ALPHA] ?: 100,
danmakuScreenPart = prefs[KEY_DANMAKU_SCREEN_PART] ?: 100,
upscaylCoverImageEnable = prefs[KEY_UPSCAYL_COVER_IMAGE_ENABLE] ?: false
)

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.tv.material3.ButtonDefaults
Expand Down Expand Up @@ -88,6 +88,7 @@ fun CatalogScreen(
Column(modifier = Modifier.padding(start = ScreenPaddingLeft)) {
Row(
modifier = Modifier
.testTag("catalogScreen_options")
.fillMaxWidth()
.offset(x = -ScreenPaddingLeft)
.padding(vertical = 30.dp),
Expand Down Expand Up @@ -242,28 +243,14 @@ fun CatalogScreen(
}
}
} else {
val gridFocusRequester = remember { FocusRequester() }

LazyVerticalGrid(
columns = GridCells.Adaptive(AgePosterSize.width + ImageCardRowCardPadding),
contentPadding = PaddingValues(
top = ImageCardRowCardPadding,
bottom = ImageCardRowCardPadding
),
modifier = Modifier
.focusRequester(gridFocusRequester)
.focusProperties {
exit = { gridFocusRequester.saveFocusedChild(); FocusRequester.Default }
enter = {
if (gridFocusRequester.restoreFocusedChild()) {
LogUtil.d("grid restoreFocusedChild")
FocusRequester.Cancel
} else {
LogUtil.d("grid focused default child")
FocusRequester.Default
}
}
}
modifier = Modifier.testTag("catalogScreen_grid")
) {
itemsIndexed(
items = searchAnimeLP.list,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.tv.material3.ButtonDefaults
Expand Down Expand Up @@ -83,6 +84,7 @@ fun FavoritesScreen(

LazyVerticalGrid(
modifier = Modifier
.testTag("favoritesScreen_grid")
.padding(start = 0.dp, top = 20.dp, end = 20.dp, bottom = 20.dp),
columns = GridCells.Adaptive(AgePosterSize.width + ImageCardRowCardPadding),
contentPadding = PaddingValues(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.tv.material3.Card
Expand Down Expand Up @@ -54,8 +54,6 @@ fun LatestUpdateScreen(

val latestUpdateLP by viewModel.latestUpdateLPSF.collectAsState()

val gridFocusRequester = remember { FocusRequester() }

LaunchedEffect(key1 = latestUpdateLP) {
if (latestUpdateLP.type == LazyType.FAILURE) {
toastController.error(latestUpdateLP.error)
Expand All @@ -71,20 +69,8 @@ fun LatestUpdateScreen(

LazyVerticalGrid(
modifier = Modifier
.padding(start = 0.dp, top = 20.dp, end = 20.dp, bottom = 20.dp)
.focusRequester(gridFocusRequester)
.focusProperties {
exit = { gridFocusRequester.saveFocusedChild(); FocusRequester.Default }
enter = {
if (gridFocusRequester.restoreFocusedChild()) {
LogUtil.d("grid restoreFocusedChild")
FocusRequester.Cancel
} else {
LogUtil.d("grid focused default child")
FocusRequester.Default
}
}
},
.testTag("latestUpdateScreen_grid")
.padding(start = 0.dp, top = 20.dp, end = 20.dp, bottom = 20.dp),
columns = GridCells.Adaptive(AgePosterSize.width + ImageCardRowCardPadding),
contentPadding = PaddingValues(
top = ImageCardRowCardPadding,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.tv.material3.MaterialTheme
Expand Down Expand Up @@ -115,6 +116,7 @@ fun MainScreen(
.height(screenHeight - firstRowHeight - tabHeight)
)
ImageCardsRow(
modifier = Modifier.testTag("mainScreen_row_1"),
title = "最近更新",
modelList = latestList,
imageFn = { _, item ->
Expand Down Expand Up @@ -142,6 +144,7 @@ fun MainScreen(
// 每日推荐
item {
StandardImageCardsRow(
modifier = Modifier.testTag("mainScreen_row_2"),
title = "每日推荐",
modelList = recommendList,
imageFn = { _, item ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.muedsa.agetv.screens.home.main

import androidx.compose.foundation.layout.Column
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import com.muedsa.agetv.model.age.WeekAnimeModel
import com.muedsa.agetv.theme.WeekCardColorList
import com.muedsa.compose.tv.model.ContentModel
Expand All @@ -21,6 +23,7 @@ fun WeekAnimeListWidget(
val dayList = model[key] ?: emptyList()

ImageCardsRow(
modifier = Modifier.testTag("mainScreen_week_$index"),
title = "每周放送 · ${WeekNameList[index]}",
modelList = dayList,
imageFn = { _, _ -> "" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
Expand Down Expand Up @@ -127,7 +128,7 @@ fun RankScreen(
color = MaterialTheme.colorScheme.onBackground,
style = MaterialTheme.typography.titleLarge
)
LazyColumn {
LazyColumn(modifier = Modifier.testTag("rankScreen_col_week")) {
items(dayList) {
RankAnimeWidget(
model = it,
Expand Down Expand Up @@ -158,7 +159,7 @@ fun RankScreen(
color = MaterialTheme.colorScheme.onBackground,
style = MaterialTheme.typography.titleLarge
)
LazyColumn {
LazyColumn(modifier = Modifier.testTag("rankScreen_col_month")) {
items(weekList) {
RankAnimeWidget(
model = it,
Expand Down Expand Up @@ -190,7 +191,7 @@ fun RankScreen(
style = MaterialTheme.typography.titleLarge
)

LazyColumn {
LazyColumn(modifier = Modifier.testTag("rankScreen_col_all")) {
items(totalList) {
RankAnimeWidget(
model = it,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusProperties
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.unit.dp
import androidx.hilt.navigation.compose.hiltViewModel
import androidx.tv.material3.MaterialTheme
Expand Down Expand Up @@ -65,24 +62,11 @@ fun RecommendScreen(

if (!recommendLD.data.isNullOrEmpty()) {
val recommendList = recommendLD.data!!
val gridFocusRequester = remember { FocusRequester() }

LazyVerticalGrid(
modifier = Modifier
.padding(start = 0.dp, top = 20.dp, end = 20.dp, bottom = 20.dp)
.focusRequester(gridFocusRequester)
.focusProperties {
exit = { gridFocusRequester.saveFocusedChild(); FocusRequester.Default }
enter = {
if (gridFocusRequester.restoreFocusedChild()) {
LogUtil.d("grid restoreFocusedChild")
FocusRequester.Cancel
} else {
LogUtil.d("grid focused default child")
FocusRequester.Default
}
}
},
.testTag("recommendScreen_grid")
.padding(start = 0.dp, top = 20.dp, end = 20.dp, bottom = 20.dp),
columns = GridCells.Adaptive(AgePosterSize.width + ImageCardRowCardPadding),
contentPadding = PaddingValues(
top = ImageCardRowCardPadding,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.muedsa.agetv.KEY_DANMAKU_ENABLE
import com.muedsa.agetv.KEY_DANMAKU_MERGE_ENABLE
import com.muedsa.agetv.KEY_DANMAKU_SCREEN_PART
import com.muedsa.agetv.KEY_DANMAKU_SIZE_SCALE
import com.muedsa.agetv.KEY_UPSCAYL_COVER_IMAGE_ENABLE
import com.muedsa.agetv.model.AppSettingModel
import com.muedsa.agetv.model.LazyData
import com.muedsa.agetv.repository.DataStoreRepo
Expand Down Expand Up @@ -90,12 +89,4 @@ class AppSettingViewModel @Inject constructor(
}
}

fun changeUpscaylCoverImageEnable(enable: Boolean) {
viewModelScope.launch(Dispatchers.IO) {
repo.dataStore.edit {
it[KEY_UPSCAYL_COVER_IMAGE_ENABLE] = enable
}
}
}

}
2 changes: 1 addition & 1 deletion scripts/year.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
for (year in 2023 downTo 2000) {
for (year in 2024 downTo 2000) {
println(String.format("data object Year%d : AgeSearchOption(\"%d\", \"%d\")", year, year, year))
}

0 comments on commit abd9617

Please sign in to comment.