From b6ede549191b02274589f1ea597a7844b68c3058 Mon Sep 17 00:00:00 2001 From: archroid Date: Sat, 7 May 2022 20:52:45 +0430 Subject: [PATCH] Redesigned player fragment(again) --- .../com/github/libretube/PlayerFragment.kt | 25 +- app/src/main/res/drawable/ic_bell.xml | 10 + app/src/main/res/layout/fragment_player.xml | 623 ++++++++++++------ 3 files changed, 452 insertions(+), 206 deletions(-) create mode 100644 app/src/main/res/drawable/ic_bell.xml diff --git a/app/src/main/java/com/github/libretube/PlayerFragment.kt b/app/src/main/java/com/github/libretube/PlayerFragment.kt index 3392b7376..c08ac332f 100644 --- a/app/src/main/java/com/github/libretube/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/PlayerFragment.kt @@ -80,7 +80,7 @@ class PlayerFragment : Fragment() { private lateinit var exoPlayer: ExoPlayer private lateinit var mediaSource: MediaSource - private lateinit var relDownloadVideo: RelativeLayout + private lateinit var relDownloadVideo: LinearLayout override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -191,7 +191,7 @@ class PlayerFragment : Fragment() { } } - view.findViewById(R.id.player_title_layout).setOnClickListener { + view.findViewById(R.id.player_title_layout).setOnClickListener { var visible = playerDescription.isVisible playerDescription.visibility = if (visible) View.GONE else View.VISIBLE @@ -502,7 +502,7 @@ class PlayerFragment : Fragment() { val channelId = response.uploaderUrl?.replace("/channel/", "") val subButton = view.findViewById(R.id.player_subscribe) isSubscribed(subButton, channelId!!) - view.findViewById(R.id.save).setOnClickListener { + view.findViewById(R.id.save).setOnClickListener { val newFragment = AddtoPlaylistDialog() var bundle = Bundle() bundle.putString("videoId", videoId) @@ -511,7 +511,7 @@ class PlayerFragment : Fragment() { } } // share button - view.findViewById(R.id.relPlayer_share).setOnClickListener { + view.findViewById(R.id.relPlayer_share).setOnClickListener { val sharedPreferences = PreferenceManager.getDefaultSharedPreferences(requireContext()) val intent = Intent() @@ -602,7 +602,7 @@ class PlayerFragment : Fragment() { Toast.makeText(context, R.string.cannotDownload, Toast.LENGTH_SHORT).show() } if (response.hls != null) { - view.findViewById(R.id.relPlayer_vlc).setOnClickListener { + view.findViewById(R.id.relPlayer_vlc).setOnClickListener { exoPlayer.pause() try { val vlcRequestCode = 42 @@ -644,36 +644,21 @@ class PlayerFragment : Fragment() { Log.e(TAG, "HttpException, unexpected response") return@launchWhenCreated } - val colorPrimary = TypedValue() - (context as Activity).theme.resolveAttribute( - android.R.attr.colorPrimary, - colorPrimary, - true - ) - val colorText = TypedValue() - (context as Activity).theme.resolveAttribute( - R.attr.colorOnSurface, - colorText, - true - ) runOnUiThread { if (response.subscribed == true) { isSubscribed = true button.text = getString(R.string.unsubscribe) - button.setTextColor(colorText.data) } if (response.subscribed != null) { button.setOnClickListener { if (isSubscribed) { unsubscribe(channel_id) button.text = getString(R.string.subscribe) - button.setTextColor(colorPrimary.data) } else { subscribe(channel_id) button.text = getString(R.string.unsubscribe) - button.setTextColor(colorText.data) } } } diff --git a/app/src/main/res/drawable/ic_bell.xml b/app/src/main/res/drawable/ic_bell.xml new file mode 100644 index 000000000..fede204c4 --- /dev/null +++ b/app/src/main/res/drawable/ic_bell.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/layout/fragment_player.xml b/app/src/main/res/layout/fragment_player.xml index 49c10696d..d9f73b634 100644 --- a/app/src/main/res/layout/fragment_player.xml +++ b/app/src/main/res/layout/fragment_player.xml @@ -6,8 +6,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" app:layoutDescription="@xml/player_scene" - tools:context=".PlayerFragment" - > + tools:context=".PlayerFragment"> + app:layout_constraintTop_toBottomOf="@+id/main_container"> - > - - - - - - - - - - - - - - - - + android:id="@+id/player_title_layout" + android:orientation="horizontal"> - + android:layout_marginStart="10dp" + android:layout_marginTop="10dp" + android:layout_marginEnd="20dp" + android:text="Video Title" + android:textSize="22sp" /> - - - - - - - - - - + android:layout_alignParentRight="true" + android:layout_centerInParent="true" + android:layout_marginEnd="10dp" + android:paddingLeft="16dp" + android:src="@drawable/ic_arrow_down" /> - + - - - + + + + + + + + android:layout_gravity="center" + android:layout_marginLeft="10dp" + android:layout_marginRight="10dp" + android:gravity="center" + android:orientation="horizontal"> - + android:layout_weight=".25" + android:gravity="center" + android:orientation="vertical"> - - - + - + + - - - + android:layout_weight=".25" + android:background="?android:attr/selectableItemBackground" + android:gravity="center" + android:orientation="vertical"> + + + + + + + + + + + + > + + + + + + + + + + + + + + + + + + + + android:layout_marginTop="15dp" + android:layout_marginBottom="15dp" + android:background="?android:attr/selectableItemBackground" + android:paddingLeft="8dp" + android:paddingRight="8dp"> + android:textSize="15dp" /> + android:textColor="@color/white" + android:textSize="12dp" + app:cornerRadius="11dp" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + app:layout_constraintTop_toTopOf="parent" />