-
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. Signed-off-by: Jonathan Nobels <[email protected]>
- Loading branch information
Showing
15 changed files
with
412 additions
and
194 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
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
29 changes: 29 additions & 0 deletions
29
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,29 @@ | ||
// Copyright (c) Tailscale Inc & AUTHORS | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
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.