fix linter

This commit is contained in:
Bnyro 2022-10-19 19:53:18 +02:00
parent 31f20219d5
commit c02b815ff2
16 changed files with 54 additions and 31 deletions

View File

@ -40,9 +40,9 @@
<activity <activity
android:name=".ui.activities.OfflinePlayerActivity" android:name=".ui.activities.OfflinePlayerActivity"
android:supportsPictureInPicture="true"
android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
android:label="@string/player" /> android:label="@string/player"
android:supportsPictureInPicture="true" />
<activity <activity
android:name=".ui.activities.MainActivity" android:name=".ui.activities.MainActivity"

View File

@ -12,5 +12,5 @@ data class Channel(
var nextpage: String? = null, var nextpage: String? = null,
var subscriberCount: Long = 0, var subscriberCount: Long = 0,
var verified: Boolean = false, var verified: Boolean = false,
var relatedStreams: List<com.github.libretube.api.obj.StreamItem>? = null var relatedStreams: List<StreamItem>? = null
) )

View File

@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
data class CommentsPage( data class CommentsPage(
val comments: MutableList<com.github.libretube.api.obj.Comment> = arrayListOf(), val comments: MutableList<Comment> = arrayListOf(),
val disabled: Boolean? = null, val disabled: Boolean? = null,
val nextpage: String? = "" val nextpage: String? = ""
) )

View File

@ -12,5 +12,5 @@ data class Playlist(
var uploaderUrl: String? = null, var uploaderUrl: String? = null,
var uploaderAvatar: String? = null, var uploaderAvatar: String? = null,
var videos: Int? = 0, var videos: Int? = 0,
var relatedStreams: List<com.github.libretube.api.obj.StreamItem>? = null var relatedStreams: List<StreamItem>? = null
) )

View File

@ -4,5 +4,5 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties
@JsonIgnoreProperties(ignoreUnknown = true) @JsonIgnoreProperties(ignoreUnknown = true)
data class Segments( data class Segments(
val segments: MutableList<com.github.libretube.api.obj.Segment> = arrayListOf() val segments: MutableList<Segment> = arrayListOf()
) )

View File

@ -19,10 +19,10 @@ fun View?.setWatchProgressLength(videoId: String, duration: Long) {
return return
} }
view.getViewTreeObserver() view.viewTreeObserver
.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener { .addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {
override fun onGlobalLayout() { override fun onGlobalLayout() {
this@setWatchProgressLength.getViewTreeObserver().removeOnGlobalLayoutListener(this) this@setWatchProgressLength.viewTreeObserver.removeOnGlobalLayoutListener(this)
if (progress == null || duration == 0L) { if (progress == null || duration == 0L) {
view.visibility = View.GONE view.visibility = View.GONE
return return

View File

@ -74,13 +74,15 @@ class RouterActivity : BaseActivity() {
val videoId = uri.getQueryParameter("v") val videoId = uri.getQueryParameter("v")
intent.putExtra(IntentData.videoId, videoId) intent.putExtra(IntentData.videoId, videoId)
uri.getQueryParameter("t")?.let { intent.putExtra(IntentData.timeStamp, it.toLong()) } uri.getQueryParameter("t")
?.let { intent.putExtra(IntentData.timeStamp, it.toLong()) }
} }
else -> { else -> {
val videoId = uri.path!!.replace("/", "") val videoId = uri.path!!.replace("/", "")
intent.putExtra(IntentData.videoId, videoId) intent.putExtra(IntentData.videoId, videoId)
uri.getQueryParameter("t")?.let { intent.putExtra(IntentData.timeStamp, it.toLong()) } uri.getQueryParameter("t")
?.let { intent.putExtra(IntentData.timeStamp, it.toLong()) }
} }
} }
return intent return intent

View File

@ -70,7 +70,10 @@ class CommentsAdapter(
if (comment.pinned == true) pinnedImageView.visibility = View.VISIBLE if (comment.pinned == true) pinnedImageView.visibility = View.VISIBLE
if (comment.hearted == true) heartedImageView.visibility = View.VISIBLE if (comment.hearted == true) heartedImageView.visibility = View.VISIBLE
if (comment.repliesPage != null) repliesAvailable.visibility = View.VISIBLE if (comment.repliesPage != null) repliesAvailable.visibility = View.VISIBLE
if ((comment.replyCount ?: -1L) > 0L) repliesCount.text = comment.replyCount?.formatShort() if ((comment.replyCount ?: -1L) > 0L) {
repliesCount.text =
comment.replyCount?.formatShort()
}
commentorImage.setOnClickListener { commentorImage.setOnClickListener {
NavigationHelper.navigateChannel(root.context, comment.commentorUrl) NavigationHelper.navigateChannel(root.context, comment.commentorUrl)

View File

@ -411,7 +411,8 @@ class PlayerFragment : BaseFragment() {
// FullScreen button trigger // FullScreen button trigger
// hide fullscreen button if auto rotation enabled // hide fullscreen button if auto rotation enabled
playerBinding.fullscreen.visibility = if (PlayerHelper.autoRotationEnabled) View.GONE else View.VISIBLE playerBinding.fullscreen.visibility =
if (PlayerHelper.autoRotationEnabled) View.GONE else View.VISIBLE
playerBinding.fullscreen.setOnClickListener { playerBinding.fullscreen.setOnClickListener {
// hide player controller // hide player controller
exoPlayerView.hideController() exoPlayerView.hideController()
@ -426,7 +427,8 @@ class PlayerFragment : BaseFragment() {
// share button // share button
binding.relPlayerShare.setOnClickListener { binding.relPlayerShare.setOnClickListener {
val shareDialog = ShareDialog(videoId!!, ShareObjectType.VIDEO, exoPlayer.currentPosition / 1000) val shareDialog =
ShareDialog(videoId!!, ShareObjectType.VIDEO, exoPlayer.currentPosition / 1000)
shareDialog.show(childFragmentManager, ShareDialog::class.java.name) shareDialog.show(childFragmentManager, ShareDialog::class.java.name)
} }
@ -670,7 +672,12 @@ class PlayerFragment : BaseFragment() {
if (binding.player.autoplayEnabled) setNextStream() if (binding.player.autoplayEnabled) setNextStream()
// add the video to the watch history // add the video to the watch history
if (PlayerHelper.watchHistoryEnabled) DatabaseHelper.addToWatchHistory(videoId!!, streams) if (PlayerHelper.watchHistoryEnabled) {
DatabaseHelper.addToWatchHistory(
videoId!!,
streams
)
}
} }
} }
} }
@ -818,7 +825,10 @@ class PlayerFragment : BaseFragment() {
playerTitle.text = response.title playerTitle.text = response.title
playerDescription.text = response.description playerDescription.text = response.description
playerChannelSubCount.text = context?.getString(R.string.subscribers, response.uploaderSubscriberCount?.formatShort()) playerChannelSubCount.text = context?.getString(
R.string.subscribers,
response.uploaderSubscriberCount?.formatShort()
)
} }
// duration that's not greater than 0 indicates that the video is live // duration that's not greater than 0 indicates that the video is live
@ -1000,7 +1010,8 @@ class PlayerFragment : BaseFragment() {
} else { } else {
View.INVISIBLE View.INVISIBLE
} }
playerBinding.skipNext.visibility = if (PlayerHelper.skipButtonsEnabled) View.VISIBLE else View.INVISIBLE playerBinding.skipNext.visibility =
if (PlayerHelper.skipButtonsEnabled) View.VISIBLE else View.INVISIBLE
playerBinding.skipPrev.setOnClickListener { playerBinding.skipPrev.setOnClickListener {
videoId = PlayingQueue.getPrev() videoId = PlayingQueue.getPrev()

View File

@ -83,6 +83,7 @@ object ImageHelper {
) )
) )
} }
private fun saveImage(context: Context, bitmapImage: Bitmap, imagePath: Uri) { private fun saveImage(context: Context, bitmapImage: Bitmap, imagePath: Uri) {
context.contentResolver.openFileDescriptor(imagePath, "w")?.use { context.contentResolver.openFileDescriptor(imagePath, "w")?.use {
FileOutputStream(it.fileDescriptor).use { fos -> FileOutputStream(it.fileDescriptor).use { fos ->

View File

@ -72,7 +72,12 @@ class NowPlayingNotification(
} }
} }
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT) PendingIntent.getActivity(
context,
0,
intent,
PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT
)
} else { } else {
PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT)
} }

View File

@ -243,7 +243,8 @@ object PlayerHelper {
false false
) )
val pipEnabled: Boolean get() = PreferenceHelper.getBoolean( val pipEnabled: Boolean
get() = PreferenceHelper.getBoolean(
PreferenceKeys.PICTURE_IN_PICTURE, PreferenceKeys.PICTURE_IN_PICTURE,
true true
) )

View File

@ -10,10 +10,10 @@
<de.hdodenhof.circleimageview.CircleImageView <de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/subscription_channel_image" android:id="@+id/subscription_channel_image"
android:layout_marginStart="8dp"
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_centerVertical="true" /> android:layout_centerVertical="true"
android:layout_marginStart="8dp" />
<TextView <TextView
android:id="@+id/subscription_channel_name" android:id="@+id/subscription_channel_name"
@ -34,10 +34,10 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="8dp"
android:stateListAnimator="@null" android:stateListAnimator="@null"
android:text="@string/unsubscribe" android:text="@string/unsubscribe"
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
android:layout_marginEnd="8dp"
android:textSize="12sp" android:textSize="12sp"
app:cornerRadius="20dp" /> app:cornerRadius="20dp" />
</RelativeLayout> </RelativeLayout>

View File

@ -28,14 +28,14 @@
</LinearLayout> </LinearLayout>
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
android:visibility="gone"
android:id="@+id/timeStampLayout" android:id="@+id/timeStampLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginHorizontal="25dp" android:layout_marginHorizontal="25dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:layout_marginBottom="25dp" android:layout_marginBottom="25dp"
android:hint="@string/time_code"> android:hint="@string/time_code"
android:visibility="gone">
<com.google.android.material.textfield.TextInputEditText <com.google.android.material.textfield.TextInputEditText
android:id="@+id/timeStamp" android:id="@+id/timeStamp"

View File

@ -27,8 +27,8 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_margin="10dp"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_margin="10dp"
android:orientation="horizontal"> android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView <de.hdodenhof.circleimageview.CircleImageView
@ -107,12 +107,12 @@
<TextView <TextView
android:id="@+id/channel_description" android:id="@+id/channel_description"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:background="@drawable/rounded_ripple"
android:layout_height="18dp" android:layout_height="18dp"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginEnd="10dp" android:layout_marginEnd="10dp"
android:layout_marginBottom="15dp" android:layout_marginBottom="15dp"
android:autoLink="web" android:autoLink="web"
android:background="@drawable/rounded_ripple"
android:ellipsize="end" android:ellipsize="end"
android:maxLines="2" /> android:maxLines="2" />

View File

@ -258,9 +258,9 @@
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1"
android:layout_gravity="center"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView