mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
added search to homepage
This commit is contained in:
parent
e2c29338d2
commit
1a5fc93eba
9 changed files with 83 additions and 44 deletions
|
@ -35,8 +35,8 @@ android {
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
|
|
||||||
versionCode 45
|
versionCode 46
|
||||||
versionName "2.9.21"
|
versionName "2.9.22"
|
||||||
|
|
||||||
resValue "string", "app_version",
|
resValue "string", "app_version",
|
||||||
"${defaultConfig.versionName}${versionNameSuffix ?: ""}"
|
"${defaultConfig.versionName}${versionNameSuffix ?: ""}"
|
||||||
|
|
|
@ -11,6 +11,7 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.*
|
import android.widget.*
|
||||||
|
import androidx.appcompat.widget.SearchView
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.core.widget.NestedScrollView
|
import androidx.core.widget.NestedScrollView
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
@ -37,6 +38,7 @@ import com.lagradost.cloudstream3.ui.APIRepository.Companion.noneApi
|
||||||
import com.lagradost.cloudstream3.ui.APIRepository.Companion.randomApi
|
import com.lagradost.cloudstream3.ui.APIRepository.Companion.randomApi
|
||||||
import com.lagradost.cloudstream3.ui.AutofitRecyclerView
|
import com.lagradost.cloudstream3.ui.AutofitRecyclerView
|
||||||
import com.lagradost.cloudstream3.ui.WatchType
|
import com.lagradost.cloudstream3.ui.WatchType
|
||||||
|
import com.lagradost.cloudstream3.ui.quicksearch.QuickSearchFragment
|
||||||
import com.lagradost.cloudstream3.ui.result.START_ACTION_RESUME_LATEST
|
import com.lagradost.cloudstream3.ui.result.START_ACTION_RESUME_LATEST
|
||||||
import com.lagradost.cloudstream3.ui.search.*
|
import com.lagradost.cloudstream3.ui.search.*
|
||||||
import com.lagradost.cloudstream3.ui.search.SearchFragment.Companion.filterSearchResponse
|
import com.lagradost.cloudstream3.ui.search.SearchFragment.Companion.filterSearchResponse
|
||||||
|
@ -65,7 +67,6 @@ import kotlinx.android.synthetic.main.fragment_home.*
|
||||||
import kotlinx.android.synthetic.main.fragment_home.home_api_fab
|
import kotlinx.android.synthetic.main.fragment_home.home_api_fab
|
||||||
import kotlinx.android.synthetic.main.fragment_home.home_bookmarked_child_recyclerview
|
import kotlinx.android.synthetic.main.fragment_home.home_bookmarked_child_recyclerview
|
||||||
import kotlinx.android.synthetic.main.fragment_home.home_bookmarked_holder
|
import kotlinx.android.synthetic.main.fragment_home.home_bookmarked_holder
|
||||||
import kotlinx.android.synthetic.main.fragment_home.home_change_api
|
|
||||||
import kotlinx.android.synthetic.main.fragment_home.home_change_api_loading
|
import kotlinx.android.synthetic.main.fragment_home.home_change_api_loading
|
||||||
import kotlinx.android.synthetic.main.fragment_home.home_loaded
|
import kotlinx.android.synthetic.main.fragment_home.home_loaded
|
||||||
import kotlinx.android.synthetic.main.fragment_home.home_loading
|
import kotlinx.android.synthetic.main.fragment_home.home_loading
|
||||||
|
@ -230,7 +231,8 @@ class HomeFragment : Fragment() {
|
||||||
}.sortedBy { it.name.lowercase() }.toMutableList()
|
}.sortedBy { it.name.lowercase() }.toMutableList()
|
||||||
currentValidApis.addAll(0, validAPIs.subList(0, 2))
|
currentValidApis.addAll(0, validAPIs.subList(0, 2))
|
||||||
|
|
||||||
val names = currentValidApis.map { if(isMultiLang) "${getFlagFromIso(it.lang)?.plus(" ") ?: ""}${it.name}" else it.name }
|
val names =
|
||||||
|
currentValidApis.map { if (isMultiLang) "${getFlagFromIso(it.lang)?.plus(" ") ?: ""}${it.name}" else it.name }
|
||||||
val index = currentValidApis.map { it.name }.indexOf(currentApiName)
|
val index = currentValidApis.map { it.name }.indexOf(currentApiName)
|
||||||
listView?.setItemChecked(index, true)
|
listView?.setItemChecked(index, true)
|
||||||
arrayAdapter.addAll(names)
|
arrayAdapter.addAll(names)
|
||||||
|
@ -379,7 +381,8 @@ class HomeFragment : Fragment() {
|
||||||
//Disable Random button, if its toggled off on settings
|
//Disable Random button, if its toggled off on settings
|
||||||
context?.let {
|
context?.let {
|
||||||
val settingsManager = PreferenceManager.getDefaultSharedPreferences(it)
|
val settingsManager = PreferenceManager.getDefaultSharedPreferences(it)
|
||||||
toggleRandomButton = settingsManager.getBoolean(getString(R.string.random_button_key), false)
|
toggleRandomButton =
|
||||||
|
settingsManager.getBoolean(getString(R.string.random_button_key), false)
|
||||||
home_random?.isVisible = toggleRandomButton
|
home_random?.isVisible = toggleRandomButton
|
||||||
if (!toggleRandomButton) {
|
if (!toggleRandomButton) {
|
||||||
home_random?.visibility = View.GONE
|
home_random?.visibility = View.GONE
|
||||||
|
@ -389,6 +392,7 @@ class HomeFragment : Fragment() {
|
||||||
observe(homeViewModel.apiName) { apiName ->
|
observe(homeViewModel.apiName) { apiName ->
|
||||||
currentApiName = apiName
|
currentApiName = apiName
|
||||||
setKey(HOMEPAGE_API, apiName)
|
setKey(HOMEPAGE_API, apiName)
|
||||||
|
home_api_fab?.text = apiName
|
||||||
home_provider_name?.text = apiName
|
home_provider_name?.text = apiName
|
||||||
home_provider_meta_info?.isVisible = false
|
home_provider_meta_info?.isVisible = false
|
||||||
|
|
||||||
|
@ -453,6 +457,19 @@ class HomeFragment : Fragment() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
home_search?.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||||
|
override fun onQueryTextSubmit(query: String): Boolean {
|
||||||
|
QuickSearchFragment.pushSearch(activity, query)
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onQueryTextChange(newText: String): Boolean {
|
||||||
|
//searchViewModel.quickSearch(newText)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
observe(homeViewModel.page) { data ->
|
observe(homeViewModel.page) { data ->
|
||||||
when (data) {
|
when (data) {
|
||||||
is Resource.Success -> {
|
is Resource.Success -> {
|
||||||
|
|
|
@ -113,11 +113,11 @@ class QuickSearchFragment : Fragment() {
|
||||||
val searchExitIcon =
|
val searchExitIcon =
|
||||||
quick_search?.findViewById<ImageView>(androidx.appcompat.R.id.search_close_btn)
|
quick_search?.findViewById<ImageView>(androidx.appcompat.R.id.search_close_btn)
|
||||||
|
|
||||||
val searchMagIcon =
|
//val searchMagIcon =
|
||||||
quick_search?.findViewById<ImageView>(androidx.appcompat.R.id.search_mag_icon)
|
// quick_search?.findViewById<ImageView>(androidx.appcompat.R.id.search_mag_icon)
|
||||||
|
|
||||||
searchMagIcon?.scaleX = 0.65f
|
//searchMagIcon?.scaleX = 0.65f
|
||||||
searchMagIcon?.scaleY = 0.65f
|
//searchMagIcon?.scaleY = 0.65f
|
||||||
|
|
||||||
quick_search?.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
quick_search?.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||||
override fun onQueryTextSubmit(query: String): Boolean {
|
override fun onQueryTextSubmit(query: String): Boolean {
|
||||||
|
|
|
@ -134,10 +134,10 @@ class SearchFragment : Fragment() {
|
||||||
|
|
||||||
val searchExitIcon =
|
val searchExitIcon =
|
||||||
main_search.findViewById<ImageView>(androidx.appcompat.R.id.search_close_btn)
|
main_search.findViewById<ImageView>(androidx.appcompat.R.id.search_close_btn)
|
||||||
val searchMagIcon =
|
// val searchMagIcon =
|
||||||
main_search.findViewById<ImageView>(androidx.appcompat.R.id.search_mag_icon)
|
// main_search.findViewById<ImageView>(androidx.appcompat.R.id.search_mag_icon)
|
||||||
searchMagIcon.scaleX = 0.65f
|
//searchMagIcon.scaleX = 0.65f
|
||||||
searchMagIcon.scaleY = 0.65f
|
//searchMagIcon.scaleY = 0.65f
|
||||||
|
|
||||||
context?.let { ctx ->
|
context?.let { ctx ->
|
||||||
val validAPIs = ctx.filterProviderByPreferredMedia()
|
val validAPIs = ctx.filterProviderByPreferredMedia()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
|
||||||
<corners android:radius="10dp" />
|
<corners android:radius="20dp" />
|
||||||
<solid android:color="?attr/primaryBlackBackground"/>
|
<solid android:color="?attr/primaryBlackBackground"/>
|
||||||
<!--<stroke android:width="0.5dp" android:color="@color/searchColorTransparent" />-->
|
<!--<stroke android:width="0.5dp" android:color="@color/searchColorTransparent" />-->
|
||||||
</shape>
|
</shape>
|
||||||
|
|
|
@ -179,7 +179,6 @@
|
||||||
android:layout_height="70dp">
|
android:layout_height="70dp">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_marginEnd="50dp"
|
|
||||||
android:paddingTop="10dp"
|
android:paddingTop="10dp"
|
||||||
android:paddingBottom="10dp"
|
android:paddingBottom="10dp"
|
||||||
|
|
||||||
|
@ -195,8 +194,8 @@
|
||||||
android:layout_marginEnd="20dp"
|
android:layout_marginEnd="20dp"
|
||||||
app:cardCornerRadius="100dp"
|
app:cardCornerRadius="100dp"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_width="35dp"
|
android:layout_width="40dp"
|
||||||
android:layout_height="35dp">
|
android:layout_height="40dp">
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/home_profile_picture"
|
android:id="@+id/home_profile_picture"
|
||||||
|
@ -205,7 +204,30 @@
|
||||||
tools:ignore="ContentDescription" />
|
tools:ignore="ContentDescription" />
|
||||||
</androidx.cardview.widget.CardView>
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:visibility="visible"
|
||||||
|
android:background="@drawable/search_background"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="40dp">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.SearchView
|
||||||
|
android:id="@+id/home_search"
|
||||||
|
app:queryBackground="@color/transparent"
|
||||||
|
|
||||||
|
app:searchIcon="@drawable/search_icon"
|
||||||
|
android:paddingStart="-10dp"
|
||||||
|
android:iconifiedByDefault="false"
|
||||||
|
app:queryHint="@string/search_hint"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
app:iconifiedByDefault="false"
|
||||||
|
tools:ignore="RtlSymmetry" />
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
android:visibility="gone"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
|
@ -235,24 +257,24 @@
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
<ImageView
|
||||||
|
android:nextFocusDown="@id/home_main_poster_recyclerview"
|
||||||
|
android:nextFocusUp="@id/nav_rail_view"
|
||||||
|
android:nextFocusLeft="@id/nav_rail_view"
|
||||||
|
|
||||||
<ImageView
|
android:id="@+id/home_change_api"
|
||||||
android:nextFocusDown="@id/home_main_poster_recyclerview"
|
android:layout_margin="10dp"
|
||||||
android:nextFocusUp="@id/nav_rail_view"
|
android:layout_gravity="center|end"
|
||||||
android:nextFocusLeft="@id/nav_rail_view"
|
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||||
|
|
||||||
android:id="@+id/home_change_api"
|
android:src="@drawable/ic_baseline_keyboard_arrow_down_24"
|
||||||
android:layout_margin="10dp"
|
android:layout_width="30dp"
|
||||||
android:layout_gravity="center|end"
|
android:layout_height="30dp"
|
||||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
android:contentDescription="@string/home_change_provider_img_des">
|
||||||
|
|
||||||
android:src="@drawable/ic_baseline_keyboard_arrow_down_24"
|
<requestFocus />
|
||||||
android:layout_width="30dp"
|
</ImageView>-->
|
||||||
android:layout_height="30dp"
|
|
||||||
android:contentDescription="@string/home_change_provider_img_des">
|
|
||||||
|
|
||||||
<requestFocus />
|
|
||||||
</ImageView>
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
@ -512,14 +534,15 @@
|
||||||
style="@style/ExtendedFloatingActionButton"
|
style="@style/ExtendedFloatingActionButton"
|
||||||
android:textColor="?attr/textColor"
|
android:textColor="?attr/textColor"
|
||||||
tools:ignore="ContentDescription" />
|
tools:ignore="ContentDescription" />
|
||||||
|
|
||||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible"
|
tools:visibility="visible"
|
||||||
android:text="@string/home_random"
|
android:text="@string/home_random"
|
||||||
android:id="@+id/home_random"
|
android:id="@+id/home_random"
|
||||||
android:layout_gravity="bottom|start"
|
android:layout_gravity="bottom|start"
|
||||||
app:icon="@drawable/ic_baseline_play_arrow_24"
|
app:icon="@drawable/ic_baseline_play_arrow_24"
|
||||||
style="@style/ExtendedFloatingActionButton"
|
style="@style/ExtendedFloatingActionButton"
|
||||||
android:textColor="?attr/textColor"
|
android:textColor="?attr/textColor"
|
||||||
tools:ignore="ContentDescription" />
|
tools:ignore="ContentDescription" />
|
||||||
</FrameLayout>
|
</FrameLayout>
|
|
@ -15,7 +15,7 @@
|
||||||
android:layout_margin="10dp"
|
android:layout_margin="10dp"
|
||||||
android:background="@drawable/search_background"
|
android:background="@drawable/search_background"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="45dp">
|
android:layout_height="40dp">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
android:background="@drawable/search_background"
|
android:background="@drawable/search_background"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="45dp">
|
android:layout_height="40dp">
|
||||||
|
|
||||||
<androidx.appcompat.widget.SearchView
|
<androidx.appcompat.widget.SearchView
|
||||||
android:nextFocusRight="@id/search_filter"
|
android:nextFocusRight="@id/search_filter"
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
<string name="search_providers_list_key" translatable="false">search_providers_list</string>
|
<string name="search_providers_list_key" translatable="false">search_providers_list</string>
|
||||||
<string name="locale_key" translatable="false">app_locale</string>
|
<string name="locale_key" translatable="false">app_locale</string>
|
||||||
<string name="search_types_list_key" translatable="false">search_type_list</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="auto_update_key" translatable="false">auto_update</string>
|
||||||
<string name="prerelease_update_key" translatable="false">prerelease_update</string>
|
<string name="prerelease_update_key" translatable="false">prerelease_update</string>
|
||||||
<string name="manual_check_update_key" translatable="false">manual_check_update</string>
|
<string name="manual_check_update_key" translatable="false">manual_check_update</string>
|
||||||
|
|
Loading…
Reference in a new issue