From c00e694d40e4d5ddf156a0e2f2d9ab8c5b416cf7 Mon Sep 17 00:00:00 2001 From: Mauricio Colli Date: Tue, 16 May 2017 21:45:38 -0300 Subject: [PATCH 1/2] Add option to disable the gesture controls of the player --- .../java/org/schabi/newpipe/player/MainVideoPlayer.java | 4 ++++ app/src/main/res/values/settings_keys.xml | 1 + app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/settings.xml | 7 +++++++ 4 files changed, 14 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java index 7af2c20a1..7e20d4940 100644 --- a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java @@ -449,6 +449,8 @@ public class MainVideoPlayer extends Activity { return true; } + private final boolean isGestureControlsEnabled = playerImpl.getSharedPreferences().getBoolean(getString(R.string.player_gesture_controls_key), true); + private final float stepsBrightness = 15, stepBrightness = (1f / stepsBrightness), minBrightness = .01f; private float currentBrightness = .5f; @@ -466,6 +468,8 @@ public class MainVideoPlayer extends Activity { // TODO: Improve video gesture controls @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { + if (!isGestureControlsEnabled) return false; + //noinspection PointlessBooleanExpression if (DEBUG && false) Log.d(TAG, "MainVideoPlayer.onScroll = " + ", e1.getRaw = [" + e1.getRawX() + ", " + e1.getRawY() + "]" + diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index ac5647aee..2c9362c93 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -13,6 +13,7 @@ use_external_audio_player autoplay_through_intent use_oldplayer + player_gesture_controls default_resolution_preference 360p diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4afab9443..180bb0ef7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -62,6 +62,8 @@ Black Remember popup size and position Remember the last size and position set to the popup + Player gesture controls + Use gestures to control the brightness and volume of the player Download diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml index aa6e2a0db..34a9eed0d 100644 --- a/app/src/main/res/xml/settings.xml +++ b/app/src/main/res/xml/settings.xml @@ -56,6 +56,13 @@ android:title="@string/use_old_player_title" android:summary="@string/use_old_player_summary" android:defaultValue="false"/> + + + Date: Tue, 16 May 2017 22:14:07 -0300 Subject: [PATCH 2/2] Add option to disable the search suggestions --- .../schabi/newpipe/fragments/search/SearchFragment.java | 9 +++++++++ app/src/main/res/values/settings_keys.xml | 1 + app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/settings.xml | 6 ++++++ 4 files changed, 18 insertions(+) diff --git a/app/src/main/java/org/schabi/newpipe/fragments/search/SearchFragment.java b/app/src/main/java/org/schabi/newpipe/fragments/search/SearchFragment.java index 11707c38d..d31addbfb 100644 --- a/app/src/main/java/org/schabi/newpipe/fragments/search/SearchFragment.java +++ b/app/src/main/java/org/schabi/newpipe/fragments/search/SearchFragment.java @@ -5,6 +5,7 @@ import android.content.Context; import android.content.Intent; import android.os.Build; import android.os.Bundle; +import android.preference.PreferenceManager; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.v7.app.ActionBar; @@ -68,6 +69,7 @@ public class SearchFragment extends BaseFragment implements SuggestionWorker.OnS private int serviceId = -1; private String searchQuery = ""; private int pageNumber = 0; + private boolean showSuggestions = true; private SearchWorker curSearchWorker; private SuggestionWorker curSuggestionWorker; @@ -135,6 +137,8 @@ public class SearchFragment extends BaseFragment implements SuggestionWorker.OnS if (pageNumber > 0) search(searchQuery, pageNumber); else search(searchQuery, 0, true); } + + showSuggestions = PreferenceManager.getDefaultSharedPreferences(activity).getBoolean(getString(R.string.show_search_suggestions_key), true); } @Override @@ -523,6 +527,11 @@ public class SearchFragment extends BaseFragment implements SuggestionWorker.OnS } private void searchSuggestions(String query) { + if (!showSuggestions) { + if (DEBUG) Log.d(TAG, "searchSuggestions() showSuggestions is disabled"); + return; + } + if (DEBUG) Log.d(TAG, "searchSuggestions() called with: query = [" + query + "]"); if (curSuggestionWorker != null && curSuggestionWorker.isRunning()) curSuggestionWorker.cancel(); curSuggestionWorker = SuggestionWorker.startForQuery(activity, serviceId, query, this); diff --git a/app/src/main/res/values/settings_keys.xml b/app/src/main/res/values/settings_keys.xml index 2c9362c93..05f08c085 100644 --- a/app/src/main/res/values/settings_keys.xml +++ b/app/src/main/res/values/settings_keys.xml @@ -44,6 +44,7 @@ 3GPP + show_search_suggestions show_play_with_kodi theme diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 180bb0ef7..a1fc44420 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -64,6 +64,8 @@ Remember the last size and position set to the popup Player gesture controls Use gestures to control the brightness and volume of the player + Search suggestions + Show suggestions when searching Download diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml index 34a9eed0d..43435dc1d 100644 --- a/app/src/main/res/xml/settings.xml +++ b/app/src/main/res/xml/settings.xml @@ -155,6 +155,12 @@ android:summary="@string/autoplay_by_calling_app_summary" android:defaultValue="false" /> + +