From e2c29338d209b9f31af96aefdd0f477f12181cd7 Mon Sep 17 00:00:00 2001
From: LagradOst <11805592+LagradOst@users.noreply.github.com>
Date: Mon, 25 Apr 2022 19:34:14 +0200
Subject: [PATCH] Poster title location
---
app/src/main/AndroidManifest.xml | 1 +
.../ui/home/HomeChildItemAdapter.kt | 5 +-
.../cloudstream3/ui/search/SearchAdaptor.kt | 8 +-
.../lagradost/cloudstream3/utils/UIHelper.kt | 21 +---
.../res/drawable/baseline_grid_view_24.xml | 12 ++
app/src/main/res/layout/home_result_grid.xml | 1 +
.../res/layout/home_result_grid_expanded.xml | 118 ++++++++++++++++++
.../layout/search_result_grid_expanded.xml | 84 +++++++++++++
app/src/main/res/values/dimens.xml | 2 +-
app/src/main/res/values/strings.xml | 16 +--
app/src/main/res/xml/settings.xml | 7 ++
11 files changed, 246 insertions(+), 29 deletions(-)
create mode 100644 app/src/main/res/drawable/baseline_grid_view_24.xml
create mode 100644 app/src/main/res/layout/home_result_grid_expanded.xml
create mode 100644 app/src/main/res/layout/search_result_grid_expanded.xml
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 07937af4..cc06223e 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -16,6 +16,7 @@
+
,
- val layout: Int = R.layout.home_result_grid,
+ private val overrideLayout : Int? = null,
private val nextFocusUp: Int? = null,
private val nextFocusDown: Int? = null,
private val clickCallback: (SearchClickCallback) -> Unit,
@@ -22,6 +23,8 @@ class HomeChildItemAdapter(
RecyclerView.Adapter() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
+ val layout = overrideLayout ?: if(parent.context.IsBottomLayout()) R.layout.home_result_grid_expanded else R.layout.home_result_grid
+
return CardViewHolder(
LayoutInflater.from(parent.context).inflate(layout, parent, false),
clickCallback,
diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchAdaptor.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchAdaptor.kt
index 54cb29c2..fe442e2b 100644
--- a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchAdaptor.kt
+++ b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchAdaptor.kt
@@ -7,10 +7,10 @@ import android.widget.FrameLayout
import android.widget.ImageView
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.RecyclerView
+import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.SearchResponse
import com.lagradost.cloudstream3.ui.AutofitRecyclerView
-import com.lagradost.cloudstream3.utils.UIHelper.getGridFormatId
-import com.lagradost.cloudstream3.utils.UIHelper.getGridIsCompact
+import com.lagradost.cloudstream3.utils.UIHelper.IsBottomLayout
import com.lagradost.cloudstream3.utils.UIHelper.toPx
import kotlinx.android.synthetic.main.search_result_compact.view.*
import kotlin.math.roundToInt
@@ -29,7 +29,7 @@ class SearchAdapter(
) : RecyclerView.Adapter() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
- val layout = parent.context.getGridFormatId()
+ val layout = if(parent.context.IsBottomLayout()) R.layout.search_result_grid_expanded else R.layout.search_result_grid
return CardViewHolder(
LayoutInflater.from(parent.context).inflate(layout, parent, false),
clickCallback,
@@ -69,7 +69,7 @@ class SearchAdapter(
RecyclerView.ViewHolder(itemView) {
val cardView: ImageView = itemView.imageView
- private val compactView = itemView.context.getGridIsCompact()
+ private val compactView = false//itemView.context.getGridIsCompact()
private val coverHeight: Int = if (compactView) 80.toPx else (resView.itemWidth / 0.68).roundToInt()
fun bind(card: SearchResponse, position: Int) {
diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/UIHelper.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/UIHelper.kt
index c7969d5e..90c8d3f5 100644
--- a/app/src/main/java/com/lagradost/cloudstream3/utils/UIHelper.kt
+++ b/app/src/main/java/com/lagradost/cloudstream3/utils/UIHelper.kt
@@ -100,10 +100,10 @@ object UIHelper {
}
fun Activity?.getSpanCount(): Int? {
- val compactView = this?.getGridIsCompact() ?: return null
+ val compactView = false
val spanCountLandscape = if (compactView) 2 else 6
val spanCountPortrait = if (compactView) 1 else 3
- val orientation = this.resources?.configuration?.orientation ?: return null
+ val orientation = this?.resources?.configuration?.orientation ?: return null
return if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
spanCountLandscape
@@ -315,21 +315,10 @@ object UIHelper {
return result
}
- private fun Context.getGridFormat(): String {
+ fun Context?.IsBottomLayout(): Boolean {
+ if(this == null) return true
val settingsManager = PreferenceManager.getDefaultSharedPreferences(this)
- return settingsManager.getString(getString(R.string.grid_format_key), "grid")!!
- }
-
- fun Context.getGridFormatId(): Int {
- return when (getGridFormat()) {
- "list" -> R.layout.search_result_compact
- "compact_list" -> R.layout.search_result_super_compact
- else -> R.layout.search_result_grid
- }
- }
-
- fun Context.getGridIsCompact(): Boolean {
- return getGridFormat() != "grid"
+ return settingsManager.getBoolean(getString(R.string.bottom_title_key), true)
}
fun Activity.changeStatusBarState(hide: Boolean): Int {
diff --git a/app/src/main/res/drawable/baseline_grid_view_24.xml b/app/src/main/res/drawable/baseline_grid_view_24.xml
new file mode 100644
index 00000000..55ffb0c9
--- /dev/null
+++ b/app/src/main/res/drawable/baseline_grid_view_24.xml
@@ -0,0 +1,12 @@
+
+
+
diff --git a/app/src/main/res/layout/home_result_grid.xml b/app/src/main/res/layout/home_result_grid.xml
index 55b9c3f6..73fe6cf9 100644
--- a/app/src/main/res/layout/home_result_grid.xml
+++ b/app/src/main/res/layout/home_result_grid.xml
@@ -35,6 +35,7 @@
tools:ignore="ContentDescription" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/search_result_grid_expanded.xml b/app/src/main/res/layout/search_result_grid_expanded.xml
new file mode 100644
index 00000000..80cee40e
--- /dev/null
+++ b/app/src/main/res/layout/search_result_grid_expanded.xml
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index e0accac5..5ac7cbf9 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -2,7 +2,7 @@
16dp
16dp
- 5dp
+ 10dp
0dp
2dp
15dp
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 3517cc9f..4965fed0 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -4,7 +4,6 @@
search_providers_list
app_locale
search_type_list
- grid_format
auto_update
skip_update_key
prerelease_update
@@ -48,7 +47,7 @@
episode_sync_enabled_key
log_enabled_key
show_logcat_key
-
+ bottom_title_key
%d %s | %sMB
@@ -401,12 +400,15 @@
Preferred Media
Auto
- TV Layout
- Phone Layout
- Emulator Layout
+ TV layout
+ Phone layout
+ Emulator layout
+
+ Primary color
+ App theme
+ Poster title location
+ Put the title under the poster
- Primary Color
- App Theme
anilist_key
diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml
index a28efef5..0519aa77 100644
--- a/app/src/main/res/xml/settings.xml
+++ b/app/src/main/res/xml/settings.xml
@@ -159,6 +159,13 @@
android:icon="@drawable/ic_baseline_color_lens_24"
android:key="@string/app_theme_key"
android:title="@string/app_theme_settings" />
+
+