[Android] Get rid of the useless clock on TV

Nicolas Pomepuy git at videolan.org
Thu Jan 11 12:38:49 UTC 2024


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Wed Jan 10 10:05:05 2024 +0100| [cbeb3cc6232542963dd2b684094c5128bc25c540] | committer: Duncan McNamara

Get rid of the useless clock on TV

> https://code.videolan.org/videolan/vlc-android/commit/cbeb3cc6232542963dd2b684094c5128bc25c540
---

 .../org/videolan/television/ui/AboutActivity.kt    |  1 -
 .../java/org/videolan/television/ui/TimeUpdater.kt | 59 ----------------------
 .../television/ui/browser/BaseTvActivity.kt        |  7 ---
 .../src/main/res/layout/activity_media_list_tv.xml |  1 -
 .../main/res/layout/moviepedia_tvshow_details.xml  |  1 -
 .../television/src/main/res/layout/tv_details.xml  |  1 -
 .../television/src/main/res/layout/tv_main.xml     |  1 -
 .../src/main/res/layout/tv_vertical_grid.xml       |  1 -
 application/vlc-android/res/layout/tv_time.xml     | 12 -----
 9 files changed, 84 deletions(-)

diff --git a/application/television/src/main/java/org/videolan/television/ui/AboutActivity.kt b/application/television/src/main/java/org/videolan/television/ui/AboutActivity.kt
index 423fd647bb..236bc1a820 100644
--- a/application/television/src/main/java/org/videolan/television/ui/AboutActivity.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/AboutActivity.kt
@@ -12,6 +12,5 @@ class AboutActivity : FragmentActivity() {
         setContentView(R.layout.about)
         UiTools.fillAboutView(this, window.decorView.rootView)
         applyOverscanMargin(this)
-        this.registerTimeView(findViewById(R.id.tv_time))
     }
 }
diff --git a/application/television/src/main/java/org/videolan/television/ui/TimeUpdater.kt b/application/television/src/main/java/org/videolan/television/ui/TimeUpdater.kt
deleted file mode 100644
index 3d26b91df2..0000000000
--- a/application/television/src/main/java/org/videolan/television/ui/TimeUpdater.kt
+++ /dev/null
@@ -1,59 +0,0 @@
-/*****************************************************************************
- * TimeUpdater.kt
- *****************************************************************************
- * Copyright © 2018 VLC authors, VideoLAN and VideoLabs
- * Author: Geoffrey Métais
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
- *****************************************************************************/
-package org.videolan.television.ui
-
-import android.app.Activity
-import android.content.BroadcastReceiver
-import android.content.Context
-import android.content.Intent
-import android.content.IntentFilter
-import android.widget.TextView
-import androidx.fragment.app.FragmentActivity
-import androidx.lifecycle.DefaultLifecycleObserver
-import androidx.lifecycle.LifecycleOwner
-import java.text.DateFormat
-import java.util.*
-
-private const val TAG = "VLC/TimeUpdater"
-
-class TimeUpdater(private val activity: Activity, private val tv: TextView) : DefaultLifecycleObserver {
-
-    private fun updateTime() {
-
-        val format = DateFormat.getTimeInstance(DateFormat.SHORT, Locale.getDefault())
-        tv.text = format.format(Date())
-    }
-
-    override fun onStart(owner: LifecycleOwner) {
-        activity.registerReceiver(clockReceiver, IntentFilter(Intent.ACTION_TIME_TICK))
-        updateTime()
-    }
-
-    override fun onStop(owner: LifecycleOwner) = activity.unregisterReceiver(clockReceiver)
-
-    private val clockReceiver = object : BroadcastReceiver() {
-        override fun onReceive(context: Context, intent: Intent) {
-            updateTime()
-        }
-    }
-}
-
-fun FragmentActivity.registerTimeView(tv: TextView?) = tv?.let { lifecycle.addObserver(TimeUpdater(this, it)) }
\ No newline at end of file
diff --git a/application/television/src/main/java/org/videolan/television/ui/browser/BaseTvActivity.kt b/application/television/src/main/java/org/videolan/television/ui/browser/BaseTvActivity.kt
index aa73c9ba1c..08ba4d2c33 100644
--- a/application/television/src/main/java/org/videolan/television/ui/browser/BaseTvActivity.kt
+++ b/application/television/src/main/java/org/videolan/television/ui/browser/BaseTvActivity.kt
@@ -31,20 +31,14 @@ import android.content.SharedPreferences
 import android.os.Build
 import android.os.Bundle
 import android.view.KeyEvent
-import android.view.View
-import android.widget.TextView
 import androidx.fragment.app.FragmentActivity
-import androidx.lifecycle.lifecycleScope
 import com.google.android.material.snackbar.Snackbar
-import kotlinx.coroutines.launch
 import org.videolan.libvlc.Dialog
 import org.videolan.medialibrary.interfaces.Medialibrary
 import org.videolan.resources.AppContextProvider
 import org.videolan.resources.util.startMedialibrary
-import org.videolan.television.R
 import org.videolan.television.ui.SearchActivity
 import org.videolan.television.ui.dialogs.ConfirmationTvActivity
-import org.videolan.television.ui.registerTimeView
 import org.videolan.tools.KeyHelper
 import org.videolan.tools.Settings
 import org.videolan.tools.getContextWithLocale
@@ -84,7 +78,6 @@ abstract class BaseTvActivity : FragmentActivity(), IDialogManager {
         mediaLibrary = Medialibrary.getInstance()
         settings = Settings.getInstance(this)
         registerLiveData()
-        lifecycleScope.launch { findViewById<View>(R.id.tv_time)?.let { registerTimeView(it as TextView) } }
         dialogsDelegate.observeDialogs(this, this)
     }
 
diff --git a/application/television/src/main/res/layout/activity_media_list_tv.xml b/application/television/src/main/res/layout/activity_media_list_tv.xml
index 4bbe08baeb..5bf5d6d8c2 100644
--- a/application/television/src/main/res/layout/activity_media_list_tv.xml
+++ b/application/television/src/main/res/layout/activity_media_list_tv.xml
@@ -182,7 +182,6 @@
                 app:layout_constraintStart_toStartOf="parent"
                 app:layout_constraintTop_toBottomOf="@+id/spacer" />
 
-        <include layout="@layout/tv_time" />
 
 
     </androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/application/television/src/main/res/layout/moviepedia_tvshow_details.xml b/application/television/src/main/res/layout/moviepedia_tvshow_details.xml
index a438179549..cd35b3762f 100644
--- a/application/television/src/main/res/layout/moviepedia_tvshow_details.xml
+++ b/application/television/src/main/res/layout/moviepedia_tvshow_details.xml
@@ -32,5 +32,4 @@
             android:layout_width="match_parent"
             android:layout_height="match_parent" />
 
-    <include layout="@layout/tv_time" />
 </FrameLayout>
\ No newline at end of file
diff --git a/application/television/src/main/res/layout/tv_details.xml b/application/television/src/main/res/layout/tv_details.xml
index 19bd82ca27..ac62fa0d11 100644
--- a/application/television/src/main/res/layout/tv_details.xml
+++ b/application/television/src/main/res/layout/tv_details.xml
@@ -7,5 +7,4 @@
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         />
-    <include layout="@layout/tv_time" />
 </FrameLayout>
\ No newline at end of file
diff --git a/application/television/src/main/res/layout/tv_main.xml b/application/television/src/main/res/layout/tv_main.xml
index a2ae5b9c8a..3730cf9f4b 100644
--- a/application/television/src/main/res/layout/tv_main.xml
+++ b/application/television/src/main/res/layout/tv_main.xml
@@ -23,5 +23,4 @@
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintTop_toTopOf="parent"
         tools:visibility="visible" />
-    <include layout="@layout/tv_time" />
 </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
diff --git a/application/television/src/main/res/layout/tv_vertical_grid.xml b/application/television/src/main/res/layout/tv_vertical_grid.xml
index eb6230ef41..cb0a769e22 100644
--- a/application/television/src/main/res/layout/tv_vertical_grid.xml
+++ b/application/television/src/main/res/layout/tv_vertical_grid.xml
@@ -36,5 +36,4 @@
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintEnd_toEndOf="parent"
         app:layout_constraintStart_toStartOf="parent" />
-    <include layout="@layout/tv_time" />
 </androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
diff --git a/application/vlc-android/res/layout/tv_time.xml b/application/vlc-android/res/layout/tv_time.xml
deleted file mode 100644
index edde88b43f..0000000000
--- a/application/vlc-android/res/layout/tv_time.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
-        xmlns:app="http://schemas.android.com/apk/res-auto"
-        android:id="@+id/tv_time"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content"
-        app:layout_constraintTop_toTopOf="parent"
-        app:layout_constraintEnd_toEndOf="parent"
-        android:layout_gravity="end"
-        android:layout_marginRight="16dp"
-        android:layout_marginEnd="16dp"
-        android:layout_marginTop="16dp" />
\ No newline at end of file



More information about the Android mailing list