Initial Refactor of WelcomeActivity, Set up Basic Splash Elements
This commit is contained in:
parent
3c3bb70b01
commit
8df6af62d7
@ -59,12 +59,18 @@
|
|||||||
</receiver>
|
</receiver>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".WelcomeActivity"
|
android:name=".MainActivity"
|
||||||
|
android:configChanges="orientation|screenSize"
|
||||||
|
android:exported="true">
|
||||||
|
|
||||||
|
</activity>
|
||||||
|
<activity
|
||||||
|
android:name=".SplashActivity"
|
||||||
|
android:theme="@style/SplashTheme"
|
||||||
android:configChanges="orientation|screenSize"
|
android:configChanges="orientation|screenSize"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
@ -70,17 +70,6 @@ public class AutoRootFragment extends ListFragment {
|
|||||||
private void initializeElements() {
|
private void initializeElements() {
|
||||||
listView = getListView();
|
listView = getListView();
|
||||||
packageManager = getActivity().getPackageManager();
|
packageManager = getActivity().getPackageManager();
|
||||||
prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
|
|
||||||
if (!prefs.contains("auto_blacklist")) {
|
|
||||||
Logger.dh("AutoRootFragment: Setting default preferences for application");
|
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
|
||||||
Set<String> set = new HashSet<>();
|
|
||||||
set.add("com.google.android.apps.walletnfcrel");
|
|
||||||
set.add("com.google.android.gms");
|
|
||||||
set.add("com.google.commerce.tapandpay");
|
|
||||||
editor.putStringSet("auto_blacklist", set);
|
|
||||||
editor.apply();
|
|
||||||
}
|
|
||||||
new LoadApplications().execute();
|
new LoadApplications().execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,11 +5,9 @@ import android.app.Fragment;
|
|||||||
import android.app.FragmentTransaction;
|
import android.app.FragmentTransaction;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.AsyncTask;
|
|
||||||
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.preference.PreferenceManager;
|
|
||||||
import android.support.annotation.IdRes;
|
import android.support.annotation.IdRes;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.design.widget.NavigationView;
|
import android.support.design.widget.NavigationView;
|
||||||
@ -22,15 +20,13 @@ import android.support.v7.widget.Toolbar;
|
|||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.services.MonitorService;
|
|
||||||
import com.topjohnwu.magisk.utils.Async;
|
|
||||||
import com.topjohnwu.magisk.utils.Logger;
|
import com.topjohnwu.magisk.utils.Logger;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
|
|
||||||
public class WelcomeActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
|
public class MainActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
|
||||||
|
|
||||||
private static final String SELECTED_ITEM_ID = "SELECTED_ITEM_ID";
|
private static final String SELECTED_ITEM_ID = "SELECTED_ITEM_ID";
|
||||||
|
|
||||||
@ -50,19 +46,11 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
@Override
|
@Override
|
||||||
protected void onCreate(final Bundle savedInstanceState) {
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_welcome);
|
setContentView(R.layout.activity_main);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
// Startups
|
// Startups
|
||||||
PreferenceManager.setDefaultValues(this, R.xml.defaultpref, false);
|
Utils.init(this);
|
||||||
if (Utils.autoToggleEnabled(getApplicationContext())) {
|
|
||||||
if (!Utils.isMyServiceRunning(MonitorService.class, getApplicationContext())) {
|
|
||||||
Intent myIntent = new Intent(getApplication(), MonitorService.class);
|
|
||||||
getApplication().startService(myIntent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Utils.SetupQuickSettingsTile(getApplicationContext());
|
|
||||||
|
|
||||||
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
|
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED
|
||||||
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
|
requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0);
|
||||||
@ -114,11 +102,6 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Utils.init(this);
|
|
||||||
new Async.CheckUpdates(this).execute();
|
|
||||||
new Async.LoadModules(this).execute();
|
|
||||||
new Async.LoadRepos(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
||||||
|
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
|
||||||
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {
|
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) {
|
69
app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
Normal file
69
app/src/main/java/com/topjohnwu/magisk/SplashActivity.java
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
package com.topjohnwu.magisk;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.os.AsyncTask;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
|
import android.support.v7.app.AppCompatActivity;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.services.MonitorService;
|
||||||
|
import com.topjohnwu.magisk.utils.Async;
|
||||||
|
import com.topjohnwu.magisk.utils.Logger;
|
||||||
|
import com.topjohnwu.magisk.utils.PrefHelper;
|
||||||
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class SplashActivity extends AppCompatActivity {
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
//setups go here
|
||||||
|
|
||||||
|
// Set up default preferences,make sure we add "extra" blacklist entries.
|
||||||
|
|
||||||
|
PreferenceManager.setDefaultValues(this, R.xml.defaultpref, false);
|
||||||
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplication());
|
||||||
|
|
||||||
|
if (!prefs.contains("auto_blacklist")) {
|
||||||
|
Logger.dh("AutoRootFragment: Setting default preferences for application");
|
||||||
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
|
Set<String> set = new HashSet<>();
|
||||||
|
set.add("com.google.android.apps.walletnfcrel");
|
||||||
|
set.add("com.google.android.gms");
|
||||||
|
set.add("com.google.commerce.tapandpay");
|
||||||
|
editor.putStringSet("auto_blacklist", set);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up toggle states based on preferences, start services, disable root if set
|
||||||
|
|
||||||
|
if (Utils.autoToggleEnabled(getApplicationContext())) {
|
||||||
|
if (!Utils.isMyServiceRunning(MonitorService.class, getApplicationContext())) {
|
||||||
|
Intent myIntent = new Intent(getApplication(), MonitorService.class);
|
||||||
|
getApplication().startService(myIntent);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (PrefHelper.CheckBool("keep_root_off", getApplication())) {
|
||||||
|
Utils.toggleRoot(false, getApplication());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set up quick settings tile
|
||||||
|
Utils.SetupQuickSettingsTile(getApplicationContext());
|
||||||
|
|
||||||
|
// Initialize
|
||||||
|
|
||||||
|
new Async.CheckUpdates(this).execute();
|
||||||
|
new Async.LoadModules(this).execute();
|
||||||
|
new Async.LoadRepos(this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
|
||||||
|
// Start main activity
|
||||||
|
Intent intent = new Intent(this, MainActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}
|
@ -15,8 +15,8 @@ import android.support.v4.app.NotificationCompat;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.accessibility.AccessibilityEvent;
|
import android.view.accessibility.AccessibilityEvent;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.MainActivity;
|
||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
import com.topjohnwu.magisk.WelcomeActivity;
|
|
||||||
import com.topjohnwu.magisk.utils.Logger;
|
import com.topjohnwu.magisk.utils.Logger;
|
||||||
import com.topjohnwu.magisk.utils.PrefHelper;
|
import com.topjohnwu.magisk.utils.PrefHelper;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
@ -112,7 +112,7 @@ public class MonitorService extends AccessibilityService {
|
|||||||
if (!PrefHelper.CheckBool("hide_root_notification", getApplicationContext())) {
|
if (!PrefHelper.CheckBool("hide_root_notification", getApplicationContext())) {
|
||||||
if (rootAction) {
|
if (rootAction) {
|
||||||
|
|
||||||
Intent intent = new Intent(getApplication(), WelcomeActivity.class);
|
Intent intent = new Intent(getApplication(), MainActivity.class);
|
||||||
intent.putExtra("relaunch", "relaunch");
|
intent.putExtra("relaunch", "relaunch");
|
||||||
String rootMessage;
|
String rootMessage;
|
||||||
PendingIntent pendingIntent = PendingIntent.getActivity(
|
PendingIntent pendingIntent = PendingIntent.getActivity(
|
||||||
|
13
app/src/main/res/drawable/ic_splash_activity.xml
Normal file
13
app/src/main/res/drawable/ic_splash_activity.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:drawable="@android:color/darker_gray"/>
|
||||||
|
|
||||||
|
<item>
|
||||||
|
<bitmap
|
||||||
|
android:gravity="center"
|
||||||
|
android:src="@mipmap/ic_launcher"/>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
</layer-list>
|
@ -24,4 +24,8 @@
|
|||||||
<style name="AppTheme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
|
<style name="AppTheme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="SplashTheme" parent="Theme.AppCompat.NoActionBar">
|
||||||
|
<item name="android:windowBackground">@drawable/ic_splash_activity</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user