Skip to content
Snippets Groups Projects
Commit f7d36b02 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Allow showing the history in the SecondaryActivity

Fixes #1280
parent 9f07a151
No related branches found
No related tags found
1 merge request!567Allow showing the history in the SecondaryActivity
Pipeline #16435 passed with stage
in 3 minutes and 46 seconds
<!--
~ *************************************************************************
~ ic_arrow_forward.xml
~ **************************************************************************
~ Copyright © 2020 VLC authors and VideoLAN
~ Author: Nicolas POMEPUY
~ 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.
~ ***************************************************************************
~
~
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="48"
android:viewportHeight="48">
<path
android:pathData="m24.1426,9.0003c0.5405,-0.0078 1.0612,0.2036 1.4433,0.5859L40,24.0003c-4.8047,4.8046 -9.6094,9.6094 -14.4141,14.4141 -0.781,0.7808 -2.0471,0.7808 -2.8281,0 -0.368,-0.3678 -0.5782,-0.8645 -0.5859,-1.3848 -0.01,-0.5405 0.2036,-1.0612 0.5859,-1.4434l9.586,-9.5859H8v-4h24.3438l-9.586,-9.5859c-0.7808,-0.781 -0.7808,-2.0471 0,-2.8281 0.3678,-0.368 0.8646,-0.5782 1.3848,-0.5859z"
android:strokeAlpha="1"
android:strokeLineJoin="bevel"
android:strokeWidth="2"
android:fillColor="?attr/font_default"
android:strokeColor="#00000000"
android:fillAlpha="1"
android:strokeLineCap="round"/>
</vector>
......@@ -87,7 +87,6 @@
android:id="@+id/history_entry"
android:layout_width="0dp"
android:layout_height="wrap_content"
app:button_icon="@drawable/ic_trash_32"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/streams_entry"
......
......@@ -28,6 +28,16 @@
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools">
<View
android:id="@+id/title_content"
android:layout_width="0dp"
android:layout_height="0dp"
android:background="?attr/selectableItemBackground"
app:layout_constraintBottom_toTopOf="@+id/list"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
......@@ -40,34 +50,36 @@
<ImageButton
android:id="@+id/action_button"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_marginEnd="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:background="?attr/selectableItemBackgroundBorderless"
app:layout_constraintBottom_toBottomOf="@+id/title"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/title" />
app:layout_constraintTop_toTopOf="@+id/title"
app:srcCompat="@drawable/ic_arrow_forward" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:clipToPadding="false"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:layout_height="wrap_content"
tools:listitem="@layout/card_browser_item"
android:layout_marginTop="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/title" />
app:layout_constraintTop_toBottomOf="@+id/title"
tools:listitem="@layout/card_browser_item" />
<org.videolan.vlc.gui.view.EmptyLoadingStateView
android:id="@+id/loading"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
app:compact_mode="true"
android:layout_marginEnd="16dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintStart_toStartOf="@+id/title"
app:layout_constraintTop_toBottomOf="@+id/title" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -30,7 +30,7 @@ import android.util.SparseBooleanArray
import android.view.*
import androidx.appcompat.view.ActionMode
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.observe
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
......@@ -93,7 +93,7 @@ class MoreFragment : BaseFragment(), IRefreshable, IHistory, SwipeRefreshLayout.
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
historyEntry = view.findViewById(R.id.history_entry)
viewModel = ViewModelProviders.of(requireActivity(), HistoryModel.Factory(requireContext())).get(HistoryModel::class.java)
viewModel = ViewModelProvider(requireActivity(), HistoryModel.Factory(requireContext())).get(HistoryModel::class.java)
viewModel.dataset.observe(viewLifecycleOwner, Observer<List<MediaWrapper>> { list ->
list?.let {
historyAdapter.update(it)
......@@ -118,7 +118,7 @@ class MoreFragment : BaseFragment(), IRefreshable, IHistory, SwipeRefreshLayout.
historyAdapter.events.onEach { it.process() }.launchWhenStarted(lifecycleScope)
streamsEntry = view.findViewById(R.id.streams_entry)
streamsViewModel = ViewModelProviders.of(requireActivity(), StreamsModel.Factory(requireContext(), showDummy = true)).get(StreamsModel::class.java)
streamsViewModel = ViewModelProvider(requireActivity(), StreamsModel.Factory(requireContext(), showDummy = true)).get(StreamsModel::class.java)
setup(this, streamsViewModel, object : KeyboardListener {
override fun hideKeyboard() {}
})
......@@ -169,7 +169,9 @@ class MoreFragment : BaseFragment(), IRefreshable, IHistory, SwipeRefreshLayout.
streamsEntry.list.adapter = streamsAdapter
historyEntry.setOnActionClickListener {
clearHistory()
val i = Intent(activity, SecondaryActivity::class.java)
i.putExtra("fragment", SecondaryActivity.HISTORY)
requireActivity().startActivityForResult(i, SecondaryActivity.ACTIVITY_RESULT_SECONDARY)
}
multiSelectHelper = historyAdapter.multiSelectHelper
......@@ -238,7 +240,7 @@ class MoreFragment : BaseFragment(), IRefreshable, IHistory, SwipeRefreshLayout.
multiSelectHelper.clearSelection()
}
fun restoreMultiSelectHelper() {
private fun restoreMultiSelectHelper() {
getMultiHelper()?.let {
if (savedSelection.size() > 0) {
......
......@@ -141,6 +141,7 @@ class SecondaryActivity : ContentActivity() {
}
ABOUT -> fragment = AboutFragment()
STREAMS -> fragment = MRLPanelFragment()
HISTORY -> fragment = HistoryFragment()
VIDEO_GROUP_LIST -> {
fragment = VideoGridFragment().apply {
arguments = Bundle(2).apply {
......@@ -174,6 +175,7 @@ class SecondaryActivity : ContentActivity() {
const val ALBUMS_SONGS = "albumsSongs"
const val ABOUT = "about"
const val STREAMS = "streams"
const val HISTORY = "history"
const val VIDEO_GROUP_LIST = "videoGroupList"
const val STORAGE_BROWSER = "storage_browser"
const val FILE_BROWSER = "file_browser"
......
......@@ -37,7 +37,6 @@ import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import org.videolan.tools.setGone
import org.videolan.vlc.R
import org.videolan.vlc.gui.helpers.getBitmapFromDrawable
class TitleListView : ConstraintLayout {
......@@ -58,6 +57,10 @@ class TitleListView : ConstraintLayout {
findViewById<ImageButton>(R.id.action_button)
}
private val titleContent: View by lazy {
findViewById<View>(R.id.title_content)
}
fun setOnActionClickListener(listener: (View) -> Unit) {
this.actionClickListener = listener
}
......@@ -71,7 +74,7 @@ class TitleListView : ConstraintLayout {
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) {
initialize()
initAttributes(attrs, 0)
initAttributes(attrs, defStyle)
}
private fun initAttributes(attrs: AttributeSet, defStyle: Int) {
......@@ -80,11 +83,12 @@ class TitleListView : ConstraintLayout {
try {
titleView.text = a.getString(R.styleable.TitleListView_title)
if (!a.getBoolean(R.styleable.TitleListView_show_button, false)) actionButton.setGone()
val drawableResId = a.getResourceId(R.styleable.TitleListView_button_icon, -1)
if (drawableResId != -1) actionButton.setImageBitmap(context.getBitmapFromDrawable(drawableResId))
actionButton.setOnClickListener {
actionClickListener?.let { listener -> listener(actionButton) }
}
titleContent.setOnClickListener {
actionClickListener?.let { listener -> listener(actionButton) }
}
list.isNestedScrollingEnabled = false
} catch (e: Exception) {
Log.w("", e.message, e)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment