-
Notifications
You must be signed in to change notification settings - Fork 479
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
android/tv: reduce layout width and fix navigation
fixes tailscale/corp#18956 fixes tailscale/corp#18964 Adds a letterboxing effect as a temporary measure to make the UI a bit more usable on AndroidTV. Fixes a few navigation peculiarities specific to TV (notably, there some padding on the user avatar so you can see when it's highlighted) Pops a QR code on AndroidTV where we have no browser to complete the flow.
- Loading branch information
Showing
23 changed files
with
660 additions
and
407 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
android/src/main/java/com/tailscale/ipn/ui/util/AndroidTVUtil.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.tailscale.ipn.ui.util | ||
|
||
import android.content.pm.PackageManager | ||
import androidx.compose.foundation.layout.padding | ||
import androidx.compose.foundation.shape.RoundedCornerShape | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.draw.clip | ||
import androidx.compose.ui.unit.dp | ||
import com.tailscale.ipn.App | ||
import com.tailscale.ipn.ui.util.AndroidTVUtil.isAndroidTV | ||
|
||
object AndroidTVUtil { | ||
fun isAndroidTV(): Boolean { | ||
return (App.appInstance.packageManager.hasSystemFeature(PackageManager.FEATURE_TELEVISION) || | ||
App.appInstance.packageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK)) | ||
} | ||
} | ||
|
||
// Applies a letterbox effect iff we're running on Android TV to reduce the overall width | ||
// of the UI. | ||
fun Modifier.universalFit(): Modifier { | ||
return when (isAndroidTV()) { | ||
true -> this.padding(horizontal = 150.dp, vertical = 10.dp).clip(RoundedCornerShape(10.dp)) | ||
false -> this | ||
} | ||
} |
Oops, something went wrong.