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 c275e55a7..3beab8188 100644
--- a/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java
+++ b/app/src/main/java/org/schabi/newpipe/player/MainVideoPlayer.java
@@ -23,6 +23,7 @@ import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
+import android.content.res.Configuration;
import android.graphics.Color;
import android.media.AudioManager;
import android.os.Build;
@@ -33,6 +34,7 @@ import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.helper.ItemTouchHelper;
import android.util.Log;
import android.view.GestureDetector;
+import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
@@ -58,6 +60,8 @@ import org.schabi.newpipe.util.NavigationHelper;
import org.schabi.newpipe.util.PermissionHelper;
import org.schabi.newpipe.util.ThemeHelper;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
import java.util.List;
import static org.schabi.newpipe.util.AnimationUtils.animateView;
@@ -150,6 +154,17 @@ public final class MainVideoPlayer extends Activity {
if (playerImpl != null) playerImpl.destroy();
}
+ @Override
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+
+ if (playerImpl.isSomePopupMenuVisible()) {
+ playerImpl.moreOptionsPopupMenu.dismiss();
+ playerImpl.getQualityPopupMenu().dismiss();
+ playerImpl.getPlaybackSpeedPopupMenu().dismiss();
+ }
+ }
+
/*//////////////////////////////////////////////////////////////////////////
// Utils
//////////////////////////////////////////////////////////////////////////*/
@@ -222,7 +237,6 @@ public final class MainVideoPlayer extends Activity {
private ImageButton repeatButton;
private ImageButton shuffleButton;
- private ImageButton screenRotationButton;
private ImageButton playPauseButton;
private ImageButton playPreviousButton;
private ImageButton playNextButton;
@@ -234,6 +248,10 @@ public final class MainVideoPlayer extends Activity {
private boolean queueVisible;
+ private ImageButton moreOptionsButton;
+ public int moreOptionsPopupMenuGroupId = 89;
+ public PopupMenu moreOptionsPopupMenu;
+
VideoPlayerImpl(final Context context) {
super("VideoPlayerImpl" + MainVideoPlayer.TAG, context);
}
@@ -249,10 +267,12 @@ public final class MainVideoPlayer extends Activity {
this.repeatButton = rootView.findViewById(R.id.repeatButton);
this.shuffleButton = rootView.findViewById(R.id.shuffleButton);
- this.screenRotationButton = rootView.findViewById(R.id.screenRotationButton);
this.playPauseButton = rootView.findViewById(R.id.playPauseButton);
this.playPreviousButton = rootView.findViewById(R.id.playPreviousButton);
this.playNextButton = rootView.findViewById(R.id.playNextButton);
+ this.moreOptionsButton = rootView.findViewById(R.id.moreOptionsButton);
+ this.moreOptionsPopupMenu = new PopupMenu(context, moreOptionsButton);
+ this.moreOptionsPopupMenu.getMenuInflater().inflate(R.menu.menu_videooptions, moreOptionsPopupMenu.getMenu());
titleTextView.setSelected(true);
channelTextView.setSelected(true);
@@ -276,7 +296,7 @@ public final class MainVideoPlayer extends Activity {
playPauseButton.setOnClickListener(this);
playPreviousButton.setOnClickListener(this);
playNextButton.setOnClickListener(this);
- screenRotationButton.setOnClickListener(this);
+ moreOptionsButton.setOnClickListener(this);
}
/*//////////////////////////////////////////////////////////////////////////
@@ -348,6 +368,28 @@ public final class MainVideoPlayer extends Activity {
finish();
}
+ public void onPlayBackgroundButtonClicked() {
+ if (DEBUG) Log.d(TAG, "onPlayBackgroundButtonClicked() called");
+ if (playerImpl.getPlayer() == null) return;
+
+ setRecovery();
+ final Intent intent = NavigationHelper.getPlayerIntent(
+ context,
+ BackgroundPlayer.class,
+ this.getPlayQueue(),
+ this.getRepeatMode(),
+ this.getPlaybackSpeed(),
+ this.getPlaybackPitch(),
+ this.getPlaybackQuality()
+ );
+ context.startService(intent);
+
+ ((View) getControlAnimationView().getParent()).setVisibility(View.GONE);
+ destroy();
+ finish();
+ }
+
+
@Override
public void onClick(View v) {
super.onClick(v);
@@ -360,9 +402,6 @@ public final class MainVideoPlayer extends Activity {
} else if (v.getId() == playNextButton.getId()) {
onPlayNext();
- } else if (v.getId() == screenRotationButton.getId()) {
- onScreenRotationClicked();
-
} else if (v.getId() == queueButton.getId()) {
onQueueClicked();
return;
@@ -372,6 +411,8 @@ public final class MainVideoPlayer extends Activity {
} else if (v.getId() == shuffleButton.getId()) {
onShuffleClicked();
return;
+ } else if (v.getId() == moreOptionsButton.getId()) {
+ onMoreOptionsClicked();
}
if (getCurrentState() != STATE_COMPLETED) {
@@ -405,6 +446,32 @@ public final class MainVideoPlayer extends Activity {
queueVisible = false;
}
+ private void onMoreOptionsClicked() {
+ if (DEBUG) Log.d(TAG, "onMoreOptionsClicked() called");
+ buildMoreOptionsMenu();
+
+ try {
+ Field[] fields = moreOptionsPopupMenu.getClass().getDeclaredFields();
+ for (Field field : fields) {
+ if ("mPopup".equals(field.getName())) {
+ field.setAccessible(true);
+ Object menuPopupHelper = field.get(moreOptionsPopupMenu);
+ Class> classPopupHelper = Class.forName(menuPopupHelper
+ .getClass().getName());
+ Method setForceIcons = classPopupHelper.getMethod(
+ "setForceShowIcon", boolean.class);
+ setForceIcons.invoke(menuPopupHelper, true);
+ break;
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ moreOptionsPopupMenu.show();
+ isSomePopupMenuVisible = true;
+ showControls(300);
+ }
+
private void onScreenRotationClicked() {
if (DEBUG) Log.d(TAG, "onScreenRotationClicked() called");
toggleOrientation();
@@ -555,6 +622,27 @@ public final class MainVideoPlayer extends Activity {
setShuffleButton(shuffleButton, playQueue.isShuffled());
}
+ private void buildMoreOptionsMenu() {
+ if (moreOptionsPopupMenu == null) return;
+ moreOptionsPopupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
+ @Override
+ public boolean onMenuItemClick(MenuItem menuItem) {
+ switch (menuItem.getItemId()) {
+ case R.id.toggleOrientation:
+ onScreenRotationClicked();
+ break;
+ case R.id.switchPopup:
+ onFullScreenButtonClicked();
+ break;
+ case R.id.switchBackground:
+ onPlayBackgroundButtonClicked();
+ break;
+ }
+ return false;
+ }
+ });
+ }
+
private void buildQueue() {
queueLayout = findViewById(R.id.playQueuePanel);
@@ -785,4 +873,4 @@ public final class MainVideoPlayer extends Activity {
}
}
-}
\ No newline at end of file
+}
diff --git a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java
index 1a386d45d..ef72bfd90 100644
--- a/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java
+++ b/app/src/main/java/org/schabi/newpipe/player/VideoPlayer.java
@@ -124,12 +124,11 @@ public abstract class VideoPlayer extends BasePlayer implements SimpleExoPlayer.
private View topControlsRoot;
private TextView qualityTextView;
- private ImageButton fullScreenButton;
private ValueAnimator controlViewAnimator;
private Handler controlsVisibilityHandler = new Handler();
- private boolean isSomePopupMenuVisible = false;
+ boolean isSomePopupMenuVisible = false;
private int qualityPopupMenuGroupId = 69;
private PopupMenu qualityPopupMenu;
@@ -166,7 +165,6 @@ public abstract class VideoPlayer extends BasePlayer implements SimpleExoPlayer.
this.bottomControlsRoot = rootView.findViewById(R.id.bottomControls);
this.topControlsRoot = rootView.findViewById(R.id.topControls);
this.qualityTextView = rootView.findViewById(R.id.qualityTextView);
- this.fullScreenButton = rootView.findViewById(R.id.fullScreenButton);
//this.aspectRatioFrameLayout.setAspectRatio(16.0f / 9.0f);
@@ -186,7 +184,6 @@ public abstract class VideoPlayer extends BasePlayer implements SimpleExoPlayer.
super.initListeners();
playbackSeekBar.setOnSeekBarChangeListener(this);
playbackSpeedTextView.setOnClickListener(this);
- fullScreenButton.setOnClickListener(this);
qualityTextView.setOnClickListener(this);
}
@@ -453,9 +450,7 @@ public abstract class VideoPlayer extends BasePlayer implements SimpleExoPlayer.
@Override
public void onClick(View v) {
if (DEBUG) Log.d(TAG, "onClick() called with: v = [" + v + "]");
- if (v.getId() == fullScreenButton.getId()) {
- onFullScreenButtonClicked();
- } else if (v.getId() == qualityTextView.getId()) {
+ if (v.getId() == qualityTextView.getId()) {
onQualitySelectorClicked();
} else if (v.getId() == playbackSpeedTextView.getId()) {
onPlaybackSpeedClicked();
@@ -753,14 +748,14 @@ public abstract class VideoPlayer extends BasePlayer implements SimpleExoPlayer.
return qualityTextView;
}
- public ImageButton getFullScreenButton() {
- return fullScreenButton;
- }
-
public PopupMenu getQualityPopupMenu() {
return qualityPopupMenu;
}
+ public PopupMenu getPlaybackSpeedPopupMenu() {
+ return playbackSpeedPopupMenu;
+ }
+
public View getSurfaceForeground() {
return surfaceForeground;
}
diff --git a/app/src/main/res/drawable-hdpi/ic_more_vert_black_24dp.png b/app/src/main/res/drawable-hdpi/ic_more_vert_black_24dp.png
new file mode 100644
index 000000000..22acc5500
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_more_vert_black_24dp.png differ
diff --git a/app/src/main/res/drawable-hdpi/ic_more_vert_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_more_vert_white_24dp.png
new file mode 100644
index 000000000..67f07e473
Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_more_vert_white_24dp.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_more_vert_black_24dp.png b/app/src/main/res/drawable-mdpi/ic_more_vert_black_24dp.png
new file mode 100644
index 000000000..0e4f2f6ea
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_more_vert_black_24dp.png differ
diff --git a/app/src/main/res/drawable-mdpi/ic_more_vert_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_more_vert_white_24dp.png
new file mode 100644
index 000000000..017e45ede
Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_more_vert_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_more_vert_black_24dp.png b/app/src/main/res/drawable-xhdpi/ic_more_vert_black_24dp.png
new file mode 100644
index 000000000..9f10aa275
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_more_vert_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xhdpi/ic_more_vert_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_more_vert_white_24dp.png
new file mode 100644
index 000000000..efab8a74f
Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_more_vert_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_more_vert_black_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_more_vert_black_24dp.png
new file mode 100644
index 000000000..94d5ab98c
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_more_vert_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/ic_more_vert_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_more_vert_white_24dp.png
new file mode 100644
index 000000000..d32281307
Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_more_vert_white_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_more_vert_black_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_more_vert_black_24dp.png
new file mode 100644
index 000000000..4642a3b66
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_more_vert_black_24dp.png differ
diff --git a/app/src/main/res/drawable-xxxhdpi/ic_more_vert_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_more_vert_white_24dp.png
new file mode 100644
index 000000000..2f2cb3d00
Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_more_vert_white_24dp.png differ
diff --git a/app/src/main/res/layout/activity_main_player.xml b/app/src/main/res/layout/activity_main_player.xml
index 5c6349c35..6086dd5cb 100644
--- a/app/src/main/res/layout/activity_main_player.xml
+++ b/app/src/main/res/layout/activity_main_player.xml
@@ -209,7 +209,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
- android:layout_toLeftOf="@+id/screenRotationButton"
+ android:layout_toLeftOf="@+id/queueButton"
android:gravity="center"
android:minHeight="35dp"
android:minWidth="40dp"
@@ -218,28 +218,13 @@
tools:ignore="RtlHardcoded,RtlSymmetry"
tools:text="1x" />
-