Skip to content

Commit c048426

Browse files
authored
feat:separate episode text in continue watching (#2093)
1 parent 7ef5753 commit c048426

File tree

13 files changed

+109
-34
lines changed

13 files changed

+109
-34
lines changed

app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchResultBuilder.kt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import com.lagradost.cloudstream3.syncproviders.SyncAPI
2222
import com.lagradost.cloudstream3.ui.settings.Globals.TV
2323
import com.lagradost.cloudstream3.ui.settings.Globals.isLayout
2424
import com.lagradost.cloudstream3.utils.AppContextUtils.getNameFull
25+
import com.lagradost.cloudstream3.utils.AppContextUtils.getShortSeasonText
2526
import com.lagradost.cloudstream3.utils.DataStoreHelper
2627
import com.lagradost.cloudstream3.utils.DataStoreHelper.fixVisual
2728
import com.lagradost.cloudstream3.utils.ImageLoader.loadImage
@@ -66,6 +67,7 @@ object SearchResultBuilder {
6667

6768
val bar: ProgressBar? = itemView.findViewById(R.id.watchProgress)
6869
val playImg: ImageView? = itemView.findViewById(R.id.search_item_download_play)
70+
val episodeText: TextView? = itemView.findViewById(R.id.episode_text)
6971

7072
// Do logic
7173

@@ -75,10 +77,12 @@ object SearchResultBuilder {
7577
textIsSub?.isVisible = false
7678
textFlag?.isVisible = false
7779
rating?.isVisible = false
80+
episodeText?.isVisible = false
7881

7982
val showSub = showCache[textIsDub?.context?.getString(R.string.show_sub_key)] ?: false
8083
val showDub = showCache[textIsDub?.context?.getString(R.string.show_dub_key)] ?: false
8184
val showTitle = showCache[cardText?.context?.getString(R.string.show_title_key)] ?: false
85+
val showEpisodeText = showCache[cardText?.context?.getString(R.string.show_episode_text_key)] ?: false
8286
val showHd = showCache[textQuality?.context?.getString(R.string.show_hd_key)] ?: false
8387
val showRatingView =
8488
showCache[textQuality?.context?.getString(R.string.show_rating_key)] ?: false
@@ -254,12 +258,12 @@ object SearchResultBuilder {
254258
bar?.progress = (pos.position / 1000).toInt()
255259
bar?.visibility = View.VISIBLE
256260
}
257-
258261
playImg?.visibility = View.VISIBLE
259-
260-
if (card.type?.isMovieType() == false) {
261-
cardText?.text =
262-
cardText.context?.getNameFull(card.name, card.episode, card.season)
262+
if (card.type?.isMovieType() == false && showEpisodeText) {
263+
episodeText?.context?.getShortSeasonText(card.episode, card.season)?.let {text->
264+
episodeText.text = text
265+
episodeText.isVisible = true
266+
}
263267
}
264268
}
265269

app/src/main/java/com/lagradost/cloudstream3/utils/AppContextUtils.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,18 @@ object AppContextUtils {
687687
return ""
688688
}
689689

690+
fun Context.getShortSeasonText(episode: Int?, season: Int?): String? {
691+
val rEpisode = if (episode == 0) null else episode
692+
val rSeason = if (season == 0) null else season
693+
val seasonNameShort = getString(R.string.season_short)
694+
val episodeNameShort = getString(R.string.episode_short)
695+
return if (rEpisode != null && rSeason != null) {
696+
"$seasonNameShort${rSeason}:$episodeNameShort${rEpisode}"
697+
} else if (rEpisode != null) {
698+
"$episodeNameShort$rEpisode"
699+
}else null
700+
}
701+
690702
fun Activity?.loadCache() {
691703
try {
692704
cacheClass("android.net.NetworkCapabilities".load())

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

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,31 @@
3535
android:src="@drawable/title_shadow"
3636
tools:ignore="ContentDescription" />
3737

38-
<TextView
39-
android:id="@+id/imageText"
38+
<LinearLayout
4039
android:layout_width="match_parent"
4140
android:layout_height="wrap_content"
4241
android:layout_gravity="bottom"
43-
android:ellipsize="end"
44-
android:gravity="center"
45-
android:maxLines="2"
46-
android:paddingStart="5dp"
47-
android:paddingTop="5dp"
48-
android:paddingEnd="5dp"
49-
android:paddingBottom="5dp"
50-
android:textColor="@color/textColor"
51-
android:textStyle="bold"
52-
tools:text="The Perfect Run" />
42+
android:orientation="vertical"
43+
android:paddingBottom="5dp">
44+
<TextView
45+
android:id="@+id/episode_text"
46+
android:layout_width="wrap_content"
47+
style="@style/EpisodeTextButton"
48+
android:layout_gravity="center"/>
49+
<TextView
50+
android:id="@+id/imageText"
51+
android:layout_width="match_parent"
52+
android:layout_height="wrap_content"
53+
android:layout_gravity="bottom"
54+
android:ellipsize="end"
55+
android:gravity="center"
56+
android:maxLines="1"
57+
android:paddingStart="5dp"
58+
android:paddingEnd="5dp"
59+
android:textColor="@color/textColor"
60+
android:textStyle="bold"
61+
tools:text="The Perfect Run" />
62+
</LinearLayout>
5363

5464

5565

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,18 @@
167167
tools:text="🇸🇪"
168168
tools:visibility="visible" />
169169
</LinearLayout>
170+
<LinearLayout
171+
android:layout_width="match_parent"
172+
android:layout_height="wrap_content"
173+
android:layout_gravity="bottom"
174+
android:orientation="vertical"
175+
android:paddingBottom="3dp">
176+
<TextView
177+
android:id="@+id/episode_text"
178+
android:layout_width="wrap_content"
179+
style="@style/EpisodeTextButton"
180+
android:layout_gravity="center"/>
181+
</LinearLayout>
170182
</androidx.cardview.widget.CardView>
171183

172184
<TextView

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

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,6 @@
4141
android:src="@drawable/title_shadow"
4242
tools:ignore="ContentDescription" />
4343

44-
<TextView
45-
android:id="@+id/imageText"
46-
47-
android:layout_width="match_parent"
48-
android:layout_height="wrap_content"
49-
android:layout_gravity="bottom"
50-
android:ellipsize="end"
51-
android:gravity="center"
52-
android:maxLines="2"
53-
android:paddingStart="5dp"
54-
android:paddingTop="5dp"
55-
android:paddingEnd="5dp"
56-
android:paddingBottom="5dp"
57-
android:textColor="@color/textColor"
58-
android:textStyle="bold" />
59-
6044
<TextView android:id="@+id/text_quality" style="@style/TypeButton" />
6145

6246
<LinearLayout
@@ -103,6 +87,31 @@
10387
android:visibility="gone"
10488
tools:progress="50"
10589
tools:visibility="visible" />
90+
<LinearLayout
91+
android:layout_width="match_parent"
92+
android:layout_height="wrap_content"
93+
android:layout_gravity="bottom"
94+
android:orientation="vertical"
95+
android:paddingBottom="5dp">
96+
<TextView
97+
android:id="@+id/episode_text"
98+
android:layout_width="wrap_content"
99+
style="@style/EpisodeTextButton"
100+
android:layout_gravity="center"/>
101+
<TextView
102+
android:id="@+id/imageText"
103+
android:layout_width="match_parent"
104+
android:layout_height="wrap_content"
105+
android:layout_gravity="bottom"
106+
android:ellipsize="end"
107+
android:gravity="center"
108+
android:maxLines="1"
109+
android:paddingStart="5dp"
110+
android:paddingEnd="5dp"
111+
android:textColor="@color/textColor"
112+
android:textStyle="bold"
113+
tools:text="The Perfect Run" />
114+
</LinearLayout>
106115
</androidx.cardview.widget.CardView>
107116

108117
</LinearLayout>

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,18 @@
9898
android:visibility="gone"
9999
tools:progress="50"
100100
tools:visibility="visible" />
101+
<LinearLayout
102+
android:layout_width="match_parent"
103+
android:layout_height="wrap_content"
104+
android:layout_gravity="bottom"
105+
android:orientation="vertical"
106+
android:paddingBottom="7dp">
107+
<TextView
108+
android:id="@+id/episode_text"
109+
android:layout_width="wrap_content"
110+
style="@style/EpisodeTextButton"
111+
android:layout_gravity="center"/>
112+
</LinearLayout>
101113
</androidx.cardview.widget.CardView>
102114
</androidx.constraintlayout.widget.ConstraintLayout>
103115

@@ -117,4 +129,5 @@
117129
android:textColor="?attr/textColor"
118130
android:textSize="13sp"
119131
tools:text="The Perfect Run\nThe Perfect Run" />
132+
120133
</LinearLayout>

app/src/main/res/values-b+es/array.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148
<item>@string/show_sub</item>
149149
<item>@string/show_rating</item>
150150
<item>@string/show_title</item>
151+
<item>@string/show_episode_text</item>
151152
</array>
152153

153154
<array name="poster_ui_options_values">
@@ -156,6 +157,7 @@
156157
<item>@string/show_sub_key</item>
157158
<item>@string/show_rating_key</item>
158159
<item>@string/show_title_key</item>
160+
<item>@string/show_episode_text_key</item>
159161
</array>
160162

161163
<array name="app_layout">

app/src/main/res/values-b+pl/array.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@
157157
<item>@string/show_sub</item>
158158
<item>@string/show_rating</item>
159159
<item>@string/show_title</item>
160+
<item>@string/show_episode_text</item>
160161
</array>
161162

162163
<array name="poster_ui_options_values">
@@ -165,6 +166,7 @@
165166
<item>@string/show_sub_key</item>
166167
<item>@string/show_rating_key</item>
167168
<item>@string/show_title_key</item>
169+
<item>@string/show_episode_text_key</item>
168170
</array>
169171

170172
<array name="app_layout">

app/src/main/res/values-b+tr/array.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@
171171
<item>@string/show_sub</item>
172172
<item>@string/show_rating</item>
173173
<item>@string/show_title</item>
174+
<item>@string/show_episode_text</item>
174175
</array>
175176

176177
<array name="poster_ui_options_values">
@@ -179,8 +180,8 @@
179180
<item>@string/show_sub_key</item>
180181
<item>@string/show_rating_key</item>
181182
<item>@string/show_title_key</item>
183+
<item>@string/show_episode_text_key</item>
182184
</array>
183-
184185
<array name="app_layout">
185186
<item>@string/automatic</item>
186187
<item>@string/phone_layout</item>

app/src/main/res/values-b+vi/array.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@
149149
<item>@string/show_sub</item>
150150
<item>@string/show_rating</item>
151151
<item>@string/show_title</item>
152+
<item>@string/show_episode_text</item>
152153
</array>
153154

154155
<array name="poster_ui_options_values">
@@ -157,6 +158,7 @@
157158
<item>@string/show_sub_key</item>
158159
<item>@string/show_rating_key</item>
159160
<item>@string/show_title_key</item>
161+
<item>@string/show_episode_text_key</item>
160162
</array>
161163

162164
<array name="app_layout">

0 commit comments

Comments
 (0)