Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
Expand Down Expand Up @@ -99,7 +100,10 @@ internal fun OutputSheetContent(outputs: RemoteRepository.Outputs, onOutput: (St
val name = when {
output.id == RemoteRepository.LOCAL_OUTPUT ->
output.name.ifBlank { stringResource(R.string.fragment_title_connection) }
output.isThisPhone -> stringResource(R.string.output_this_phone, output.name)
output.isThisPhone -> stringResource(
if (isTablet()) R.string.output_this_tablet else R.string.output_this_phone,
output.name,
)
else -> output.name
}
ListItem(
Expand All @@ -122,12 +126,17 @@ internal fun OutputSheetContent(outputs: RemoteRepository.Outputs, onOutput: (St
}

/**
* What an output is, as an icon: Clementine's computer, this phone, or another device. Clementine
* doesn't say what kind of device the others are, so they're shown as speakers.
* What an output is, as an icon: Clementine's computer, this phone or tablet, or another device.
* Clementine doesn't say what kind of device the others are, so they're shown as speakers.
*/
@DrawableRes
@Composable
internal fun outputIcon(output: RemoteRepository.Output): Int = when {
output.id == RemoteRepository.LOCAL_OUTPUT -> R.drawable.ic_computer
output.isThisPhone -> R.drawable.ic_smartphone
output.isThisPhone -> if (isTablet()) R.drawable.ic_tablet else R.drawable.ic_smartphone
else -> R.drawable.ic_speaker
}

/** Whether this device is a tablet: at least 600dp wide whichever way it's held. */
@Composable
private fun isTablet(): Boolean = LocalConfiguration.current.smallestScreenWidthDp >= 600
11 changes: 11 additions & 0 deletions app/src/main/res/drawable/ic_tablet.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Material Icons "tablet" (Apache 2.0). -->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M21,4H3c-1.1,0 -2,0.9 -2,2v12c0,1.1 0.9,2 2,2h18c1.1,0 1.99,-0.9 1.99,-2L23,6c0,-1.1 -0.9,-2 -2,-2zM19,18H5V6h14v12z" />
</vector>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
<string name="connection_switch_summary">Pick another computer on your network</string>
<string name="output_title">Play on</string>
<string name="output_this_phone">%1$s (this phone)</string>
<string name="output_this_tablet">%1$s (this tablet)</string>
<string name="output_switching">Switching…</string>
<string name="output_playing_on">Playing on %1$s</string>
<string name="output_choose">Choose where to play</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config

/** The output sheet lists where Clementine can play, and moves playback when one is picked. */
@RunWith(RobolectricTestRunner::class)
Expand Down Expand Up @@ -67,6 +68,18 @@ class OutputSheetTest {
compose.onNodeWithText("Clementine").assertExists()
}

@Test
@Config(qualifiers = "sw600dp")
fun aTabletIsCalledATablet() {
compose.setContent {
ClementineTheme(dynamicColor = false) {
OutputSheetContent(outputs(RemoteRepository.LOCAL_OUTPUT), onOutput = {})
}
}

compose.onNodeWithText("Pixel 9 (this tablet)").assertExists()
}

@Test
fun theButtonSaysWhereClementinePlays() {
var outputs by mutableStateOf(outputs(RemoteRepository.LOCAL_OUTPUT))
Expand Down
Loading