Lock orientation in SuRequestActivity

Fix #1302, close #1318
This commit is contained in:
topjohnwu 2019-04-10 05:36:02 -04:00
parent 0dbdf336d6
commit 96127f8bd1
2 changed files with 10 additions and 0 deletions

View File

@ -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();

View File

@ -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);
}