mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-15 13:21:22 +01:00
-Replace main player dropdown menu with expand/collapse custom UI.
This commit is contained in:
parent
5773152ed3
commit
6485327b97
@ -61,7 +61,6 @@ import org.schabi.newpipe.util.AnimationUtils;
|
||||
import org.schabi.newpipe.util.ListHelper;
|
||||
import org.schabi.newpipe.util.NavigationHelper;
|
||||
import org.schabi.newpipe.util.PermissionHelper;
|
||||
import org.schabi.newpipe.util.PopupMenuIconHacker;
|
||||
import org.schabi.newpipe.util.ThemeHelper;
|
||||
|
||||
import java.util.List;
|
||||
@ -194,7 +193,6 @@ public final class MainVideoPlayer extends Activity {
|
||||
super.onConfigurationChanged(newConfig);
|
||||
|
||||
if (playerImpl.isSomePopupMenuVisible()) {
|
||||
playerImpl.moreOptionsPopupMenu.dismiss();
|
||||
playerImpl.getQualityPopupMenu().dismiss();
|
||||
playerImpl.getPlaybackSpeedPopupMenu().dismiss();
|
||||
}
|
||||
@ -301,8 +299,11 @@ public final class MainVideoPlayer extends Activity {
|
||||
private boolean queueVisible;
|
||||
|
||||
private ImageButton moreOptionsButton;
|
||||
public int moreOptionsPopupMenuGroupId = 89;
|
||||
public PopupMenu moreOptionsPopupMenu;
|
||||
private ImageButton toggleOrientationButton;
|
||||
private ImageButton switchPopupButton;
|
||||
private ImageButton switchBackgroundButton;
|
||||
|
||||
private View secondaryControls;
|
||||
|
||||
VideoPlayerImpl(final Context context) {
|
||||
super("VideoPlayerImpl" + MainVideoPlayer.TAG, context);
|
||||
@ -322,9 +323,12 @@ public final class MainVideoPlayer extends Activity {
|
||||
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);
|
||||
buildMoreOptionsMenu();
|
||||
this.secondaryControls = rootView.findViewById(R.id.secondaryControls);
|
||||
this.toggleOrientationButton = rootView.findViewById(R.id.toggleOrientation);
|
||||
this.switchBackgroundButton = rootView.findViewById(R.id.switchBackground);
|
||||
this.switchPopupButton = rootView.findViewById(R.id.switchPopup);
|
||||
|
||||
titleTextView.setSelected(true);
|
||||
channelTextView.setSelected(true);
|
||||
@ -348,7 +352,11 @@ public final class MainVideoPlayer extends Activity {
|
||||
playPauseButton.setOnClickListener(this);
|
||||
playPreviousButton.setOnClickListener(this);
|
||||
playNextButton.setOnClickListener(this);
|
||||
|
||||
moreOptionsButton.setOnClickListener(this);
|
||||
toggleOrientationButton.setOnClickListener(this);
|
||||
switchBackgroundButton.setOnClickListener(this);
|
||||
switchPopupButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
/*//////////////////////////////////////////////////////////////////////////
|
||||
@ -464,6 +472,16 @@ public final class MainVideoPlayer extends Activity {
|
||||
return;
|
||||
} else if (v.getId() == moreOptionsButton.getId()) {
|
||||
onMoreOptionsClicked();
|
||||
|
||||
} else if (v.getId() == toggleOrientationButton.getId()) {
|
||||
onScreenRotationClicked();
|
||||
|
||||
} else if (v.getId() == switchPopupButton.getId()) {
|
||||
onFullScreenButtonClicked();
|
||||
|
||||
} else if (v.getId() == switchBackgroundButton.getId()) {
|
||||
onPlayBackgroundButtonClicked();
|
||||
|
||||
}
|
||||
|
||||
if (getCurrentState() != STATE_COMPLETED) {
|
||||
@ -497,8 +515,15 @@ public final class MainVideoPlayer extends Activity {
|
||||
private void onMoreOptionsClicked() {
|
||||
if (DEBUG) Log.d(TAG, "onMoreOptionsClicked() called");
|
||||
|
||||
moreOptionsPopupMenu.show();
|
||||
isSomePopupMenuVisible = true;
|
||||
if (secondaryControls.getVisibility() == View.VISIBLE) {
|
||||
moreOptionsButton.setImageDrawable(getResources().getDrawable(
|
||||
R.drawable.ic_expand_more_white_24dp));
|
||||
animateView(secondaryControls, false, 200);
|
||||
} else {
|
||||
moreOptionsButton.setImageDrawable(getResources().getDrawable(
|
||||
R.drawable.ic_expand_less_white_24dp));
|
||||
animateView(secondaryControls, true, 200);
|
||||
}
|
||||
showControls(300);
|
||||
}
|
||||
|
||||
@ -637,42 +662,6 @@ public final class MainVideoPlayer extends Activity {
|
||||
setShuffleButton(shuffleButton, playQueue.isShuffled());
|
||||
}
|
||||
|
||||
private void buildMoreOptionsMenu() {
|
||||
this.moreOptionsPopupMenu.getMenuInflater().inflate(R.menu.menu_videooptions,
|
||||
moreOptionsPopupMenu.getMenu());
|
||||
|
||||
moreOptionsPopupMenu.setOnMenuItemClickListener(menuItem -> {
|
||||
switch (menuItem.getItemId()) {
|
||||
case R.id.toggleOrientation:
|
||||
onScreenRotationClicked();
|
||||
break;
|
||||
case R.id.switchPopup:
|
||||
onFullScreenButtonClicked();
|
||||
break;
|
||||
case R.id.switchBackground:
|
||||
onPlayBackgroundButtonClicked();
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
try {
|
||||
PopupMenuIconHacker.setShowPopupIcon(moreOptionsPopupMenu);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// fix icon theme
|
||||
if(ThemeHelper.isLightThemeSelected(MainVideoPlayer.this)) {
|
||||
moreOptionsPopupMenu.getMenu()
|
||||
.findItem(R.id.toggleOrientation)
|
||||
.setIcon(R.drawable.ic_screen_rotation_black_24dp);
|
||||
moreOptionsPopupMenu.getMenu()
|
||||
.findItem(R.id.switchPopup)
|
||||
.setIcon(R.drawable.ic_fullscreen_exit_black_24dp);
|
||||
}
|
||||
}
|
||||
|
||||
private void buildQueue() {
|
||||
queueLayout = findViewById(R.id.playQueuePanel);
|
||||
|
||||
|
@ -145,10 +145,10 @@
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@drawable/player_top_controls_bg"
|
||||
android:gravity="top"
|
||||
android:paddingBottom="70dp"
|
||||
android:paddingLeft="2dp"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
tools:ignore="RtlHardcoded">
|
||||
|
||||
<LinearLayout
|
||||
@ -209,6 +209,7 @@
|
||||
android:text="720p"
|
||||
android:textColor="@android:color/white"
|
||||
android:textStyle="bold"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
tools:ignore="HardcodedText,RtlHardcoded"/>
|
||||
|
||||
<TextView
|
||||
@ -222,6 +223,7 @@
|
||||
android:minWidth="40dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textStyle="bold"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry"
|
||||
tools:text="1x" />
|
||||
|
||||
@ -232,12 +234,12 @@
|
||||
android:layout_marginLeft="2dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:layout_toLeftOf="@+id/moreOptionsButton"
|
||||
android:background="#00ffffff"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:padding="5dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/list"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
tools:ignore="ContentDescription,RtlHardcoded"/>
|
||||
|
||||
<ImageButton
|
||||
@ -247,12 +249,25 @@
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginLeft="2dp"
|
||||
android:padding="5dp"
|
||||
android:background="#00ffffff"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_more_vert_white_24dp"
|
||||
android:src="@drawable/ic_expand_more_white_24dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
tools:ignore="ContentDescription,RtlHardcoded"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/secondaryControls"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/topControls"
|
||||
android:gravity="top"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingRight="5dp"
|
||||
android:visibility="gone"
|
||||
tools:ignore="RtlHardcoded"
|
||||
tools:visibility="visible">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/resizeTextView"
|
||||
@ -260,22 +275,21 @@
|
||||
android:layout_height="35dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_below="@id/metadataView"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:gravity="center"
|
||||
android:minWidth="50dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textStyle="bold"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
tools:ignore="HardcodedText,RtlHardcoded"
|
||||
tools:text="FIT"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/captionTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_below="@id/metadataView"
|
||||
android:layout_toRightOf="@id/resizeTextView"
|
||||
android:gravity="center"
|
||||
android:minHeight="35dp"
|
||||
@ -284,8 +298,59 @@
|
||||
android:paddingRight="2dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textStyle="bold"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
tools:ignore="RtlHardcoded"
|
||||
tools:text="English" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/toggleOrientation"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginLeft="2dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:padding="5dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_screen_rotation_white"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:contentDescription="@string/toggle_orientation"
|
||||
tools:ignore="RtlHardcoded"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/switchPopup"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginLeft="2dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:layout_toLeftOf="@id/toggleOrientation"
|
||||
android:layout_centerVertical="true"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_fullscreen_exit_white"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:contentDescription="@string/switch_to_popup"
|
||||
tools:ignore="RtlHardcoded"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/switchBackground"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginLeft="2dp"
|
||||
android:layout_marginRight="2dp"
|
||||
android:layout_toLeftOf="@id/switchPopup"
|
||||
android:layout_centerVertical="true"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:padding="5dp"
|
||||
android:scaleType="fitXY"
|
||||
android:src="@drawable/ic_headset_white_24dp"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:contentDescription="@string/switch_to_background"
|
||||
tools:ignore="RtlHardcoded"/>
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
@ -417,7 +482,10 @@
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_gravity="center"
|
||||
android:layout_toEndOf="@+id/loading_panel"
|
||||
android:layout_toRightOf="@+id/loading_panel"
|
||||
tools:ignore="RtlHardcoded">
|
||||
|
||||
<TextView
|
||||
@ -437,7 +505,7 @@
|
||||
android:visibility="gone"
|
||||
tools:ignore="RtlHardcoded"
|
||||
tools:text="Volume 0"
|
||||
tools:visibility="visible"/>
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/brightnessTextView"
|
||||
@ -456,7 +524,7 @@
|
||||
android:visibility="gone"
|
||||
tools:ignore="RtlHardcoded"
|
||||
tools:text="Brightness 0"
|
||||
tools:visibility="visible"/>
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/currentDisplaySeek"
|
||||
@ -475,7 +543,7 @@
|
||||
android:visibility="gone"
|
||||
tools:ignore="RtlHardcoded"
|
||||
tools:text="1:06:29"
|
||||
tools:visibility="visible"/>
|
||||
tools:visibility="visible" />
|
||||
</RelativeLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user