Add homepage search on TV (#618)

* Add search button on homepage for TV
This commit is contained in:
CranberrySoup 2023-09-21 20:50:31 +00:00 committed by GitHub
parent 527a6388a9
commit d4fff7cee6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 67 additions and 4 deletions

View file

@ -497,6 +497,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener {
R.id.navigation_results_phone,
R.id.navigation_results_tv,
R.id.navigation_player,
R.id.navigation_quick_search,
).contains(destination.id)
binding?.navHostFragment?.apply {

View file

@ -461,6 +461,11 @@ class HomeParentItemAdapterPreview(
}
}
homePreviewSearchButton.setOnClickListener { _ ->
// Open blank screen.
viewModel.queryTextSubmit("")
}
// This makes the hidden next buttons only available when on the info button
// Otherwise you might be able to go to the next item without being at the info button
homePreviewInfoBtt.setOnFocusChangeListener { _, hasFocus ->

View file

@ -33,6 +33,7 @@ import com.lagradost.cloudstream3.ui.search.SearchAdapter
import com.lagradost.cloudstream3.ui.search.SearchClickCallback
import com.lagradost.cloudstream3.ui.search.SearchHelper
import com.lagradost.cloudstream3.ui.search.SearchViewModel
import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.isTrueTvSettings
import com.lagradost.cloudstream3.utils.AppUtils.ownShow
import com.lagradost.cloudstream3.utils.UIHelper
import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar
@ -269,6 +270,10 @@ class QuickSearchFragment : Fragment() {
activity?.popCurrentPage()
}
if (isTrueTvSettings()) {
binding?.quickSearch?.requestFocus()
}
arguments?.getString(AUTOSEARCH_KEY)?.let {
binding?.quickSearch?.setQuery(it, true)
arguments?.remove(AUTOSEARCH_KEY)

View file

@ -114,6 +114,22 @@
android:nextFocusRight="@id/home_switch_account"
/>
<ImageView
android:id="@+id/home_preview_search_button"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="@drawable/player_button_tv_attr_no_bg"
android:contentDescription="@string/search"
android:nextFocusLeft="@id/home_change_api"
android:nextFocusRight="@id/home_preview_switch_account"
android:nextFocusDown="@id/home_preview_info_btt"
android:padding="10dp"
android:visibility="gone"
android:src="@drawable/search_icon"
android:tag="@string/tv_no_focus_tag"
app:tint="@color/player_on_button_tv_attr" />
<ImageView
android:id="@+id/home_switch_account"

View file

@ -45,9 +45,24 @@
android:background="@drawable/player_button_tv_attr_no_bg"
android:gravity="center_vertical"
android:nextFocusLeft="@id/nav_rail_view"
android:nextFocusRight="@id/home_preview_switch_account"
android:nextFocusRight="@id/home_preview_search_button"
android:nextFocusDown="@id/home_preview_play_btt" />
<ImageView
android:id="@+id/home_preview_search_button"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="@drawable/player_button_tv_attr_no_bg"
android:contentDescription="@string/search"
android:nextFocusLeft="@id/home_preview_change_api"
android:nextFocusRight="@id/home_preview_switch_account"
android:nextFocusDown="@id/home_preview_info_btt"
android:padding="10dp"
android:src="@drawable/search_icon"
android:tag="@string/tv_no_focus_tag"
app:tint="@color/player_on_button_tv_attr" />
<ImageView
android:id="@+id/home_preview_switch_account"
android:layout_width="wrap_content"
@ -55,7 +70,8 @@
android:layout_gravity="end"
android:background="@drawable/player_button_tv_attr_no_bg"
android:contentDescription="@string/account"
android:nextFocusLeft="@id/home_preview_change_api"
android:nextFocusLeft="@id/home_preview_search_button"
android:nextFocusRight="@id/home_preview_switch_account"
android:nextFocusDown="@id/home_preview_info_btt"
android:padding="10dp"

View file

@ -113,7 +113,25 @@
android:background="@drawable/player_button_tv_attr_no_bg"
android:gravity="center_vertical"
android:nextFocusLeft="@id/nav_rail_view"
android:nextFocusRight="@id/home_switch_account" />
android:nextFocusRight="@id/home_preview_search_button"
android:nextFocusDown="@id/home_preview_play_btt" />
<ImageView
android:id="@+id/home_preview_search_button"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="@drawable/player_button_tv_attr_no_bg"
android:clickable="true"
android:contentDescription="@string/search"
android:focusable="true"
android:nextFocusLeft="@id/home_change_api"
android:nextFocusRight="@id/home_switch_account"
android:nextFocusDown="@id/home_preview_info_btt"
android:padding="10dp"
android:src="@drawable/search_icon"
android:tag="@string/tv_no_focus_tag"
app:tint="@color/player_on_button_tv_attr" />
<ImageView
android:id="@+id/home_switch_account"
@ -122,7 +140,9 @@
android:layout_gravity="end"
android:background="@drawable/player_button_tv_attr_no_bg"
android:contentDescription="@string/account"
android:nextFocusLeft="@id/home_change_api"
android:nextFocusLeft="@id/home_preview_search_button"
android:nextFocusRight="@id/home_switch_account"
android:nextFocusDown="@id/home_change_api"
android:padding="10dp"
android:src="@drawable/ic_outline_account_circle_24"