mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-11-10 12:47:26 +01:00
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:
parent
988989826f
commit
7bef0f28ca
@ -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,23 +236,27 @@ 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);
|
||||||
|
|
||||||
OrientationEventListener orientationEventListener = new OrientationEventListener(this) {
|
if (android.provider.Settings.System.getInt(getContentResolver(),
|
||||||
@Override
|
Settings.System.ACCELEROMETER_ROTATION, 0) == 1) {
|
||||||
public void onOrientationChanged(int orientation) {
|
OrientationEventListener orientationEventListener = new OrientationEventListener(this) {
|
||||||
int epsilon = 10;
|
@Override
|
||||||
int leftLandscape = 90;
|
public void onOrientationChanged(int orientation) {
|
||||||
int rightLandscape = 270;
|
int epsilon = 10;
|
||||||
if(epsilonCheck(orientation, leftLandscape, epsilon) ||
|
int leftLandscape = 90;
|
||||||
epsilonCheck(orientation, rightLandscape, epsilon)){
|
int rightLandscape = 270;
|
||||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
if(epsilonCheck(orientation, leftLandscape, epsilon) ||
|
||||||
|
epsilonCheck(orientation, rightLandscape, epsilon)) {
|
||||||
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
|
||||||
|
disable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private boolean epsilonCheck(int a, int b, int epsilon) {
|
private boolean epsilonCheck(int a, int b, int epsilon) {
|
||||||
return a > b - epsilon && a < b + epsilon;
|
return a > b - epsilon && a < b + epsilon;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
orientationEventListener.enable();
|
orientationEventListener.enable();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user