Commit 53c1c33b authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

TV: Show current time on top right corner

parent 0de8c2d8
......@@ -108,4 +108,5 @@
</LinearLayout>
<include layout="@layout/tv_time" />
</ScrollView>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
android:name="org.videolan.vlc.gui.tv.MediaItemDetailsFragment"
android:id="@+id/details_fragment"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
\ No newline at end of file
android:layout_height="match_parent" >
<fragment
android:id="@+id/details_fragment"
android:name="org.videolan.vlc.gui.tv.MediaItemDetailsFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<include layout="@layout/tv_time" />
</FrameLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tv_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent">
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/tv_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/transparent">
<fragment
android:name="org.videolan.vlc.gui.tv.MainTvFragment"
android:id="@+id/browse_fragment"
......@@ -14,8 +15,12 @@
android:id="@+id/tv_main_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|right"
android:layout_gravity="top|end"
android:layout_marginRight="128dp"
android:layout_marginEnd="128dp"
android:layout_marginTop="32dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:visibility="gone" />
</FrameLayout>
\ No newline at end of file
<include layout="@layout/tv_time" />
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
<?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
......@@ -19,4 +19,5 @@
android:layout_gravity="center"
android:text="@string/directory_empty"
android:visibility="gone"/>
<include layout="@layout/tv_time" />
</FrameLayout>
\ No newline at end of file
/*****************************************************************************
* MainTvActivity.java
*****************************************************************************
* Copyright © 2014-2016 VLC authors, VideoLAN and VideoLabs
* Copyright © 2014-2018 VLC authors, VideoLAN and VideoLabs
* Author: Geoffrey Métais
*
* This program is free software; you can redistribute it and/or modify
......
......@@ -57,6 +57,4 @@ class TimeUpdater(private val activity: Activity, private val tv: TextView) : Li
}
}
fun FragmentActivity.registerTimeView(tv: TextView) {
lifecycle.addObserver(TimeUpdater(this, tv))
}
\ No newline at end of file
fun FragmentActivity.registerTimeView(tv: TextView?) = tv?.let { lifecycle.addObserver(TimeUpdater(this, it)) }
\ No newline at end of file
......@@ -29,18 +29,22 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.support.annotation.Nullable;
import android.view.KeyEvent;
import android.widget.TextView;
import org.videolan.medialibrary.Medialibrary;
import org.videolan.vlc.ExternalMonitor;
import org.videolan.vlc.MediaParsingService;
import org.videolan.vlc.R;
import org.videolan.vlc.ScanProgress;
import org.videolan.vlc.VLCApplication;
import org.videolan.vlc.gui.PlaybackServiceActivity;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.gui.tv.SearchActivity;
import org.videolan.vlc.gui.tv.TimeUpdaterKt;
import org.videolan.vlc.util.Constants;
import org.videolan.vlc.util.Permissions;
......@@ -64,6 +68,12 @@ public abstract class BaseTvActivity extends PlaybackServiceActivity {
mMediaLibrary = VLCApplication.getMLInstance();
mSettings = PreferenceManager.getDefaultSharedPreferences(this);
registerLiveData();
new Handler().post(new Runnable() {
@Override
public void run() {
TimeUpdaterKt.registerTimeView(BaseTvActivity.this, (TextView) findViewById(R.id.tv_time));
}
});
}
@Override
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment