Allow orientation change if auto rotate is on in ViewVideoActivity when switching to landscape orientation in video player automatically is on.

This commit is contained in:
Alex Ning 2021-07-19 23:34:09 +08:00
parent 988989826f
commit 7bef0f28ca

View File

@ -14,6 +14,7 @@ import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.provider.Settings;
import android.text.Html; import android.text.Html;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
@ -235,6 +236,8 @@ public class ViewVideoActivity extends AppCompatActivity {
originalOrientation = resources.getConfiguration().orientation; originalOrientation = resources.getConfiguration().orientation;
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
if (android.provider.Settings.System.getInt(getContentResolver(),
Settings.System.ACCELEROMETER_ROTATION, 0) == 1) {
OrientationEventListener orientationEventListener = new OrientationEventListener(this) { OrientationEventListener orientationEventListener = new OrientationEventListener(this) {
@Override @Override
public void onOrientationChanged(int orientation) { public void onOrientationChanged(int orientation) {
@ -243,7 +246,8 @@ public class ViewVideoActivity extends AppCompatActivity {
int rightLandscape = 270; int rightLandscape = 270;
if(epsilonCheck(orientation, leftLandscape, epsilon) || if(epsilonCheck(orientation, leftLandscape, epsilon) ||
epsilonCheck(orientation, rightLandscape, epsilon)) { epsilonCheck(orientation, rightLandscape, epsilon)) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
disable();
} }
} }
@ -254,6 +258,7 @@ public class ViewVideoActivity extends AppCompatActivity {
orientationEventListener.enable(); orientationEventListener.enable();
} }
} }
}
if (postTitle != null) { if (postTitle != null) {