Made description toggleable

This commit is contained in:
Abdu Ameen 2022-03-27 15:38:00 -07:00
parent 03d5001ffa
commit 7e56fdd8f2
2 changed files with 53 additions and 24 deletions

View File

@ -26,6 +26,7 @@ import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.core.net.toUri import androidx.core.net.toUri
import androidx.core.os.bundleOf import androidx.core.os.bundleOf
import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.lifecycle.lifecycleScope import androidx.lifecycle.lifecycleScope
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager
@ -48,7 +49,6 @@ import com.google.android.exoplayer2.upstream.DataSource
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource import com.google.android.exoplayer2.upstream.DefaultHttpDataSource
import com.google.android.material.button.MaterialButton import com.google.android.material.button.MaterialButton
import com.squareup.picasso.Picasso import com.squareup.picasso.Picasso
import org.w3c.dom.Text
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
import java.net.URLEncoder import java.net.URLEncoder
@ -95,6 +95,8 @@ class PlayerFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
hideKeyboard() hideKeyboard()
val playerDescription = view.findViewById<TextView>(R.id.player_description)
videoId = videoId!!.replace("/watch?v=", "") videoId = videoId!!.replace("/watch?v=", "")
relDownloadVideo = view.findViewById(R.id.relPlayer_download) relDownloadVideo = view.findViewById(R.id.relPlayer_download)
val mainActivity = activity as MainActivity val mainActivity = activity as MainActivity
@ -175,6 +177,12 @@ class PlayerFragment : Fragment() {
true true
} }
} }
view.findViewById<ConstraintLayout>(R.id.player_title_layout).setOnClickListener {
var visible = playerDescription.isVisible
playerDescription.visibility = if (visible) View.GONE else View.VISIBLE
}
// FullScreen button trigger // FullScreen button trigger
view.findViewById<ImageButton>(R.id.fullscreen).setOnClickListener { view.findViewById<ImageButton>(R.id.fullscreen).setOnClickListener {
// remember to hide everything when new thing added // remember to hide everything when new thing added

View File

@ -30,35 +30,55 @@
> >
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/player_title_layout" android:id="@+id/player_info_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
<TextView <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/player_title" android:id="@+id/player_title_layout"
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="Title"
android:textSize="18sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent">
<TextView <TextView
android:id="@+id/player_views_info" android:id="@+id/player_title"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingLeft="8dp" android:padding="8dp"
android:paddingRight="8dp" android:paddingLeft="8dp"
android:text="TextView" android:paddingRight="8dp"
android:textSize="12sp" android:text="Title"
app:layout_constraintEnd_toEndOf="parent" android:textSize="18sp"
app:layout_constraintStart_toStartOf="parent" android:textStyle="bold"
app:layout_constraintTop_toBottomOf="@+id/player_title" /> app:layout_constraintEnd_toStartOf="@id/player_description_arrow"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/player_views_info"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:text="TextView"
android:textSize="12sp"
app:layout_constraintEnd_toStartOf="@id/player_description_arrow"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/player_title" />
<ImageView
android:id="@+id/player_description_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:paddingLeft="16dp"
android:src="@drawable/ic_arrow_down"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<TextView <TextView
android:id="@+id/player_description" android:id="@+id/player_description"
@ -66,9 +86,10 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:padding="8dp" android:padding="8dp"
android:textSize="14sp" android:textSize="14sp"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/player_views_info" /> app:layout_constraintTop_toBottomOf="@id/player_title_layout" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout <LinearLayout