mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-11 09:50:32 +00:00
Updated search fragment to be amazon fire tv friendly
This commit is contained in:
parent
2c2c61b2fc
commit
ed4b4a1a3c
11
app/src/main/java/org/schabi/newpipe/firetv/FireTvUtils.java
Normal file
11
app/src/main/java/org/schabi/newpipe/firetv/FireTvUtils.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package org.schabi.newpipe.firetv;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import org.schabi.newpipe.App;
|
||||||
|
|
||||||
|
public class FireTvUtils {
|
||||||
|
public static boolean isFireTv(){
|
||||||
|
final String AMAZON_FEATURE_FIRE_TV = "amazon.hardware.fire_tv";
|
||||||
|
return App.getApp().getPackageManager().hasSystemFeature(AMAZON_FEATURE_FIRE_TV);
|
||||||
|
}
|
||||||
|
}
|
@ -39,6 +39,7 @@ import org.schabi.newpipe.extractor.StreamingService;
|
|||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.search.SearchExtractor;
|
import org.schabi.newpipe.extractor.search.SearchExtractor;
|
||||||
import org.schabi.newpipe.extractor.search.SearchInfo;
|
import org.schabi.newpipe.extractor.search.SearchInfo;
|
||||||
|
import org.schabi.newpipe.firetv.FireTvUtils;
|
||||||
import org.schabi.newpipe.fragments.BackPressable;
|
import org.schabi.newpipe.fragments.BackPressable;
|
||||||
import org.schabi.newpipe.fragments.list.BaseListFragment;
|
import org.schabi.newpipe.fragments.list.BaseListFragment;
|
||||||
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
import org.schabi.newpipe.local.history.HistoryRecordManager;
|
||||||
@ -449,6 +450,9 @@ public class SearchFragment
|
|||||||
if (isSuggestionsEnabled && errorPanelRoot.getVisibility() != View.VISIBLE) {
|
if (isSuggestionsEnabled && errorPanelRoot.getVisibility() != View.VISIBLE) {
|
||||||
showSuggestionsPanel();
|
showSuggestionsPanel();
|
||||||
}
|
}
|
||||||
|
if(FireTvUtils.isFireTv()){
|
||||||
|
showKeyboardSearch();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
searchEditText.setOnFocusChangeListener((View v, boolean hasFocus) -> {
|
searchEditText.setOnFocusChangeListener((View v, boolean hasFocus) -> {
|
||||||
@ -499,7 +503,9 @@ public class SearchFragment
|
|||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.d(TAG, "onEditorAction() called with: v = [" + v + "], actionId = [" + actionId + "], event = [" + event + "]");
|
Log.d(TAG, "onEditorAction() called with: v = [" + v + "], actionId = [" + actionId + "], event = [" + event + "]");
|
||||||
}
|
}
|
||||||
if (event != null
|
if(actionId == EditorInfo.IME_ACTION_PREVIOUS){
|
||||||
|
hideKeyboardSearch();
|
||||||
|
} else if (event != null
|
||||||
&& (event.getKeyCode() == KeyEvent.KEYCODE_ENTER
|
&& (event.getKeyCode() == KeyEvent.KEYCODE_ENTER
|
||||||
|| event.getAction() == EditorInfo.IME_ACTION_SEARCH)) {
|
|| event.getAction() == EditorInfo.IME_ACTION_SEARCH)) {
|
||||||
search(searchEditText.getText().toString(), new String[0], "");
|
search(searchEditText.getText().toString(), new String[0], "");
|
||||||
@ -541,7 +547,7 @@ public class SearchFragment
|
|||||||
if (searchEditText.requestFocus()) {
|
if (searchEditText.requestFocus()) {
|
||||||
InputMethodManager imm = (InputMethodManager) activity.getSystemService(
|
InputMethodManager imm = (InputMethodManager) activity.getSystemService(
|
||||||
Context.INPUT_METHOD_SERVICE);
|
Context.INPUT_METHOD_SERVICE);
|
||||||
imm.showSoftInput(searchEditText, InputMethodManager.SHOW_IMPLICIT);
|
imm.showSoftInput(searchEditText, InputMethodManager.SHOW_FORCED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -551,8 +557,7 @@ public class SearchFragment
|
|||||||
|
|
||||||
InputMethodManager imm = (InputMethodManager) activity.getSystemService(
|
InputMethodManager imm = (InputMethodManager) activity.getSystemService(
|
||||||
Context.INPUT_METHOD_SERVICE);
|
Context.INPUT_METHOD_SERVICE);
|
||||||
imm.hideSoftInputFromWindow(searchEditText.getWindowToken(),
|
imm.hideSoftInputFromWindow(searchEditText.getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN);
|
||||||
InputMethodManager.HIDE_NOT_ALWAYS);
|
|
||||||
|
|
||||||
searchEditText.clearFocus();
|
searchEditText.clearFocus();
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,9 @@
|
|||||||
android:layout_width="48dp"
|
android:layout_width="48dp"
|
||||||
android:layout_height="48dp"
|
android:layout_height="48dp"
|
||||||
android:layout_gravity="right|center_vertical"
|
android:layout_gravity="right|center_vertical"
|
||||||
tools:ignore="RtlHardcoded">
|
android:focusable="true"
|
||||||
|
tools:ignore="RtlHardcoded"
|
||||||
|
android:background="?attr/selectableItemBackground">
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="28dp"
|
android:layout_width="28dp"
|
||||||
|
Loading…
Reference in New Issue
Block a user