diff --git a/app/src/main/java/org/schabi/newpipe/player/AbstractPlayer.java b/app/src/main/java/org/schabi/newpipe/player/AbstractPlayer.java index a9987bee9..1c6d4822b 100644 --- a/app/src/main/java/org/schabi/newpipe/player/AbstractPlayer.java +++ b/app/src/main/java/org/schabi/newpipe/player/AbstractPlayer.java @@ -18,7 +18,6 @@ import android.preference.PreferenceManager; import android.support.v4.content.ContextCompat; import android.text.TextUtils; import android.util.Log; -import android.view.Gravity; import android.view.Menu; import android.view.MenuItem; import android.view.SurfaceView; @@ -232,8 +231,7 @@ public abstract class AbstractPlayer implements StateInterface, SeekBar.OnSeekBa if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) playbackSeekBar.getThumb().setColorFilter(Color.RED, PorterDuff.Mode.SRC_IN); this.playbackSeekBar.getProgressDrawable().setColorFilter(Color.RED, PorterDuff.Mode.MULTIPLY); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) this.qualityPopupMenu = new PopupMenu(context, qualityTextView, Gravity.CENTER | Gravity.BOTTOM); - else this.qualityPopupMenu = new PopupMenu(context, qualityTextView); + this.qualityPopupMenu = new PopupMenu(context, qualityTextView); ((ProgressBar) this.loadingPanel.findViewById(R.id.progressBarLoadingPanel)).getIndeterminateDrawable().setColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY); @@ -419,7 +417,7 @@ public abstract class AbstractPlayer implements StateInterface, SeekBar.OnSeekBa if (DEBUG) Log.d(TAG, "onBuffering() called"); loadingPanel.setBackgroundColor(Color.TRANSPARENT); animateView(loadingPanel, true, 500, 0); - animateView(controlsRoot, false, 0, 0); + animateView(controlsRoot, false, 0, 0, true); } @Override diff --git a/app/src/main/java/org/schabi/newpipe/player/ExoPlayerActivity.java b/app/src/main/java/org/schabi/newpipe/player/ExoPlayerActivity.java index 58e93fc61..3a7c5e085 100644 --- a/app/src/main/java/org/schabi/newpipe/player/ExoPlayerActivity.java +++ b/app/src/main/java/org/schabi/newpipe/player/ExoPlayerActivity.java @@ -5,6 +5,7 @@ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; +import android.content.pm.ActivityInfo; import android.graphics.Color; import android.media.AudioManager; import android.net.Uri; @@ -173,6 +174,12 @@ public class ExoPlayerActivity extends Activity { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } + private void toggleOrientation() { + setRequestedOrientation(getResources().getDisplayMetrics().heightPixels > getResources().getDisplayMetrics().widthPixels + ? ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE + : ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); + } + /////////////////////////////////////////////////////////////////////////// @SuppressWarnings({"unused", "WeakerAccess"}) @@ -183,6 +190,7 @@ public class ExoPlayerActivity extends Activity { private TextView brightnessTextView; private ImageButton repeatButton; + private ImageButton screenRotationButton; private ImageButton playPauseButton; AbstractPlayerImpl() { @@ -198,6 +206,7 @@ public class ExoPlayerActivity extends Activity { this.brightnessTextView = (TextView) rootView.findViewById(R.id.brightnessTextView); this.repeatButton = (ImageButton) rootView.findViewById(R.id.repeatButton); + this.screenRotationButton = (ImageButton) rootView.findViewById(R.id.screenRotationButton); this.playPauseButton = (ImageButton) rootView.findViewById(R.id.playPauseButton); // Due to a bug on lower API, lets set the alpha instead of using a drawable @@ -219,6 +228,7 @@ public class ExoPlayerActivity extends Activity { repeatButton.setOnClickListener(this); playPauseButton.setOnClickListener(this); + screenRotationButton.setOnClickListener(this); } @Override @@ -285,6 +295,7 @@ public class ExoPlayerActivity extends Activity { super.onClick(v); if (v.getId() == repeatButton.getId()) onRepeatClicked(); else if (v.getId() == playPauseButton.getId()) onVideoPlayPause(); + else if (v.getId() == screenRotationButton.getId()) onScreenRotationClicked(); if (getCurrentState() != STATE_COMPLETED) { animateView(playerImpl.getControlsRoot(), true, 300, 0, new Runnable() { @@ -298,6 +309,11 @@ public class ExoPlayerActivity extends Activity { } } + private void onScreenRotationClicked() { + if (DEBUG) Log.d(TAG, "onScreenRotationClicked() called"); + toggleOrientation(); + } + @Override public void onVideoPlayPause() { super.onVideoPlayPause(); @@ -348,7 +364,6 @@ public class ExoPlayerActivity extends Activity { @Override public void onLoading() { super.onLoading(); - hideSystemUi(); playPauseButton.setImageResource(R.drawable.ic_pause_white); } diff --git a/app/src/main/res/drawable-hdpi/ic_screen_rotation_white.png b/app/src/main/res/drawable-hdpi/ic_screen_rotation_white.png new file mode 100644 index 000000000..b81f22246 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_screen_rotation_white.png differ diff --git a/app/src/main/res/drawable-hdpi/ic_screen_rotation_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_screen_rotation_white_24dp.png deleted file mode 100644 index fa2c881e0..000000000 Binary files a/app/src/main/res/drawable-hdpi/ic_screen_rotation_white_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-mdpi/ic_screen_rotation_white.png b/app/src/main/res/drawable-mdpi/ic_screen_rotation_white.png new file mode 100644 index 000000000..bb36eef34 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_screen_rotation_white.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_screen_rotation_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_screen_rotation_white_24dp.png deleted file mode 100644 index b6acecf34..000000000 Binary files a/app/src/main/res/drawable-mdpi/ic_screen_rotation_white_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-xhdpi/ic_screen_rotation_white.png b/app/src/main/res/drawable-xhdpi/ic_screen_rotation_white.png new file mode 100644 index 000000000..449b6725f Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_screen_rotation_white.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_screen_rotation_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_screen_rotation_white_24dp.png deleted file mode 100644 index 9092249af..000000000 Binary files a/app/src/main/res/drawable-xhdpi/ic_screen_rotation_white_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_screen_rotation_white.png b/app/src/main/res/drawable-xxhdpi/ic_screen_rotation_white.png new file mode 100644 index 000000000..a160572a4 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_screen_rotation_white.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_screen_rotation_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_screen_rotation_white_24dp.png deleted file mode 100644 index cc0fa87f7..000000000 Binary files a/app/src/main/res/drawable-xxhdpi/ic_screen_rotation_white_24dp.png and /dev/null differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_screen_rotation_white.png b/app/src/main/res/drawable-xxxhdpi/ic_screen_rotation_white.png new file mode 100644 index 000000000..3cde2bfef Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_screen_rotation_white.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_screen_rotation_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_screen_rotation_white_24dp.png deleted file mode 100644 index d67b21ae8..000000000 Binary files a/app/src/main/res/drawable-xxxhdpi/ic_screen_rotation_white_24dp.png and /dev/null differ diff --git a/app/src/main/res/layout/activity_exo_player.xml b/app/src/main/res/layout/activity_exo_player.xml index 72f8aa897..134e5ab69 100644 --- a/app/src/main/res/layout/activity_exo_player.xml +++ b/app/src/main/res/layout/activity_exo_player.xml @@ -105,9 +105,9 @@ android:id="@+id/qualityTextView" android:layout_width="wrap_content" android:layout_height="35dp" - android:layout_marginLeft="4dp" + android:layout_marginLeft="2dp" android:layout_marginRight="2dp" - android:layout_toLeftOf="@+id/repeatButton" + android:layout_toLeftOf="@+id/screenRotationButton" android:gravity="center" android:minWidth="50dp" android:text="720p" @@ -115,12 +115,26 @@ android:textStyle="bold" tools:ignore="HardcodedText,RtlHardcoded"/> + +