Implement screen orientation toggle
|
@ -18,7 +18,6 @@ import android.preference.PreferenceManager;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.SurfaceView;
|
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);
|
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);
|
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);
|
this.qualityPopupMenu = new PopupMenu(context, qualityTextView);
|
||||||
else this.qualityPopupMenu = new PopupMenu(context, qualityTextView);
|
|
||||||
|
|
||||||
((ProgressBar) this.loadingPanel.findViewById(R.id.progressBarLoadingPanel)).getIndeterminateDrawable().setColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY);
|
((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");
|
if (DEBUG) Log.d(TAG, "onBuffering() called");
|
||||||
loadingPanel.setBackgroundColor(Color.TRANSPARENT);
|
loadingPanel.setBackgroundColor(Color.TRANSPARENT);
|
||||||
animateView(loadingPanel, true, 500, 0);
|
animateView(loadingPanel, true, 500, 0);
|
||||||
animateView(controlsRoot, false, 0, 0);
|
animateView(controlsRoot, false, 0, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -5,6 +5,7 @@ import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.IntentFilter;
|
import android.content.IntentFilter;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
@ -173,6 +174,12 @@ public class ExoPlayerActivity extends Activity {
|
||||||
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
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"})
|
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||||
|
@ -183,6 +190,7 @@ public class ExoPlayerActivity extends Activity {
|
||||||
private TextView brightnessTextView;
|
private TextView brightnessTextView;
|
||||||
private ImageButton repeatButton;
|
private ImageButton repeatButton;
|
||||||
|
|
||||||
|
private ImageButton screenRotationButton;
|
||||||
private ImageButton playPauseButton;
|
private ImageButton playPauseButton;
|
||||||
|
|
||||||
AbstractPlayerImpl() {
|
AbstractPlayerImpl() {
|
||||||
|
@ -198,6 +206,7 @@ public class ExoPlayerActivity extends Activity {
|
||||||
this.brightnessTextView = (TextView) rootView.findViewById(R.id.brightnessTextView);
|
this.brightnessTextView = (TextView) rootView.findViewById(R.id.brightnessTextView);
|
||||||
this.repeatButton = (ImageButton) rootView.findViewById(R.id.repeatButton);
|
this.repeatButton = (ImageButton) rootView.findViewById(R.id.repeatButton);
|
||||||
|
|
||||||
|
this.screenRotationButton = (ImageButton) rootView.findViewById(R.id.screenRotationButton);
|
||||||
this.playPauseButton = (ImageButton) rootView.findViewById(R.id.playPauseButton);
|
this.playPauseButton = (ImageButton) rootView.findViewById(R.id.playPauseButton);
|
||||||
|
|
||||||
// Due to a bug on lower API, lets set the alpha instead of using a drawable
|
// 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);
|
repeatButton.setOnClickListener(this);
|
||||||
playPauseButton.setOnClickListener(this);
|
playPauseButton.setOnClickListener(this);
|
||||||
|
screenRotationButton.setOnClickListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -285,6 +295,7 @@ public class ExoPlayerActivity extends Activity {
|
||||||
super.onClick(v);
|
super.onClick(v);
|
||||||
if (v.getId() == repeatButton.getId()) onRepeatClicked();
|
if (v.getId() == repeatButton.getId()) onRepeatClicked();
|
||||||
else if (v.getId() == playPauseButton.getId()) onVideoPlayPause();
|
else if (v.getId() == playPauseButton.getId()) onVideoPlayPause();
|
||||||
|
else if (v.getId() == screenRotationButton.getId()) onScreenRotationClicked();
|
||||||
|
|
||||||
if (getCurrentState() != STATE_COMPLETED) {
|
if (getCurrentState() != STATE_COMPLETED) {
|
||||||
animateView(playerImpl.getControlsRoot(), true, 300, 0, new Runnable() {
|
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
|
@Override
|
||||||
public void onVideoPlayPause() {
|
public void onVideoPlayPause() {
|
||||||
super.onVideoPlayPause();
|
super.onVideoPlayPause();
|
||||||
|
@ -348,7 +364,6 @@ public class ExoPlayerActivity extends Activity {
|
||||||
@Override
|
@Override
|
||||||
public void onLoading() {
|
public void onLoading() {
|
||||||
super.onLoading();
|
super.onLoading();
|
||||||
hideSystemUi();
|
|
||||||
playPauseButton.setImageResource(R.drawable.ic_pause_white);
|
playPauseButton.setImageResource(R.drawable.ic_pause_white);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
BIN
app/src/main/res/drawable-hdpi/ic_screen_rotation_white.png
Normal file
After Width: | Height: | Size: 976 B |
Before Width: | Height: | Size: 858 B |
BIN
app/src/main/res/drawable-mdpi/ic_screen_rotation_white.png
Normal file
After Width: | Height: | Size: 673 B |
Before Width: | Height: | Size: 639 B |
BIN
app/src/main/res/drawable-xhdpi/ic_screen_rotation_white.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.2 KiB |
BIN
app/src/main/res/drawable-xxhdpi/ic_screen_rotation_white.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.8 KiB |
BIN
app/src/main/res/drawable-xxxhdpi/ic_screen_rotation_white.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 2.5 KiB |
|
@ -105,9 +105,9 @@
|
||||||
android:id="@+id/qualityTextView"
|
android:id="@+id/qualityTextView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="35dp"
|
android:layout_height="35dp"
|
||||||
android:layout_marginLeft="4dp"
|
android:layout_marginLeft="2dp"
|
||||||
android:layout_marginRight="2dp"
|
android:layout_marginRight="2dp"
|
||||||
android:layout_toLeftOf="@+id/repeatButton"
|
android:layout_toLeftOf="@+id/screenRotationButton"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:minWidth="50dp"
|
android:minWidth="50dp"
|
||||||
android:text="720p"
|
android:text="720p"
|
||||||
|
@ -115,12 +115,26 @@
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
tools:ignore="HardcodedText,RtlHardcoded"/>
|
tools:ignore="HardcodedText,RtlHardcoded"/>
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/screenRotationButton"
|
||||||
|
android:layout_width="35dp"
|
||||||
|
android:layout_height="35dp"
|
||||||
|
android:layout_marginLeft="2dp"
|
||||||
|
android:layout_marginRight="2dp"
|
||||||
|
android:layout_toLeftOf="@+id/repeatButton"
|
||||||
|
android:background="#00ffffff"
|
||||||
|
android:clickable="true"
|
||||||
|
android:padding="8dp"
|
||||||
|
android:scaleType="fitXY"
|
||||||
|
android:src="@drawable/ic_screen_rotation_white"
|
||||||
|
tools:ignore="ContentDescription,RtlHardcoded"/>
|
||||||
|
|
||||||
<ImageButton
|
<ImageButton
|
||||||
android:id="@+id/repeatButton"
|
android:id="@+id/repeatButton"
|
||||||
android:layout_width="35dp"
|
android:layout_width="35dp"
|
||||||
android:layout_height="35dp"
|
android:layout_height="35dp"
|
||||||
android:layout_marginLeft="4dp"
|
android:layout_marginLeft="2dp"
|
||||||
android:layout_marginRight="4dp"
|
android:layout_marginRight="2dp"
|
||||||
android:layout_toLeftOf="@+id/fullScreenButton"
|
android:layout_toLeftOf="@+id/fullScreenButton"
|
||||||
android:background="#00ffffff"
|
android:background="#00ffffff"
|
||||||
android:clickable="true"
|
android:clickable="true"
|
||||||
|
|