mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-13 22:00:30 +05:30
Merge pull request #31 from FireMasterK/improvements
Update dependencies, improvements, TimeAgo changes, and StreamItem duration
This commit is contained in:
commit
31d7461bd4
@ -18,10 +18,14 @@ android {
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
|
||||
debug {
|
||||
debuggable true
|
||||
applicationIdSuffix ".debug"
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
@ -38,10 +42,10 @@ dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.4.1'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
|
||||
implementation 'com.google.android.material:material:1.6.0-alpha02'
|
||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.0'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.4.0'
|
||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.4.1'
|
||||
implementation 'androidx.navigation:navigation-ui-ktx:2.4.1'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
implementation("androidx.preference:preference-ktx:1.2.0")
|
||||
implementation 'androidx.preference:preference-ktx:1.2.0'
|
||||
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
|
||||
|
@ -191,7 +191,7 @@ class ChannelFragment : Fragment() {
|
||||
isLoading=false
|
||||
runOnUiThread {
|
||||
view.findViewById<TextView>(R.id.channel_name).text=response.name
|
||||
view.findViewById<TextView>(R.id.channel_subs).text=response.subscriberCount.videoViews() + " subscribers"
|
||||
view.findViewById<TextView>(R.id.channel_subs).text=response.subscriberCount.formatShort() + " subscribers"
|
||||
view.findViewById<TextView>(R.id.channel_description).text=response.description
|
||||
val bannerImage = view.findViewById<ImageView>(R.id.channel_banner)
|
||||
val channelImage = view.findViewById<ImageView>(R.id.channel_image)
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.github.libretube
|
||||
|
||||
import android.R.attr
|
||||
import android.R.attr.*
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import androidx.fragment.app.Fragment
|
||||
@ -9,18 +7,14 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.constraintlayout.motion.widget.MotionLayout
|
||||
import androidx.constraintlayout.widget.ConstraintSet
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.google.android.exoplayer2.ExoPlayer
|
||||
import com.google.android.exoplayer2.MediaItem
|
||||
import com.google.android.exoplayer2.MediaItem.SubtitleConfiguration
|
||||
import com.google.android.exoplayer2.source.MediaSource
|
||||
|
||||
import com.google.android.exoplayer2.ui.PlayerView
|
||||
import com.google.android.exoplayer2.ui.StyledPlayerControlView
|
||||
import com.google.android.exoplayer2.ui.StyledPlayerView
|
||||
|
||||
import okhttp3.*
|
||||
import java.io.IOException
|
||||
import kotlin.math.abs
|
||||
import com.google.android.exoplayer2.util.MimeTypes
|
||||
@ -29,26 +23,17 @@ import android.app.ActionBar
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.graphics.Color
|
||||
import android.widget.*
|
||||
import androidx.core.net.toUri
|
||||
import com.google.android.exoplayer2.C.SELECTION_FLAG_DEFAULT
|
||||
import com.google.android.exoplayer2.MediaItem.fromUri
|
||||
import com.google.android.exoplayer2.Player.REPEAT_MODE_ONE
|
||||
import com.google.android.exoplayer2.source.MergingMediaSource
|
||||
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector
|
||||
import com.google.android.exoplayer2.source.ProgressiveMediaSource
|
||||
import com.google.android.exoplayer2.upstream.DataSource
|
||||
|
||||
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource
|
||||
import android.widget.PopupWindow
|
||||
import android.widget.TextView
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import com.google.android.exoplayer2.util.Util
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.os.Build
|
||||
import android.text.Html
|
||||
import android.util.Log
|
||||
@ -56,27 +41,14 @@ import android.util.TypedValue
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.core.text.PrecomputedTextCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.google.android.exoplayer2.Player
|
||||
import com.google.android.exoplayer2.Player.STATE_IDLE
|
||||
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory
|
||||
import com.google.android.exoplayer2.util.RepeatModeUtil
|
||||
|
||||
import com.google.android.exoplayer2.ui.TimeBar
|
||||
import com.google.android.exoplayer2.ui.TimeBar.OnScrubListener
|
||||
import com.squareup.picasso.Picasso
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import retrofit2.HttpException
|
||||
import retrofit2.Retrofit
|
||||
import retrofit2.converter.jackson.JacksonConverterFactory
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Path
|
||||
import com.github.libretube.adapters.TrendingAdapter
|
||||
import com.github.libretube.obj.PipedStream
|
||||
import com.github.libretube.obj.Subscribe
|
||||
@ -372,8 +344,8 @@ class PlayerFragment : Fragment() {
|
||||
} else {
|
||||
Html.fromHtml(response.description)
|
||||
}
|
||||
view.findViewById<TextView>(R.id.player_sub).text = response.views.videoViews() + " views • "+response.uploadDate
|
||||
view.findViewById<TextView>(R.id.textLike).text = response.likes.videoViews()
|
||||
view.findViewById<TextView>(R.id.player_sub).text = response.views.formatShort() + " views • "+response.uploadDate
|
||||
view.findViewById<TextView>(R.id.textLike).text = response.likes.formatShort()
|
||||
val channelImage = view.findViewById<ImageView>(R.id.player_channelImage)
|
||||
Picasso.get().load(response.uploaderAvatar).into(channelImage)
|
||||
view.findViewById<TextView>(R.id.player_channelName).text=response.uploader
|
||||
|
@ -3,20 +3,20 @@ package com.github.libretube
|
||||
import java.math.BigDecimal
|
||||
import java.math.RoundingMode
|
||||
|
||||
fun Long?.videoViews(): String = when {
|
||||
this!!<1000 -> {
|
||||
this.toString()
|
||||
}
|
||||
this in 1000..999999 -> {
|
||||
val decimal = BigDecimal(this/1000).setScale(0, RoundingMode.HALF_EVEN)
|
||||
decimal.toString()+"K"
|
||||
}
|
||||
this in 1000000..10000000 -> {
|
||||
val decimal = BigDecimal(this/1000000).setScale(0, RoundingMode.HALF_EVEN)
|
||||
decimal.toString()+"M"
|
||||
}
|
||||
else -> {
|
||||
val decimal = BigDecimal(this/1000000).setScale(0, RoundingMode.HALF_EVEN)
|
||||
decimal.toString()+"M"
|
||||
}
|
||||
}
|
||||
fun Long?.formatShort(): String = when {
|
||||
this!! < 1000 -> {
|
||||
this.toString()
|
||||
}
|
||||
this in 1000..999999 -> {
|
||||
val decimal = BigDecimal(this / 1000).setScale(0, RoundingMode.HALF_EVEN)
|
||||
decimal.toString() + "K"
|
||||
}
|
||||
this in 1000000..10000000 -> {
|
||||
val decimal = BigDecimal(this / 1000000).setScale(0, RoundingMode.HALF_EVEN)
|
||||
decimal.toString() + "M"
|
||||
}
|
||||
else -> {
|
||||
val decimal = BigDecimal(this / 1000000).setScale(0, RoundingMode.HALF_EVEN)
|
||||
decimal.toString() + "M"
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,19 @@
|
||||
package com.github.libretube.adapters
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.format.DateUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.libretube.MainActivity
|
||||
import com.squareup.picasso.Picasso
|
||||
import com.github.libretube.PlayerFragment
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.obj.StreamItem
|
||||
import com.github.libretube.videoViews
|
||||
import com.github.libretube.formatShort
|
||||
|
||||
class ChannelAdapter(private val videoFeed: MutableList<StreamItem>): RecyclerView.Adapter<ChannelViewHolder>() {
|
||||
override fun getItemCount(): Int {
|
||||
@ -35,7 +34,8 @@ class ChannelAdapter(private val videoFeed: MutableList<StreamItem>): RecyclerVi
|
||||
override fun onBindViewHolder(holder: ChannelViewHolder, position: Int) {
|
||||
val trending = videoFeed[position]
|
||||
holder.v.findViewById<TextView>(R.id.channel_description).text = trending.title
|
||||
holder.v.findViewById<TextView>(R.id.channel_views).text = trending.views.videoViews()+" • "+trending.uploadedDate
|
||||
holder.v.findViewById<TextView>(R.id.channel_views).text = trending.views.formatShort()+" • "+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
|
||||
holder.v.findViewById<TextView>(R.id.channel_duration).text = DateUtils.formatElapsedTime(trending.duration!!)
|
||||
val thumbnailImage = holder.v.findViewById<ImageView>(R.id.channel_thumbnail)
|
||||
Picasso.get().load(trending.thumbnail).into(thumbnailImage)
|
||||
holder.v.setOnClickListener{
|
||||
|
@ -1,20 +1,18 @@
|
||||
package com.github.libretube.adapters
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.format.DateUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.libretube.MainActivity
|
||||
import com.squareup.picasso.Picasso
|
||||
import com.github.libretube.PlayerFragment
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.obj.StreamItem
|
||||
import com.github.libretube.videoViews
|
||||
|
||||
class PlaylistAdapter(private val videoFeed: MutableList<StreamItem>): RecyclerView.Adapter<PlaylistViewHolder>() {
|
||||
override fun getItemCount(): Int {
|
||||
@ -36,6 +34,7 @@ class PlaylistAdapter(private val videoFeed: MutableList<StreamItem>): RecyclerV
|
||||
val streamItem = videoFeed[position]
|
||||
holder.v.findViewById<TextView>(R.id.channel_description).text = streamItem.title
|
||||
holder.v.findViewById<TextView>(R.id.channel_views).text = streamItem.uploaderName
|
||||
holder.v.findViewById<TextView>(R.id.channel_duration).text = DateUtils.formatElapsedTime(streamItem.duration!!)
|
||||
val thumbnailImage = holder.v.findViewById<ImageView>(R.id.channel_thumbnail)
|
||||
Picasso.get().load(streamItem.thumbnail).into(thumbnailImage)
|
||||
holder.v.setOnClickListener{
|
||||
|
@ -7,9 +7,7 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import android.widget.VideoView
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.github.libretube.MainActivity
|
||||
@ -17,8 +15,7 @@ import com.squareup.picasso.Picasso
|
||||
import com.github.libretube.PlayerFragment
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.obj.SearchItem
|
||||
import com.github.libretube.obj.StreamItem
|
||||
import com.github.libretube.videoViews
|
||||
import com.github.libretube.formatShort
|
||||
|
||||
|
||||
class SearchAdapter(private val searchItems: List<SearchItem>): RecyclerView.Adapter<CustomViewHolder1>() {
|
||||
@ -61,7 +58,7 @@ class CustomViewHolder1(private val v: View): RecyclerView.ViewHolder(v){
|
||||
val title = v.findViewById<TextView>(R.id.search_description)
|
||||
title.text = item.title
|
||||
val views = v.findViewById<TextView>(R.id.search_views)
|
||||
views.text = item.views.videoViews() +" • "+item.uploadedDate
|
||||
views.text = item.views.formatShort() +" • "+item.uploadedDate
|
||||
val channelName = v.findViewById<TextView>(R.id.search_channel_name)
|
||||
channelName.text = item.uploaderName
|
||||
v.setOnClickListener{
|
||||
@ -89,7 +86,7 @@ class CustomViewHolder1(private val v: View): RecyclerView.ViewHolder(v){
|
||||
val channelName = v.findViewById<TextView>(R.id.search_channel_name)
|
||||
channelName.text = item.name
|
||||
val channelViews = v.findViewById<TextView>(R.id.search_views)
|
||||
channelViews.text = item.subscribers.videoViews() + "subscribers • "+ item.videos + " videos"
|
||||
channelViews.text = item.subscribers.formatShort() + "subscribers • "+ item.videos + " videos"
|
||||
v.setOnClickListener {
|
||||
val activity = v.context as MainActivity
|
||||
val bundle = bundleOf("channel_id" to item.url)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.github.libretube.adapters
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.format.DateUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -15,7 +16,7 @@ import com.squareup.picasso.Picasso
|
||||
import com.github.libretube.PlayerFragment
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.obj.StreamItem
|
||||
import com.github.libretube.videoViews
|
||||
import com.github.libretube.formatShort
|
||||
|
||||
class SubscriptionAdapter(private val videoFeed: List<StreamItem>): RecyclerView.Adapter<SubscriptionViewHolder>() {
|
||||
//private var limitedVideoFeed: MutableList<String> = [""].toMutableList()
|
||||
@ -42,8 +43,9 @@ class SubscriptionAdapter(private val videoFeed: List<StreamItem>): RecyclerView
|
||||
override fun onBindViewHolder(holder: SubscriptionViewHolder, position: Int) {
|
||||
val trending = videoFeed[position]
|
||||
holder.v.findViewById<TextView>(R.id.textView_title).text = trending.title
|
||||
holder.v.findViewById<TextView>(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.videoViews()+" • "+trending.uploadedDate
|
||||
holder.v.findViewById<TextView>(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.formatShort()+" • "+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
|
||||
val thumbnailImage = holder.v.findViewById<ImageView>(R.id.thumbnail)
|
||||
holder.v.findViewById<TextView>(R.id.thumbnail_duration).text = DateUtils.formatElapsedTime(trending.duration!!)
|
||||
val channelImage = holder.v.findViewById<ImageView>(R.id.channel_image)
|
||||
channelImage.setOnClickListener{
|
||||
val activity = holder.v.context as MainActivity
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.github.libretube.adapters
|
||||
|
||||
import android.os.Bundle
|
||||
import android.text.format.DateUtils
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
@ -15,7 +16,7 @@ import com.squareup.picasso.Picasso
|
||||
import com.github.libretube.PlayerFragment
|
||||
import com.github.libretube.R
|
||||
import com.github.libretube.obj.StreamItem
|
||||
import com.github.libretube.videoViews
|
||||
import com.github.libretube.formatShort
|
||||
|
||||
class TrendingAdapter(private val videoFeed: List<StreamItem>): RecyclerView.Adapter<CustomViewHolder>() {
|
||||
override fun getItemCount(): Int {
|
||||
@ -31,8 +32,9 @@ class TrendingAdapter(private val videoFeed: List<StreamItem>): RecyclerView.Ada
|
||||
override fun onBindViewHolder(holder: CustomViewHolder, position: Int) {
|
||||
val trending = videoFeed[position]
|
||||
holder.v.findViewById<TextView>(R.id.textView_title).text = trending.title
|
||||
holder.v.findViewById<TextView>(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.videoViews()+" • "+trending.uploadedDate
|
||||
holder.v.findViewById<TextView>(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.formatShort()+" • "+DateUtils.getRelativeTimeSpanString(trending.uploaded!!)
|
||||
val thumbnailImage = holder.v.findViewById<ImageView>(R.id.thumbnail)
|
||||
holder.v.findViewById<TextView>(R.id.thumbnail_duration).text = DateUtils.formatElapsedTime(trending.duration!!)
|
||||
val channelImage = holder.v.findViewById<ImageView>(R.id.channel_image)
|
||||
channelImage.setOnClickListener{
|
||||
val activity = holder.v.context as MainActivity
|
||||
|
@ -27,6 +27,15 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
/>
|
||||
<TextView
|
||||
android:id="@+id/thumbnail_duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="5dp"
|
||||
android:textColor="@color/duration_text_color"
|
||||
android:background="@color/duration_background_color"
|
||||
android:padding="0.5dp"/>
|
||||
</androidx.cardview.widget.CardView>
|
||||
|
||||
|
||||
|
@ -34,6 +34,15 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:srcCompat="@tools:sample/backgrounds/scenic" />
|
||||
<TextView
|
||||
android:id="@+id/channel_duration"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="5dp"
|
||||
android:textColor="@color/duration_text_color"
|
||||
android:background="@color/duration_background_color"
|
||||
android:padding="0.5dp"/>
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
<TextView
|
||||
|
@ -3,6 +3,9 @@
|
||||
<color name="black">#000000</color>
|
||||
<color name="white">#ffffff</color>
|
||||
|
||||
<color name="duration_background_color">#AA000000</color>
|
||||
<color name="duration_text_color">#EEFFFFFF</color>
|
||||
|
||||
<color name="colorPrimary">#B81B3B</color>
|
||||
<color name="md_theme_light_primary">#B81B3B</color>
|
||||
<color name="md_theme_light_onPrimary">#FFFFFF</color>
|
||||
|
@ -5,7 +5,7 @@ buildscript {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:7.1.0'
|
||||
classpath 'com.android.tools.build:gradle:7.1.1'
|
||||
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
|
Loading…
Reference in New Issue
Block a user