From 96127f8bd19294dca9082952a9c93a4d77fddfe6 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Wed, 10 Apr 2019 05:36:02 -0400 Subject: [PATCH] Lock orientation in SuRequestActivity Fix #1302, close #1318 --- .../java/com/topjohnwu/magisk/SuRequestActivity.java | 1 + .../com/topjohnwu/magisk/components/BaseActivity.java | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/app/src/main/java/com/topjohnwu/magisk/SuRequestActivity.java b/app/src/main/java/com/topjohnwu/magisk/SuRequestActivity.java index 787b93005..c0e01f57a 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SuRequestActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/SuRequestActivity.java @@ -71,6 +71,7 @@ public class SuRequestActivity extends BaseActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); + lockOrientation(); supportRequestWindowFeature(Window.FEATURE_NO_TITLE); PackageManager pm = getPackageManager(); diff --git a/app/src/main/java/com/topjohnwu/magisk/components/BaseActivity.java b/app/src/main/java/com/topjohnwu/magisk/components/BaseActivity.java index 8e0918439..fad77b7b8 100644 --- a/app/src/main/java/com/topjohnwu/magisk/components/BaseActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/components/BaseActivity.java @@ -4,7 +4,9 @@ import android.Manifest; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; +import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; +import android.os.Build; import android.os.Bundle; import android.text.TextUtils; import android.view.WindowManager; @@ -81,6 +83,13 @@ public abstract class BaseActivity extends AppCompatActivity implements Event.Au } } + protected void lockOrientation() { + if (Build.VERSION.SDK_INT < 18) + setRequestedOrientation(getResources().getConfiguration().orientation); + else + setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED); + } + public void runWithExternalRW(Runnable callback) { runWithPermission(new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, callback); }