diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index bd017eda7..658f47ac7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -59,12 +59,18 @@ + + + - diff --git a/app/src/main/java/com/topjohnwu/magisk/AutoRootFragment.java b/app/src/main/java/com/topjohnwu/magisk/AutoRootFragment.java index 35e61e481..c13ed80c2 100644 --- a/app/src/main/java/com/topjohnwu/magisk/AutoRootFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/AutoRootFragment.java @@ -70,17 +70,6 @@ public class AutoRootFragment extends ListFragment { private void initializeElements() { listView = getListView(); 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 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(); } diff --git a/app/src/main/java/com/topjohnwu/magisk/WelcomeActivity.java b/app/src/main/java/com/topjohnwu/magisk/MainActivity.java similarity index 89% rename from app/src/main/java/com/topjohnwu/magisk/WelcomeActivity.java rename to app/src/main/java/com/topjohnwu/magisk/MainActivity.java index 182e4f345..d630341fa 100644 --- a/app/src/main/java/com/topjohnwu/magisk/WelcomeActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/MainActivity.java @@ -5,11 +5,9 @@ import android.app.Fragment; import android.app.FragmentTransaction; import android.content.Intent; import android.content.pm.PackageManager; -import android.os.AsyncTask; import android.os.Build; import android.os.Bundle; import android.os.Handler; -import android.preference.PreferenceManager; import android.support.annotation.IdRes; import android.support.annotation.NonNull; import android.support.design.widget.NavigationView; @@ -22,15 +20,13 @@ import android.support.v7.widget.Toolbar; import android.view.MenuItem; 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.Utils; import butterknife.BindView; 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"; @@ -50,19 +46,11 @@ public class WelcomeActivity extends AppCompatActivity implements NavigationView @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_welcome); + setContentView(R.layout.activity_main); ButterKnife.bind(this); // Startups - PreferenceManager.setDefaultValues(this, R.xml.defaultpref, false); - if (Utils.autoToggleEnabled(getApplicationContext())) { - if (!Utils.isMyServiceRunning(MonitorService.class, getApplicationContext())) { - Intent myIntent = new Intent(getApplication(), MonitorService.class); - getApplication().startService(myIntent); - } - } - Utils.SetupQuickSettingsTile(getApplicationContext()); - + Utils.init(this); if (ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { 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); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close) { diff --git a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java new file mode 100644 index 000000000..17bb7e1b2 --- /dev/null +++ b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java @@ -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 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(); + } +} diff --git a/app/src/main/java/com/topjohnwu/magisk/services/MonitorService.java b/app/src/main/java/com/topjohnwu/magisk/services/MonitorService.java index ea378f2ab..66ae75e1c 100644 --- a/app/src/main/java/com/topjohnwu/magisk/services/MonitorService.java +++ b/app/src/main/java/com/topjohnwu/magisk/services/MonitorService.java @@ -15,8 +15,8 @@ import android.support.v4.app.NotificationCompat; import android.util.Log; import android.view.accessibility.AccessibilityEvent; +import com.topjohnwu.magisk.MainActivity; import com.topjohnwu.magisk.R; -import com.topjohnwu.magisk.WelcomeActivity; import com.topjohnwu.magisk.utils.Logger; import com.topjohnwu.magisk.utils.PrefHelper; import com.topjohnwu.magisk.utils.Utils; @@ -112,7 +112,7 @@ public class MonitorService extends AccessibilityService { if (!PrefHelper.CheckBool("hide_root_notification", getApplicationContext())) { if (rootAction) { - Intent intent = new Intent(getApplication(), WelcomeActivity.class); + Intent intent = new Intent(getApplication(), MainActivity.class); intent.putExtra("relaunch", "relaunch"); String rootMessage; PendingIntent pendingIntent = PendingIntent.getActivity( diff --git a/app/src/main/res/drawable/ic_splash_activity.xml b/app/src/main/res/drawable/ic_splash_activity.xml new file mode 100644 index 000000000..fbc416e10 --- /dev/null +++ b/app/src/main/res/drawable/ic_splash_activity.xml @@ -0,0 +1,13 @@ + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_welcome.xml b/app/src/main/res/layout/activity_main.xml similarity index 100% rename from app/src/main/res/layout/activity_welcome.xml rename to app/src/main/res/layout/activity_main.xml diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 786d3bc0e..4a16c777e 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -24,4 +24,8 @@ + +