From 4f39e4ecbfaacb59e4e30449744cddea0951e7a3 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Mon, 5 Feb 2024 14:07:59 -0500 Subject: [PATCH] Temp workaround for compose-settings height bug. (#1345) - See https://github.com/alorma/Compose-Settings/issues/203 - Fixes #1338 --- .../components/settings/SettingsActivity.kt | 5 ++++ .../settings/about/AboutActivity.kt | 11 +++++++- .../settings/account/AccountSettings.kt | 11 ++++++++ .../lookandfeel/LookAndFeelActivity.kt | 25 ++++++++++++++++++- .../main/java/com/jerboa/ui/theme/Sizes.kt | 5 +++- 5 files changed, 54 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/jerboa/ui/components/settings/SettingsActivity.kt b/app/src/main/java/com/jerboa/ui/components/settings/SettingsActivity.kt index 01c3407b7..df5cfb877 100644 --- a/app/src/main/java/com/jerboa/ui/components/settings/SettingsActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/settings/SettingsActivity.kt @@ -4,6 +4,7 @@ package com.jerboa.ui.components.settings import android.util.Log import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.material.icons.Icons import androidx.compose.material.icons.outlined.Info @@ -25,6 +26,7 @@ import com.jerboa.model.AccountViewModel import com.jerboa.ui.components.common.JerboaSnackbarHost import com.jerboa.ui.components.common.SimpleTopAppBar import com.jerboa.ui.components.common.getCurrentAccount +import com.jerboa.ui.theme.SETTINGS_MENU_LINK_HEIGHT @Composable fun SettingsActivity( @@ -47,6 +49,7 @@ fun SettingsActivity( content = { padding -> Column(modifier = Modifier.padding(padding)) { SettingsMenuLink( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), title = { Text(stringResource(R.string.settings_activity_look_and_feel)) }, icon = { Icon( @@ -58,6 +61,7 @@ fun SettingsActivity( ) if (!account.isAnon()) { SettingsMenuLink( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), title = { Text( stringResource( @@ -76,6 +80,7 @@ fun SettingsActivity( ) } SettingsMenuLink( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), title = { Text(stringResource(R.string.settings_activity_about)) }, icon = { Icon( diff --git a/app/src/main/java/com/jerboa/ui/components/settings/about/AboutActivity.kt b/app/src/main/java/com/jerboa/ui/components/settings/about/AboutActivity.kt index 15bd33f6c..341806021 100644 --- a/app/src/main/java/com/jerboa/ui/components/settings/about/AboutActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/settings/about/AboutActivity.kt @@ -2,6 +2,7 @@ package com.jerboa.ui.components.settings.about import android.util.Log import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.rememberScrollState @@ -29,6 +30,7 @@ import androidx.compose.ui.unit.dp import com.alorma.compose.settings.ui.SettingsMenuLink import com.jerboa.R import com.jerboa.ui.components.common.SimpleTopAppBar +import com.jerboa.ui.theme.SETTINGS_MENU_LINK_HEIGHT const val GITHUB_URL = "https://github.com/dessalines/jerboa" const val JERBOA_MATRIX_CHAT = "https://matrix.to/#/#jerboa-dev:matrix.org" @@ -73,6 +75,7 @@ fun AboutActivity( .padding(padding), ) { SettingsMenuLink( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), title = { Text(stringResource(R.string.settings_about_what_s_new)) }, subtitle = { Text( @@ -95,6 +98,7 @@ fun AboutActivity( SettingsDivider() SettingsHeader(text = stringResource(R.string.settings_about_support)) SettingsMenuLink( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), title = { Text(stringResource(R.string.settings_about_issue_tracker)) }, icon = { Icon( @@ -107,6 +111,7 @@ fun AboutActivity( }, ) SettingsMenuLink( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), title = { Text(stringResource(R.string.crash_logs)) }, icon = { Icon( @@ -117,6 +122,7 @@ fun AboutActivity( onClick = onClickCrashLogs, ) SettingsMenuLink( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), title = { Text(stringResource(R.string.settings_about_developer_matrix_chatroom)) }, icon = { Icon( @@ -129,6 +135,7 @@ fun AboutActivity( }, ) SettingsMenuLink( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), title = { Text(stringResource(R.string.settings_about_donate_to_jerboa_development)) }, icon = { Icon( @@ -143,6 +150,7 @@ fun AboutActivity( SettingsDivider() SettingsHeader(text = stringResource(R.string.about_social)) SettingsMenuLink( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), title = { Text(stringResource(R.string.settings_about_join_c_jerboa)) }, icon = { Icon( @@ -156,6 +164,7 @@ fun AboutActivity( }, ) SettingsMenuLink( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), title = { Text(stringResource(R.string.settings_about_follow_on_mastodon)) }, icon = { Icon( @@ -170,7 +179,7 @@ fun AboutActivity( SettingsDivider() SettingsHeader(text = stringResource(R.string.settings_about_open_source)) SettingsMenuLink( - modifier = Modifier.padding(top = 20.dp), + modifier = Modifier.padding(top = 20.dp).height(SETTINGS_MENU_LINK_HEIGHT), title = { Text(stringResource(R.string.settings_about_source_code)) }, subtitle = { Text( diff --git a/app/src/main/java/com/jerboa/ui/components/settings/account/AccountSettings.kt b/app/src/main/java/com/jerboa/ui/components/settings/account/AccountSettings.kt index c76282986..f9c146857 100644 --- a/app/src/main/java/com/jerboa/ui/components/settings/account/AccountSettings.kt +++ b/app/src/main/java/com/jerboa/ui/components/settings/account/AccountSettings.kt @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.imePadding import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState @@ -48,6 +49,7 @@ import com.jerboa.ui.components.common.MarkdownTextField import com.jerboa.ui.components.common.PickImage import com.jerboa.ui.components.common.PictrsBannerImage import com.jerboa.ui.theme.MEDIUM_PADDING +import com.jerboa.ui.theme.SETTINGS_MENU_LINK_HEIGHT import com.jerboa.ui.theme.muted import it.vercruysse.lemmyapi.dto.ListingType import it.vercruysse.lemmyapi.dto.SortType @@ -254,6 +256,7 @@ fun SettingsForm( } } SettingsListDropdown( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = defaultListingType, title = { Text(text = stringResource(R.string.account_settings_default_listing_type)) }, items = @@ -264,24 +267,28 @@ fun SettingsForm( ), ) SettingsListDropdown( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = defaultSortType, title = { Text(text = stringResource(R.string.account_settings_default_sort_type)) }, items = sortTypeNames, ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = showNsfw, title = { Text(text = stringResource(R.string.account_settings_show_nsfw)) }, ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = showAvatars, title = { Text(text = stringResource(R.string.account_settings_show_avatars)) }, ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = showReadPosts, title = { Text(text = stringResource(R.string.account_settings_show_read_posts)) @@ -289,24 +296,28 @@ fun SettingsForm( ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = botAccount, title = { Text(text = stringResource(R.string.account_settings_bot_account)) }, ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = showBotAccount, title = { Text(text = stringResource(R.string.account_settings_show_bot_accounts)) }, ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = showScores, title = { Text(text = stringResource(R.string.account_settings_show_scores)) }, ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), enabled = email.isNotEmpty(), state = sendNotificationsToEmail, title = { diff --git a/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt b/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt index 46e065895..28321fcb3 100644 --- a/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt +++ b/app/src/main/java/com/jerboa/ui/components/settings/lookandfeel/LookAndFeelActivity.kt @@ -3,6 +3,7 @@ package com.jerboa.ui.components.settings.lookandfeel import android.util.Log import androidx.appcompat.app.AppCompatDelegate import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.height import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll @@ -50,6 +51,7 @@ import com.jerboa.matchLocale import com.jerboa.model.AppSettingsViewModel import com.jerboa.ui.components.common.JerboaSnackbarHost import com.jerboa.ui.components.common.SimpleTopAppBar +import com.jerboa.ui.theme.SETTINGS_MENU_LINK_HEIGHT @OptIn(ExperimentalMaterial3Api::class) @Composable @@ -150,6 +152,7 @@ fun LookAndFeelActivity( .padding(padding), ) { SettingsListDropdown( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), title = { Text(text = stringResource(R.string.lang_language)) }, @@ -168,7 +171,7 @@ fun LookAndFeelActivity( }, ) SettingsSlider( - modifier = Modifier.padding(top = 10.dp), + modifier = Modifier.padding(top = 10.dp).height(SETTINGS_MENU_LINK_HEIGHT), valueRange = 8f..48f, state = fontSizeState, icon = { @@ -189,6 +192,7 @@ fun LookAndFeelActivity( onValueChangeFinished = { updateAppSettings() }, ) SettingsList( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = themeState, items = ThemeMode.entries.map { stringResource(it.mode) }, icon = { @@ -206,6 +210,7 @@ fun LookAndFeelActivity( }, ) SettingsList( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = themeColorState, items = ThemeColor.entries.map { stringResource(it.mode) }, icon = { @@ -223,6 +228,7 @@ fun LookAndFeelActivity( }, ) SettingsList( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = postViewModeState, items = PostViewMode.entries.map { stringResource(it.mode) }, icon = { @@ -240,6 +246,7 @@ fun LookAndFeelActivity( }, ) SettingsList( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = postNavigationGestureModeState, items = PostNavigationGestureMode.entries.map { stringResource(it.mode) }, icon = { @@ -257,6 +264,7 @@ fun LookAndFeelActivity( }, ) SettingsList( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), title = { Text(text = stringResource(R.string.confirm_exit)) }, @@ -274,6 +282,7 @@ fun LookAndFeelActivity( }, ) SettingsList( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), title = { Text(text = stringResource(R.string.post_actionbar)) }, @@ -291,6 +300,7 @@ fun LookAndFeelActivity( }, ) SettingsListDropdown( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = blurNSFW, icon = { Icon( @@ -303,6 +313,7 @@ fun LookAndFeelActivity( onItemSelected = { _, _ -> updateAppSettings() }, ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = showBottomNavState, title = { Text(text = stringResource(R.string.look_and_feel_show_navigation_bar)) @@ -310,6 +321,7 @@ fun LookAndFeelActivity( onCheckedChange = { updateAppSettings() }, ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = showTextDescriptionsInNavbar, title = { Text(text = stringResource(R.string.look_and_feel_show_text_descriptions_in_navbar)) @@ -318,6 +330,7 @@ fun LookAndFeelActivity( enabled = showBottomNavState.value, ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = showCollapsedCommentContentState, title = { Text(text = stringResource(R.string.look_and_feel_activity_show_content_for_collapsed_comments)) @@ -325,6 +338,7 @@ fun LookAndFeelActivity( onCheckedChange = { updateAppSettings() }, ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = showCommentActionBarByDefaultState, title = { Text(text = stringResource(R.string.look_and_feel_show_action_bar_for_comments)) @@ -332,6 +346,7 @@ fun LookAndFeelActivity( onCheckedChange = { updateAppSettings() }, ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = showVotingArrowsInListViewState, title = { Text(text = stringResource(R.string.look_and_feel_show_voting_arrows_list_view)) @@ -339,6 +354,7 @@ fun LookAndFeelActivity( onCheckedChange = { updateAppSettings() }, ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = showParentCommentNavigationButtonsState, title = { Text(text = stringResource(R.string.look_and_feel_show_parent_comment_navigation_buttons)) @@ -346,6 +362,7 @@ fun LookAndFeelActivity( onCheckedChange = { updateAppSettings() }, ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = navigateParentCommentsWithVolumeButtonsState, title = { Text(text = stringResource(R.string.look_and_feel_navigate_parent_comments_with_volume_buttons)) @@ -353,6 +370,7 @@ fun LookAndFeelActivity( onCheckedChange = { updateAppSettings() }, ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = useCustomTabsState, title = { Text(text = stringResource(id = R.string.look_and_feel_use_custom_tabs)) @@ -360,6 +378,7 @@ fun LookAndFeelActivity( onCheckedChange = { updateAppSettings() }, ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = usePrivateTabsState, title = { Text(text = stringResource(id = R.string.look_and_feel_use_private_tabs)) @@ -367,6 +386,7 @@ fun LookAndFeelActivity( onCheckedChange = { updateAppSettings() }, ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = secureWindowState, title = { Text(text = stringResource(R.string.look_and_feel_secure_window)) @@ -374,6 +394,7 @@ fun LookAndFeelActivity( onCheckedChange = { updateAppSettings() }, ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = showPostLinkPreviewMode, title = { Text(stringResource(id = R.string.show_post_link_previews)) @@ -381,6 +402,7 @@ fun LookAndFeelActivity( onCheckedChange = { updateAppSettings() }, ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = markAsReadOnScroll, title = { Text(stringResource(id = R.string.mark_as_read_on_scroll)) @@ -388,6 +410,7 @@ fun LookAndFeelActivity( onCheckedChange = { updateAppSettings() }, ) SettingsCheckbox( + modifier = Modifier.height(SETTINGS_MENU_LINK_HEIGHT), state = autoPlayGifs, title = { Text(stringResource(id = R.string.settings_autoplaygifs)) diff --git a/app/src/main/java/com/jerboa/ui/theme/Sizes.kt b/app/src/main/java/com/jerboa/ui/theme/Sizes.kt index 0e6c736c6..da690fd1d 100644 --- a/app/src/main/java/com/jerboa/ui/theme/Sizes.kt +++ b/app/src/main/java/com/jerboa/ui/theme/Sizes.kt @@ -22,8 +22,11 @@ val THUMBNAIL_CARET_SIZE = 10.dp val DRAWER_ITEM_SPACING = 24.dp -// TODO remove all DPs from code, put here. +// TODO this needs to be removed when Intrinsic height min is fixed +// See https://github.com/alorma/Compose-Settings/issues/203 +val SETTINGS_MENU_LINK_HEIGHT = 88.dp +// TODO remove all DPs from code, put here. const val ICON_THUMBNAIL_SIZE = 96 const val LARGER_ICON_THUMBNAIL_SIZE = 256 const val THUMBNAIL_SIZE = 256