Merge pull request #1644 from ritiek/separate-gesture-options
Separate options for volume and brightness gestures
This commit is contained in:
commit
2d17cfaf2b
|
@ -1006,12 +1006,14 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||||
|
|
||||||
private static final int MOVEMENT_THRESHOLD = 40;
|
private static final int MOVEMENT_THRESHOLD = 40;
|
||||||
|
|
||||||
private final boolean isPlayerGestureEnabled = PlayerHelper.isPlayerGestureEnabled(getApplicationContext());
|
private final boolean isVolumeGestureEnabled = PlayerHelper.isVolumeGestureEnabled(getApplicationContext());
|
||||||
|
private final boolean isBrightnessGestureEnabled = PlayerHelper.isBrightnessGestureEnabled(getApplicationContext());
|
||||||
|
|
||||||
private final int maxVolume = playerImpl.getAudioReactor().getMaxVolume();
|
private final int maxVolume = playerImpl.getAudioReactor().getMaxVolume();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onScroll(MotionEvent initialEvent, MotionEvent movingEvent, float distanceX, float distanceY) {
|
public boolean onScroll(MotionEvent initialEvent, MotionEvent movingEvent, float distanceX, float distanceY) {
|
||||||
if (!isPlayerGestureEnabled) return false;
|
if (!isVolumeGestureEnabled && !isBrightnessGestureEnabled) return false;
|
||||||
|
|
||||||
//noinspection PointlessBooleanExpression
|
//noinspection PointlessBooleanExpression
|
||||||
if (DEBUG && false) Log.d(TAG, "MainVideoPlayer.onScroll = " +
|
if (DEBUG && false) Log.d(TAG, "MainVideoPlayer.onScroll = " +
|
||||||
|
@ -1027,7 +1029,11 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||||
|
|
||||||
isMoving = true;
|
isMoving = true;
|
||||||
|
|
||||||
if (initialEvent.getX() > playerImpl.getRootView().getWidth() / 2) {
|
boolean acceptAnyArea = isVolumeGestureEnabled != isBrightnessGestureEnabled;
|
||||||
|
boolean acceptVolumeArea = acceptAnyArea || initialEvent.getX() > playerImpl.getRootView().getWidth() / 2;
|
||||||
|
boolean acceptBrightnessArea = acceptAnyArea || !acceptVolumeArea;
|
||||||
|
|
||||||
|
if (isVolumeGestureEnabled && acceptVolumeArea) {
|
||||||
playerImpl.getVolumeProgressBar().incrementProgressBy((int) distanceY);
|
playerImpl.getVolumeProgressBar().incrementProgressBy((int) distanceY);
|
||||||
float currentProgressPercent =
|
float currentProgressPercent =
|
||||||
(float) playerImpl.getVolumeProgressBar().getProgress() / playerImpl.getMaxGestureLength();
|
(float) playerImpl.getVolumeProgressBar().getProgress() / playerImpl.getMaxGestureLength();
|
||||||
|
@ -1052,7 +1058,7 @@ public final class MainVideoPlayer extends AppCompatActivity
|
||||||
if (playerImpl.getBrightnessRelativeLayout().getVisibility() == View.VISIBLE) {
|
if (playerImpl.getBrightnessRelativeLayout().getVisibility() == View.VISIBLE) {
|
||||||
playerImpl.getBrightnessRelativeLayout().setVisibility(View.GONE);
|
playerImpl.getBrightnessRelativeLayout().setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (isBrightnessGestureEnabled && acceptBrightnessArea) {
|
||||||
playerImpl.getBrightnessProgressBar().incrementProgressBy((int) distanceY);
|
playerImpl.getBrightnessProgressBar().incrementProgressBy((int) distanceY);
|
||||||
float currentProgressPercent =
|
float currentProgressPercent =
|
||||||
(float) playerImpl.getBrightnessProgressBar().getProgress() / playerImpl.getMaxGestureLength();
|
(float) playerImpl.getBrightnessProgressBar().getProgress() / playerImpl.getMaxGestureLength();
|
||||||
|
|
|
@ -169,8 +169,12 @@ public class PlayerHelper {
|
||||||
return isResumeAfterAudioFocusGain(context, false);
|
return isResumeAfterAudioFocusGain(context, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPlayerGestureEnabled(@NonNull final Context context) {
|
public static boolean isVolumeGestureEnabled(@NonNull final Context context) {
|
||||||
return isPlayerGestureEnabled(context, true);
|
return isVolumeGestureEnabled(context, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isBrightnessGestureEnabled(@NonNull final Context context) {
|
||||||
|
return isBrightnessGestureEnabled(context, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isUsingOldPlayer(@NonNull final Context context) {
|
public static boolean isUsingOldPlayer(@NonNull final Context context) {
|
||||||
|
@ -306,8 +310,12 @@ public class PlayerHelper {
|
||||||
return getPreferences(context).getBoolean(context.getString(R.string.resume_on_audio_focus_gain_key), b);
|
return getPreferences(context).getBoolean(context.getString(R.string.resume_on_audio_focus_gain_key), b);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isPlayerGestureEnabled(@NonNull final Context context, final boolean b) {
|
private static boolean isVolumeGestureEnabled(@NonNull final Context context, final boolean b) {
|
||||||
return getPreferences(context).getBoolean(context.getString(R.string.player_gesture_controls_key), b);
|
return getPreferences(context).getBoolean(context.getString(R.string.volume_gesture_control_key), b);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isBrightnessGestureEnabled(@NonNull final Context context, final boolean b) {
|
||||||
|
return getPreferences(context).getBoolean(context.getString(R.string.brightness_gesture_control_key), b);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isUsingOldPlayer(@NonNull final Context context, final boolean b) {
|
private static boolean isUsingOldPlayer(@NonNull final Context context, final boolean b) {
|
||||||
|
|
|
@ -19,7 +19,8 @@
|
||||||
<string name="autoplay_through_intent_key" translatable="false">autoplay_through_intent</string>
|
<string name="autoplay_through_intent_key" translatable="false">autoplay_through_intent</string>
|
||||||
<string name="use_old_player_key" translatable="false">use_oldplayer</string>
|
<string name="use_old_player_key" translatable="false">use_oldplayer</string>
|
||||||
|
|
||||||
<string name="player_gesture_controls_key" translatable="false">player_gesture_controls</string>
|
<string name="volume_gesture_control_key" translatable="false">volume_gesture_control</string>
|
||||||
|
<string name="brightness_gesture_control_key" translatable="false">brightness_gesture_control</string>
|
||||||
<string name="resume_on_audio_focus_gain_key" translatable="false">resume_on_audio_focus_gain</string>
|
<string name="resume_on_audio_focus_gain_key" translatable="false">resume_on_audio_focus_gain</string>
|
||||||
<string name="popup_remember_size_pos_key" translatable="false">popup_remember_size_pos_key</string>
|
<string name="popup_remember_size_pos_key" translatable="false">popup_remember_size_pos_key</string>
|
||||||
<string name="use_inexact_seek_key" translatable="false">use_inexact_seek_key</string>
|
<string name="use_inexact_seek_key" translatable="false">use_inexact_seek_key</string>
|
||||||
|
@ -894,4 +895,4 @@
|
||||||
<item>@string/grid</item>
|
<item>@string/grid</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -83,8 +83,10 @@
|
||||||
<string name="metadata_cache_wipe_complete_notice">Metadata cache wiped</string>
|
<string name="metadata_cache_wipe_complete_notice">Metadata cache wiped</string>
|
||||||
<string name="auto_queue_title">Auto-queue next stream</string>
|
<string name="auto_queue_title">Auto-queue next stream</string>
|
||||||
<string name="auto_queue_summary">Auto-append a related stream when playing the last stream in a non-repeating queue.</string>
|
<string name="auto_queue_summary">Auto-append a related stream when playing the last stream in a non-repeating queue.</string>
|
||||||
<string name="player_gesture_controls_title">Player gesture controls</string>
|
<string name="volume_gesture_control_title">Volume gesture control</string>
|
||||||
<string name="player_gesture_controls_summary">Use gestures to control the brightness and volume of the player</string>
|
<string name="volume_gesture_control_summary">Use gestures to control the volume of the player</string>
|
||||||
|
<string name="brightness_gesture_control_title">Brightness gesture control</string>
|
||||||
|
<string name="brightness_gesture_control_summary">Use gestures to control the brightness of the player</string>
|
||||||
<string name="show_search_suggestions_title">Search suggestions</string>
|
<string name="show_search_suggestions_title">Search suggestions</string>
|
||||||
<string name="show_search_suggestions_summary">Show suggestions when searching</string>
|
<string name="show_search_suggestions_summary">Show suggestions when searching</string>
|
||||||
<string name="enable_search_history_title">Search history</string>
|
<string name="enable_search_history_title">Search history</string>
|
||||||
|
|
|
@ -106,9 +106,15 @@
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
android:key="@string/player_gesture_controls_key"
|
android:key="@string/volume_gesture_control_key"
|
||||||
android:summary="@string/player_gesture_controls_summary"
|
android:summary="@string/volume_gesture_control_summary"
|
||||||
android:title="@string/player_gesture_controls_title"/>
|
android:title="@string/volume_gesture_control_title"/>
|
||||||
|
|
||||||
|
<SwitchPreference
|
||||||
|
android:defaultValue="true"
|
||||||
|
android:key="@string/brightness_gesture_control_key"
|
||||||
|
android:summary="@string/brightness_gesture_control_summary"
|
||||||
|
android:title="@string/brightness_gesture_control_title"/>
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:defaultValue="true"
|
android:defaultValue="true"
|
||||||
|
|
Loading…
Reference in New Issue