From 7ac31f9fb5ce73f546aadf99ec7afd72d5c39754 Mon Sep 17 00:00:00 2001 From: Bnyro Date: Fri, 23 Dec 2022 14:54:53 +0100 Subject: [PATCH 1/2] Remove the `CircleImageView` dependency --- app/build.gradle | 1 - app/src/main/res/layout/activity_about.xml | 2 +- app/src/main/res/layout/activity_community.xml | 2 +- app/src/main/res/layout/app_icon_item.xml | 4 +++- app/src/main/res/layout/channel_row.xml | 5 +++-- app/src/main/res/layout/channel_subscription_row.xml | 5 +++-- app/src/main/res/layout/comments_row.xml | 5 +++-- app/src/main/res/layout/fragment_channel.xml | 5 +++-- app/src/main/res/layout/fragment_player.xml | 5 +++-- app/src/main/res/layout/legacy_subscription_channel.xml | 6 ++++-- app/src/main/res/layout/trending_row.xml | 5 +++-- app/src/main/res/layout/video_row.xml | 5 +++-- app/src/main/res/layout/watch_history_row.xml | 5 +++-- gradle/libs.versions.toml | 2 -- 14 files changed, 33 insertions(+), 24 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 2491ff778..19f6f23dd 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -102,7 +102,6 @@ dependencies { /* Design */ implementation libs.material - implementation libs.circleimageview /* ExoPlayer */ implementation libs.exoplayer diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index d2e672cd9..e06e93f56 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -23,7 +23,7 @@ android:layout_gravity="center" android:layout_marginTop="30dp" android:src="@mipmap/ic_launcher_round" - app:shapeAppearanceOverlay="@style/CircleImageView" /> + app:shapeAppearance="@style/CircleImageView" /> + app:shapeAppearance="@style/CircleImageView" /> - - + app:layout_constraintTop_toTopOf="parent" + app:shapeAppearance="@style/CircleImageView"/> - + android:layout_marginStart="8dp" + app:shapeAppearance="@style/CircleImageView"/> - + app:srcCompat="@mipmap/ic_launcher" + app:shapeAppearance="@style/CircleImageView"/> - + android:layout_gravity="center" + app:shapeAppearance="@style/CircleImageView"/> - + android:layout_marginEnd="4dp" + app:shapeAppearance="@style/CircleImageView"/> - + android:layout_gravity="center" + app:shapeAppearance="@style/CircleImageView"/> - + app:srcCompat="@mipmap/ic_launcher" + app:shapeAppearance="@style/CircleImageView"/> \ No newline at end of file diff --git a/app/src/main/res/layout/video_row.xml b/app/src/main/res/layout/video_row.xml index ee8c71d39..695d2f63e 100644 --- a/app/src/main/res/layout/video_row.xml +++ b/app/src/main/res/layout/video_row.xml @@ -99,10 +99,11 @@ app:layout_constraintStart_toStartOf="@+id/guideline" app:layout_constraintTop_toBottomOf="@id/video_info"> - + android:layout_height="27dp" + app:shapeAppearance="@style/CircleImageView"/> - + app:layout_constraintTop_toBottomOf="@id/video_info" + app:shapeAppearance="@style/CircleImageView"/> Date: Fri, 23 Dec 2022 14:57:10 +0100 Subject: [PATCH 2/2] Reformat the whole project --- app/src/main/AndroidManifest.xml | 31 +++++--- .../github/libretube/api/PlaylistsHelper.kt | 3 +- .../libretube/db/obj/PlaylistBookmark.kt | 1 - .../libretube/ui/adapters/CommentsAdapter.kt | 3 +- .../libretube/ui/adapters/VideosAdapter.kt | 11 ++- .../libretube/ui/dialogs/BackupDialog.kt | 1 + .../libretube/ui/dialogs/ShareDialog.kt | 1 + .../libretube/ui/fragments/PlayerFragment.kt | 14 +++- .../ui/fragments/PlaylistFragment.kt | 6 +- .../github/libretube/util/BrightnessHelper.kt | 6 +- .../libretube/util/PlayerGestureController.kt | 6 +- app/src/main/res/drawable/ic_done.xml | 1 - .../drawable/ic_launcher_light_foreground.xml | 29 ++++---- .../res/drawable/ic_launcher_lockscreen.xml | 7 +- app/src/main/res/drawable/ic_restart.xml | 4 +- .../main/res/drawable/ic_share_outlined.xml | 10 +-- app/src/main/res/layout/all_caught_up_row.xml | 6 +- app/src/main/res/layout/channel_row.xml | 2 +- .../res/layout/channel_subscription_row.xml | 2 +- app/src/main/res/layout/comments_row.xml | 4 +- .../main/res/layout/dialog_addtoplaylist.xml | 4 +- app/src/main/res/layout/fragment_channel.xml | 2 +- app/src/main/res/layout/fragment_home.xml | 4 +- app/src/main/res/layout/fragment_player.xml | 2 +- .../res/layout/fragment_search_result.xml | 2 +- .../layout/legacy_subscription_channel.xml | 4 +- app/src/main/res/layout/nav_options_item.xml | 2 +- app/src/main/res/layout/trending_row.xml | 4 +- app/src/main/res/layout/video_row.xml | 2 +- app/src/main/res/layout/watch_history_row.xml | 2 +- app/src/main/res/menu/bottom_menu.xml | 8 +- .../mipmap-anydpi-v26/ic_launcher_light.xml | 4 +- .../ic_launcher_light_round.xml | 4 +- app/src/main/res/values-night/themes.xml | 3 +- app/src/main/res/values/colors.xml | 74 +++++++++++++------ app/src/main/res/values/style.xml | 4 +- .../main/res/xml/notification_settings.xml | 3 +- app/src/main/res/xml/shortcuts.xml | 32 ++++---- 38 files changed, 186 insertions(+), 122 deletions(-) diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 925a61dcf..c05d5176a 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -19,6 +19,7 @@ + tools:targetApi="n"> - @@ -91,7 +92,8 @@ - @@ -114,7 +116,8 @@ - @@ -137,7 +140,8 @@ - @@ -160,7 +164,8 @@ - @@ -181,7 +186,8 @@ - @@ -204,7 +210,8 @@ - @@ -227,7 +234,8 @@ - @@ -250,7 +258,8 @@ - diff --git a/app/src/main/java/com/github/libretube/api/PlaylistsHelper.kt b/app/src/main/java/com/github/libretube/api/PlaylistsHelper.kt index 87050aebf..add8856f9 100644 --- a/app/src/main/java/com/github/libretube/api/PlaylistsHelper.kt +++ b/app/src/main/java/com/github/libretube/api/PlaylistsHelper.kt @@ -29,7 +29,8 @@ import kotlinx.coroutines.runBlocking import retrofit2.HttpException object PlaylistsHelper { - private val pipedPlaylistRegex = "[\\da-fA-F]{8}-[\\da-fA-F]{4}-[\\da-fA-F]{4}-[\\da-fA-F]{4}-[\\da-fA-F]{12}".toRegex() + private val pipedPlaylistRegex = + "[\\da-fA-F]{8}-[\\da-fA-F]{4}-[\\da-fA-F]{4}-[\\da-fA-F]{4}-[\\da-fA-F]{12}".toRegex() private val token get() = PreferenceHelper.getToken() diff --git a/app/src/main/java/com/github/libretube/db/obj/PlaylistBookmark.kt b/app/src/main/java/com/github/libretube/db/obj/PlaylistBookmark.kt index fa7280580..328270830 100644 --- a/app/src/main/java/com/github/libretube/db/obj/PlaylistBookmark.kt +++ b/app/src/main/java/com/github/libretube/db/obj/PlaylistBookmark.kt @@ -1,4 +1,3 @@ - package com.github.libretube.db.obj import androidx.room.Entity diff --git a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt index 33c3e374b..73502253b 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/CommentsAdapter.kt @@ -66,7 +66,8 @@ class CommentsAdapter( commentorImage.scaleY = REPLIES_ADAPTER_SCALE } - commentInfos.text = comment.author.toString() + TextUtils.SEPARATOR + comment.commentedTime.toString() + commentInfos.text = + comment.author.toString() + TextUtils.SEPARATOR + comment.commentedTime.toString() commentText.text = HtmlCompat.fromHtml( comment.commentText.toString(), HtmlCompat.FROM_HTML_MODE_LEGACY diff --git a/app/src/main/java/com/github/libretube/ui/adapters/VideosAdapter.kt b/app/src/main/java/com/github/libretube/ui/adapters/VideosAdapter.kt index e547988a1..00decf927 100644 --- a/app/src/main/java/com/github/libretube/ui/adapters/VideosAdapter.kt +++ b/app/src/main/java/com/github/libretube/ui/adapters/VideosAdapter.kt @@ -68,7 +68,11 @@ class VideosAdapter( viewType == CAUGHT_UP_TYPE -> VideosViewHolder( AllCaughtUpRowBinding.inflate(layoutInflater, parent, false) ) - forceMode in listOf(ForceMode.TRENDING, ForceMode.RELATED, ForceMode.HOME) -> VideosViewHolder( + forceMode in listOf( + ForceMode.TRENDING, + ForceMode.RELATED, + ForceMode.HOME + ) -> VideosViewHolder( TrendingRowBinding.inflate(layoutInflater, parent, false) ) forceMode == ForceMode.CHANNEL -> VideosViewHolder( @@ -101,8 +105,9 @@ class VideosAdapter( } videoId?.let { - val shouldHide = (holder.trendingRowBinding?.watchProgress ?: holder.videoRowBinding!!.watchProgress) - .setWatchProgressLength(it, video.duration ?: 0L) + val shouldHide = + (holder.trendingRowBinding?.watchProgress ?: holder.videoRowBinding!!.watchProgress) + .setWatchProgressLength(it, video.duration ?: 0L) if (hideWatched && shouldHide) { hideItemView(holder) return diff --git a/app/src/main/java/com/github/libretube/ui/dialogs/BackupDialog.kt b/app/src/main/java/com/github/libretube/ui/dialogs/BackupDialog.kt index 51a5f088e..12e1ab34d 100644 --- a/app/src/main/java/com/github/libretube/ui/dialogs/BackupDialog.kt +++ b/app/src/main/java/com/github/libretube/ui/dialogs/BackupDialog.kt @@ -50,6 +50,7 @@ class BackupDialog( } }) } + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { val backupOptions = listOf( BackupOption.WatchHistory, diff --git a/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt b/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt index da10fe705..67fbcf391 100644 --- a/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt +++ b/app/src/main/java/com/github/libretube/ui/dialogs/ShareDialog.kt @@ -107,6 +107,7 @@ class ShareDialog( } return "" } + private fun getShareableTitle(shareData: ShareData): String { shareData.apply { currentChannel?.let { diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt index ca8c6feae..9922d219e 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlayerFragment.kt @@ -235,7 +235,8 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { motionLayout: MotionLayout?, startId: Int, endId: Int - ) {} + ) { + } override fun onTransitionChange( motionLayout: MotionLayout?, @@ -273,7 +274,8 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { triggerId: Int, positive: Boolean, progress: Float - ) {} + ) { + } }) binding.playerMotionLayout.progress = 1.toFloat() @@ -649,7 +651,13 @@ class PlayerFragment : BaseFragment(), OnlinePlayerOptions { setupSeekbarPreview() if (!isLive) seekToWatchPosition() exoPlayer.prepare() - if (!PreferenceHelper.getBoolean(PreferenceKeys.DATA_SAVER_MODE, false)) exoPlayer.play() + if (!PreferenceHelper.getBoolean( + PreferenceKeys.DATA_SAVER_MODE, + false + ) + ) { + exoPlayer.play() + } if (binding.playerMotionLayout.progress != 1.0f) { // show controllers when not in picture in picture mode diff --git a/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt b/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt index c89458648..0bdf9194b 100644 --- a/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt +++ b/app/src/main/java/com/github/libretube/ui/fragments/PlaylistFragment.kt @@ -121,10 +121,12 @@ class PlaylistFragment : BaseFragment() { binding.playlistName.text = response.name binding.playlistName.setOnClickListener { - binding.playlistName.maxLines = if (binding.playlistName.maxLines == 2) Int.MAX_VALUE else 2 + binding.playlistName.maxLines = + if (binding.playlistName.maxLines == 2) Int.MAX_VALUE else 2 } - binding.playlistInfo.text = (if (response.uploader != null) response.uploader + TextUtils.SEPARATOR else "") + + binding.playlistInfo.text = + (if (response.uploader != null) response.uploader + TextUtils.SEPARATOR else "") + getString(R.string.videoCount, response.videos.toString()) // show playlist options diff --git a/app/src/main/java/com/github/libretube/util/BrightnessHelper.kt b/app/src/main/java/com/github/libretube/util/BrightnessHelper.kt index 1c2a21984..09b3ec427 100644 --- a/app/src/main/java/com/github/libretube/util/BrightnessHelper.kt +++ b/app/src/main/java/com/github/libretube/util/BrightnessHelper.kt @@ -66,7 +66,11 @@ class BrightnessHelper(private val activity: Activity) { * Get scaled brightness with given range. if [saved] is * ture value will be retrived from shared preferences. */ - fun getBrightnessWithScale(maxValue: Float, minValue: Float = 0.0f, saved: Boolean = false): Float { + fun getBrightnessWithScale( + maxValue: Float, + minValue: Float = 0.0f, + saved: Boolean = false + ): Float { return if (saved) { savedBrightness.normalize(minBrightness, maxBrightness, minValue, maxValue) } else { diff --git a/app/src/main/java/com/github/libretube/util/PlayerGestureController.kt b/app/src/main/java/com/github/libretube/util/PlayerGestureController.kt index a74d9e8c3..03f13d020 100644 --- a/app/src/main/java/com/github/libretube/util/PlayerGestureController.kt +++ b/app/src/main/java/com/github/libretube/util/PlayerGestureController.kt @@ -64,7 +64,8 @@ class PlayerGestureController(activity: BaseActivity, private val listener: Play try { scaleGestureDetector.onTouchEvent(event) gestureDetector.onTouchEvent(event) - } catch (_: Exception) { } + } catch (_: Exception) { + } // If video is playing in full-screen mode, then allow `onScroll` to consume // event and return true. @@ -136,7 +137,8 @@ class PlayerGestureController(activity: BaseActivity, private val listener: Play if (!isEnabled || scaleGestureDetector.isInProgress) return false val insideThreshHold = abs(e2.y - e1.y) <= MOVEMENT_THRESHOLD - val insideBorder = (e1.x < BORDER_THRESHOLD || e1.y < BORDER_THRESHOLD || e1.x > width - BORDER_THRESHOLD || e1.y > height - BORDER_THRESHOLD) + val insideBorder = + (e1.x < BORDER_THRESHOLD || e1.y < BORDER_THRESHOLD || e1.x > width - BORDER_THRESHOLD || e1.y > height - BORDER_THRESHOLD) // If the movement is inside threshold or scroll is horizontal then return false if (!isMoving && (insideThreshHold || insideBorder || abs(distanceX) > abs(distanceY))) { diff --git a/app/src/main/res/drawable/ic_done.xml b/app/src/main/res/drawable/ic_done.xml index 98c38381c..160f0a052 100644 --- a/app/src/main/res/drawable/ic_done.xml +++ b/app/src/main/res/drawable/ic_done.xml @@ -1,5 +1,4 @@ - - - - - + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_lockscreen.xml b/app/src/main/res/drawable/ic_launcher_lockscreen.xml index 1c2eb3863..12ba65e7d 100644 --- a/app/src/main/res/drawable/ic_launcher_lockscreen.xml +++ b/app/src/main/res/drawable/ic_launcher_lockscreen.xml @@ -7,7 +7,8 @@ android:fillColor="#000" android:pathData="M1130.145 639.54c0-6.202-3.236-11.865-8.358-14.831L225.77 93.247c-15.64-9.168-35.324 2.157-35.324 20.493v229.194c0 8.629 4.584 16.449 11.864 20.762l446.525 255.619c15.91 9.169 15.91 32.358 0 41.525L202.31 916.46c-7.28 4.315-11.864 12.135-11.864 20.763v228.925c0 18.336 19.684 29.93 35.324 20.493l895.747-532.271c5.122-3.236 8.359-8.898 8.359-14.83h0.269Z" android:strokeWidth="30" - android:strokeColor="#000"/> - + android:strokeColor="#000" /> + diff --git a/app/src/main/res/drawable/ic_restart.xml b/app/src/main/res/drawable/ic_restart.xml index 576fccffe..2eed1b8b9 100644 --- a/app/src/main/res/drawable/ic_restart.xml +++ b/app/src/main/res/drawable/ic_restart.xml @@ -6,7 +6,7 @@ android:viewportHeight="24"> + android:strokeColor="@android:color/black" /> diff --git a/app/src/main/res/drawable/ic_share_outlined.xml b/app/src/main/res/drawable/ic_share_outlined.xml index 8a0cf890a..accd9ba1a 100644 --- a/app/src/main/res/drawable/ic_share_outlined.xml +++ b/app/src/main/res/drawable/ic_share_outlined.xml @@ -4,9 +4,9 @@ android:tint="?attr/colorControlNormal" android:viewportWidth="24" android:viewportHeight="24"> - + diff --git a/app/src/main/res/layout/all_caught_up_row.xml b/app/src/main/res/layout/all_caught_up_row.xml index 0ea7c35d0..d288ec398 100644 --- a/app/src/main/res/layout/all_caught_up_row.xml +++ b/app/src/main/res/layout/all_caught_up_row.xml @@ -17,9 +17,9 @@ @@ -28,8 +28,8 @@ android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginTop="5dp" - android:textSize="13sp" android:text="@string/all_caught_up_summary" - android:textColor="?attr/colorControlNormal" /> + android:textColor="?attr/colorControlNormal" + android:textSize="13sp" /> \ No newline at end of file diff --git a/app/src/main/res/layout/channel_row.xml b/app/src/main/res/layout/channel_row.xml index e6e47ac57..d4ed392a2 100644 --- a/app/src/main/res/layout/channel_row.xml +++ b/app/src/main/res/layout/channel_row.xml @@ -12,7 +12,7 @@ android:layout_marginEnd="55dp" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" - app:shapeAppearance="@style/CircleImageView"/> + app:shapeAppearance="@style/CircleImageView" /> + app:shapeAppearance="@style/CircleImageView" /> + app:shapeAppearance="@style/CircleImageView" + app:srcCompat="@mipmap/ic_launcher" /> + android:layout_marginEnd="8dp" + android:text="@string/createPlaylist" />