Commit 2b020e31 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy Committed by Geoffrey Métais

Force custom video popup

parent 38025c89
......@@ -696,4 +696,7 @@
<string name="add_to_new_playlist">Add to new playlist</string>
<string name="theme_follow_system_mode">Follow system mode</string>
<string name="resume_card_message">Resume playback of %1$s?</string>
<string name="misc">Miscellaneous</string>
<string name="popup_force_legacy_title">Use custom Picture-in-Picture popup</string>
<string name="popup_force_legacy_summary">Use custom Picture-in-Picture resizable popup</string>
</resources>
......@@ -44,6 +44,12 @@
android:summary="@string/video_transition_summary"
android:title="@string/video_transition_title" />
<CheckBoxPreference
android:defaultValue="false"
android:key="popup_force_legacy"
android:summary="@string/popup_force_legacy_summary"
android:title="@string/popup_force_legacy_title" />
<PreferenceCategory android:title="@string/controls_prefs_category">
<CheckBoxPreference
android:defaultValue="false"
......
......@@ -145,6 +145,13 @@ public class NotificationHelper {
channel.setDescription(description);
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
notificationManager.createNotificationChannel(channel);
// Misc channel
name = appCtx.getString(R.string.misc);
channel = new NotificationChannel("misc", name, NotificationManager.IMPORTANCE_LOW);
channel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC);
notificationManager.createNotificationChannel(channel);
// Recommendations channel
if (AndroidDevices.isAndroidTv) {
name = appCtx.getString(R.string.recommendations);
......
......@@ -23,11 +23,12 @@
package org.videolan.vlc.gui.preferences;
import android.os.Bundle;
import androidx.preference.Preference;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.R;
import androidx.preference.Preference;
public class PreferencesVideo extends BasePreferenceFragment {
@Override
......@@ -44,6 +45,7 @@ public class PreferencesVideo extends BasePreferenceFragment {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
findPreference("popup_keepscreen").setVisible(!AndroidUtil.isOOrLater);
findPreference("popup_force_legacy").setVisible(AndroidUtil.isOOrLater);
}
@Override
......
......@@ -54,6 +54,7 @@ public class PreferencesVideo extends BasePreferenceFragment {
findPreference("enable_volume_gesture").setVisible(AndroidDevices.hasTsp);
findPreference("enable_brightness_gesture").setVisible(AndroidDevices.hasTsp);
findPreference("popup_keepscreen").setVisible(false);
findPreference("popup_force_legacy").setVisible(false);
findPreference("force_play_all").setVisible(false);
}
......
......@@ -281,7 +281,7 @@ public class PopupManager implements PlaybackService.Callback, GestureDetector.O
@SuppressWarnings("deprecation")
private void showNotification() {
final PendingIntent piStop = KextensionsKt.getPendingIntent(mService, new Intent(Constants.ACTION_REMOTE_STOP));
final NotificationCompat.Builder builder = new NotificationCompat.Builder(mService)
final NotificationCompat.Builder builder = new NotificationCompat.Builder(mService, "misc")
.setSmallIcon(R.drawable.ic_notif_video)
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setContentTitle(mService.getTitle())
......
......@@ -491,7 +491,9 @@ public class VideoPlayerActivity extends AppCompatActivity implements IPlaybackS
final MediaWrapper mw = mService != null ? mService.getCurrentMediaWrapper() : null;
if (mw == null || !AndroidDevices.pipAllowed
|| !getLifecycle().getCurrentState().isAtLeast(Lifecycle.State.STARTED)) return;
if (AndroidDevices.hasPiP) {
boolean forceLegacy = Settings.INSTANCE.getInstance(this).getBoolean("popup_force_legacy", false);
if (AndroidDevices.hasPiP && !forceLegacy) {
if (AndroidUtil.isOOrLater) try {
final SurfaceView videoSurface = (SurfaceView) (mVideoLayout != null ? mVideoLayout.findViewById(R.id.surface_video) : null);
final int height = videoSurface != null && videoSurface.getHeight() != 0 ? videoSurface.getHeight() : mw.getHeight();
......
......@@ -29,7 +29,6 @@ import android.content.Context;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.os.Build;
import androidx.core.view.GestureDetectorCompat;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;
......@@ -39,8 +38,10 @@ import android.view.WindowManager;
import android.widget.RelativeLayout;
import org.videolan.libvlc.IVLCVout;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.vlc.R;
import org.videolan.vlc.VLCApplication;
import androidx.core.view.GestureDetectorCompat;
public class PopupLayout extends RelativeLayout implements ScaleGestureDetector.OnScaleGestureListener, View.OnTouchListener {
private static final String TAG = "VLC/PopupView";
......@@ -100,7 +101,7 @@ public class PopupLayout extends RelativeLayout implements ScaleGestureDetector.
height = height * mScreenWidth / width;
width = mScreenWidth;
}
if (height > mScreenHeight){
if (height > mScreenHeight) {
width = width * mScreenHeight / height;
height = mScreenHeight;
}
......@@ -121,7 +122,7 @@ public class PopupLayout extends RelativeLayout implements ScaleGestureDetector.
final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
mPopupWidth,
mPopupHeight,
WindowManager.LayoutParams.TYPE_PHONE,
AndroidUtil.isOOrLater ? WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY : WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.OPAQUE);
......@@ -131,7 +132,7 @@ public class PopupLayout extends RelativeLayout implements ScaleGestureDetector.
mScaleGestureDetector = new ScaleGestureDetector(context, this);
setOnTouchListener(this);
mWindowManager.addView(this, params);
mLayoutParams = (WindowManager.LayoutParams)getLayoutParams();
mLayoutParams = (WindowManager.LayoutParams) getLayoutParams();
updateWindowSize();
}
......@@ -178,10 +179,11 @@ public class PopupLayout extends RelativeLayout implements ScaleGestureDetector.
mScaleFactor *= detector.getScaleFactor();
mScaleFactor = Math.max(0.1d, Math.min(mScaleFactor, 5.0d));
mPopupWidth = (int) (getWidth()*mScaleFactor);
mPopupHeight = (int) (getHeight()*mScaleFactor);
mPopupWidth = (int) (getWidth() * mScaleFactor);
mPopupHeight = (int) (getHeight() * mScaleFactor);
return true;
}
@Override
public boolean onScaleBegin(ScaleGestureDetector detector) {
return true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment