From 9c1dd21f3c606d0565a8e1f8aa86758f6cb0b32f Mon Sep 17 00:00:00 2001 From: HuanCheng65 <22636177+HuanCheng65@users.noreply.github.com> Date: Fri, 29 Sep 2023 11:26:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=9A=90=E8=97=8F=E5=9B=9E=E8=B4=B4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=85=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../settings/custom/CustomSettingsPage.kt | 1 + .../page/settings/habit/HabitSettingsPage.kt | 28 +++++++++++++- .../post/ui/page/subposts/SubPostsPage.kt | 19 ++++++---- .../tieba/post/ui/page/thread/ThreadPage.kt | 38 +++++++++++-------- .../tieba/post/ui/widgets/compose/Toolbar.kt | 1 + .../tieba/post/utils/AppPreferencesUtils.kt | 2 + app/src/main/res/values/strings.xml | 1 + 7 files changed, 64 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/settings/custom/CustomSettingsPage.kt b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/settings/custom/CustomSettingsPage.kt index 7323e4e6..4f475335 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/settings/custom/CustomSettingsPage.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/settings/custom/CustomSettingsPage.kt @@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.material.ExperimentalMaterialApi import androidx.compose.material.MaterialTheme +import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Apps import androidx.compose.material.icons.outlined.Brightness2 diff --git a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/settings/habit/HabitSettingsPage.kt b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/settings/habit/HabitSettingsPage.kt index 5da6a2a0..63437b8a 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/settings/habit/HabitSettingsPage.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/settings/habit/HabitSettingsPage.kt @@ -3,6 +3,8 @@ package com.huanchengfly.tieba.post.ui.page.settings.habit import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.padding import androidx.compose.material.ExperimentalMaterialApi +import androidx.compose.material.MaterialTheme +import androidx.compose.material.Text import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.BrandingWatermark import androidx.compose.material.icons.outlined.CalendarViewDay @@ -10,6 +12,7 @@ import androidx.compose.material.icons.outlined.ExitToApp import androidx.compose.material.icons.outlined.NightsStay import androidx.compose.material.icons.outlined.PhotoSizeSelectActual import androidx.compose.material.icons.outlined.SecurityUpdateWarning +import androidx.compose.material.icons.outlined.SpeakerNotesOff import androidx.compose.material.icons.outlined.StarOutline import androidx.compose.material.icons.outlined.Verified import androidx.compose.runtime.Composable @@ -20,6 +23,7 @@ import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.vectorResource +import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import com.huanchengfly.tieba.post.R import com.huanchengfly.tieba.post.dataStore @@ -41,12 +45,16 @@ import com.ramcosta.composedestinations.navigation.DestinationsNavigator fun HabitSettingsPage( navigator: DestinationsNavigator ) { - val context = LocalContext.current MyScaffold( backgroundColor = Color.Transparent, topBar = { TitleCentredToolbar( - title = stringResource(id = R.string.title_settings_read_habit), + title = { + Text( + text = stringResource(id = R.string.title_settings_read_habit), + fontWeight = FontWeight.Bold, style = MaterialTheme.typography.h6 + ) + }, navigationIcon = { BackNavigationIcon(onBackPressed = { navigator.navigateUp() }) } @@ -232,6 +240,22 @@ fun HabitSettingsPage( }, ) } + prefsItem { + SwitchPref( + key = "hideReply", + title = stringResource(id = R.string.title_hide_reply), + defaultChecked = false, + leadingIcon = { + LeadingIcon { + AvatarIcon( + icon = Icons.Outlined.SpeakerNotesOff, + size = Sizes.Small, + contentDescription = null, + ) + } + }, + ) + } } } } \ No newline at end of file diff --git a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/subposts/SubPostsPage.kt b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/subposts/SubPostsPage.kt index 0cdb9a99..7d5e3496 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/subposts/SubPostsPage.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/subposts/SubPostsPage.kt @@ -75,6 +75,7 @@ import com.huanchengfly.tieba.post.utils.AccountUtil.LocalAccount import com.huanchengfly.tieba.post.utils.DateTimeUtils import com.huanchengfly.tieba.post.utils.StringUtil import com.huanchengfly.tieba.post.utils.TiebaUtil +import com.huanchengfly.tieba.post.utils.appPreferences import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.navigation.DestinationsNavigator import com.ramcosta.composedestinations.spec.DestinationStyleBottomSheet @@ -298,7 +299,7 @@ internal fun SubPostsContent( ) }, bottomBar = { - if (account != null) { + if (account != null && !LocalContext.current.appPreferences.hideReply) { Surface( elevation = 16.dp, color = ExtendedTheme.colors.bottomBar, @@ -521,13 +522,15 @@ private fun SubPostItem( menuState = menuState, indication = null, menuContent = { - DropdownMenuItem( - onClick = { - onReplyClick(subPost.get()) - menuState.expanded = false + if (!context.appPreferences.hideReply) { + DropdownMenuItem( + onClick = { + onReplyClick(subPost.get()) + menuState.expanded = false + } + ) { + Text(text = stringResource(id = R.string.btn_reply)) } - ) { - Text(text = stringResource(id = R.string.btn_reply)) } DropdownMenuItem( onClick = { @@ -558,7 +561,7 @@ private fun SubPostItem( } } }, - onClick = { onReplyClick(subPost.get()) } + onClick = { onReplyClick(subPost.get()) }.takeUnless { context.appPreferences.hideReply } ) { Card( header = { diff --git a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/thread/ThreadPage.kt b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/thread/ThreadPage.kt index 46655c09..a40c01c3 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/ui/page/thread/ThreadPage.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/ui/page/thread/ThreadPage.kt @@ -1463,7 +1463,7 @@ private fun BottomBar( verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp) ) { - if (user.get { is_login } == 1) { + if (user.get { is_login } == 1 && !LocalContext.current.appPreferences.hideReply) { Avatar( data = StringUtil.getAvatarUrl(user.get { portrait }), size = Sizes.Tiny, @@ -1568,15 +1568,17 @@ fun PostCard( indication = null, onClick = { onReplyClick(post) - }, + }.takeIf { !context.appPreferences.hideReply }, menuContent = { - DropdownMenuItem( - onClick = { - onReplyClick(post) - menuState.expanded = false + if (!context.appPreferences.hideReply) { + DropdownMenuItem( + onClick = { + onReplyClick(post) + menuState.expanded = false + } + ) { + Text(text = stringResource(id = R.string.btn_reply)) } - ) { - Text(text = stringResource(id = R.string.btn_reply)) } DropdownMenuItem( onClick = { @@ -1727,7 +1729,9 @@ fun PostCard( modifier = Modifier .fillMaxWidth() .padding(horizontal = 12.dp), - onReplyClick = { onSubPostReplyClick?.invoke(post, it) }, + onReplyClick = { + onSubPostReplyClick?.invoke(post, it) + }, onOpenSubPosts = onOpenSubPosts, ) } @@ -1764,7 +1768,7 @@ private fun SubPostItem( subPostList: ImmutableHolder, subPostContent: AnnotatedString, modifier: Modifier = Modifier, - onReplyClick: (SubPostList) -> Unit, + onReplyClick: ((SubPostList) -> Unit)?, onOpenSubPosts: (Long) -> Unit, ) { val context = LocalContext.current @@ -1772,13 +1776,15 @@ private fun SubPostItem( LongClickMenu( menuState = menuState, menuContent = { - DropdownMenuItem( - onClick = { - onReplyClick(subPostList.get()) - menuState.expanded = false + if (!context.appPreferences.hideReply) { + DropdownMenuItem( + onClick = { + onReplyClick?.invoke(subPostList.get()) + menuState.expanded = false + } + ) { + Text(text = stringResource(id = R.string.title_reply)) } - ) { - Text(text = stringResource(id = R.string.title_reply)) } DropdownMenuItem( onClick = { diff --git a/app/src/main/java/com/huanchengfly/tieba/post/ui/widgets/compose/Toolbar.kt b/app/src/main/java/com/huanchengfly/tieba/post/ui/widgets/compose/Toolbar.kt index 5da66c0d..7f8e2893 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/ui/widgets/compose/Toolbar.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/ui/widgets/compose/Toolbar.kt @@ -195,6 +195,7 @@ fun BackNavigationIcon(onBackPressed: () -> Unit) { )""", "androidx.compose.ui.text.font.FontWeight", "androidx.compose.material.MaterialTheme", + "androidx.compose.material.Text" ) ) @Composable diff --git a/app/src/main/java/com/huanchengfly/tieba/post/utils/AppPreferencesUtils.kt b/app/src/main/java/com/huanchengfly/tieba/post/utils/AppPreferencesUtils.kt index da1b0fa5..ebc23572 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/utils/AppPreferencesUtils.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/utils/AppPreferencesUtils.kt @@ -113,6 +113,8 @@ open class AppPreferencesUtils private constructor(ctx: Context) { var hideForumIntroAndStat by DataStoreDelegates.boolean(defaultValue = false) + var hideReply by DataStoreDelegates.boolean(defaultValue = false) + var homePageScroll by DataStoreDelegates.boolean(defaultValue = false) var imageDarkenWhenNightMode by DataStoreDelegates.boolean(defaultValue = true) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f42b0b48..c7653de6 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -726,4 +726,5 @@ 夜间主题 夜间模式压暗缩略图 修改重启后生效 + 隐藏回贴入口