Commit 674999dd authored by Nicolas Pomepuy's avatar Nicolas Pomepuy

Info activity: manage not scanned / no length medias

Fixes #1032
parent 20270cac
Pipeline #9637 passed with stage
in 25 minutes and 21 seconds
......@@ -55,6 +55,10 @@
name="resolution"
type="String"/>
<variable
name="scanned"
type="boolean" />
</data>
<androidx.coordinatorlayout.widget.CoordinatorLayout
......@@ -200,16 +204,43 @@
android:clipToPadding="false"
android:layout_marginTop="8dp"/>
<ImageView
<TextView
android:id="@+id/directory_not_scanned_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginEnd="8dp"
android:text="@string/directory_not_scanned"
android:textStyle="bold"
android:visibility="@{scanned ? View.GONE : View.VISIBLE}"
vlc:layout_constraintBottom_toBottomOf="@+id/directory_not_scanned_button"
vlc:layout_constraintEnd_toStartOf="@+id/directory_not_scanned_button"
vlc:layout_constraintStart_toStartOf="parent"
vlc:layout_constraintTop_toTopOf="@+id/directory_not_scanned_button" />
<Button
android:id="@+id/directory_not_scanned_button"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
vlc:srcCompat="@drawable/ic_duration"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:text="@string/add"
android:visibility="@{scanned ? View.GONE : View.VISIBLE}"
vlc:layout_constraintEnd_toEndOf="parent"
vlc:layout_constraintTop_toBottomOf="@+id/ariane" />
<ImageView
android:id="@+id/length_icon"
android:layout_marginTop="24dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:padding="8dp"
vlc:layout_constraintTop_toBottomOf="@+id/ariane"
android:visibility="@{TextUtils.isEmpty(length) ? View.GONE : View.VISIBLE}"
vlc:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="16dp"/>
vlc:layout_constraintTop_toBottomOf="@+id/directory_not_scanned_button"
vlc:srcCompat="@drawable/ic_duration" />
<TextView
android:id="@+id/length_title"
......@@ -217,6 +248,7 @@
android:layout_height="wrap_content"
android:text="@string/length"
android:textColor="?attr/font_audio_light"
android:visibility="@{TextUtils.isEmpty(length) ? View.GONE : View.VISIBLE}"
android:textStyle="bold"
vlc:layout_constraintStart_toEndOf="@+id/length_icon"
android:layout_marginStart="16dp"
......
......@@ -731,6 +731,8 @@
<string name="report_a_crash">Report a crash</string>
<string name="describe_crash">Please describe how this crash happened</string>
<string name="favorite">Favorite</string>
<string name="directory_not_scanned">This directory is not scanned</string>
<string name="scanned_directory_added">%s added to your scanned directories</string>
<string name="video_group_size_dialog_text">Number of characters used to group by name</string>
<string name="video_group_size_summary">Group by %s first letters</string>
<string name="video_group_size">Group videos by name</string>
......
......@@ -2,11 +2,11 @@ package org.videolan.vlc.gui
import android.content.Context
import android.graphics.Bitmap
import android.graphics.Rect
import android.graphics.drawable.BitmapDrawable
import android.net.Uri
import android.os.Bundle
import android.os.Parcelable
import android.util.Log
import android.view.Gravity
import android.view.View
import androidx.coordinatorlayout.widget.CoordinatorLayout
......@@ -18,22 +18,23 @@ import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModel
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.snackbar.Snackbar
import kotlinx.coroutines.*
import org.videolan.libvlc.Media
import org.videolan.libvlc.util.Extensions
import org.videolan.medialibrary.Tools
import org.videolan.medialibrary.interfaces.AbstractMedialibrary
import org.videolan.medialibrary.interfaces.media.AbstractArtist
import org.videolan.medialibrary.interfaces.media.AbstractMediaWrapper
import org.videolan.medialibrary.media.MediaLibraryItem
import org.videolan.vlc.BuildConfig
import org.videolan.vlc.R
import org.videolan.vlc.databinding.InfoActivityBinding
import org.videolan.vlc.gui.browser.PathAdapter
import org.videolan.vlc.gui.browser.PathAdapterListener
import org.videolan.vlc.gui.helpers.AudioUtil
import org.videolan.vlc.gui.helpers.FloatingActionButtonBehavior
import org.videolan.vlc.gui.helpers.MedialibraryUtils
import org.videolan.vlc.gui.video.MediaInfoAdapter
import org.videolan.vlc.gui.view.VLCDividerItemDecoration
import org.videolan.vlc.media.MediaUtils
......@@ -104,6 +105,13 @@ class InfoActivity : AudioPlayerContainerActivity(), View.OnClickListener, PathA
})
if (model.cover.value === null) model.getCover(item.artworkMrl, getScreenWidth())
launch { updateMeta() }
binding.directoryNotScannedButton.setOnClickListener {
val media = item as AbstractMediaWrapper
val parent = media.uri.toString().substring(0, media.uri.toString().lastIndexOf("/"))
MedialibraryUtils.addDir(parent, applicationContext)
Snackbar.make(binding.root, getString(R.string.scanned_directory_added, Uri.parse(parent).lastPathSegment), Snackbar.LENGTH_LONG).show()
binding.scanned = true
}
}
private fun updateMeta() {
......@@ -112,18 +120,17 @@ class InfoActivity : AudioPlayerContainerActivity(), View.OnClickListener, PathA
val nbTracks = tracks?.size ?: 0
if (nbTracks > 0) for (media in tracks!!) length += media.length
if (length > 0)
binding.length = Tools.millisToTextLarge(length)
if (item is AbstractMediaWrapper) {
val media = item as AbstractMediaWrapper
val resolution = generateResolutionClass(media.width, media.height)
binding.resolution = resolution
}
if (item is AbstractMediaWrapper) {
val media = item as AbstractMediaWrapper
val resolution = generateResolutionClass(media.width, media.height)
binding.resolution = resolution
}
binding.scanned = true
when {
item.itemType == MediaLibraryItem.TYPE_MEDIA -> {
val media = item as AbstractMediaWrapper
// binding.path = Uri.decode(media!!.uri.path).replace("/", " > ")
binding.progress = if (media.length == 0L) 0 else (100.toLong() * media.time / length).toInt()
binding.sizeTitleText = getString(R.string.file_size)
......@@ -136,6 +143,15 @@ class InfoActivity : AudioPlayerContainerActivity(), View.OnClickListener, PathA
if (binding.ariane.itemDecorationCount == 0) {
binding.ariane.addItemDecoration(VLCDividerItemDecoration(this, DividerItemDecoration.HORIZONTAL, ContextCompat.getDrawable(this, R.drawable.ic_divider)!!))
}
//scheme is supported => test if the parent is scanned
var isScanned = false
AbstractMedialibrary.getInstance().foldersList.forEach search@{
if (media.uri.toString().startsWith(Uri.parse(it).toString())) {
isScanned = true
return@search
}
}
binding.scanned = isScanned
} else binding.ariane.visibility = View.GONE
}
item.itemType == MediaLibraryItem.TYPE_ARTIST -> {
......
......@@ -10,7 +10,6 @@ import androidx.core.content.ContextCompat
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.lifecycle.ViewModelProviders
import androidx.recyclerview.widget.DividerItemDecoration
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
......
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