Poster title location

This commit is contained in:
LagradOst 2022-04-25 19:34:14 +02:00
parent ea7dfdad5a
commit e2c29338d2
11 changed files with 246 additions and 29 deletions

View file

@ -16,6 +16,7 @@
<uses-feature android:name="android.software.leanback"
android:required="false"/>
<!--TODO https://stackoverflow.com/questions/41799732/chromecast-button-not-visible-in-android-->
<application
android:name=".AcraApplication"
android:allowBackup="true"

View file

@ -10,11 +10,12 @@ import com.lagradost.cloudstream3.SearchResponse
import com.lagradost.cloudstream3.ui.search.SearchClickCallback
import com.lagradost.cloudstream3.ui.search.SearchResponseDiffCallback
import com.lagradost.cloudstream3.ui.search.SearchResultBuilder
import com.lagradost.cloudstream3.utils.UIHelper.IsBottomLayout
import kotlinx.android.synthetic.main.home_result_grid.view.*
class HomeChildItemAdapter(
val cardList: MutableList<SearchResponse>,
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<RecyclerView.ViewHolder>() {
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,

View file

@ -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<RecyclerView.ViewHolder>() {
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) {

View file

@ -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 {

View file

@ -0,0 +1,12 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
app:tint="?attr/white">
<path
android:fillColor="@android:color/white"
android:pathData="M3,3v8h8L11,3L3,3zM9,9L5,9L5,5h4v4zM3,13v8h8v-8L3,13zM9,19L5,19v-4h4v4zM13,3v8h8L21,3h-8zM19,9h-4L15,5h4v4zM13,13v8h8v-8h-8zM19,19h-4v-4h4v4z"
android:fillType="evenOdd"/>
</vector>

View file

@ -35,6 +35,7 @@
tools:ignore="ContentDescription" />
<TextView
tools:text="The Perfect Run"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"

View file

@ -0,0 +1,118 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- android:layout_width="114dp"
android:layout_height="180dp"-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:foreground="@drawable/outline_drawable"
android:layout_margin="2dp"
android:layout_width="114dp"
android:layout_height="180dp"
android:layout_marginBottom="2dp"
android:elevation="10dp"
app:cardCornerRadius="@dimen/rounded_image_radius"
android:id="@+id/backgroundCard"
app:cardBackgroundColor="?attr/primaryGrayBackground">
<ImageView
android:duplicateParentState="true"
android:id="@+id/imageView"
tools:src="@drawable/example_poster"
android:scaleType="centerCrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foreground="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/search_poster_img_des" />
<ImageView
android:id="@+id/search_item_download_play"
android:layout_gravity="center"
android:src="@drawable/play_button"
android:layout_width="60dp"
android:layout_height="60dp" />
<androidx.core.widget.ContentLoadingProgressBar
android:layout_marginBottom="-1.5dp"
android:id="@+id/watchProgress"
android:progressTint="?attr/colorPrimary"
android:progressBackgroundTint="?attr/colorPrimary"
style="@android:style/Widget.Material.ProgressBar.Horizontal"
android:layout_width="match_parent"
tools:progress="50"
android:layout_gravity="bottom"
android:layout_height="5dp" />
<!--<View
android:id="@+id/search_result_lang"
android:layout_gravity="bottom"
android:layout_width="match_parent"
android:layout_height="4dp"
android:alpha="0.9">
</View>-->
<!--<ImageView
android:src="@drawable/ic_baseline_bookmark_24"
android:id="@+id/search_result_lang"
android:layout_gravity="right"
android:layout_marginTop="-5dp"
android:layout_marginRight="-6.5dp"
android:layout_width="30dp"
android:layout_height="30dp">
</ImageView>-->
<TextView
tools:text="@string/quality_hd"
android:id="@+id/text_quality"
style="@style/SearchBox"
android:background="@drawable/type_bg_color" />
<LinearLayout
android:orientation="vertical"
android:layout_gravity="end"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--
<ImageView android:id="@+id/text_is_dub" android:tint="?attr/colorPrimary"
android:src="@drawable/ic_baseline_subtitles_24" android:layout_width="wrap_content"
android:layout_height="20dp">
</ImageView>-->
<TextView
android:text="@string/app_dubbed_text"
android:id="@+id/text_is_dub"
style="@style/SearchBox"
android:layout_gravity="end"
android:background="@drawable/dub_bg_color" />
<TextView
android:id="@+id/text_is_sub"
android:text="@string/app_subbed_text"
style="@style/SearchBox"
android:layout_gravity="end"
android:background="@drawable/sub_bg_color" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<TextView
tools:text="The Perfect Run\nThe Perfect Run"
android:layout_width="match_parent"
android:layout_height="40sp"
android:textSize="13sp"
android:gravity="center"
android:layout_gravity="bottom"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:textColor="@color/textColor"
android:id="@+id/imageText"
android:maxLines="2"
android:paddingStart="5dp"
android:paddingEnd="5dp"
android:ellipsize="end" />
</LinearLayout>

View file

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:foreground="@drawable/outline_drawable"
android:focusable="true"
android:clickable="true"
android:id="@+id/search_result_root">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.cardview.widget.CardView
android:layout_margin="2dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="2dp"
android:elevation="10dp"
app:cardCornerRadius="@dimen/rounded_image_radius"
android:id="@+id/backgroundCard"
app:cardBackgroundColor="?attr/primaryGrayBackground">
<ImageView
android:id="@+id/imageView"
tools:src="@drawable/example_poster"
android:duplicateParentState="true"
android:scaleType="centerCrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:foreground="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/search_poster_img_des" />
<TextView
tools:text="@string/quality_hd"
android:id="@+id/text_quality"
android:textColor="@color/textColor"
style="@style/SearchBox"
android:background="@drawable/type_bg_color" />
<LinearLayout
android:orientation="vertical"
android:layout_gravity="end"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="@string/app_dubbed_text"
android:id="@+id/text_is_dub"
android:layout_gravity="end"
style="@style/SearchBox"
android:background="@drawable/dub_bg_color" />
<TextView
android:id="@+id/text_is_sub"
android:text="@string/app_subbed_text"
android:layout_gravity="end"
style="@style/SearchBox"
android:background="@drawable/sub_bg_color" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<TextView
tools:text="The Perfect Run\nThe Perfect Run"
android:layout_width="match_parent"
android:layout_height="40sp"
android:textSize="13sp"
android:gravity="center"
android:layout_gravity="bottom"
android:paddingBottom="5dp"
android:paddingTop="5dp"
android:textColor="@color/textColor"
android:id="@+id/imageText"
android:maxLines="2"
android:paddingStart="5dp"
android:paddingEnd="5dp"
android:ellipsize="end" />
</LinearLayout>
</FrameLayout>

View file

@ -2,7 +2,7 @@
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="rounded_image_radius">5dp</dimen>
<dimen name="rounded_image_radius">10dp</dimen>
<dimen name="navbar_height">0dp</dimen>
<dimen name="card_corner_radius">2dp</dimen>
<dimen name="result_padding">15dp</dimen>

View file

@ -4,7 +4,6 @@
<string name="search_providers_list_key" translatable="false">search_providers_list</string>
<string name="locale_key" translatable="false">app_locale</string>
<string name="search_types_list_key" translatable="false">search_type_list</string>
<string name="grid_format_key" translatable="false">grid_format</string>
<string name="auto_update_key" translatable="false">auto_update</string>
<string name="skip_update_key" translatable="false">skip_update_key</string>
<string name="prerelease_update_key" translatable="false">prerelease_update</string>
@ -48,7 +47,7 @@
<string name="episode_sync_enabled_key" translatable="false">episode_sync_enabled_key</string>
<string name="log_enabled_key" translatable="false">log_enabled_key</string>
<string name="show_logcat_key" translatable="false">show_logcat_key</string>
<string name="bottom_title_key" translatable="false">bottom_title_key</string>
<!-- FORMAT MIGHT TRANSLATE, WILL CAUSE CRASH IF APPLIED WRONG -->
<string name="extra_info_format" translatable="false" formatted="true">%d %s | %sMB</string>
@ -401,12 +400,15 @@
<string name="preferred_media_settings">Preferred Media</string>
<string name="automatic">Auto</string>
<string name="tv_layout">TV Layout</string>
<string name="phone_layout">Phone Layout</string>
<string name="emulator_layout">Emulator Layout</string>
<string name="tv_layout">TV layout</string>
<string name="phone_layout">Phone layout</string>
<string name="emulator_layout">Emulator layout</string>
<string name="primary_color_settings">Primary color</string>
<string name="app_theme_settings">App theme</string>
<string name="bottom_title_settings">Poster title location</string>
<string name="bottom_title_settings_des">Put the title under the poster</string>
<string name="primary_color_settings">Primary Color</string>
<string name="app_theme_settings">App Theme</string>
<!-- account stuff -->
<string name="anilist_key" translatable="false">anilist_key</string>

View file

@ -159,6 +159,13 @@
android:icon="@drawable/ic_baseline_color_lens_24"
android:key="@string/app_theme_key"
android:title="@string/app_theme_settings" />
<SwitchPreference
android:defaultValue="true"
android:icon="@drawable/baseline_grid_view_24"
android:key="@string/bottom_title_key"
android:summary="@string/bottom_title_settings_des"
android:title="@string/bottom_title_settings" />
</PreferenceCategory>
<PreferenceCategory
android:key="search"