Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add homepage search on TV #618

Merged
merged 5 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
20 changes: 18 additions & 2 deletions app/src/main/res/layout/fragment_home_head_tv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,33 @@
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"
android:layout_height="match_parent"
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"
Expand Down
24 changes: 22 additions & 2 deletions app/src/main/res/layout/fragment_home_tv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
Loading