From fbafb618df3cd172b4fec798173e7b4fe0b23c56 Mon Sep 17 00:00:00 2001 From: toasterofbread Date: Fri, 8 Nov 2024 19:27:18 +0000 Subject: [PATCH] Remove widget debug information display option --- .../toasterofbread/spmp/widget/SpMpWidget.kt | 54 +++++++------------ .../spmp/widget/impl/LyricsWidget.kt | 9 +--- .../spmp/widget/impl/SongQueueWidget.kt | 4 -- .../widget/impl/SplitImageControlsWidget.kt | 4 -- .../values-ja-rJP/strings.xml | 1 - .../composeResources/values/strings.xml | 1 - .../configuration/base/BaseWidgetConfig.kt | 19 +------ .../base/BaseWidgetConfigDefaultsMask.kt | 6 +-- 8 files changed, 23 insertions(+), 75 deletions(-) diff --git a/shared/src/androidMain/kotlin/com/toasterofbread/spmp/widget/SpMpWidget.kt b/shared/src/androidMain/kotlin/com/toasterofbread/spmp/widget/SpMpWidget.kt index 5341a974..069307a8 100644 --- a/shared/src/androidMain/kotlin/com/toasterofbread/spmp/widget/SpMpWidget.kt +++ b/shared/src/androidMain/kotlin/com/toasterofbread/spmp/widget/SpMpWidget.kt @@ -199,44 +199,34 @@ abstract class SpMpWidget>( .clickable(WidgetActionCallback(configuration.type_configuration.click_action)), contentAlignment = Alignment.Center ) { - if (base_configuration.show_debug_information) { - shouldHide() - hasContent() - } - else { + WithCurrentSongImage { song, song_image -> if (shouldHide() || !visible) { - return@Box + return@WithCurrentSongImage } - if (!hasContent() && base_configuration.hide_when_no_content) { - return@Box + if (!hasContent(song) && base_configuration.hide_when_no_content) { + return@WithCurrentSongImage } - } - GlanceBorderBox( - base_configuration.border_radius_dp.dp, - theme.theme.accent, - GlanceModifier - .fillMaxSize() - .systemCornerRadius() - ) { - Column( + GlanceBorderBox( + base_configuration.border_radius_dp.dp, + theme.theme.accent, GlanceModifier .fillMaxSize() - .thenIf(!custom_background) { - background(widget_background_colour) - } .systemCornerRadius() ) { - if (base_configuration.show_debug_information) { - DebugInfoItems(GlanceModifier) - } - - Box( - GlanceModifier.fillMaxSize().defaultWeight(), - contentAlignment = Alignment.Center + Column( + GlanceModifier + .fillMaxSize() + .thenIf(!custom_background) { + background(widget_background_colour) + } + .systemCornerRadius() ) { - WithCurrentSongImage { song, song_image -> + Box( + GlanceModifier.fillMaxSize().defaultWeight(), + contentAlignment = Alignment.Center + ) { Content( song, song_image, GlanceModifier.wrapContentSize(), PaddingValues(15.dp) @@ -321,17 +311,11 @@ abstract class SpMpWidget>( ) @Composable - protected open fun hasContent(): Boolean = true + protected open fun hasContent(song: Song?): Boolean = song != null @Composable protected open fun shouldHide(): Boolean = false - @Composable - protected open fun DebugInfoItems(item_modifier: GlanceModifier) { - WidgetText("ID: $widget_id", item_modifier) - WidgetText("Update: ${widget_type.getUpdateValue()}", item_modifier) - } - @Composable fun WidgetText( text: String, diff --git a/shared/src/androidMain/kotlin/com/toasterofbread/spmp/widget/impl/LyricsWidget.kt b/shared/src/androidMain/kotlin/com/toasterofbread/spmp/widget/impl/LyricsWidget.kt index ef767152..0c06aa65 100644 --- a/shared/src/androidMain/kotlin/com/toasterofbread/spmp/widget/impl/LyricsWidget.kt +++ b/shared/src/androidMain/kotlin/com/toasterofbread/spmp/widget/impl/LyricsWidget.kt @@ -53,18 +53,11 @@ internal abstract class LyricsWidget: SpMpWidget throw IllegalStateException(action.toString()) } - @Composable - override fun hasContent(): Boolean = - LocalPlayerState.current.status.m_song != null - @Composable private fun Heading(text: String, modifier: GlanceModifier = GlanceModifier) { WidgetText( diff --git a/shared/src/androidMain/kotlin/com/toasterofbread/spmp/widget/impl/SplitImageControlsWidget.kt b/shared/src/androidMain/kotlin/com/toasterofbread/spmp/widget/impl/SplitImageControlsWidget.kt index 1ceccdfe..159d3e57 100644 --- a/shared/src/androidMain/kotlin/com/toasterofbread/spmp/widget/impl/SplitImageControlsWidget.kt +++ b/shared/src/androidMain/kotlin/com/toasterofbread/spmp/widget/impl/SplitImageControlsWidget.kt @@ -58,10 +58,6 @@ internal class SplitImageControlsWidget: SpMpWidget throw IllegalStateException(action.toString()) } - @Composable - override fun hasContent(): Boolean = - LocalPlayerState.current.status.m_song != null - @Composable override fun Content( song: Song?, diff --git a/shared/src/commonMain/composeResources/values-ja-rJP/strings.xml b/shared/src/commonMain/composeResources/values-ja-rJP/strings.xml index 7e5348be..ba039eb6 100644 --- a/shared/src/commonMain/composeResources/values-ja-rJP/strings.xml +++ b/shared/src/commonMain/composeResources/values-ja-rJP/strings.xml @@ -1084,7 +1084,6 @@ ボーダーの半径(dp) コンテンツがないときは非表示 アプリのアイコンを表示 - デバッグ情報を表示 タップアクション 不透明度 バックグラウンド diff --git a/shared/src/commonMain/composeResources/values/strings.xml b/shared/src/commonMain/composeResources/values/strings.xml index 7521879e..52c3ac2d 100644 --- a/shared/src/commonMain/composeResources/values/strings.xml +++ b/shared/src/commonMain/composeResources/values/strings.xml @@ -1139,7 +1139,6 @@ Border radius (dp) Hide when no content Show app icon - Show debug information Tap action Opacity Background diff --git a/shared/src/commonMain/kotlin/com/toasterofbread/spmp/widget/configuration/base/BaseWidgetConfig.kt b/shared/src/commonMain/kotlin/com/toasterofbread/spmp/widget/configuration/base/BaseWidgetConfig.kt index 0eb33742..d9428f59 100644 --- a/shared/src/commonMain/kotlin/com/toasterofbread/spmp/widget/configuration/base/BaseWidgetConfig.kt +++ b/shared/src/commonMain/kotlin/com/toasterofbread/spmp/widget/configuration/base/BaseWidgetConfig.kt @@ -7,7 +7,6 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.remember import androidx.compose.ui.Modifier -import com.toasterofbread.spmp.ProjectBuildConfig import com.toasterofbread.spmp.model.settings.category.AccentColourSource import com.toasterofbread.spmp.model.settings.category.FontMode import com.toasterofbread.spmp.platform.AppContext @@ -33,7 +32,6 @@ import spmp.shared.generated.resources.widget_config_common_key_font import spmp.shared.generated.resources.widget_config_common_key_font_size import spmp.shared.generated.resources.widget_config_common_key_hide_when_no_content import spmp.shared.generated.resources.widget_config_common_key_show_app_icon -import spmp.shared.generated.resources.widget_config_common_key_show_debug_information import spmp.shared.generated.resources.widget_config_common_key_styled_border_mode import spmp.shared.generated.resources.widget_config_common_key_theme import spmp.shared.generated.resources.widget_config_common_option_accent_colour_source_app @@ -56,8 +54,7 @@ data class BaseWidgetConfig( val styled_border_mode: WidgetStyledBorderMode = WidgetStyledBorderMode.WAVE, val border_radius_dp: Float = 0f, val hide_when_no_content: Boolean = false, - val show_app_icon: Boolean = true, - val show_debug_information: Boolean = ProjectBuildConfig.IS_DEBUG + val show_app_icon: Boolean = true ): WidgetConfig() { fun LazyListScope.ConfigItems( context: AppContext, @@ -233,20 +230,6 @@ data class BaseWidgetConfig( onItemChanged() } } - configItem( - defaults_mask?.show_debug_information, - item_modifier, - { onDefaultsMaskChanged(defaults_mask!!.copy(show_debug_information = it)) } - ) { modifier, onItemChanged -> - ToggleItem( - show_debug_information, - Res.string.widget_config_common_key_show_debug_information, - modifier - ) { - onChanged(copy(show_debug_information = it)) - onItemChanged() - } - } } @Composable diff --git a/shared/src/commonMain/kotlin/com/toasterofbread/spmp/widget/configuration/base/BaseWidgetConfigDefaultsMask.kt b/shared/src/commonMain/kotlin/com/toasterofbread/spmp/widget/configuration/base/BaseWidgetConfigDefaultsMask.kt index a6af9727..6b5f1fd1 100644 --- a/shared/src/commonMain/kotlin/com/toasterofbread/spmp/widget/configuration/base/BaseWidgetConfigDefaultsMask.kt +++ b/shared/src/commonMain/kotlin/com/toasterofbread/spmp/widget/configuration/base/BaseWidgetConfigDefaultsMask.kt @@ -13,8 +13,7 @@ data class BaseWidgetConfigDefaultsMask( val styled_border_mode: Boolean = true, val border_radius_dp: Boolean = true, val hide_when_no_content: Boolean = true, - val show_app_icon: Boolean = true, - val show_debug_information: Boolean = true + val show_app_icon: Boolean = true ) { fun applyTo(config: BaseWidgetConfig, default: BaseWidgetConfig): BaseWidgetConfig = BaseWidgetConfig( @@ -27,7 +26,6 @@ data class BaseWidgetConfigDefaultsMask( styled_border_mode = if (this.styled_border_mode) default.styled_border_mode else config.styled_border_mode, border_radius_dp = if (this.border_radius_dp) default.border_radius_dp else config.border_radius_dp, hide_when_no_content = if (this.hide_when_no_content) default.hide_when_no_content else config.hide_when_no_content, - show_app_icon = if (this.show_app_icon) default.show_app_icon else config.show_app_icon, - show_debug_information = if (this.show_debug_information) default.show_debug_information else config.show_debug_information, + show_app_icon = if (this.show_app_icon) default.show_app_icon else config.show_app_icon ) } \ No newline at end of file