tv: add text when there are no tunnels

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2020-09-22 20:37:41 +02:00
parent 10bb413187
commit 03189e7b20
3 changed files with 18 additions and 1 deletions

View File

@ -84,6 +84,8 @@ class TvMainActivity : AppCompatActivity() {
if (isDeleting.get()) {
try {
item.deleteAsync()
if (this@TvMainActivity.binding.tunnels?.isEmpty() != false)
isDeleting.set(false)
} catch (e: Throwable) {
val error = ErrorMessages[e]
val message = getString(R.string.config_delete_error, error)

View File

@ -35,8 +35,8 @@
android:layout_marginTop="5dp"
app:cardElevation="2dp"
app:contentPadding="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
@ -54,6 +54,7 @@
android:layout_height="0dp"
android:layout_marginTop="16dp"
android:orientation="horizontal"
android:visibility="@{tunnels.isEmpty() ? View.GONE : View.VISIBLE}"
app:configurationHandler="@{rowConfigurationHandler}"
app:items="@{tunnels}"
app:layout="@{@layout/tv_tunnel_list_item}"
@ -65,6 +66,19 @@
tools:itemCount="10"
tools:listitem="@layout/tv_tunnel_list_item" />
<TextView
style="@style/TextAppearance.MaterialComponents.Headline4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/tv_add_tunnel_get_started"
android:visibility="@{tunnels.isEmpty() ? View.VISIBLE : View.GONE}"
app:layout_constraintBottom_toTopOf="@id/delete_button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/banner_logo"
tools:visibility="gone" />
<com.google.android.material.button.MaterialButton
android:id="@+id/import_button"
style="@style/Widget.MaterialComponents.Button"

View File

@ -103,6 +103,7 @@
<string name="delete">Delete</string>
<string name="tv_delete">Select tunnel to delete</string>
<string name="tv_error">Your TV does not have a file picker</string>
<string name="tv_add_tunnel_get_started">Add a tunnel to get started</string>
<string name="disable_config_export_title">Disable config exporting</string>
<string name="disable_config_export_description">Disabling config exporting makes private keys less accessible</string>
<string name="dns_servers">DNS servers</string>