[Android] Video player: cache 'isTv' value
Geoffrey Métais
git at videolan.org
Wed Sep 12 12:25:31 CEST 2018
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Sep 12 11:46:56 2018 +0200| [b7e3867a2b7a42b9e50c9e2e694a9bb668d06371] | committer: Geoffrey Métais
Video player: cache 'isTv' value
> https://code.videolan.org/videolan/vlc-android/commit/b7e3867a2b7a42b9e50c9e2e694a9bb668d06371
---
.../org/videolan/vlc/gui/video/VideoPlayerActivity.java | 17 +++++++++--------
.../org/videolan/vlc/gui/video/VideoTouchDelegate.kt | 8 ++++----
2 files changed, 13 insertions(+), 12 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 1e3426377..cbe834416 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -113,7 +113,6 @@ import org.videolan.vlc.gui.MainActivity;
import org.videolan.vlc.gui.PlaybackServiceActivity;
import org.videolan.vlc.gui.audio.PlaylistAdapter;
import org.videolan.vlc.gui.browser.FilePickerActivity;
-import org.videolan.vlc.gui.browser.FilePickerFragment;
import org.videolan.vlc.gui.browser.FilePickerFragmentKt;
import org.videolan.vlc.gui.dialogs.AdvOptionsDialog;
import org.videolan.vlc.gui.dialogs.RenderersDialog;
@@ -268,6 +267,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
private float mFov;
private VideoTouchDelegate mTouchDelegate;
+ private boolean mIsTv;
// Tracks & Subtitles
private MediaPlayer.TrackDescription[] mAudioTracksList;
@@ -371,16 +371,17 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
// 100 is the value for screen_orientation_start_lock
setRequestedOrientation(getScreenOrientation(mScreenOrientation));
// Extra initialization when no secondary display is detected
+ mIsTv = VLCApplication.showTvUi();
if (mDisplayManager.isPrimary()) {
// Orientation
// Tips
- if (!BuildConfig.DEBUG && !VLCApplication.showTvUi() && !mSettings.getBoolean(PREF_TIPS_SHOWN, false)) {
+ if (!BuildConfig.DEBUG && !mIsTv && !mSettings.getBoolean(PREF_TIPS_SHOWN, false)) {
((ViewStubCompat) findViewById(R.id.player_overlay_tips)).inflate();
mOverlayTips = findViewById(R.id.overlay_tips_layout);
}
//Set margins for TV overscan
- if (VLCApplication.showTvUi()) {
+ if (mIsTv) {
int hm = getResources().getDimensionPixelSize(R.dimen.tv_overscan_horizontal);
int vm = getResources().getDimensionPixelSize(R.dimen.tv_overscan_vertical);
@@ -403,7 +404,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
}
mMedialibrary = VLCApplication.getMLInstance();
final int touch;
- if (!VLCApplication.showTvUi()) {
+ if (!mIsTv) {
touch = (mSettings.getBoolean("enable_volume_gesture", true) ? VideoTouchDelegateKt.TOUCH_FLAG_AUDIO_VOLUME : 0)
+ (mSettings.getBoolean("enable_brightness_gesture", true) ? VideoTouchDelegateKt.TOUCH_FLAG_BRIGHTNESS : 0)
+ (mSettings.getBoolean("enable_double_tap_seek", true) ? VideoTouchDelegateKt.TOUCH_FLAG_SEEK : 0);
@@ -416,7 +417,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
int yRange = Math.min(dm.widthPixels, dm.heightPixels);
int xRange = Math.max(dm.widthPixels, dm.heightPixels);
final ScreenConfig sc = new ScreenConfig(dm, xRange, yRange, mCurrentScreenOrientation);
- mTouchDelegate = new VideoTouchDelegate(this, touch, sc, isRtl);
+ mTouchDelegate = new VideoTouchDelegate(this, touch, sc, isRtl, mIsTv);
}
UiTools.setRotationAnimation(this);
}
@@ -926,7 +927,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
togglePlaylist();
} else if (isPlaybackSettingActive()){
endPlaybackSetting();
- } else if (VLCApplication.showTvUi() && mShowing && !mIsLocked) {
+ } else if (mIsTv && mShowing && !mIsLocked) {
hideOverlay(true);
} else {
exitOK();
@@ -1648,7 +1649,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mSwitchingView = true;
// Show the MainActivity if it is not in background.
if (showUI) {
- Intent i = new Intent(this, VLCApplication.showTvUi() ? AudioPlayerActivity.class : MainActivity.class);
+ Intent i = new Intent(this, mIsTv ? AudioPlayerActivity.class : MainActivity.class);
startActivity(i);
} else
mSettings.edit().putBoolean(PreferencesActivity.VIDEO_RESTORE, true).apply();
@@ -2463,7 +2464,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
mHudBinding.progressOverlay.setLayoutParams(layoutParams);
mOverlayBackground = findViewById(R.id.player_overlay_background);
mNavMenu = findViewById(R.id.player_overlay_navmenu);
- if (!AndroidDevices.isChromeBook && !VLCApplication.showTvUi()) {
+ if (!AndroidDevices.isChromeBook && !mIsTv) {
mRendererBtn = findViewById(R.id.video_renderer);
RendererDelegate.INSTANCE.getSelectedRenderer().observe(this, new Observer<RendererItem>() {
@Override
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt b/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
index 54e940b87..e38d8781f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoTouchDelegate.kt
@@ -8,7 +8,6 @@ import android.util.DisplayMetrics
import android.view.*
import org.videolan.medialibrary.Tools
import org.videolan.vlc.R
-import org.videolan.vlc.VLCApplication
import org.videolan.vlc.util.AndroidDevices
const val TOUCH_FLAG_AUDIO_VOLUME = 1
@@ -29,7 +28,8 @@ private const val JOYSTICK_INPUT_DELAY = 300
class VideoTouchDelegate(private val player: VideoPlayerActivity,
private val mTouchControls : Int,
var screenConfig : ScreenConfig,
- private val rtl: Boolean) {
+ private val rtl: Boolean,
+ private val tv : Boolean) {
private var mTouchAction = TOUCH_NONE
private var mInitTouchY = 0f
@@ -151,12 +151,12 @@ class VideoTouchDelegate(private val player: VideoPlayerActivity,
if (System.currentTimeMillis() - mLastMove > JOYSTICK_INPUT_DELAY) {
if (Math.abs(x) > 0.3) {
- if (VLCApplication.showTvUi()) {
+ if (tv) {
player.navigateDvdMenu(if (x > 0.0f) KeyEvent.KEYCODE_DPAD_RIGHT else KeyEvent.KEYCODE_DPAD_LEFT)
} else
player.seekDelta(if (x > 0.0f) 10000 else -10000)
} else if (Math.abs(y) > 0.3) {
- if (VLCApplication.showTvUi())
+ if (tv)
player.navigateDvdMenu(if (x > 0.0f) KeyEvent.KEYCODE_DPAD_UP else KeyEvent.KEYCODE_DPAD_DOWN)
else {
if (mIsFirstBrightnessGesture)
More information about the Android
mailing list