From 79c71509f62dd0b92fa85c0e97da042071e0c90b Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Sun, 10 Jun 2018 14:51:37 +0800 Subject: [PATCH] Add NoUIActivity --- src/full/AndroidManifest.xml | 9 ++++--- .../com/topjohnwu/magisk/AboutActivity.java | 2 +- .../com/topjohnwu/magisk/FlashActivity.java | 2 +- .../com/topjohnwu/magisk/NoUIActivity.java | 26 +++++++++++++++++++ .../topjohnwu/magisk/SettingsActivity.java | 2 +- src/full/res/layout/activity_main.xml | 11 ++++---- src/full/res/layout/activity_settings.xml | 12 ++++----- src/full/res/values-sw600dp/styles.xml | 4 +-- src/full/res/values/styles.xml | 12 +++++++-- .../topjohnwu/magisk/components/Activity.java | 13 +++++----- src/stub/AndroidManifest.xml | 2 +- ...{SplashActivity.java => NoUIActivity.java} | 20 +++++++------- 12 files changed, 74 insertions(+), 41 deletions(-) create mode 100644 src/full/java/com/topjohnwu/magisk/NoUIActivity.java rename src/stub/java/com/topjohnwu/magisk/{SplashActivity.java => NoUIActivity.java} (77%) diff --git a/src/full/AndroidManifest.xml b/src/full/AndroidManifest.xml index 060379904..2e2f59434 100644 --- a/src/full/AndroidManifest.xml +++ b/src/full/AndroidManifest.xml @@ -26,15 +26,18 @@ + android:theme="@style/AppTheme.StatusBar" /> + android:theme="@style/AppTheme.StatusBar" /> + android:theme="@style/AppTheme.StatusBar" /> + - + android:layout_height="match_parent" /> - + @@ -30,6 +29,6 @@ android:layout_height="match_parent" android:layout_gravity="start" android:fitsSystemWindows="true" - app:menu="@menu/drawer"/> + app:menu="@menu/drawer" /> diff --git a/src/full/res/layout/activity_settings.xml b/src/full/res/layout/activity_settings.xml index 593b14b38..10434c358 100644 --- a/src/full/res/layout/activity_settings.xml +++ b/src/full/res/layout/activity_settings.xml @@ -1,16 +1,16 @@ + android:layout_width="match_parent" + android:layout_height="match_parent" + android:background="?android:windowBackground" + android:orientation="vertical"> - + + android:layout_weight="1" /> \ No newline at end of file diff --git a/src/full/res/values-sw600dp/styles.xml b/src/full/res/values-sw600dp/styles.xml index 388ccf1bf..73325c6af 100644 --- a/src/full/res/values-sw600dp/styles.xml +++ b/src/full/res/values-sw600dp/styles.xml @@ -1,7 +1,7 @@ - - + + @@ -38,11 +46,11 @@ @android:color/background_light - - diff --git a/src/main/java/com/topjohnwu/magisk/components/Activity.java b/src/main/java/com/topjohnwu/magisk/components/Activity.java index 6a5ada4a7..9c0e75c44 100644 --- a/src/main/java/com/topjohnwu/magisk/components/Activity.java +++ b/src/main/java/com/topjohnwu/magisk/components/Activity.java @@ -9,21 +9,20 @@ import android.support.v4.app.ActivityCompat; import android.support.v4.content.ContextCompat; import android.widget.Toast; -import com.topjohnwu.magisk.MagiskManager; +import com.topjohnwu.magisk.NoUIActivity; import com.topjohnwu.magisk.R; -import com.topjohnwu.magisk.SplashActivity; import com.topjohnwu.magisk.utils.Const; public abstract class Activity extends FlavorActivity { - private static Runnable permissionGrantCallback; + protected static Runnable permissionGrantCallback; private ActivityResultListener activityResultListener; public Activity() { super(); Configuration configuration = new Configuration(); - configuration.setLocale(MagiskManager.locale); + configuration.setLocale(Application.locale); applyOverrideConfiguration(configuration); } @@ -40,12 +39,12 @@ public abstract class Activity extends FlavorActivity { permissionGrantCallback = callback; if (!(context instanceof Activity)) { // Start activity to show dialog - Intent intent = new Intent(context, SplashActivity.class); + Intent intent = new Intent(context, NoUIActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(Const.Key.INTENT_PERM, permissions); context.startActivity(intent); } else { - ActivityCompat.requestPermissions((android.app.Activity) context, permissions, 0); + ActivityCompat.requestPermissions((Activity) context, permissions, 0); } } } @@ -71,7 +70,7 @@ public abstract class Activity extends FlavorActivity { permissionGrantCallback.run(); } } else { - MagiskManager.toast(R.string.no_rw_storage, Toast.LENGTH_LONG); + Application.toast(R.string.no_rw_storage, Toast.LENGTH_LONG); } permissionGrantCallback = null; } diff --git a/src/stub/AndroidManifest.xml b/src/stub/AndroidManifest.xml index 9e66bac3b..be13a2b7e 100644 --- a/src/stub/AndroidManifest.xml +++ b/src/stub/AndroidManifest.xml @@ -4,7 +4,7 @@ diff --git a/src/stub/java/com/topjohnwu/magisk/SplashActivity.java b/src/stub/java/com/topjohnwu/magisk/NoUIActivity.java similarity index 77% rename from src/stub/java/com/topjohnwu/magisk/SplashActivity.java rename to src/stub/java/com/topjohnwu/magisk/NoUIActivity.java index 5acbc9a31..83bff37f6 100644 --- a/src/stub/java/com/topjohnwu/magisk/SplashActivity.java +++ b/src/stub/java/com/topjohnwu/magisk/NoUIActivity.java @@ -15,7 +15,7 @@ import com.topjohnwu.magisk.utils.WebService; import org.json.JSONException; import org.json.JSONObject; -public class SplashActivity extends Activity { +public class NoUIActivity extends Activity { private String apkLink; private String version; @@ -44,16 +44,14 @@ public class SplashActivity extends Activity { .setCancelable(false) .setTitle(R.string.app_name) .setMessage(R.string.upgrade_msg) - .setPositiveButton(R.string.yes, (d, w) -> { - runWithPermission(new String[] - { Manifest.permission.WRITE_EXTERNAL_STORAGE }, () -> { - Intent intent = new Intent(this, ManagerUpdate.class); - intent.putExtra(Const.Key.INTENT_SET_LINK, apkLink); - intent.putExtra(Const.Key.INTENT_SET_FILENAME, filename); - sendBroadcast(intent); - finish(); - }); - }) + .setPositiveButton(R.string.yes, (d, w) -> runWithPermission(new String[] + { Manifest.permission.WRITE_EXTERNAL_STORAGE }, () -> { + Intent intent = new Intent(this, ManagerUpdate.class); + intent.putExtra(Const.Key.INTENT_SET_LINK, apkLink); + intent.putExtra(Const.Key.INTENT_SET_FILENAME, filename); + sendBroadcast(intent); + finish(); + })) .setNegativeButton(R.string.no_thanks, (d, w) -> finish()) .show(); });