Skip to content

Commit

Permalink
Remove widget debug information display option
Browse files Browse the repository at this point in the history
  • Loading branch information
toasterofbread committed Nov 8, 2024
1 parent 4ee5a00 commit fbafb61
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,44 +199,34 @@ abstract class SpMpWidget<A: TypeWidgetClickAction, T: TypeWidgetConfig<A>>(
.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)
Expand Down Expand Up @@ -321,17 +311,11 @@ abstract class SpMpWidget<A: TypeWidgetClickAction, T: TypeWidgetConfig<A>>(
)

@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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,11 @@ internal abstract class LyricsWidget: SpMpWidget<LyricsWidgetClickAction, Lyrics
}

@Composable
override fun hasContent(): Boolean {
val song: Song? = LocalPlayerState.current.status.m_song
override fun hasContent(song: Song?): Boolean {
lyrics_state = song?.let { SongLyricsLoader.rememberItemState(it, context) }
return lyrics_state?.lyrics?.sync_type?.let { it != SongLyrics.SyncType.NONE } == true
}

@Composable
override fun DebugInfoItems(item_modifier: GlanceModifier) {
super.DebugInfoItems(item_modifier)
WidgetText("Song: ${lyrics_state?.song} (${lyrics_state?.song?.observeActiveTitle()?.value})", item_modifier)
}

@Composable
final override fun Content(
song: Song?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ internal class SongQueueWidget: SpMpWidget<SongQueueWidgetClickAction, SongQueue
else -> 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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ internal class SplitImageControlsWidget: SpMpWidget<SplitImageControlsWidgetClic
else -> throw IllegalStateException(action.toString())
}

@Composable
override fun hasContent(): Boolean =
LocalPlayerState.current.status.m_song != null

@Composable
override fun Content(
song: Song?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,6 @@
<string name="widget_config_common_key_border_radius">ボーダーの半径(dp)</string>
<string name="widget_config_common_key_hide_when_no_content">コンテンツがないときは非表示</string>
<string name="widget_config_common_key_show_app_icon">アプリのアイコンを表示</string>
<string name="widget_config_common_key_show_debug_information">デバッグ情報を表示</string>
<string name="widget_config_common_key_click_action">タップアクション</string>
<string name="widget_config_common_key_section_theme_opacity">不透明度</string>
<string name="widget_config_common_option_section_theme_mode_background">バックグラウンド</string>
Expand Down
1 change: 0 additions & 1 deletion shared/src/commonMain/composeResources/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,6 @@
<string name="widget_config_common_key_border_radius">Border radius (dp)</string>
<string name="widget_config_common_key_hide_when_no_content">Hide when no content</string>
<string name="widget_config_common_key_show_app_icon">Show app icon</string>
<string name="widget_config_common_key_show_debug_information">Show debug information</string>
<string name="widget_config_common_key_click_action">Tap action</string>
<string name="widget_config_common_key_section_theme_opacity">Opacity</string>
<string name="widget_config_common_option_section_theme_mode_background">Background</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
)
}

0 comments on commit fbafb61

Please sign in to comment.