diff options
author | Alex Ning <chineseperson5@gmail.com> | 2021-07-19 15:34:09 +0000 |
---|---|---|
committer | Alex Ning <chineseperson5@gmail.com> | 2021-07-19 15:34:09 +0000 |
commit | 7bef0f28ca320e44b50ebed7253ec1dd6075693e (patch) | |
tree | 9c62a80cbbda4afd67be8b43df491c45f1c3ad02 /app | |
parent | 988989826fe0624141405808ec6f59067477a496 (diff) | |
download | infinity-for-reddit-7bef0f28ca320e44b50ebed7253ec1dd6075693e.tar infinity-for-reddit-7bef0f28ca320e44b50ebed7253ec1dd6075693e.tar.gz infinity-for-reddit-7bef0f28ca320e44b50ebed7253ec1dd6075693e.tar.bz2 infinity-for-reddit-7bef0f28ca320e44b50ebed7253ec1dd6075693e.tar.lz infinity-for-reddit-7bef0f28ca320e44b50ebed7253ec1dd6075693e.tar.xz infinity-for-reddit-7bef0f28ca320e44b50ebed7253ec1dd6075693e.tar.zst infinity-for-reddit-7bef0f28ca320e44b50ebed7253ec1dd6075693e.zip |
Allow orientation change if auto rotate is on in ViewVideoActivity when switching to landscape orientation in video player automatically is on.
Diffstat (limited to 'app')
-rw-r--r-- | app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java index 3ba9d497..848cd2d1 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/activities/ViewVideoActivity.java @@ -14,6 +14,7 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; import android.os.Handler; +import android.provider.Settings; import android.text.Html; import android.view.Menu; import android.view.MenuItem; @@ -235,23 +236,27 @@ public class ViewVideoActivity extends AppCompatActivity { originalOrientation = resources.getConfiguration().orientation; setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); - OrientationEventListener orientationEventListener = new OrientationEventListener(this) { - @Override - public void onOrientationChanged(int orientation) { - int epsilon = 10; - int leftLandscape = 90; - int rightLandscape = 270; - if(epsilonCheck(orientation, leftLandscape, epsilon) || - epsilonCheck(orientation, rightLandscape, epsilon)){ - setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); + if (android.provider.Settings.System.getInt(getContentResolver(), + Settings.System.ACCELEROMETER_ROTATION, 0) == 1) { + OrientationEventListener orientationEventListener = new OrientationEventListener(this) { + @Override + public void onOrientationChanged(int orientation) { + int epsilon = 10; + int leftLandscape = 90; + int rightLandscape = 270; + if(epsilonCheck(orientation, leftLandscape, epsilon) || + epsilonCheck(orientation, rightLandscape, epsilon)) { + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); + disable(); + } } - } - private boolean epsilonCheck(int a, int b, int epsilon) { - return a > b - epsilon && a < b + epsilon; - } - }; - orientationEventListener.enable(); + private boolean epsilonCheck(int a, int b, int epsilon) { + return a > b - epsilon && a < b + epsilon; + } + }; + orientationEventListener.enable(); + } } } |