Add NoUIActivity

This commit is contained in:
topjohnwu 2018-06-10 14:51:37 +08:00
parent 5dab580cfc
commit 79c71509f6
12 changed files with 74 additions and 41 deletions

View File

@ -26,15 +26,18 @@
</activity>
<activity
android:name=".AboutActivity"
android:theme="@style/AppTheme.Transparent" />
android:theme="@style/AppTheme.StatusBar" />
<activity
android:name=".SettingsActivity"
android:theme="@style/AppTheme.Transparent" />
android:theme="@style/AppTheme.StatusBar" />
<activity
android:name=".FlashActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:screenOrientation="nosensor"
android:theme="@style/AppTheme.Transparent" />
android:theme="@style/AppTheme.StatusBar" />
<activity
android:name=".NoUIActivity"
android:theme="@style/AppTheme.Translucent" />
<activity
android:name=".superuser.RequestActivity"
android:excludeFromRecents="true"

View File

@ -31,7 +31,7 @@ public class AboutActivity extends Activity {
@Override
public int getDarkTheme() {
return R.style.AppTheme_Transparent_Dark;
return R.style.AppTheme_StatusBar_Dark;
}
@Override

View File

@ -77,7 +77,7 @@ public class FlashActivity extends Activity {
@Override
public int getDarkTheme() {
return R.style.AppTheme_Transparent_Dark;
return R.style.AppTheme_StatusBar_Dark;
}
@Override

View File

@ -0,0 +1,26 @@
package com.topjohnwu.magisk;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import com.topjohnwu.magisk.components.Activity;
import com.topjohnwu.magisk.utils.Const;
public class NoUIActivity extends Activity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String[] perms = getIntent().getStringArrayExtra(Const.Key.INTENT_PERM);
if (perms != null) {
ActivityCompat.requestPermissions(this, perms, 0);
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
finish();
}
}

View File

@ -42,7 +42,7 @@ public class SettingsActivity extends Activity implements Topic.Subscriber {
@Override
public int getDarkTheme() {
return R.style.AppTheme_Transparent_Dark;
return R.style.AppTheme_StatusBar_Dark;
}
@Override

View File

@ -1,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
@ -18,9 +17,9 @@
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="match_parent" />
<include layout="@layout/toolbar"/>
<include layout="@layout/toolbar" />
</FrameLayout>
@ -30,6 +29,6 @@
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/drawer"/>
app:menu="@menu/drawer" />
</android.support.v4.widget.DrawerLayout>

View File

@ -1,16 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:windowBackground"
android:orientation="vertical">
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:windowBackground"
android:orientation="vertical">
<include layout="@layout/toolbar"/>
<include layout="@layout/toolbar" />
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"/>
android:layout_weight="1" />
</LinearLayout>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppTheme.Transparent" parent="AppTheme">
<style name="AppTheme.StatusBar" parent="AppTheme">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
@ -9,7 +9,7 @@
<item name="android:windowNoTitle">true</item>
</style>
<style name="AppTheme.Transparent.Dark" parent="AppTheme.Dark">
<style name="AppTheme.StatusBar.Dark" parent="AppTheme.Dark">
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>

View File

@ -30,6 +30,14 @@
<item name="preferenceTheme">@style/PreferenceThemeOverlay.v14.Material</item>
</style>
<style name="AppTheme.Translucent" parent="Theme.AppCompat.NoActionBar">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">@null</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@android:style/Animation</item>
</style>
<style name="CardViewStyle.Dark" parent="CardView">
<item name="cardBackgroundColor">@android:color/background_dark</item>
</style>
@ -38,11 +46,11 @@
<item name="cardBackgroundColor">@android:color/background_light</item>
</style>
<style name="AppTheme.Transparent" parent="AppTheme">
<style name="AppTheme.StatusBar" parent="AppTheme">
<item name="android:statusBarColor">?attr/colorPrimaryDark</item>
</style>
<style name="AppTheme.Transparent.Dark" parent="AppTheme.Dark">
<style name="AppTheme.StatusBar.Dark" parent="AppTheme.Dark">
<item name="android:statusBarColor">?attr/colorPrimaryDark</item>
</style>

View File

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

View File

@ -4,7 +4,7 @@
<application>
<activity
android:name=".SplashActivity"
android:name=".NoUIActivity"
android:theme="@android:style/Theme.Translucent.NoTitleBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

View File

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