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
|
||||
targetSdkVersion 30
|
||||
|
||||
versionCode 45
|
||||
versionName "2.9.21"
|
||||
versionCode 46
|
||||
versionName "2.9.22"
|
||||
|
||||
resValue "string", "app_version",
|
||||
"${defaultConfig.versionName}${versionNameSuffix ?: ""}"
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.view.LayoutInflater
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.*
|
||||
import androidx.appcompat.widget.SearchView
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.widget.NestedScrollView
|
||||
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.AutofitRecyclerView
|
||||
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.search.*
|
||||
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_bookmarked_child_recyclerview
|
||||
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_loaded
|
||||
import kotlinx.android.synthetic.main.fragment_home.home_loading
|
||||
|
@ -230,7 +231,8 @@ class HomeFragment : Fragment() {
|
|||
}.sortedBy { it.name.lowercase() }.toMutableList()
|
||||
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)
|
||||
listView?.setItemChecked(index, true)
|
||||
arrayAdapter.addAll(names)
|
||||
|
@ -379,7 +381,8 @@ class HomeFragment : Fragment() {
|
|||
//Disable Random button, if its toggled off on settings
|
||||
context?.let {
|
||||
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
|
||||
if (!toggleRandomButton) {
|
||||
home_random?.visibility = View.GONE
|
||||
|
@ -389,6 +392,7 @@ class HomeFragment : Fragment() {
|
|||
observe(homeViewModel.apiName) { apiName ->
|
||||
currentApiName = apiName
|
||||
setKey(HOMEPAGE_API, apiName)
|
||||
home_api_fab?.text = apiName
|
||||
home_provider_name?.text = apiName
|
||||
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 ->
|
||||
when (data) {
|
||||
is Resource.Success -> {
|
||||
|
|
|
@ -113,11 +113,11 @@ class QuickSearchFragment : Fragment() {
|
|||
val searchExitIcon =
|
||||
quick_search?.findViewById<ImageView>(androidx.appcompat.R.id.search_close_btn)
|
||||
|
||||
val searchMagIcon =
|
||||
quick_search?.findViewById<ImageView>(androidx.appcompat.R.id.search_mag_icon)
|
||||
//val searchMagIcon =
|
||||
// quick_search?.findViewById<ImageView>(androidx.appcompat.R.id.search_mag_icon)
|
||||
|
||||
searchMagIcon?.scaleX = 0.65f
|
||||
searchMagIcon?.scaleY = 0.65f
|
||||
//searchMagIcon?.scaleX = 0.65f
|
||||
//searchMagIcon?.scaleY = 0.65f
|
||||
|
||||
quick_search?.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||
override fun onQueryTextSubmit(query: String): Boolean {
|
||||
|
|
|
@ -134,10 +134,10 @@ class SearchFragment : Fragment() {
|
|||
|
||||
val searchExitIcon =
|
||||
main_search.findViewById<ImageView>(androidx.appcompat.R.id.search_close_btn)
|
||||
val searchMagIcon =
|
||||
main_search.findViewById<ImageView>(androidx.appcompat.R.id.search_mag_icon)
|
||||
searchMagIcon.scaleX = 0.65f
|
||||
searchMagIcon.scaleY = 0.65f
|
||||
// val searchMagIcon =
|
||||
// main_search.findViewById<ImageView>(androidx.appcompat.R.id.search_mag_icon)
|
||||
//searchMagIcon.scaleX = 0.65f
|
||||
//searchMagIcon.scaleY = 0.65f
|
||||
|
||||
context?.let { ctx ->
|
||||
val validAPIs = ctx.filterProviderByPreferredMedia()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<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"/>
|
||||
<!--<stroke android:width="0.5dp" android:color="@color/searchColorTransparent" />-->
|
||||
</shape>
|
||||
|
|
|
@ -179,7 +179,6 @@
|
|||
android:layout_height="70dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_marginEnd="50dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
|
||||
|
@ -195,8 +194,8 @@
|
|||
android:layout_marginEnd="20dp"
|
||||
app:cardCornerRadius="100dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="35dp">
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/home_profile_picture"
|
||||
|
@ -205,7 +204,30 @@
|
|||
tools:ignore="ContentDescription" />
|
||||
</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
|
||||
android:visibility="gone"
|
||||
android:gravity="center"
|
||||
|
||||
android:orientation="vertical"
|
||||
|
@ -235,7 +257,7 @@
|
|||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<!--
|
||||
<ImageView
|
||||
android:nextFocusDown="@id/home_main_poster_recyclerview"
|
||||
android:nextFocusUp="@id/nav_rail_view"
|
||||
|
@ -252,7 +274,7 @@
|
|||
android:contentDescription="@string/home_change_provider_img_des">
|
||||
|
||||
<requestFocus />
|
||||
</ImageView>
|
||||
</ImageView>-->
|
||||
</FrameLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
@ -512,6 +534,7 @@
|
|||
style="@style/ExtendedFloatingActionButton"
|
||||
android:textColor="?attr/textColor"
|
||||
tools:ignore="ContentDescription" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
android:layout_margin="10dp"
|
||||
android:background="@drawable/search_background"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="45dp">
|
||||
android:layout_height="40dp">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_gravity="center_vertical"
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
android:background="@drawable/search_background"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="45dp">
|
||||
android:layout_height="40dp">
|
||||
|
||||
<androidx.appcompat.widget.SearchView
|
||||
android:nextFocusRight="@id/search_filter"
|
||||
|
|
|
@ -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="prerelease_update_key" translatable="false">prerelease_update</string>
|
||||
<string name="manual_check_update_key" translatable="false">manual_check_update</string>
|
||||
|
|
Loading…
Reference in a new issue