Skip to content

Commit 55cf70c

Browse files
author
KotlinCrafter
committed
changes made in player and optimized the file
1 parent 10adb93 commit 55cf70c

File tree

4 files changed

+63
-86
lines changed

4 files changed

+63
-86
lines changed

app/src/main/java/com/google/android/piyush/dopamine/activities/YoutubePlayer.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,18 +164,18 @@ class YoutubePlayer : AppCompatActivity() {
164164
val videoDescription = videoDetails.data.items?.get(0)?.snippet?.description
165165
val videoThumbnail = videoDetails.data.items?.get(0)?.snippet?.thumbnails?.high?.url
166166
val videoDuration = videoDetails.data.items?.get(0)?.contentDetails?.duration
167-
val videoKind = videoDetails.data.items?.get(0)?.kind
167+
//val videoKind = videoDetails.data.items?.get(0)?.kind
168168
val videoPublishedAt = videoDetails.data.items?.get(0)?.snippet?.publishedAt
169169
val channelTitle = videoDetails.data.items?.get(0)?.snippet?.channelTitle
170170
val videoUrl = "https://YouTube.com/watch?v=${intent.getStringExtra("videoId")}"
171171
val videoLikes = counter(videoDetails.data.items?.get(0)?.statistics?.likeCount!!.toInt())
172172
val videoViews = counter(videoDetails.data.items?.get(0)?.statistics?.viewCount!!.toInt())
173-
val videoTags = videoDetails.data.items?.get(0)?.snippet?.tags.toString()
173+
//val videoTags = videoDetails.data.items?.get(0)?.snippet?.tags.toString()
174174

175175
binding.apply {
176176
textTitle.text = videoTitle
177-
textKind.text = videoKind
178-
textTags.text = videoTags
177+
//textKind.text = videoKind
178+
//textTags.text = videoTags
179179
videoLink.text = videoUrl
180180
textLiked.text = videoLikes
181181
textView.text = videoViews
@@ -349,13 +349,13 @@ class MyBottomSheetFragment : BottomSheetDialogFragment(){
349349
}
350350

351351
if(FirebaseAuth.getInstance().currentUser?.email.isNullOrEmpty()){
352-
if(databaseViewModel.isPlaylistExist(databaseViewModel.isUserFromPhoneAuth).equals(false)){
352+
if(!databaseViewModel.isPlaylistExist(databaseViewModel.isUserFromPhoneAuth)){
353353
databaseViewModel.userFromPhoneAuth()
354354
}else{
355355
Log.d(TAG, "${databaseViewModel.isUserFromPhoneAuth} : Exists")
356356
}
357357
}else {
358-
if (databaseViewModel.isPlaylistExist(databaseViewModel.newPlaylistName).equals(false)) {
358+
if (!databaseViewModel.isPlaylistExist(databaseViewModel.newPlaylistName)) {
359359
databaseViewModel.defaultUserPlaylist()
360360
} else {
361361
Log.d(TAG, "${databaseViewModel.newPlaylistName} : Exists")
@@ -370,5 +370,6 @@ class MyBottomSheetFragment : BottomSheetDialogFragment(){
370370
)
371371
}
372372
return view
373+
373374
}
374375
}

app/src/main/res/layout/activity_youtube_player.xml

Lines changed: 54 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,18 @@
6464
<ScrollView
6565
android:id="@+id/scrollView"
6666
android:layout_width="match_parent"
67-
android:layout_height="wrap_content"
67+
android:layout_height="0dp"
6868
android:scrollbars="none"
69-
android:overScrollMode="ifContentScrolls"
70-
app:layout_constraintStart_toStartOf="parent"
69+
app:layout_constraintBottom_toBottomOf="parent"
7170
app:layout_constraintEnd_toEndOf="parent"
71+
app:layout_constraintStart_toStartOf="parent"
7272
app:layout_constraintTop_toBottomOf="@id/YtPlayerLayout">
7373

7474
<androidx.constraintlayout.widget.ConstraintLayout
75+
android:id="@+id/yt_des"
7576
android:layout_width="match_parent"
7677
android:layout_height="wrap_content">
78+
7779
<com.google.android.material.card.MaterialCardView
7880
android:id="@+id/secondContainer"
7981
style="@style/Widget.Material3.CardView.Filled"
@@ -88,7 +90,7 @@
8890
<androidx.constraintlayout.widget.ConstraintLayout
8991
android:id="@+id/constraint"
9092
android:layout_width="match_parent"
91-
android:layout_height="wrap_content">
93+
android:layout_height="match_parent">
9294

9395
<com.google.android.material.textview.MaterialTextView
9496
android:id="@+id/textTitle"
@@ -99,56 +101,43 @@
99101
android:layout_marginEnd="8dp"
100102
android:layout_marginBottom="4dp"
101103
android:fontFamily="@font/circular_spotify"
102-
android:text="Video Title"
103-
android:textSize="16sp"
104-
app:layout_constraintBottom_toTopOf="@id/textKind"
105-
app:layout_constraintEnd_toEndOf="parent"
106-
app:layout_constraintStart_toStartOf="parent"
107-
app:layout_constraintTop_toTopOf="parent" />
108-
109-
<com.google.android.material.textview.MaterialTextView
110-
android:id="@+id/textKind"
111-
android:layout_width="match_parent"
112-
android:layout_height="wrap_content"
113-
android:layout_marginStart="8dp"
114-
android:layout_marginTop="4dp"
115-
android:layout_marginEnd="8dp"
116-
android:layout_marginBottom="4dp"
117-
android:fontFamily="@font/proxima_nova"
118-
android:text="Video Kind"
104+
android:text="@string/video_title"
119105
android:textSize="14sp"
120-
app:layout_constraintBottom_toTopOf="@id/textTags"
121106
app:layout_constraintEnd_toEndOf="parent"
122107
app:layout_constraintStart_toStartOf="parent"
123-
app:layout_constraintTop_toBottomOf="@id/textTitle" />
108+
app:layout_constraintTop_toTopOf="parent" />
124109

125110
<com.google.android.material.textview.MaterialTextView
126-
android:id="@+id/textTags"
111+
android:id="@+id/textDescription"
127112
android:layout_width="match_parent"
128113
android:layout_height="wrap_content"
129114
android:layout_marginStart="8dp"
130-
android:layout_marginTop="4dp"
115+
android:layout_marginTop="8dp"
131116
android:layout_marginEnd="8dp"
132117
android:layout_marginBottom="8dp"
133118
android:fontFamily="@font/proxima_nova"
134-
android:text="Video Tags"
135-
android:textSize="14sp"
119+
android:maxLines="5"
120+
android:text="@string/video_title"
121+
android:textSize="12sp"
136122
app:layout_constraintBottom_toBottomOf="parent"
137123
app:layout_constraintEnd_toEndOf="parent"
124+
app:layout_constraintHorizontal_bias="0.5"
138125
app:layout_constraintStart_toStartOf="parent"
139-
app:layout_constraintTop_toBottomOf="@id/textKind" />
126+
app:layout_constraintTop_toBottomOf="@+id/textTitle" />
127+
140128
</androidx.constraintlayout.widget.ConstraintLayout>
141129
</com.google.android.material.card.MaterialCardView>
142130

143131
<LinearLayout
144-
android:gravity="center"
145-
android:orientation="horizontal"
146132
android:id="@+id/fourthContainer"
147133
android:layout_width="match_parent"
148134
android:layout_height="wrap_content"
135+
android:gravity="left"
136+
android:orientation="horizontal"
149137
app:layout_constraintEnd_toEndOf="parent"
150138
app:layout_constraintStart_toStartOf="parent"
151-
app:layout_constraintTop_toBottomOf="@+id/secondContainer">
139+
app:layout_constraintTop_toBottomOf="@+id/secondContainer"
140+
tools:ignore="RtlHardcoded">
152141

153142
<com.google.android.material.card.MaterialCardView
154143
android:id="@+id/materialCardView3"
@@ -177,12 +166,15 @@
177166
android:id="@+id/textView"
178167
android:layout_width="wrap_content"
179168
android:layout_height="wrap_content"
180-
android:layout_margin="16dp"
169+
android:layout_marginStart="4dp"
170+
android:layout_marginTop="12dp"
171+
android:layout_marginEnd="8dp"
172+
android:layout_marginBottom="12dp"
181173
android:ellipsize="end"
182174
android:fontFamily="@font/circular_spotify"
183175
android:maxLines="2"
184176
android:text="@string/video_view"
185-
android:textSize="14sp"
177+
android:textSize="12sp"
186178
app:layout_constraintBottom_toBottomOf="parent"
187179
app:layout_constraintEnd_toEndOf="parent"
188180
app:layout_constraintStart_toEndOf="@+id/view_video_eye"
@@ -221,12 +213,15 @@
221213
android:id="@+id/textLiked"
222214
android:layout_width="wrap_content"
223215
android:layout_height="wrap_content"
224-
android:layout_margin="16dp"
216+
android:layout_marginStart="4dp"
217+
android:layout_marginTop="12dp"
218+
android:layout_marginEnd="8dp"
219+
android:layout_marginBottom="12dp"
225220
android:ellipsize="end"
226221
android:fontFamily="@font/circular_spotify"
227222
android:maxLines="2"
228223
android:text="@string/like"
229-
android:textSize="14sp"
224+
android:textSize="12sp"
230225
app:layout_constraintBottom_toBottomOf="parent"
231226
app:layout_constraintEnd_toEndOf="parent"
232227
app:layout_constraintHorizontal_bias="0.0"
@@ -243,8 +238,8 @@
243238
android:layout_gravity="center"
244239
android:layout_marginStart="8dp"
245240
android:layout_marginTop="8dp"
246-
android:layout_marginBottom="8dp"
247241
android:layout_marginEnd="8dp"
242+
android:layout_marginBottom="8dp"
248243
app:layout_constraintBottom_toBottomOf="parent"
249244
app:layout_constraintEnd_toStartOf="@+id/materialCardView3"
250245
app:layout_constraintStart_toEndOf="@+id/materialCardView2"
@@ -267,10 +262,13 @@
267262
<com.google.android.material.textview.MaterialTextView
268263
android:layout_width="wrap_content"
269264
android:layout_height="wrap_content"
270-
android:layout_margin="16dp"
265+
android:layout_marginStart="4dp"
266+
android:layout_marginTop="12dp"
267+
android:layout_marginEnd="8dp"
268+
android:layout_marginBottom="12dp"
271269
android:fontFamily="@font/circular_spotify"
272270
android:text="@string/pip"
273-
android:textSize="14sp"
271+
android:textSize="12sp"
274272
app:layout_constraintBottom_toBottomOf="parent"
275273
app:layout_constraintEnd_toEndOf="parent"
276274
app:layout_constraintStart_toEndOf="@+id/pip_img"
@@ -283,10 +281,12 @@
283281
<com.google.android.material.card.MaterialCardView
284282
android:id="@+id/video_link_button"
285283
style="@style/Widget.Material3.CardView.Filled"
286-
android:backgroundTint="?attr/colorSecondaryContainer"
287284
android:layout_width="match_parent"
288285
android:layout_height="wrap_content"
289-
android:layout_margin="8dp"
286+
android:layout_marginStart="8dp"
287+
android:layout_marginTop="2dp"
288+
android:layout_marginEnd="8dp"
289+
android:backgroundTint="?attr/colorSecondaryContainer"
290290
app:layout_constraintEnd_toEndOf="parent"
291291
app:layout_constraintStart_toStartOf="parent"
292292
app:layout_constraintTop_toBottomOf="@id/fourthContainer">
@@ -306,9 +306,9 @@
306306
android:fontFamily="@font/circular_spotify"
307307
android:gravity="center"
308308
android:maxLines="2"
309-
android:text="Video Link"
309+
android:text="@string/video_link"
310310
android:textColor="?attr/colorControlActivated"
311-
android:textSize="14sp"
311+
android:textSize="12sp"
312312
app:layout_constraintBottom_toBottomOf="parent"
313313
app:layout_constraintEnd_toStartOf="@+id/copy_video_link"
314314
app:layout_constraintStart_toStartOf="parent"
@@ -324,53 +324,32 @@
324324
android:text="@string/copy"
325325
app:icon="@drawable/ic_copy_text"
326326
app:layout_constraintBottom_toBottomOf="parent"
327+
app:layout_constraintEnd_toEndOf="parent"
327328
app:layout_constraintTop_toTopOf="parent"
328-
app:layout_constraintEnd_toEndOf="parent"/>
329+
tools:ignore="PrivateResource" />
329330

330331
</androidx.constraintlayout.widget.ConstraintLayout>
331332

332333
</com.google.android.material.card.MaterialCardView>
333334

334-
<com.google.android.material.card.MaterialCardView
335-
android:id="@+id/thirdContainer"
336-
style="@style/Widget.Material3.CardView.Filled"
337-
android:layout_width="match_parent"
338-
android:layout_height="wrap_content"
339-
android:layout_margin="8dp"
340-
android:backgroundTint="?attr/colorTertiaryContainer"
341-
app:layout_constraintEnd_toEndOf="parent"
342-
app:layout_constraintStart_toStartOf="parent"
343-
app:layout_constraintTop_toBottomOf="@id/video_link_button">
344-
345-
<com.google.android.material.textview.MaterialTextView
346-
android:id="@+id/textDescription"
347-
android:layout_width="wrap_content"
348-
android:layout_height="wrap_content"
349-
android:layout_margin="16dp"
350-
android:fontFamily="@font/proxima_nova"
351-
android:maxLines="10"
352-
android:text="Video Description"
353-
android:textSize="14sp" />
354-
</com.google.android.material.card.MaterialCardView>
355-
356335
<com.google.android.material.imageview.ShapeableImageView
357336
android:id="@+id/imageView"
358-
android:layout_width="92dp"
359-
android:layout_height="92dp"
337+
android:layout_width="64dp"
338+
android:layout_height="64dp"
360339
android:layout_marginStart="12dp"
361340
android:layout_marginTop="12dp"
362341
app:layout_constraintStart_toStartOf="parent"
363-
app:layout_constraintTop_toBottomOf="@id/thirdContainer"
342+
app:layout_constraintTop_toBottomOf="@id/video_link_button"
364343
app:shapeAppearance="@style/ShapeAppearance.Material3.Corner.Medium" />
365344

366345
<com.google.android.material.textview.MaterialTextView
367346
android:id="@+id/text1"
368347
android:layout_width="wrap_content"
369348
android:layout_height="wrap_content"
370349
android:layout_marginStart="12dp"
371-
android:layout_marginTop="8dp"
350+
android:layout_marginTop="0dp"
372351
android:fontFamily="@font/circular_spotify"
373-
android:text="Channel Name"
352+
android:text="@string/channel_title"
374353
android:textSize="16sp"
375354
android:textStyle="bold"
376355
app:layout_constraintStart_toEndOf="@id/imageView"
@@ -383,7 +362,7 @@
383362
android:layout_marginStart="12dp"
384363
android:layout_marginTop="2dp"
385364
android:fontFamily="@font/proxima_nova"
386-
android:text="Custom Url"
365+
android:text="@string/custom_url"
387366
android:textSize="14sp"
388367
app:layout_constraintStart_toEndOf="@id/imageView"
389368
app:layout_constraintTop_toBottomOf="@id/text1" />
@@ -395,7 +374,7 @@
395374
android:layout_marginStart="12dp"
396375
android:layout_marginTop="2dp"
397376
android:fontFamily="@font/proxima_nova"
398-
android:text="Channel Subscribers"
377+
android:text="@string/channel_description"
399378
android:textSize="14sp"
400379
app:layout_constraintStart_toEndOf="@id/imageView"
401380
app:layout_constraintTop_toBottomOf="@id/text2" />
@@ -407,8 +386,8 @@
407386
android:layout_margin="12dp"
408387
android:fontFamily="@font/proxima_nova"
409388
android:maxLines="3"
410-
android:text="Channel Description"
411-
android:textSize="14sp"
389+
android:text="@string/channel_description"
390+
android:textSize="12sp"
412391
app:layout_constraintEnd_toEndOf="parent"
413392
app:layout_constraintStart_toStartOf="parent"
414393
app:layout_constraintTop_toBottomOf="@id/imageView" />
@@ -420,13 +399,10 @@
420399
android:layout_margin="8dp"
421400
android:layout_marginStart="8dp"
422401
android:layout_marginEnd="8dp"
423-
android:layout_marginBottom="8dp"
424402
android:scrollbars="none"
425-
app:layout_constraintBottom_toBottomOf="parent"
426403
app:layout_constraintEnd_toEndOf="parent"
427404
app:layout_constraintStart_toStartOf="parent"
428-
app:layout_constraintTop_toBottomOf="@id/text4"
429-
app:layout_constraintVertical_bias="0.0" />
405+
app:layout_constraintTop_toBottomOf="@id/text4" />
430406

431407
</androidx.constraintlayout.widget.ConstraintLayout>
432408
</ScrollView>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<string name="youtube_data">Youtube Data</string>
1919
<string name="video_view">View</string>
2020
<string name="like">Like</string>
21-
<string name="pip">PIP</string>
21+
<string name="pip">Picture In Picture</string>
2222
<string name="copy">Copy</string>
2323
<string name="your_favourites">Your Liked Videos</string>
2424
<string name="create_new_playlist">Create new playlist !</string>

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
agp = "8.7.2"
2+
agp = "8.7.3"
33
androidappupdatelibrary = "1.0.4"
44
exomedia = "5.1.0"
55
kotlin = "1.9.23"

0 commit comments

Comments
 (0)