From e4cba70008347d669fec94857c652d301ddc53eb Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Thu, 29 Sep 2016 23:24:31 +0800 Subject: [PATCH] Ready for release --- app/build.gradle | 10 +- .../com/topjohnwu/magisk/AboutActivity.java | 8 +- .../com/topjohnwu/magisk/LogFragment.java | 114 ++++--- .../com/topjohnwu/magisk/MagiskFragment.java | 19 +- .../com/topjohnwu/magisk/MainActivity.java | 9 +- .../com/topjohnwu/magisk/ModulesAdapter.java | 1 - .../com/topjohnwu/magisk/ModulesFragment.java | 2 +- .../com/topjohnwu/magisk/ReposAdapter.java | 79 +++-- .../com/topjohnwu/magisk/RootFragment.java | 287 +++++++++--------- .../topjohnwu/magisk/SettingsFragment.java | 66 ++-- .../com/topjohnwu/magisk/SplashActivity.java | 7 +- .../com/topjohnwu/magisk/module/Module.java | 34 ++- .../magisk/receivers/AutoStartReceiver.java | 2 +- .../receivers/PrivateBroadcastReceiver.java | 2 +- .../com/topjohnwu/magisk/utils/Async.java | 55 +++- .../com/topjohnwu/magisk/utils/Utils.java | 30 +- app/src/main/res/anim/fade_in.xml | 8 - app/src/main/res/anim/fade_out.xml | 8 - app/src/main/res/drawable/ic_attach_money.xml | 9 + app/src/main/res/drawable/ic_done_black.xml | 9 - .../drawable/ic_system_update_alt_black.xml | 9 - app/src/main/res/layout/activity_about.xml | 25 +- app/src/main/res/layout/list_item_app.xml | 46 +-- app/src/main/res/menu/drawer.xml | 43 +-- app/src/main/res/menu/menu_module.xml | 11 - app/src/main/res/values/colors.xml | 6 - app/src/main/res/values/dimens.xml | 1 - app/src/main/res/values/strings.xml | 30 +- app/src/main/res/values/styles.xml | 8 - app/src/main/res/xml/uisettings.xml | 17 +- 30 files changed, 541 insertions(+), 414 deletions(-) delete mode 100644 app/src/main/res/anim/fade_in.xml delete mode 100644 app/src/main/res/anim/fade_out.xml create mode 100644 app/src/main/res/drawable/ic_attach_money.xml delete mode 100644 app/src/main/res/drawable/ic_done_black.xml delete mode 100644 app/src/main/res/drawable/ic_system_update_alt_black.xml delete mode 100644 app/src/main/res/menu/menu_module.xml diff --git a/app/build.gradle b/app/build.gradle index 55797f589..a4903422e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,13 +2,13 @@ apply plugin: 'com.android.application' android { compileSdkVersion 24 - buildToolsVersion "24.0.2" + buildToolsVersion "24.0.3" defaultConfig { applicationId "com.topjohnwu.magisk" minSdkVersion 21 targetSdkVersion 24 - versionCode 4 + versionCode 5 versionName "2.0" jackOptions { enabled true @@ -32,9 +32,9 @@ repositories { dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') - compile 'com.android.support:recyclerview-v7:24.2.0' - compile 'com.android.support:cardview-v7:24.2.0' - compile 'com.android.support:design:24.2.0' + compile 'com.android.support:recyclerview-v7:24.2.1' + compile 'com.android.support:cardview-v7:24.2.1' + compile 'com.android.support:design:24.2.1' compile 'com.github.d8ahazard:BroadcastTileSupportUpdate:master' compile 'com.getkeepsafe.taptargetview:taptargetview:1.2.0' compile 'com.jakewharton:butterknife:8.4.0' diff --git a/app/src/main/java/com/topjohnwu/magisk/AboutActivity.java b/app/src/main/java/com/topjohnwu/magisk/AboutActivity.java index 81cf1e330..35da88c57 100644 --- a/app/src/main/java/com/topjohnwu/magisk/AboutActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/AboutActivity.java @@ -29,7 +29,9 @@ import butterknife.ButterKnife; public class AboutActivity extends AppCompatActivity { private static final String SOURCE_CODE_URL = "https://github.com/topjohnwu/MagiskManager"; - private static final String XDA_THREAD = "http://forum.xda-developers.com/android/software/mod-magisk-v1-universal-systemless-t3432382"; + private static final String XDA_THREAD = "http://forum.xda-developers.com/showthread.php?t=3432382"; + private static final String DONATION_URL = "http://topjohnwu.github.io/donate"; + private AlertDialog.Builder builder; @BindView(R.id.toolbar) Toolbar toolbar; @@ -39,6 +41,7 @@ public class AboutActivity extends AppCompatActivity { @BindView(R.id.app_translators) RowItem appTranslators; @BindView(R.id.app_source_code) RowItem appSourceCode; @BindView(R.id.support_thread) RowItem supportThread; + @BindView(R.id.donation) RowItem donation; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -139,6 +142,9 @@ public class AboutActivity extends AppCompatActivity { supportThread.removeSummary(); supportThread.setOnClickListener(view -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(XDA_THREAD)))); + donation.removeSummary(); + donation.setOnClickListener(view -> startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(DONATION_URL)))); + setFloating(); } diff --git a/app/src/main/java/com/topjohnwu/magisk/LogFragment.java b/app/src/main/java/com/topjohnwu/magisk/LogFragment.java index 1b70f7d04..59ca46d4f 100644 --- a/app/src/main/java/com/topjohnwu/magisk/LogFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/LogFragment.java @@ -90,10 +90,7 @@ public class LogFragment extends Fragment { reloadErrorLog(); return true; case R.id.menu_send: - try { - send(); - } catch (NullPointerException ignored) { - } + send(); return true; case R.id.menu_save: save(); @@ -117,11 +114,23 @@ public class LogFragment extends Fragment { } private void send() { - Intent sendIntent = new Intent(); - sendIntent.setAction(Intent.ACTION_SEND); - sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(save())); - sendIntent.setType("application/html"); - startActivity(Intent.createChooser(sendIntent, getResources().getString(R.string.menuSend))); + new SaveLog() { + @Override + protected void onPostExecute(Boolean bool) { + super.onPostExecute(bool); + if (bool) { + Intent sendIntent = new Intent(); + sendIntent.setAction(Intent.ACTION_SEND); + sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(targetFile)); + sendIntent.setType("application/html"); + startActivity(Intent.createChooser(sendIntent, getResources().getString(R.string.menuSend))); + } else { + Toast.makeText(getActivity(), getString(R.string.logs_save_failed), Toast.LENGTH_LONG).show(); + } + + } + }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); + } @Override @@ -138,45 +147,66 @@ public class LogFragment extends Fragment { } } - @SuppressLint("DefaultLocale") - private File save() { - if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0); + private void save() { + new SaveLog(){ + @Override + protected void onPostExecute(Boolean bool) { + super.onPostExecute(bool); + if (bool) { + Toast.makeText(getActivity(), targetFile.toString(), Toast.LENGTH_LONG).show(); + } else { + Toast.makeText(getActivity(), getString(R.string.logs_save_failed), Toast.LENGTH_LONG).show(); + } } - return null; - } + }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); + } - if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { - Snackbar.make(txtLog, R.string.sdcard_not_writable, Snackbar.LENGTH_LONG).show(); - return null; - } + private class SaveLog extends AsyncTask { - Calendar now = Calendar.getInstance(); - String filename = String.format( - "magisk_%s_%04d%02d%02d_%02d%02d%02d.log", "error", - now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1, - now.get(Calendar.DAY_OF_MONTH), now.get(Calendar.HOUR_OF_DAY), - now.get(Calendar.MINUTE), now.get(Calendar.SECOND)); + File targetFile; - File dir = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/Magisk/"); - dir.mkdir(); - - File targetFile = new File(dir, filename); - List in = Utils.readFile(MAGISK_LOG); - - try { - FileWriter out = new FileWriter(targetFile); - for (String line : in) { - out.write(line + "\n"); + @SuppressLint("DefaultLocale") + @Override + protected Boolean doInBackground(Void... voids) { + if (ActivityCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0); + } + return false; } - out.close(); - Toast.makeText(getActivity(), targetFile.toString(), Toast.LENGTH_LONG).show(); - return targetFile; - } catch (IOException e) { - Toast.makeText(getActivity(), getResources().getString(R.string.logs_save_failed) + "\n" + e.getMessage(), Toast.LENGTH_LONG).show(); - return null; + if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { + return false; + } + + Calendar now = Calendar.getInstance(); + String filename = String.format( + "magisk_%s_%04d%02d%02d_%02d%02d%02d.log", "error", + now.get(Calendar.YEAR), now.get(Calendar.MONTH) + 1, + now.get(Calendar.DAY_OF_MONTH), now.get(Calendar.HOUR_OF_DAY), + now.get(Calendar.MINUTE), now.get(Calendar.SECOND)); + + targetFile = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + "/MagiskManager/" + filename); + + if ((!targetFile.getParentFile().exists() && !targetFile.getParentFile().mkdirs()) || (targetFile.exists() && !targetFile.delete())) { + return false; + } + + List in = Utils.readFile(MAGISK_LOG); + + try { + FileWriter out = new FileWriter(targetFile); + for (String line : in) { + out.write(line + "\n"); + } + out.close(); + + + return true; + } catch (IOException e) { + e.printStackTrace(); + return false; + } } } diff --git a/app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java b/app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java index 7dcb0e001..a7e616675 100644 --- a/app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/MagiskFragment.java @@ -152,7 +152,7 @@ public class MagiskFragment extends Fragment { private void updateUI() { String theme = PreferenceManager.getDefaultSharedPreferences(getActivity()).getString("theme", ""); if (theme.equals("Dark")) { - builder = new AlertDialog.Builder(getActivity(),R.style.AlertDialog_dh); + builder = new AlertDialog.Builder(getActivity(), R.style.AlertDialog_dh); } else { builder = new AlertDialog.Builder(getActivity()); } @@ -190,11 +190,28 @@ public class MagiskFragment extends Fragment { "Magisk-v" + String.valueOf(remoteMagiskVersion) + ".zip")) .setNegativeButton(R.string.no_thanks, null) .show()); + } else { magiskCheckUpdatesContainer.setBackgroundColor(colorOK); magiskCheckUpdatesIcon.setImageResource(R.drawable.ic_check_circle); magiskCheckUpdatesStatus.setText(getString(R.string.up_to_date, getString(R.string.magisk))); magiskCheckUpdatesStatus.setTextColor(colorOK); + magiskUpdateView.setOnClickListener(view -> builder + .setTitle(getString(R.string.repo_install_title, getString(R.string.magisk))) + .setMessage(getString(R.string.repo_install_msg, "Magisk-v" + String.valueOf(remoteMagiskVersion))) + .setCancelable(true) + .setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.downloadAndReceive( + getActivity(), + new DownloadReceiver() { + @Override + public void task(Uri uri) { + new Async.FlashZIP(mContext, uri).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); + } + }, + magiskLink, + "Magisk-v" + String.valueOf(remoteMagiskVersion) + ".zip")) + .setNegativeButton(R.string.no_thanks, null) + .show()); } if (remoteAppVersionCode > BuildConfig.VERSION_CODE) { diff --git a/app/src/main/java/com/topjohnwu/magisk/MainActivity.java b/app/src/main/java/com/topjohnwu/magisk/MainActivity.java index b9cd163e5..ac07e9432 100644 --- a/app/src/main/java/com/topjohnwu/magisk/MainActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/MainActivity.java @@ -35,12 +35,9 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On private final Handler mDrawerHandler = new Handler(); private String currentTitle; - @BindView(R.id.toolbar) - Toolbar toolbar; - @BindView(R.id.drawer_layout) - DrawerLayout drawer; - @BindView(R.id.nav_view) - NavigationView navigationView; + @BindView(R.id.toolbar) Toolbar toolbar; + @BindView(R.id.drawer_layout) DrawerLayout drawer; + @BindView(R.id.nav_view) NavigationView navigationView; @IdRes private int mSelectedId = R.id.magisk; diff --git a/app/src/main/java/com/topjohnwu/magisk/ModulesAdapter.java b/app/src/main/java/com/topjohnwu/magisk/ModulesAdapter.java index 1110f814b..118185ebd 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ModulesAdapter.java +++ b/app/src/main/java/com/topjohnwu/magisk/ModulesAdapter.java @@ -67,7 +67,6 @@ public class ModulesAdapter extends RecyclerView.Adapter { recyclerView.setVisibility(View.GONE); prefs.edit().putBoolean("module_done", false).apply(); - new Async.LoadModules(getActivity()).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); + new Async.LoadModules(getActivity()).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); }); if (prefs.getBoolean("module_done", false)) { diff --git a/app/src/main/java/com/topjohnwu/magisk/ReposAdapter.java b/app/src/main/java/com/topjohnwu/magisk/ReposAdapter.java index 5e4257c60..a15ee6848 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ReposAdapter.java +++ b/app/src/main/java/com/topjohnwu/magisk/ReposAdapter.java @@ -4,9 +4,12 @@ import android.animation.Animator; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.content.Context; +import android.content.Intent; import android.graphics.Color; import android.net.Uri; import android.os.AsyncTask; +import android.preference.PreferenceManager; +import android.support.v7.app.AlertDialog; import android.support.v7.widget.RecyclerView; import android.util.DisplayMetrics; import android.util.Log; @@ -39,6 +42,7 @@ public class ReposAdapter extends RecyclerView.Adapter private final List mList; private View mView; private Context context; + private AlertDialog.Builder builder; public ReposAdapter(List list) { mList = list; @@ -49,6 +53,14 @@ public class ReposAdapter extends RecyclerView.Adapter mView = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_repo, parent, false); ButterKnife.bind(this, mView); context = parent.getContext(); + + String theme = PreferenceManager.getDefaultSharedPreferences(context).getString("theme", ""); + if (theme.equals("Dark")) { + builder = new AlertDialog.Builder(context,R.style.AlertDialog_dh); + } else { + builder = new AlertDialog.Builder(context); + } + return new ViewHolder(mView); } @@ -75,44 +87,51 @@ public class ReposAdapter extends RecyclerView.Adapter View.OnClickListener listener = view -> { if (view.getId() == holder.updateImage.getId()) { - Utils.downloadAndReceive( - context, - new DownloadReceiver(repo.getName() + "-" + repo.getVersion()) { - @Override - public void task(Uri uri) { - new Async.FlashZIP(context, uri, mName) { + String fullname = repo.getName() + "-" + repo.getVersion(); + builder + .setTitle(context.getString(R.string.repo_install_title, repo.getName())) + .setMessage(context.getString(R.string.repo_install_msg, fullname)) + .setCancelable(true) + .setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.downloadAndReceive( + context, + new DownloadReceiver(fullname) { @Override - protected void preProcessing() throws Throwable { - super.preProcessing(); - new File(mUri.getPath()).delete(); - Shell.su( - "cd " + mFile.getParent(), - "mkdir git", - "unzip -o install.zip -d git", - "mv git/* install", - "cd install", - "rm -rf system/placeholder", - "chmod 644 $(find . -type f)", - "chmod 755 $(find . -type d)", - "rm -rf ../install.zip ../git", - "zip -r ../install.zip *", - "rm -rf ../install" - ); + public void task(Uri uri) { + new Async.FlashZIP(context, uri, mName) { + @Override + protected void preProcessing() throws Throwable { + super.preProcessing(); + new File(mUri.getPath()).delete(); + Shell.su( + "cd " + mFile.getParent(), + "mkdir git", + "unzip -o install.zip -d git", + "mv git/* install", + "cd install", + "rm -rf system/placeholder", + "chmod 644 $(find . -type f)", + "chmod 755 $(find . -type d)", + "rm -rf ../install.zip ../git", + "zip -r ../install.zip *", + "rm -rf ../install" + ); + } + }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); } - }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); - } - }, - repo.getZipUrl(), - repo.getId().replace(" ", "") + ".zip"); + }, + repo.getZipUrl(), + repo.getId().replace(" ", "") + ".zip")) + .setNegativeButton(R.string.no_thanks, null) + .show(); } if ((view.getId() == holder.changeLog.getId()) && (!repo.getLogUrl().equals(""))) { - new WebWindow("Changelog", repo.getLogUrl(), context); + new WebWindow(context.getString(R.string.changelog), repo.getLogUrl(), context); } if ((view.getId() == holder.authorLink.getId()) && (!repo.getSupportUrl().equals(""))) { - new WebWindow("Donate", repo.getDonateUrl(), context); + context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(repo.getDonateUrl()))); } if ((view.getId() == holder.supportLink.getId()) && (!repo.getSupportUrl().equals(""))) { - new WebWindow("Support", repo.getSupportUrl(), context); + context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(repo.getSupportUrl()))); } }; diff --git a/app/src/main/java/com/topjohnwu/magisk/RootFragment.java b/app/src/main/java/com/topjohnwu/magisk/RootFragment.java index 24119c7d0..55670eb3c 100644 --- a/app/src/main/java/com/topjohnwu/magisk/RootFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/RootFragment.java @@ -89,6 +89,8 @@ public class RootFragment extends Fragment { ta3.recycle(); autoRootStatus = Utils.autoToggleEnabled(getActivity()); + prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); + if (autoRootStatus) { if (!Utils.hasServicePermission(getActivity())) { autoRootStatus = false; @@ -96,9 +98,18 @@ public class RootFragment extends Fragment { } rootToggle.setEnabled(!autoRootStatus); autoRootToggle.setChecked(autoRootStatus); - new updateUI().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); + updateUI(); - rootToggle.setOnClickListener(toggle -> Utils.toggleRoot(((CompoundButton) toggle).isChecked(), getActivity())); + rootToggle.setOnClickListener(toggle -> { + new AsyncTask() { + @Override + protected Void doInBackground(Boolean... bools) { + Utils.toggleRoot(bools[0], getActivity()); + return null; + } + }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, ((CompoundButton) toggle).isChecked()); + + }); autoRootToggle.setOnClickListener(toggle -> { if (!Utils.hasServicePermission(getActivity())) { @@ -106,7 +117,7 @@ public class RootFragment extends Fragment { Toast.makeText(getActivity(), "Please enable accessibility access for Magisk's auto-toggle feature to work.", Toast.LENGTH_LONG).show(); startActivityForResult(intent, 100); } else { - ToggleAutoRoot(autoRootToggle.isChecked()); + toggleAutoRoot(autoRootToggle.isChecked()); } } @@ -114,19 +125,45 @@ public class RootFragment extends Fragment { ); selinuxToggle.setOnClickListener(toggle -> { - Shell.su(((CompoundButton) toggle).isChecked() ? "setenforce 1" : "setenforce 0"); - new updateUI().executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); + + new AsyncTask() { + @Override + protected Void doInBackground(Boolean... bools) { + Shell.su(bools[0] ? "setenforce 1" : "setenforce 0"); + return null; + } + @Override + protected void onPostExecute(Void v) { + super.onPostExecute(v); + updateUI(); + } + }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, ((CompoundButton) toggle).isChecked()); }); return view; } + @Override + public void onResume() { + super.onResume(); + getActivity().setTitle(R.string.root); + listener = (pref, key) -> { + + if ((key.contains("autoRootEnable")) || (key.equals("root"))) { + Logger.dev("RootFragmnet, keychange detected for " + key); + //new updateUI().execute(); + updateUI(); + } + + }; + prefs.registerOnSharedPreferenceChangeListener(listener); + updateUI(); + } + @Override public void onDestroy() { super.onDestroy(); - if (null != listener) { - prefs.unregisterOnSharedPreferenceChangeListener(listener); - } + prefs.unregisterOnSharedPreferenceChangeListener(listener); } @Override @@ -135,7 +172,7 @@ public class RootFragment extends Fragment { Log.d("Magisk", "Got result: " + requestCode + " and " + resultCode); if (requestCode == 100) { if (Utils.hasServicePermission(getActivity())) { - ToggleAutoRoot(true); + toggleAutoRoot(true); Snackbar.make(view, getActivity().getString(R.string.auto_toggle) + " has been enabled.", Snackbar.LENGTH_LONG).show(); } else { @@ -146,7 +183,7 @@ public class RootFragment extends Fragment { } } - private void ToggleAutoRoot(boolean toggleState) { + private void toggleAutoRoot(boolean toggleState) { autoRootStatus = toggleState; Utils.toggleAutoRoot(toggleState, getActivity()); if (toggleState) { @@ -166,155 +203,119 @@ public class RootFragment extends Fragment { } - @Override - public void onResume() { - super.onResume(); - getActivity().setTitle("Root"); - prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); - listener = (prefs1, key) -> { + private void updateUI() { + autoRootToggle.setChecked(autoRootStatus); + progressBar.setVisibility(View.GONE); + rootStatusView.setVisibility(View.VISIBLE); + safetynetStatusView.setVisibility(View.VISIBLE); + selinuxStatusView.setVisibility(View.VISIBLE); - if ((key.contains("autoRootEnable")) | (key.equals("root"))) { - Logger.dev("RootFragmnet, keychange detected for " + key); - new updateUI().execute(); - } - - }; - - prefs.registerOnSharedPreferenceChangeListener(listener); - new updateUI().execute(); - - } - - public class updateUI extends AsyncTask { - - @Override - protected Void doInBackground(Void... voids) { - // Make sure static block invoked - Shell.rootAccess(); - // Set up Tile on UI Refresh - if (PreferenceManager.getDefaultSharedPreferences(getActivity()).getBoolean("enable_quicktile", false)) { - Utils.SetupQuickSettingsTile(getActivity()); - } - autoRootStatus = Utils.autoToggleEnabled(getActivity()); - return null; + if (Shell.rootAccess()) { + rootToggleView.setVisibility(View.VISIBLE); + autoRootToggleView.setVisibility(View.VISIBLE); + selinuxToggleView.setVisibility(View.VISIBLE); } - @Override - protected void onPostExecute(Void v) { - super.onPostExecute(v); - autoRootToggle.setChecked(autoRootStatus); - progressBar.setVisibility(View.GONE); - rootStatusView.setVisibility(View.VISIBLE); - safetynetStatusView.setVisibility(View.VISIBLE); - selinuxStatusView.setVisibility(View.VISIBLE); + List selinux = Shell.sh("getenforce"); - if (Shell.rootAccess()) { - rootToggleView.setVisibility(View.VISIBLE); - autoRootToggleView.setVisibility(View.VISIBLE); - selinuxToggleView.setVisibility(View.VISIBLE); - } + if (selinux.isEmpty()) { + selinuxStatusContainer.setBackgroundColor(colorNeutral); + selinuxStatusIcon.setImageResource(statusUnknown); - List selinux = Shell.sh("getenforce"); + selinuxStatus.setText(R.string.selinux_error_info); + selinuxStatus.setTextColor(colorNeutral); + selinuxToggle.setChecked(false); + } else if (selinux.get(0).equals("Enforcing")) { + selinuxStatusContainer.setBackgroundColor(colorOK); + selinuxStatusIcon.setImageResource(statusOK); - if (selinux.isEmpty()) { - selinuxStatusContainer.setBackgroundColor(colorNeutral); - selinuxStatusIcon.setImageResource(statusUnknown); + selinuxStatus.setText(R.string.selinux_enforcing_info); + selinuxStatus.setTextColor(colorOK); + selinuxToggle.setChecked(true); + } else { + selinuxStatusContainer.setBackgroundColor(colorFail); + selinuxStatusIcon.setImageResource(statusError); - selinuxStatus.setText(R.string.selinux_error_info); - selinuxStatus.setTextColor(colorNeutral); - selinuxToggle.setChecked(false); - } else if (selinux.get(0).equals("Enforcing")) { - selinuxStatusContainer.setBackgroundColor(colorOK); - selinuxStatusIcon.setImageResource(statusOK); + selinuxStatus.setText(R.string.selinux_permissive_info); + selinuxStatus.setTextColor(colorFail); + selinuxToggle.setChecked(false); + } - selinuxStatus.setText(R.string.selinux_enforcing_info); - selinuxStatus.setTextColor(colorOK); - selinuxToggle.setChecked(true); - } else { - selinuxStatusContainer.setBackgroundColor(colorFail); - selinuxStatusIcon.setImageResource(statusError); + if (new File("/system/framework/twframework.jar").exists()) { + selinuxStatus.append("\n" + getString(R.string.selinux_samsung_info)); + } - selinuxStatus.setText(R.string.selinux_permissive_info); - selinuxStatus.setTextColor(colorFail); - selinuxToggle.setChecked(false); - } - - if (new File("/system/framework/twframework.jar").exists()) { - selinuxStatus.append("\n" + getString(R.string.selinux_samsung_info)); - } - - switch (Shell.rootStatus) { - case -1: - // Root Error - rootStatusContainer.setBackgroundColor(colorFail); - rootStatusIcon.setImageResource(statusUnknown); - rootStatus.setTextColor(colorNeutral); - rootStatus.setText(R.string.root_error); - rootToggle.setChecked(false); - safetyNetStatusIcon.setImageResource(statusUnknown); - safetyNetStatus.setText(R.string.root_error_info); - break; - case 0: - // Not rooted + switch (Shell.rootStatus) { + case -1: + // Root Error + rootStatusContainer.setBackgroundColor(colorFail); + rootStatusIcon.setImageResource(statusUnknown); + rootStatus.setTextColor(colorNeutral); + rootStatus.setText(R.string.root_error); + rootToggle.setChecked(false); + safetyNetStatusIcon.setImageResource(statusUnknown); + safetyNetStatus.setText(R.string.root_error_info); + break; + case 0: + // Not rooted + rootStatusContainer.setBackgroundColor(colorOK); + rootStatusIcon.setImageResource(statusOK); + rootStatus.setTextColor(colorOK); + rootStatus.setText(R.string.root_none); + rootToggle.setChecked(false); + safetyNetStatusIcon.setImageResource(statusOK); + safetyNetStatus.setText(R.string.root_none_info); + break; + case 1: + // Proper root + if (autoRootStatus) { rootStatusContainer.setBackgroundColor(colorOK); - rootStatusIcon.setImageResource(statusOK); + rootStatusIcon.setImageResource(statusAuto); + rootStatusIcon.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP); rootStatus.setTextColor(colorOK); - rootStatus.setText(R.string.root_none); - rootToggle.setChecked(false); + rootStatus.setText(R.string.root_auto_unmounted); + rootToggle.setEnabled(false); + autoRootToggle.setChecked(true); safetyNetStatusIcon.setImageResource(statusOK); - safetyNetStatus.setText(R.string.root_none_info); + safetyNetStatus.setText(R.string.root_auto_unmounted_info); break; - case 1: - // Proper root - if (autoRootStatus) { - rootStatusContainer.setBackgroundColor(colorOK); - rootStatusIcon.setImageResource(statusAuto); - rootStatusIcon.setColorFilter(Color.WHITE, PorterDuff.Mode.SRC_ATOP); - rootStatus.setTextColor(colorOK); - rootStatus.setText(R.string.root_auto_unmounted); - rootToggle.setEnabled(false); - autoRootToggle.setChecked(true); - safetyNetStatusIcon.setImageResource(statusOK); - safetyNetStatus.setText(R.string.root_auto_unmounted_info); + } else { + rootToggle.setEnabled(true); + if (Utils.rootEnabled()) { + // Mounted + rootStatusContainer.setBackgroundColor(colorWarn); + rootStatusIcon.setImageResource(statusError); + rootStatus.setTextColor(colorWarn); + rootStatus.setText(R.string.root_enabled); + rootToggle.setChecked(true); + safetyNetStatusIcon.setImageResource(statusError); + safetyNetStatus.setText(R.string.root_enabled_info); break; } else { - rootToggle.setEnabled(true); - if (Utils.rootEnabled()) { - // Mounted - rootStatusContainer.setBackgroundColor(colorWarn); - rootStatusIcon.setImageResource(statusError); - rootStatus.setTextColor(colorWarn); - rootStatus.setText(R.string.root_enabled); - rootToggle.setChecked(true); - safetyNetStatusIcon.setImageResource(statusError); - safetyNetStatus.setText(R.string.root_enabled_info); - break; - } else { - // Disabled - rootStatusContainer.setBackgroundColor(colorOK); - rootStatusIcon.setImageResource(statusOK); - rootStatus.setTextColor(colorOK); - rootStatus.setText(R.string.root_disabled); - rootToggle.setChecked(false); - safetyNetStatusIcon.setImageResource(statusOK); - safetyNetStatus.setText(R.string.root_disabled_info); - break; - } + // Disabled + rootStatusContainer.setBackgroundColor(colorOK); + rootStatusIcon.setImageResource(statusOK); + rootStatus.setTextColor(colorOK); + rootStatus.setText(R.string.root_disabled); + rootToggle.setChecked(false); + safetyNetStatusIcon.setImageResource(statusOK); + safetyNetStatus.setText(R.string.root_disabled_info); + break; } - case 2: - // Improper root - rootStatusContainer.setBackgroundColor(colorFail); - rootStatusIcon.setImageResource(statusError); - rootStatus.setTextColor(colorFail); - rootStatus.setText(R.string.root_system); - rootToggle.setChecked(true); - safetyNetStatusIcon.setImageResource(statusError); - safetyNetStatus.setText(R.string.root_system_info); - autoRootToggleView.setVisibility(View.GONE); - rootToggleView.setVisibility(View.GONE); - selinuxToggleView.setVisibility(View.GONE); - break; - } + } + case 2: + // Improper root + rootStatusContainer.setBackgroundColor(colorFail); + rootStatusIcon.setImageResource(statusError); + rootStatus.setTextColor(colorFail); + rootStatus.setText(R.string.root_system); + rootToggle.setChecked(true); + safetyNetStatusIcon.setImageResource(statusError); + safetyNetStatus.setText(R.string.root_system_info); + autoRootToggleView.setVisibility(View.GONE); + rootToggleView.setVisibility(View.GONE); + selinuxToggleView.setVisibility(View.GONE); + break; } } diff --git a/app/src/main/java/com/topjohnwu/magisk/SettingsFragment.java b/app/src/main/java/com/topjohnwu/magisk/SettingsFragment.java index f04b25e9e..7dcbed811 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SettingsFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/SettingsFragment.java @@ -2,6 +2,7 @@ package com.topjohnwu.magisk; import android.content.Intent; import android.content.SharedPreferences; +import android.os.AsyncTask; import android.os.Bundle; import android.preference.CheckBoxPreference; import android.preference.ListPreference; @@ -12,19 +13,18 @@ import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.Toast; +import com.topjohnwu.magisk.utils.Async; import com.topjohnwu.magisk.utils.Logger; import com.topjohnwu.magisk.utils.Utils; import butterknife.ButterKnife; public class SettingsFragment extends PreferenceFragment implements SharedPreferences.OnSharedPreferenceChangeListener { - private CheckBoxPreference quickTilePreference; + private CheckBoxPreference quickTilePreference, busyboxPreference; private ListPreference themePreference; - public SettingsFragment() { - } - @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -50,9 +50,10 @@ public class SettingsFragment extends PreferenceFragment implements SharedPrefer @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); - ButterKnife.bind(this, view); - quickTilePreference = (CheckBoxPreference) findPreference("enable_quicktile"); themePreference = (ListPreference) findPreference("theme"); + busyboxPreference = (CheckBoxPreference) findPreference("busybox"); + quickTilePreference = (CheckBoxPreference) findPreference("enable_quicktile") ; + busyboxPreference.setChecked(Utils.commandExists("unzip")); PreferenceManager.getDefaultSharedPreferences(getActivity()).registerOnSharedPreferenceChangeListener(this); CheckBoxPreference keepRootOffPreference = (CheckBoxPreference) findPreference("keep_root_off"); CheckBoxPreference hideRootNotificationPreference = (CheckBoxPreference) findPreference("hide_root_notification"); @@ -67,21 +68,6 @@ public class SettingsFragment extends PreferenceFragment implements SharedPrefer hideRootNotificationPreference.setEnabled(true); } - Preference.OnPreferenceClickListener preferenceClickListener = preference -> { - if (preference == quickTilePreference) { - boolean isChecked = quickTilePreference.isChecked(); - if (isChecked) { - Utils.installTile(getActivity()); - } else { - Utils.uninstallTile(getActivity()); - } - - } - - return false; - }; - - quickTilePreference.setOnPreferenceClickListener(preferenceClickListener); // calculate margins int horizontalMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics()); int verticalMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, getResources().getDisplayMetrics()); @@ -118,6 +104,44 @@ public class SettingsFragment extends PreferenceFragment implements SharedPrefer Logger.dev("SettingsFragment: theme is " + pref); + } else if (key.equals("enable_quicktile")) { + boolean checked = sharedPreferences.getBoolean("enable_quicktile", false); + if (checked) { + new AsyncTask () { + @Override + protected Boolean doInBackground(Void... voids) { + return Utils.installTile(getActivity()); + } + @Override + protected void onPostExecute(Boolean result) { + super.onPostExecute(result); + if (result) { + Toast.makeText(getActivity(), "Tile installed", Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(getActivity(), "Tile installation error", Toast.LENGTH_SHORT).show(); + } + } + }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); + } else { + new AsyncTask () { + @Override + protected Boolean doInBackground(Void... voids) { + return Utils.uninstallTile(getActivity()); + } + @Override + protected void onPostExecute(Boolean result) { + super.onPostExecute(result); + if (result) { + Toast.makeText(getActivity(), "Tile uninstalled", Toast.LENGTH_SHORT).show(); + } else { + Toast.makeText(getActivity(), "Tile uninstallation error", Toast.LENGTH_SHORT).show(); + } + } + }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); + } + } else if (key.equals("busybox")) { + boolean checked = sharedPreferences.getBoolean("busybox", false); + new Async.LinkBusyBox(checked).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); } } diff --git a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java index d5bae8e33..302abc7ee 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java @@ -19,7 +19,6 @@ public class SplashActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); SharedPreferences defaultPrefs = PreferenceManager.getDefaultSharedPreferences(getApplication()); if (defaultPrefs.getString("theme","").equals("Dark")) { @@ -35,8 +34,8 @@ public class SplashActivity extends AppCompatActivity { set.add("com.google.android.gms"); set.add("com.google.commerce.tapandpay"); editor.putStringSet("auto_blacklist", set); - editor.putBoolean("autoRootEnable",false); - editor.putBoolean("root",Utils.rootEnabled()); + editor.putBoolean("autoRootEnable", false); + editor.putBoolean("root", Utils.rootEnabled()); editor.apply(); } @@ -56,7 +55,7 @@ public class SplashActivity extends AppCompatActivity { } // Set up quick settings tile - Utils.SetupQuickSettingsTile(getApplicationContext()); + Utils.setupQuickSettingsTile(getApplicationContext()); // Initialize Utils.init(this); diff --git a/app/src/main/java/com/topjohnwu/magisk/module/Module.java b/app/src/main/java/com/topjohnwu/magisk/module/Module.java index 74c201975..833638667 100644 --- a/app/src/main/java/com/topjohnwu/magisk/module/Module.java +++ b/app/src/main/java/com/topjohnwu/magisk/module/Module.java @@ -1,5 +1,7 @@ package com.topjohnwu.magisk.module; +import android.os.AsyncTask; + import com.topjohnwu.magisk.utils.Logger; import com.topjohnwu.magisk.utils.ModuleHelper; import com.topjohnwu.magisk.utils.Utils; @@ -34,11 +36,23 @@ public class Module extends BaseModule { } public void createDisableFile() { - mEnable = !Utils.createFile(mDisableFile); + new AsyncTask() { + @Override + protected Void doInBackground(Void... voids) { + mEnable = !Utils.createFile(mDisableFile); + return null; + } + }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); } public void removeDisableFile() { - mEnable = Utils.removeFile(mDisableFile); + new AsyncTask() { + @Override + protected Void doInBackground(Void... voids) { + mEnable = Utils.removeFile(mDisableFile); + return null; + } + }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); } public boolean isEnabled() { @@ -46,11 +60,23 @@ public class Module extends BaseModule { } public void createRemoveFile() { - mRemove = Utils.createFile(mRemoveFile); + new AsyncTask() { + @Override + protected Void doInBackground(Void... voids) { + mRemove = Utils.createFile(mRemoveFile); + return null; + } + }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); } public void deleteRemoveFile() { - mRemove = !Utils.removeFile(mRemoveFile); + new AsyncTask() { + @Override + protected Void doInBackground(Void... voids) { + mRemove = !Utils.removeFile(mRemoveFile); + return null; + } + }.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); } public boolean willBeRemoved() { diff --git a/app/src/main/java/com/topjohnwu/magisk/receivers/AutoStartReceiver.java b/app/src/main/java/com/topjohnwu/magisk/receivers/AutoStartReceiver.java index 9fb694943..0049e3e7f 100644 --- a/app/src/main/java/com/topjohnwu/magisk/receivers/AutoStartReceiver.java +++ b/app/src/main/java/com/topjohnwu/magisk/receivers/AutoStartReceiver.java @@ -19,7 +19,7 @@ public class AutoStartReceiver extends BroadcastReceiver { Utils.toggleRoot(false, context); } if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("enable_quicktile", false)) { - Utils.SetupQuickSettingsTile(context); + Utils.setupQuickSettingsTile(context); } diff --git a/app/src/main/java/com/topjohnwu/magisk/receivers/PrivateBroadcastReceiver.java b/app/src/main/java/com/topjohnwu/magisk/receivers/PrivateBroadcastReceiver.java index 1da217462..fec1d40a8 100644 --- a/app/src/main/java/com/topjohnwu/magisk/receivers/PrivateBroadcastReceiver.java +++ b/app/src/main/java/com/topjohnwu/magisk/receivers/PrivateBroadcastReceiver.java @@ -32,6 +32,6 @@ public final class PrivateBroadcastReceiver extends BroadcastReceiver { Utils.toggleRoot(false, context); } - Utils.SetupQuickSettingsTile(context); + Utils.setupQuickSettingsTile(context); } } \ No newline at end of file diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/Async.java b/app/src/main/java/com/topjohnwu/magisk/utils/Async.java index 3e377e533..9b472340b 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/Async.java +++ b/app/src/main/java/com/topjohnwu/magisk/utils/Async.java @@ -46,16 +46,18 @@ public class Async { String busybox = mContext.getApplicationInfo().dataDir + "/lib/libbusybox.so"; String zip = mContext.getApplicationInfo().dataDir + "/lib/libzip.so"; if (Shell.rootAccess()) { - if (!Utils.commandExists("unzip") || !Utils.commandExists("zip") || !Utils.itemExist(toolPath)) { + if (!Utils.itemExist(toolPath)) { Shell.sh( "rm -rf " + toolPath, "mkdir " + toolPath, "chmod 755 " + toolPath, - "ln -s " + busybox + " " + toolPath + "/busybox", - "for tool in $(" + toolPath + "/busybox --list); do", - "ln -s " + busybox + " " + toolPath + "/$tool", + "cd " + toolPath, + "ln -s " + busybox + " busybox", + "for tool in $(./busybox --list); do", + "ln -s " + busybox + " $tool", "done", - "ln -s " + zip + " " + toolPath + "/zip" + "rm -f su sh", + "ln -s " + zip + " zip" ); } } @@ -165,15 +167,18 @@ public class Async { mContext = context; mUri = uri; Cursor c = mContext.getContentResolver().query(uri, null, null, null, null); - int nameIndex = c.getColumnIndex(OpenableColumns.DISPLAY_NAME); - c.moveToFirst(); - if (nameIndex != -1) { - mName = c.getString(nameIndex); - } else { + if (c != null) { + int nameIndex = c.getColumnIndex(OpenableColumns.DISPLAY_NAME); + c.moveToFirst(); + if (nameIndex != -1) { + mName = c.getString(nameIndex); + } + c.close(); + } + if (mName == null) { int idx = uri.getPath().lastIndexOf('/'); mName = uri.getPath().substring(idx + 1); } - c.close(); copyToSD = false; } @@ -296,6 +301,10 @@ public class Async { } protected void done() { + SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext); + prefs.edit().putBoolean("module_done", false).apply(); + new LoadModules(mContext).executeOnExecutor(AsyncTask.SERIAL_EXECUTOR); + AlertDialog.Builder builder; String theme = PreferenceManager.getDefaultSharedPreferences(mContext).getString("theme", ""); if (theme.equals("Dark")) { @@ -306,9 +315,31 @@ public class Async { builder .setTitle(R.string.reboot_title) .setMessage(R.string.reboot_msg) - .setPositiveButton(R.string.reboot, (dialogInterface1, i) -> Shell.su("sh -c reboot")) + .setPositiveButton(R.string.reboot, (dialogInterface1, i) -> Shell.sh("su -c reboot")) .setNegativeButton(R.string.no_thanks, null) .show(); } } + + public static class LinkBusyBox extends AsyncTask { + + private boolean link; + + public LinkBusyBox(boolean b) { + link = b; + } + + @Override + protected Void doInBackground(Void... voids) { + if (link) { + Shell.su( + "rm -rf /magisk/.core/busybox", + "ln -s /data/busybox /magisk/.core/busybox" + ); + } else { + Shell.su("rm -rf /magisk/.core/busybox"); + } + return null; + } + } } diff --git a/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java b/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java index 02e356652..2236f572b 100644 --- a/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java +++ b/app/src/main/java/com/topjohnwu/magisk/utils/Utils.java @@ -23,7 +23,6 @@ import android.widget.Toast; import com.kcoppock.broadcasttilesupport.BroadcastTileIntentBuilder; import com.topjohnwu.magisk.MagiskFragment; import com.topjohnwu.magisk.R; -import com.topjohnwu.magisk.module.BaseModule; import com.topjohnwu.magisk.receivers.DownloadReceiver; import com.topjohnwu.magisk.receivers.PrivateBroadcastReceiver; import com.topjohnwu.magisk.services.MonitorService; @@ -36,7 +35,6 @@ import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.spec.InvalidKeySpecException; import java.util.Arrays; -import java.util.Comparator; import java.util.LinkedList; import java.util.List; @@ -63,7 +61,7 @@ public class Utils { MagiskFragment.magiskVersion = Integer.parseInt(ret.get(0)); } String toolPath = context.getApplicationInfo().dataDir + "/tools"; - Shell.su("PATH=$PATH:" + toolPath); + Shell.su("PATH=" + toolPath + ":$PATH"); } public static boolean itemExist(String path) { @@ -113,7 +111,7 @@ public class Utils { Shell.su("rm -rf /magisk/.core/bin", "setprop magisk.root 0"); } if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("enable_quicktile", false)) { - SetupQuickSettingsTile(context); + setupQuickSettingsTile(context); } PreferenceManager.getDefaultSharedPreferences(context).edit().putBoolean("root", b).apply(); } @@ -140,7 +138,7 @@ public class Utils { } } if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean("enable_quicktile", false)) { - SetupQuickSettingsTile(context); + setupQuickSettingsTile(context); } } @@ -174,7 +172,7 @@ public class Utils { } if ((!file.getParentFile().exists() && !file.getParentFile().mkdirs()) || (file.exists() && !file.delete())) { - Toast.makeText(context, R.string.toast_error_makedir, Toast.LENGTH_LONG).show(); + Toast.makeText(context, R.string.permissionNotGranted, Toast.LENGTH_LONG).show(); } DownloadManager downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE); @@ -208,7 +206,7 @@ public class Utils { return secret; } - public static void SetupQuickSettingsTile(Context mContext) { + public static void setupQuickSettingsTile(Context mContext) { Logger.dev("Utils: SetupQuickSettings called"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { Logger.dev("Utils: Starting N quick settings service"); @@ -266,7 +264,7 @@ public class Utils { } } - public static void installTile(Context context) { + public static boolean installTile(Context context) { String qsTileId; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { qsTileId = "custom(com.topjohnwu.magisk/.services.TileServiceNewApi)"; @@ -281,8 +279,7 @@ public class Utils { if (tiles.size() > 1) { for (String tile : tiles) { if (tile.equals(qsTileId)) { - Toast.makeText(context, "Tile already installed", Toast.LENGTH_SHORT).show(); - return; + return true; } } @@ -290,17 +287,16 @@ public class Utils { String newTiles = TextUtils.join(",", tiles); Logger.dev("Utils: NewtilesString is " + newTiles); Shell.su("settings put secure sysui_qs_tiles \"" + newTiles + "\""); - Toast.makeText(context, "Tile installed", Toast.LENGTH_SHORT).show(); if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) { Utils.refreshService(context); } - return; + return true; } } - Toast.makeText(context, "Tile installation error", Toast.LENGTH_SHORT).show(); + return false; } - public static void uninstallTile(Context context) { + public static boolean uninstallTile(Context context) { String qsTileId; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { @@ -323,17 +319,15 @@ public class Utils { if (isPresent) { String newTiles = TextUtils.join(",", tiles); Shell.su("settings put secure sysui_qs_tiles \"" + newTiles + "\""); - Toast.makeText(context, "Tile uninstalled", Toast.LENGTH_SHORT).show(); if (Build.VERSION.SDK_INT == Build.VERSION_CODES.M) { Utils.refreshService(context); } - return; } - Toast.makeText(context, "Tile already uninstalled", Toast.LENGTH_SHORT).show(); + return true; } } - Toast.makeText(context, "Tile uninstallation error", Toast.LENGTH_SHORT).show(); + return false; } private static void refreshService(Context context) { diff --git a/app/src/main/res/anim/fade_in.xml b/app/src/main/res/anim/fade_in.xml deleted file mode 100644 index f1d8eed54..000000000 --- a/app/src/main/res/anim/fade_in.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/anim/fade_out.xml b/app/src/main/res/anim/fade_out.xml deleted file mode 100644 index a5f9254e1..000000000 --- a/app/src/main/res/anim/fade_out.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_attach_money.xml b/app/src/main/res/drawable/ic_attach_money.xml new file mode 100644 index 000000000..4fb28d7f4 --- /dev/null +++ b/app/src/main/res/drawable/ic_attach_money.xml @@ -0,0 +1,9 @@ + + + diff --git a/app/src/main/res/drawable/ic_done_black.xml b/app/src/main/res/drawable/ic_done_black.xml deleted file mode 100644 index 7affe9ba9..000000000 --- a/app/src/main/res/drawable/ic_done_black.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/drawable/ic_system_update_alt_black.xml b/app/src/main/res/drawable/ic_system_update_alt_black.xml deleted file mode 100644 index fb2d85e57..000000000 --- a/app/src/main/res/drawable/ic_system_update_alt_black.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - diff --git a/app/src/main/res/layout/activity_about.xml b/app/src/main/res/layout/activity_about.xml index 83340256b..828892bb6 100644 --- a/app/src/main/res/layout/activity_about.xml +++ b/app/src/main/res/layout/activity_about.xml @@ -104,12 +104,27 @@ style="?attr/cardStyle" app:cardUseCompatPadding="true"> - + android:layout_marginBottom="8dp" + android:orientation="vertical"> + + + + + + diff --git a/app/src/main/res/layout/list_item_app.xml b/app/src/main/res/layout/list_item_app.xml index 6e1b27583..b3402a2fb 100644 --- a/app/src/main/res/layout/list_item_app.xml +++ b/app/src/main/res/layout/list_item_app.xml @@ -1,19 +1,19 @@ - + - + + android:src="@drawable/ic_menu_overflow_material"/> + diff --git a/app/src/main/res/menu/drawer.xml b/app/src/main/res/menu/drawer.xml index 371a009b0..e6775ce10 100644 --- a/app/src/main/res/menu/drawer.xml +++ b/app/src/main/res/menu/drawer.xml @@ -10,15 +10,7 @@ android:icon="@drawable/magisk" android:title="@string/magisk"/> - - + + + + + + + + + + + + - - - - - + \ No newline at end of file diff --git a/app/src/main/res/menu/menu_module.xml b/app/src/main/res/menu/menu_module.xml deleted file mode 100644 index fffc6982c..000000000 --- a/app/src/main/res/menu/menu_module.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 4bab5f5eb..542a451e3 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -4,27 +4,21 @@ #009688 #00796B #FFC107 - #212121 - #FFFFFF #757575 #F44336 #4CAF50 - #2196F3 #9E9E9E #FFC107 #3F51B5 #303F9F - #C5CAE9 #448AFF #dedede - #8A8A8A #dedede #313131 #FF9800 @color/dh_accent - @color/dh_primary_light @color/red500 diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index a7e1b21f2..2f67c4f6b 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -2,7 +2,6 @@ 650dp 500dp - 100dp 5sp 8dip 3dip diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ceb4f62c4..560bd492e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -24,7 +24,6 @@ Root Toggle - Auto Root SELinux Toggle Root Error @@ -48,7 +47,6 @@ (No info provided) No modules found - Module is not installed Module will be updated at next reboot Module will be removed at next reboot Module will not be removed at next reboot @@ -60,6 +58,7 @@ Update Available Installed Not Installed + Changelog Save to SD @@ -80,6 +79,7 @@ App\'s version Source code + Donation App\'s translators Support thread @@ -90,6 +90,8 @@ Accessibility service required for Magisk auto-unroot feature %1$s Update! New version v%2$s of %1$s is available!\nChangelog:\n%3$s + Install %1$s + Do you want to install %1$s ? Download and install Error downloading file Installation error! @@ -102,10 +104,6 @@ "Installing %1$s …" No Magisk Installed! Do you want to download and install Magisk? - Choose a root method - phh\'s superuser - SuperSU - It seems that you have incompatible root installed\nDo you want to install Magisk compatible root now? https://api.github.com/orgs/Magisk-Modules-Repo/repos?access_token= @@ -113,20 +111,24 @@ https://github.com/Magisk-Modules-Repo/%1$s/archive/master.zip + General + Theme + Select a theme + Enable BusyBox + Make Magisk\'s built-in BusyBox be visible in PATH + Quick Settings Enable Quicksettings Tile Click here to enable or disable the quick settings tile. + + Root Disable root unless otherwise enabled by auto-toggle or toggle. Keep root turned off - Enable advanced debug logging - Check this to enable more verbose logging. - Root - Development When checked, auto-toggle notifications will not be displayed. Hide auto-toggle notifications - - Error creating directory, could not download file. - Error removing old files, cancelled. - General + Development + Enable advanced debug logging + Check this to enable more verbose logging. + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index a173c067f..e46416ae9 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -17,14 +17,6 @@ @color/grey500 - -