diff --git a/app/src/main/java/com/github/libretube/ChannelFragment.kt b/app/src/main/java/com/github/libretube/ChannelFragment.kt index 9346aa0f0..b2f25cff0 100644 --- a/app/src/main/java/com/github/libretube/ChannelFragment.kt +++ b/app/src/main/java/com/github/libretube/ChannelFragment.kt @@ -191,7 +191,7 @@ class ChannelFragment : Fragment() { isLoading=false runOnUiThread { view.findViewById(R.id.channel_name).text=response.name - view.findViewById(R.id.channel_subs).text=response.subscriberCount.videoViews() + " subscribers" + view.findViewById(R.id.channel_subs).text=response.subscriberCount.formatShort() + " subscribers" view.findViewById(R.id.channel_description).text=response.description val bannerImage = view.findViewById(R.id.channel_banner) val channelImage = view.findViewById(R.id.channel_image) diff --git a/app/src/main/java/com/github/libretube/PlayerFragment.kt b/app/src/main/java/com/github/libretube/PlayerFragment.kt index d5f71ac97..abbe01082 100644 --- a/app/src/main/java/com/github/libretube/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/PlayerFragment.kt @@ -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(R.id.player_sub).text = response.views.videoViews() + " views • "+response.uploadDate - view.findViewById(R.id.textLike).text = response.likes.videoViews() + view.findViewById(R.id.player_sub).text = response.views.formatShort() + " views • "+response.uploadDate + view.findViewById(R.id.textLike).text = response.likes.formatShort() val channelImage = view.findViewById(R.id.player_channelImage) Picasso.get().load(response.uploaderAvatar).into(channelImage) view.findViewById(R.id.player_channelName).text=response.uploader diff --git a/app/src/main/java/com/github/libretube/VideoViews.kt b/app/src/main/java/com/github/libretube/VideoViews.kt index 81c301160..f8f45677c 100644 --- a/app/src/main/java/com/github/libretube/VideoViews.kt +++ b/app/src/main/java/com/github/libretube/VideoViews.kt @@ -3,7 +3,7 @@ package com.github.libretube import java.math.BigDecimal import java.math.RoundingMode -fun Long?.videoViews(): String = when { +fun Long?.formatShort(): String = when { this!!<1000 -> { this.toString() } diff --git a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt index ab4339994..1144bf460 100644 --- a/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/ChannelAdapter.kt @@ -8,14 +8,12 @@ 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): RecyclerView.Adapter() { override fun getItemCount(): Int { @@ -36,7 +34,7 @@ class ChannelAdapter(private val videoFeed: MutableList): RecyclerVi override fun onBindViewHolder(holder: ChannelViewHolder, position: Int) { val trending = videoFeed[position] holder.v.findViewById(R.id.channel_description).text = trending.title - holder.v.findViewById(R.id.channel_views).text = trending.views.videoViews()+" • "+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!) + holder.v.findViewById(R.id.channel_views).text = trending.views.formatShort()+" • "+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!) holder.v.findViewById(R.id.channel_duration).text = DateUtils.formatElapsedTime(trending.duration!!) val thumbnailImage = holder.v.findViewById(R.id.channel_thumbnail) Picasso.get().load(trending.thumbnail).into(thumbnailImage) diff --git a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt index 1577c101d..ecdbe9194 100644 --- a/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/PlaylistAdapter.kt @@ -8,14 +8,11 @@ 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): RecyclerView.Adapter() { override fun getItemCount(): Int { diff --git a/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt index b3ef217b5..ce17acfb3 100644 --- a/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/SearchAdapter.kt @@ -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): RecyclerView.Adapter() { @@ -61,7 +58,7 @@ class CustomViewHolder1(private val v: View): RecyclerView.ViewHolder(v){ val title = v.findViewById(R.id.search_description) title.text = item.title val views = v.findViewById(R.id.search_views) - views.text = item.views.videoViews() +" • "+item.uploadedDate + views.text = item.views.formatShort() +" • "+item.uploadedDate val channelName = v.findViewById(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(R.id.search_channel_name) channelName.text = item.name val channelViews = v.findViewById(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) diff --git a/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt b/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt index 4ce20afc5..5fa6da238 100644 --- a/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/SubscriptionAdapter.kt @@ -16,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): RecyclerView.Adapter() { //private var limitedVideoFeed: MutableList = [""].toMutableList() @@ -43,7 +43,7 @@ class SubscriptionAdapter(private val videoFeed: List): RecyclerView override fun onBindViewHolder(holder: SubscriptionViewHolder, position: Int) { val trending = videoFeed[position] holder.v.findViewById(R.id.textView_title).text = trending.title - holder.v.findViewById(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.videoViews()+" • "+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!) + holder.v.findViewById(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.formatShort()+" • "+ DateUtils.getRelativeTimeSpanString(trending.uploaded!!) val thumbnailImage = holder.v.findViewById(R.id.thumbnail) holder.v.findViewById(R.id.thumbnail_duration).text = DateUtils.formatElapsedTime(trending.duration!!) val channelImage = holder.v.findViewById(R.id.channel_image) diff --git a/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt b/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt index 89da2c561..6fabbd68f 100644 --- a/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt +++ b/app/src/main/java/com/github/libretube/adapters/TrendingAdapter.kt @@ -16,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): RecyclerView.Adapter() { override fun getItemCount(): Int { @@ -32,7 +32,7 @@ class TrendingAdapter(private val videoFeed: List): RecyclerView.Ada override fun onBindViewHolder(holder: CustomViewHolder, position: Int) { val trending = videoFeed[position] holder.v.findViewById(R.id.textView_title).text = trending.title - holder.v.findViewById(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.videoViews()+" • "+DateUtils.getRelativeTimeSpanString(trending.uploaded!!) + holder.v.findViewById(R.id.textView_channel).text = trending.uploaderName +" • "+ trending.views.formatShort()+" • "+DateUtils.getRelativeTimeSpanString(trending.uploaded!!) val thumbnailImage = holder.v.findViewById(R.id.thumbnail) holder.v.findViewById(R.id.thumbnail_duration).text = DateUtils.formatElapsedTime(trending.duration!!) val channelImage = holder.v.findViewById(R.id.channel_image)