Project restructure
This commit is contained in:
parent
478b7eeb65
commit
ad16a6fc1b
2
app/proguard-rules.pro
vendored
2
app/proguard-rules.pro
vendored
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
# Application classes that will be serialized/deserialized over Gson
|
# Application classes that will be serialized/deserialized over Gson
|
||||||
-keep class com.topjohnwu.magisk.module.** { *; }
|
-keep class com.topjohnwu.magisk.module.** { *; }
|
||||||
-keep class com.topjohnwu.magisk.utils.ModuleHelper$ValueSortedMap { *; }
|
-keep class com.topjohnwu.magisk.module.ModuleHelper$ValueSortedMap { *; }
|
||||||
|
|
||||||
# Prevent proguard from stripping interface information from TypeAdapterFactory,
|
# Prevent proguard from stripping interface information from TypeAdapterFactory,
|
||||||
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
|
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
|
||||||
|
@ -28,9 +28,10 @@ import butterknife.ButterKnife;
|
|||||||
|
|
||||||
public class AboutActivity extends AppCompatActivity {
|
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/showthread.php?t=3432382";
|
|
||||||
private static final String DONATION_URL = "http://topjohnwu.github.io/donate";
|
private static final String DONATION_URL = "http://topjohnwu.github.io/donate";
|
||||||
|
private static final String XDA_THREAD = "http://forum.xda-developers.com/showthread.php?t=3432382";
|
||||||
|
private static final String SOURCE_CODE_URL = "https://github.com/topjohnwu/MagiskManager";
|
||||||
|
|
||||||
@BindView(R.id.toolbar) Toolbar toolbar;
|
@BindView(R.id.toolbar) Toolbar toolbar;
|
||||||
@BindView(R.id.app_version_info) AboutCardRow appVersionInfo;
|
@BindView(R.id.app_version_info) AboutCardRow appVersionInfo;
|
||||||
@BindView(R.id.app_changelog) AboutCardRow appChangelog;
|
@BindView(R.id.app_changelog) AboutCardRow appChangelog;
|
||||||
|
37
app/src/main/java/com/topjohnwu/magisk/Global.java
Normal file
37
app/src/main/java/com/topjohnwu/magisk/Global.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package com.topjohnwu.magisk;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.module.Repo;
|
||||||
|
import com.topjohnwu.magisk.utils.CallbackHandler;
|
||||||
|
import com.topjohnwu.magisk.utils.ValueSortedMap;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Global {
|
||||||
|
public static class Constant {
|
||||||
|
// No global constants now
|
||||||
|
}
|
||||||
|
public static class Info {
|
||||||
|
public static double magiskVersion;
|
||||||
|
public static double remoteMagiskVersion = -1;
|
||||||
|
public static String magiskVersionString = "(none)";
|
||||||
|
public static String magiskLink;
|
||||||
|
public static String releaseNoteLink;
|
||||||
|
public static int SNCheckResult = -1;
|
||||||
|
public static String bootBlock = null;
|
||||||
|
}
|
||||||
|
public static class Data {
|
||||||
|
public static ValueSortedMap<String, Repo> repoMap = new ValueSortedMap<>();
|
||||||
|
public static ValueSortedMap<String, com.topjohnwu.magisk.module.Module> moduleMap = new ValueSortedMap<>();
|
||||||
|
public static List<String> blockList;
|
||||||
|
}
|
||||||
|
public static class Events {
|
||||||
|
public static final CallbackHandler.Event blockDetectionDone = new CallbackHandler.Event();
|
||||||
|
public static final CallbackHandler.Event packageLoadDone = new CallbackHandler.Event();
|
||||||
|
public static final CallbackHandler.Event reloadMainActivity = new CallbackHandler.Event();
|
||||||
|
public static final CallbackHandler.Event moduleLoadDone = new CallbackHandler.Event();
|
||||||
|
public static final CallbackHandler.Event repoLoadDone = new CallbackHandler.Event();
|
||||||
|
public static final CallbackHandler.Event updateCheckDone = new CallbackHandler.Event();
|
||||||
|
public static final CallbackHandler.Event safetyNetDone = new CallbackHandler.Event();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -28,11 +28,6 @@ import butterknife.Unbinder;
|
|||||||
|
|
||||||
public class InstallFragment extends Fragment implements CallbackHandler.EventListener {
|
public class InstallFragment extends Fragment implements CallbackHandler.EventListener {
|
||||||
|
|
||||||
public static final CallbackHandler.Event blockDetectionDone = new CallbackHandler.Event();
|
|
||||||
|
|
||||||
public static List<String> blockList;
|
|
||||||
public static String bootBlock = null;
|
|
||||||
|
|
||||||
private Unbinder unbinder;
|
private Unbinder unbinder;
|
||||||
@BindView(R.id.current_version_title) TextView currentVersionTitle;
|
@BindView(R.id.current_version_title) TextView currentVersionTitle;
|
||||||
@BindView(R.id.install_title) TextView installTitle;
|
@BindView(R.id.install_title) TextView installTitle;
|
||||||
@ -48,14 +43,14 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
|
|||||||
View v = inflater.inflate(R.layout.install_fragment, container, false);
|
View v = inflater.inflate(R.layout.install_fragment, container, false);
|
||||||
unbinder = ButterKnife.bind(this, v);
|
unbinder = ButterKnife.bind(this, v);
|
||||||
detectButton.setOnClickListener(v1 -> toAutoDetect());
|
detectButton.setOnClickListener(v1 -> toAutoDetect());
|
||||||
currentVersionTitle.setText(getString(R.string.current_magisk_title, StatusFragment.magiskVersionString));
|
currentVersionTitle.setText(getString(R.string.current_magisk_title, Global.Info.magiskVersionString));
|
||||||
installTitle.setText(getString(R.string.install_magisk_title, StatusFragment.remoteMagiskVersion));
|
installTitle.setText(getString(R.string.install_magisk_title, Global.Info.remoteMagiskVersion));
|
||||||
flashButton.setOnClickListener(v1 -> {
|
flashButton.setOnClickListener(v1 -> {
|
||||||
String bootImage = bootBlock;
|
String bootImage = Global.Info.bootBlock;
|
||||||
if (bootImage == null) {
|
if (bootImage == null) {
|
||||||
bootImage = blockList.get(spinner.getSelectedItemPosition() - 1);
|
bootImage = Global.Data.blockList.get(spinner.getSelectedItemPosition() - 1);
|
||||||
}
|
}
|
||||||
String filename = "Magisk-v" + StatusFragment.remoteMagiskVersion + ".zip";
|
String filename = "Magisk-v" + Global.Info.remoteMagiskVersion + ".zip";
|
||||||
String finalBootImage = bootImage;
|
String finalBootImage = bootImage;
|
||||||
Utils.getAlertDialogBuilder(getActivity())
|
Utils.getAlertDialogBuilder(getActivity())
|
||||||
.setTitle(getString(R.string.repo_install_title, getString(R.string.magisk)))
|
.setTitle(getString(R.string.repo_install_title, getString(R.string.magisk)))
|
||||||
@ -64,15 +59,15 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
|
|||||||
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.dlAndReceive(
|
.setPositiveButton(R.string.download_install, (dialogInterface, i) -> Utils.dlAndReceive(
|
||||||
getActivity(),
|
getActivity(),
|
||||||
new MagiskDlReceiver(finalBootImage, keepEncChkbox.isChecked(), keepVerityChkbox.isChecked()),
|
new MagiskDlReceiver(finalBootImage, keepEncChkbox.isChecked(), keepVerityChkbox.isChecked()),
|
||||||
StatusFragment.magiskLink,
|
Global.Info.magiskLink,
|
||||||
Utils.getLegalFilename(filename)))
|
Utils.getLegalFilename(filename)))
|
||||||
.setNeutralButton(R.string.check_release_notes, (dialog, which) -> {
|
.setNeutralButton(R.string.check_release_notes, (dialog, which) -> {
|
||||||
getActivity().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(StatusFragment.releaseNoteLink)));
|
getActivity().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Global.Info.releaseNoteLink)));
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.no_thanks, null)
|
.setNegativeButton(R.string.no_thanks, null)
|
||||||
.show();
|
.show();
|
||||||
});
|
});
|
||||||
if (blockDetectionDone.isTriggered) {
|
if (Global.Events.blockDetectionDone.isTriggered) {
|
||||||
updateUI();
|
updateUI();
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
@ -84,8 +79,8 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateUI() {
|
private void updateUI() {
|
||||||
List<String> items = new ArrayList<>(blockList);
|
List<String> items = new ArrayList<>(Global.Data.blockList);
|
||||||
items.add(0, getString(R.string.auto_detect, bootBlock));
|
items.add(0, getString(R.string.auto_detect, Global.Info.bootBlock));
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(),
|
ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(),
|
||||||
android.R.layout.simple_spinner_item, items);
|
android.R.layout.simple_spinner_item, items);
|
||||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
@ -94,7 +89,7 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void toAutoDetect() {
|
private void toAutoDetect() {
|
||||||
if (bootBlock != null) {
|
if (Global.Info.bootBlock != null) {
|
||||||
spinner.setSelection(0);
|
spinner.setSelection(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,12 +98,12 @@ public class InstallFragment extends Fragment implements CallbackHandler.EventLi
|
|||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
getActivity().setTitle(R.string.install);
|
getActivity().setTitle(R.string.install);
|
||||||
CallbackHandler.register(blockDetectionDone, this);
|
CallbackHandler.register(Global.Events.blockDetectionDone, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
CallbackHandler.unRegister(blockDetectionDone, this);
|
CallbackHandler.unRegister(Global.Events.blockDetectionDone, this);
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,19 +29,16 @@ import butterknife.Unbinder;
|
|||||||
|
|
||||||
public class MagiskHideFragment extends Fragment implements CallbackHandler.EventListener {
|
public class MagiskHideFragment extends Fragment implements CallbackHandler.EventListener {
|
||||||
|
|
||||||
private Unbinder unbinder;
|
public static final List<String> HIDEBLACKLIST = Arrays.asList(
|
||||||
@BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout;
|
|
||||||
@BindView(R.id.recyclerView) RecyclerView recyclerView;
|
|
||||||
|
|
||||||
// Don't show in list...
|
|
||||||
public static final List<String> BLACKLIST = Arrays.asList(
|
|
||||||
"android",
|
"android",
|
||||||
"com.topjohnwu.magisk",
|
"com.topjohnwu.magisk",
|
||||||
"com.google.android.gms",
|
"com.google.android.gms",
|
||||||
"com.google.android.apps.walletnfcrel",
|
"com.google.android.apps.walletnfcrel",
|
||||||
"com.nianticlabs.pokemongo"
|
"com.nianticlabs.pokemongo"
|
||||||
);
|
);
|
||||||
public static final CallbackHandler.Event packageLoadDone = new CallbackHandler.Event();
|
private Unbinder unbinder;
|
||||||
|
@BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout;
|
||||||
|
@BindView(R.id.recyclerView) RecyclerView recyclerView;
|
||||||
|
|
||||||
private ApplicationAdapter appAdapter;
|
private ApplicationAdapter appAdapter;
|
||||||
|
|
||||||
@ -98,15 +95,15 @@ public class MagiskHideFragment extends Fragment implements CallbackHandler.Even
|
|||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
getActivity().setTitle(R.string.magiskhide);
|
getActivity().setTitle(R.string.magiskhide);
|
||||||
CallbackHandler.register(packageLoadDone, this);
|
CallbackHandler.register(Global.Events.packageLoadDone, this);
|
||||||
if (packageLoadDone.isTriggered) {
|
if (Global.Events.packageLoadDone.isTriggered) {
|
||||||
onTrigger(packageLoadDone);
|
onTrigger(Global.Events.packageLoadDone);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
CallbackHandler.unRegister(packageLoadDone, this);
|
CallbackHandler.unRegister(Global.Events.packageLoadDone, this);
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,8 +34,6 @@ public class MainActivity extends AppCompatActivity
|
|||||||
|
|
||||||
private static final String SELECTED_ITEM_ID = "SELECTED_ITEM_ID";
|
private static final String SELECTED_ITEM_ID = "SELECTED_ITEM_ID";
|
||||||
|
|
||||||
public static final CallbackHandler.Event recreate = new CallbackHandler.Event();
|
|
||||||
|
|
||||||
private final Handler mDrawerHandler = new Handler();
|
private final Handler mDrawerHandler = new Handler();
|
||||||
private SharedPreferences prefs;
|
private SharedPreferences prefs;
|
||||||
|
|
||||||
@ -88,28 +86,28 @@ public class MainActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
navigationView.setNavigationItemSelectedListener(this);
|
navigationView.setNavigationItemSelectedListener(this);
|
||||||
CallbackHandler.register(recreate, this);
|
CallbackHandler.register(Global.Events.reloadMainActivity, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
CallbackHandler.register(StatusFragment.updateCheckDone, this);
|
CallbackHandler.register(Global.Events.updateCheckDone, this);
|
||||||
if (StatusFragment.updateCheckDone.isTriggered) {
|
if (Global.Events.updateCheckDone.isTriggered) {
|
||||||
onTrigger(StatusFragment.updateCheckDone);
|
onTrigger(Global.Events.updateCheckDone);
|
||||||
}
|
}
|
||||||
checkHideSection();
|
checkHideSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPause() {
|
protected void onPause() {
|
||||||
CallbackHandler.unRegister(StatusFragment.updateCheckDone, this);
|
CallbackHandler.unRegister(Global.Events.updateCheckDone, this);
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
CallbackHandler.unRegister(recreate, this);
|
CallbackHandler.unRegister(Global.Events.reloadMainActivity, this);
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,22 +137,22 @@ public class MainActivity extends AppCompatActivity
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrigger(CallbackHandler.Event event) {
|
public void onTrigger(CallbackHandler.Event event) {
|
||||||
if (event == StatusFragment.updateCheckDone) {
|
if (event == Global.Events.updateCheckDone) {
|
||||||
Menu menu = navigationView.getMenu();
|
Menu menu = navigationView.getMenu();
|
||||||
menu.findItem(R.id.install).setVisible(StatusFragment.remoteMagiskVersion > 0 &&
|
menu.findItem(R.id.install).setVisible(Global.Info.remoteMagiskVersion > 0 &&
|
||||||
Shell.rootAccess());
|
Shell.rootAccess());
|
||||||
} else if (event == recreate) {
|
} else if (event == Global.Events.reloadMainActivity) {
|
||||||
recreate();
|
recreate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkHideSection() {
|
private void checkHideSection() {
|
||||||
Menu menu = navigationView.getMenu();
|
Menu menu = navigationView.getMenu();
|
||||||
menu.findItem(R.id.magiskhide).setVisible(StatusFragment.magiskVersion >= 8 &&
|
menu.findItem(R.id.magiskhide).setVisible(Global.Info.magiskVersion >= 8 &&
|
||||||
prefs.getBoolean("magiskhide", false) && Shell.rootAccess());
|
prefs.getBoolean("magiskhide", false) && Shell.rootAccess());
|
||||||
menu.findItem(R.id.modules).setVisible(StatusFragment.magiskVersion >= 4 &&
|
menu.findItem(R.id.modules).setVisible(Global.Info.magiskVersion >= 4 &&
|
||||||
Shell.rootAccess());
|
Shell.rootAccess());
|
||||||
menu.findItem(R.id.downloads).setVisible(StatusFragment.magiskVersion >= 4 &&
|
menu.findItem(R.id.downloads).setVisible(Global.Info.magiskVersion >= 4 &&
|
||||||
Shell.rootAccess());
|
Shell.rootAccess());
|
||||||
menu.findItem(R.id.log).setVisible(Shell.rootAccess());
|
menu.findItem(R.id.log).setVisible(Shell.rootAccess());
|
||||||
menu.findItem(R.id.install).setVisible(Shell.rootAccess());
|
menu.findItem(R.id.install).setVisible(Shell.rootAccess());
|
||||||
|
@ -19,7 +19,7 @@ import com.topjohnwu.magisk.module.Module;
|
|||||||
import com.topjohnwu.magisk.utils.Async;
|
import com.topjohnwu.magisk.utils.Async;
|
||||||
import com.topjohnwu.magisk.utils.CallbackHandler;
|
import com.topjohnwu.magisk.utils.CallbackHandler;
|
||||||
import com.topjohnwu.magisk.utils.Logger;
|
import com.topjohnwu.magisk.utils.Logger;
|
||||||
import com.topjohnwu.magisk.utils.ModuleHelper;
|
import com.topjohnwu.magisk.module.ModuleHelper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -30,8 +30,6 @@ import butterknife.Unbinder;
|
|||||||
|
|
||||||
public class ModulesFragment extends Fragment implements CallbackHandler.EventListener {
|
public class ModulesFragment extends Fragment implements CallbackHandler.EventListener {
|
||||||
|
|
||||||
public static final CallbackHandler.Event moduleLoadDone = new CallbackHandler.Event();
|
|
||||||
|
|
||||||
private static final int FETCH_ZIP_CODE = 2;
|
private static final int FETCH_ZIP_CODE = 2;
|
||||||
|
|
||||||
private Unbinder unbinder;
|
private Unbinder unbinder;
|
||||||
@ -71,7 +69,7 @@ public class ModulesFragment extends Fragment implements CallbackHandler.EventLi
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (moduleLoadDone.isTriggered) {
|
if (Global.Events.moduleLoadDone.isTriggered) {
|
||||||
updateUI();
|
updateUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,13 +95,13 @@ public class ModulesFragment extends Fragment implements CallbackHandler.EventLi
|
|||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
CallbackHandler.register(moduleLoadDone, this);
|
CallbackHandler.register(Global.Events.moduleLoadDone, this);
|
||||||
getActivity().setTitle(R.string.modules);
|
getActivity().setTitle(R.string.modules);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
CallbackHandler.unRegister(moduleLoadDone, this);
|
CallbackHandler.unRegister(Global.Events.moduleLoadDone, this);
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import com.topjohnwu.magisk.module.Repo;
|
|||||||
import com.topjohnwu.magisk.utils.Async;
|
import com.topjohnwu.magisk.utils.Async;
|
||||||
import com.topjohnwu.magisk.utils.CallbackHandler;
|
import com.topjohnwu.magisk.utils.CallbackHandler;
|
||||||
import com.topjohnwu.magisk.utils.Logger;
|
import com.topjohnwu.magisk.utils.Logger;
|
||||||
import com.topjohnwu.magisk.utils.ModuleHelper;
|
import com.topjohnwu.magisk.module.ModuleHelper;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -31,8 +31,6 @@ import butterknife.Unbinder;
|
|||||||
|
|
||||||
public class ReposFragment extends Fragment implements CallbackHandler.EventListener {
|
public class ReposFragment extends Fragment implements CallbackHandler.EventListener {
|
||||||
|
|
||||||
public static final CallbackHandler.Event repoLoadDone = new CallbackHandler.Event();
|
|
||||||
|
|
||||||
private Unbinder unbinder;
|
private Unbinder unbinder;
|
||||||
@BindView(R.id.recyclerView) RecyclerView recyclerView;
|
@BindView(R.id.recyclerView) RecyclerView recyclerView;
|
||||||
@BindView(R.id.empty_rv) TextView emptyTv;
|
@BindView(R.id.empty_rv) TextView emptyTv;
|
||||||
@ -74,7 +72,7 @@ public class ReposFragment extends Fragment implements CallbackHandler.EventList
|
|||||||
new Async.LoadRepos(getActivity()).exec();
|
new Async.LoadRepos(getActivity()).exec();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (repoLoadDone.isTriggered) {
|
if (Global.Events.repoLoadDone.isTriggered) {
|
||||||
reloadRepos();
|
reloadRepos();
|
||||||
updateUI();
|
updateUI();
|
||||||
}
|
}
|
||||||
@ -112,13 +110,13 @@ public class ReposFragment extends Fragment implements CallbackHandler.EventList
|
|||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
CallbackHandler.register(repoLoadDone, this);
|
CallbackHandler.register(Global.Events.repoLoadDone, this);
|
||||||
getActivity().setTitle(R.string.downloads);
|
getActivity().setTitle(R.string.downloads);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
CallbackHandler.unRegister(repoLoadDone, this);
|
CallbackHandler.unRegister(Global.Events.repoLoadDone, this);
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,9 +14,9 @@ import android.support.v7.widget.Toolbar;
|
|||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import com.topjohnwu.magisk.module.ModuleHelper;
|
||||||
import com.topjohnwu.magisk.utils.Async;
|
import com.topjohnwu.magisk.utils.Async;
|
||||||
import com.topjohnwu.magisk.utils.Logger;
|
import com.topjohnwu.magisk.utils.Logger;
|
||||||
import com.topjohnwu.magisk.utils.ModuleHelper;
|
|
||||||
import com.topjohnwu.magisk.utils.Shell;
|
import com.topjohnwu.magisk.utils.Shell;
|
||||||
import com.topjohnwu.magisk.utils.Utils;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
|
||||||
@ -107,10 +107,10 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
themePreference.setSummary(R.string.theme_default);
|
themePreference.setSummary(R.string.theme_default);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (StatusFragment.magiskVersion < 9) {
|
if (Global.Info.magiskVersion < 9) {
|
||||||
hostsPreference.setEnabled(false);
|
hostsPreference.setEnabled(false);
|
||||||
busyboxPreference.setEnabled(false);
|
busyboxPreference.setEnabled(false);
|
||||||
} else if (StatusFragment.magiskVersion < 8) {
|
} else if (Global.Info.magiskVersion < 8) {
|
||||||
magiskhidePreference.setEnabled(false);
|
magiskhidePreference.setEnabled(false);
|
||||||
} else if (! Shell.rootAccess()) {
|
} else if (! Shell.rootAccess()) {
|
||||||
busyboxPreference.setEnabled(false);
|
busyboxPreference.setEnabled(false);
|
||||||
@ -146,7 +146,7 @@ public class SettingsActivity extends AppCompatActivity {
|
|||||||
if (Utils.isDarkTheme != theme.equalsIgnoreCase(getString(R.string.theme_dark_value))) {
|
if (Utils.isDarkTheme != theme.equalsIgnoreCase(getString(R.string.theme_dark_value))) {
|
||||||
Utils.isDarkTheme = !Utils.isDarkTheme;
|
Utils.isDarkTheme = !Utils.isDarkTheme;
|
||||||
getActivity().recreate();
|
getActivity().recreate();
|
||||||
MainActivity.recreate.trigger();
|
Global.Events.reloadMainActivity.trigger();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "magiskhide":
|
case "magiskhide":
|
||||||
|
@ -30,15 +30,8 @@ import butterknife.Unbinder;
|
|||||||
|
|
||||||
public class StatusFragment extends Fragment implements CallbackHandler.EventListener {
|
public class StatusFragment extends Fragment implements CallbackHandler.EventListener {
|
||||||
|
|
||||||
public static double magiskVersion, remoteMagiskVersion = -1;
|
|
||||||
public static String magiskVersionString = "(none)", magiskLink, releaseNoteLink;
|
|
||||||
public static int SNCheckResult = -1;
|
|
||||||
|
|
||||||
private static boolean noDialog = false;
|
private static boolean noDialog = false;
|
||||||
|
|
||||||
public static final CallbackHandler.Event updateCheckDone = new CallbackHandler.Event();
|
|
||||||
public static final CallbackHandler.Event safetyNetDone = new CallbackHandler.Event();
|
|
||||||
|
|
||||||
private Unbinder unbinder;
|
private Unbinder unbinder;
|
||||||
@BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout;
|
@BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout;
|
||||||
|
|
||||||
@ -93,7 +86,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
|||||||
safetyNetStatusText.setText(R.string.safetyNet_check_text);
|
safetyNetStatusText.setText(R.string.safetyNet_check_text);
|
||||||
safetyNetStatusText.setTextColor(defaultColor);
|
safetyNetStatusText.setTextColor(defaultColor);
|
||||||
|
|
||||||
safetyNetDone.isTriggered = false;
|
Global.Events.safetyNetDone.isTriggered = false;
|
||||||
noDialog = false;
|
noDialog = false;
|
||||||
|
|
||||||
updateUI();
|
updateUI();
|
||||||
@ -108,7 +101,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
|||||||
Async.checkSafetyNet(getActivity());
|
Async.checkSafetyNet(getActivity());
|
||||||
});
|
});
|
||||||
|
|
||||||
if (magiskVersion < 0 && Shell.rootAccess() && !noDialog) {
|
if (Global.Info.magiskVersion < 0 && Shell.rootAccess() && !noDialog) {
|
||||||
noDialog = true;
|
noDialog = true;
|
||||||
Utils.getAlertDialogBuilder(getActivity())
|
Utils.getAlertDialogBuilder(getActivity())
|
||||||
.setTitle(R.string.no_magisk_title)
|
.setTitle(R.string.no_magisk_title)
|
||||||
@ -133,10 +126,10 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTrigger(CallbackHandler.Event event) {
|
public void onTrigger(CallbackHandler.Event event) {
|
||||||
if (event == updateCheckDone) {
|
if (event == Global.Events.updateCheckDone) {
|
||||||
Logger.dev("StatusFragment: Update Check UI refresh triggered");
|
Logger.dev("StatusFragment: Update Check UI refresh triggered");
|
||||||
updateCheckUI();
|
updateCheckUI();
|
||||||
} else if (event == safetyNetDone) {
|
} else if (event == Global.Events.safetyNetDone) {
|
||||||
Logger.dev("StatusFragment: SafetyNet UI refresh triggered");
|
Logger.dev("StatusFragment: SafetyNet UI refresh triggered");
|
||||||
updateSafetyNetUI();
|
updateSafetyNetUI();
|
||||||
}
|
}
|
||||||
@ -145,12 +138,12 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
|||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
CallbackHandler.register(updateCheckDone, this);
|
CallbackHandler.register(Global.Events.updateCheckDone, this);
|
||||||
CallbackHandler.register(safetyNetDone, this);
|
CallbackHandler.register(Global.Events.safetyNetDone, this);
|
||||||
if (updateCheckDone.isTriggered) {
|
if (Global.Events.updateCheckDone.isTriggered) {
|
||||||
updateCheckUI();
|
updateCheckUI();
|
||||||
}
|
}
|
||||||
if (safetyNetDone.isTriggered) {
|
if (Global.Events.safetyNetDone.isTriggered) {
|
||||||
updateSafetyNetUI();
|
updateSafetyNetUI();
|
||||||
}
|
}
|
||||||
getActivity().setTitle(R.string.status);
|
getActivity().setTitle(R.string.status);
|
||||||
@ -158,8 +151,8 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
CallbackHandler.unRegister(updateCheckDone, this);
|
CallbackHandler.unRegister(Global.Events.updateCheckDone, this);
|
||||||
CallbackHandler.unRegister(safetyNetDone, this);
|
CallbackHandler.unRegister(Global.Events.safetyNetDone, this);
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,14 +165,14 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
|||||||
private static void checkMagiskInfo() {
|
private static void checkMagiskInfo() {
|
||||||
List<String> ret = Shell.sh("getprop magisk.version");
|
List<String> ret = Shell.sh("getprop magisk.version");
|
||||||
if (ret.get(0).length() == 0) {
|
if (ret.get(0).length() == 0) {
|
||||||
magiskVersion = -1;
|
Global.Info.magiskVersion = -1;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
magiskVersionString = ret.get(0);
|
Global.Info.magiskVersionString = ret.get(0);
|
||||||
magiskVersion = Double.parseDouble(ret.get(0));
|
Global.Info.magiskVersion = Double.parseDouble(ret.get(0));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
// Custom version don't need to receive updates
|
// Custom version don't need to receive updates
|
||||||
magiskVersion = Double.POSITIVE_INFINITY;
|
Global.Info.magiskVersion = Double.POSITIVE_INFINITY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,10 +182,10 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
|||||||
|
|
||||||
checkMagiskInfo();
|
checkMagiskInfo();
|
||||||
|
|
||||||
if (magiskVersion < 0) {
|
if (Global.Info.magiskVersion < 0) {
|
||||||
magiskVersionText.setText(R.string.magisk_version_error);
|
magiskVersionText.setText(R.string.magisk_version_error);
|
||||||
} else {
|
} else {
|
||||||
magiskVersionText.setText(getString(R.string.magisk_version, magiskVersionString));
|
magiskVersionText.setText(getString(R.string.magisk_version, Global.Info.magiskVersionString));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Shell.rootStatus == 1) {
|
if (Shell.rootStatus == 1) {
|
||||||
@ -222,21 +215,21 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
|||||||
private void updateCheckUI() {
|
private void updateCheckUI() {
|
||||||
int image, color;
|
int image, color;
|
||||||
|
|
||||||
if (remoteMagiskVersion < 0) {
|
if (Global.Info.remoteMagiskVersion < 0) {
|
||||||
color = colorNeutral;
|
color = colorNeutral;
|
||||||
image = R.drawable.ic_help;
|
image = R.drawable.ic_help;
|
||||||
magiskUpdateText.setText(R.string.cannot_check_updates);
|
magiskUpdateText.setText(R.string.cannot_check_updates);
|
||||||
} else if (remoteMagiskVersion > magiskVersion) {
|
} else if (Global.Info.remoteMagiskVersion > Global.Info.magiskVersion) {
|
||||||
color = colorInfo;
|
color = colorInfo;
|
||||||
image = R.drawable.ic_update;
|
image = R.drawable.ic_update;
|
||||||
magiskUpdateText.setText(getString(R.string.magisk_update_available, remoteMagiskVersion));
|
magiskUpdateText.setText(getString(R.string.magisk_update_available, Global.Info.remoteMagiskVersion));
|
||||||
} else {
|
} else {
|
||||||
color = colorOK;
|
color = colorOK;
|
||||||
image = R.drawable.ic_check_circle;
|
image = R.drawable.ic_check_circle;
|
||||||
magiskUpdateText.setText(getString(R.string.up_to_date, getString(R.string.magisk)));
|
magiskUpdateText.setText(getString(R.string.up_to_date, getString(R.string.magisk)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (magiskVersion < 0) {
|
if (Global.Info.magiskVersion < 0) {
|
||||||
color = colorBad;
|
color = colorBad;
|
||||||
image = R.drawable.ic_cancel;
|
image = R.drawable.ic_cancel;
|
||||||
}
|
}
|
||||||
@ -250,7 +243,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
|||||||
|
|
||||||
updateMagisk = Utils.getAlertDialogBuilder(getActivity())
|
updateMagisk = Utils.getAlertDialogBuilder(getActivity())
|
||||||
.setTitle(R.string.magisk_update_title)
|
.setTitle(R.string.magisk_update_title)
|
||||||
.setMessage(getString(R.string.magisk_update_message, remoteMagiskVersion))
|
.setMessage(getString(R.string.magisk_update_message, Global.Info.remoteMagiskVersion))
|
||||||
.setCancelable(true)
|
.setCancelable(true)
|
||||||
.setPositiveButton(R.string.goto_install, (dialogInterface, i) -> {
|
.setPositiveButton(R.string.goto_install, (dialogInterface, i) -> {
|
||||||
((MainActivity) getActivity()).navigationView.setCheckedItem(R.id.install);
|
((MainActivity) getActivity()).navigationView.setCheckedItem(R.id.install);
|
||||||
@ -261,12 +254,12 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
|||||||
} catch (IllegalStateException ignored) {}
|
} catch (IllegalStateException ignored) {}
|
||||||
})
|
})
|
||||||
.setNeutralButton(R.string.check_release_notes, (dialog, which) -> {
|
.setNeutralButton(R.string.check_release_notes, (dialog, which) -> {
|
||||||
getActivity().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(releaseNoteLink)));
|
getActivity().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(Global.Info.releaseNoteLink)));
|
||||||
})
|
})
|
||||||
.setNegativeButton(R.string.no_thanks, null)
|
.setNegativeButton(R.string.no_thanks, null)
|
||||||
.create();
|
.create();
|
||||||
|
|
||||||
if (magiskVersion < remoteMagiskVersion && Shell.rootAccess()) {
|
if (Global.Info.magiskVersion < Global.Info.remoteMagiskVersion && Shell.rootAccess()) {
|
||||||
magiskStatusContainer.setOnClickListener(view -> updateMagisk.show());
|
magiskStatusContainer.setOnClickListener(view -> updateMagisk.show());
|
||||||
if (!noDialog) {
|
if (!noDialog) {
|
||||||
noDialog = true;
|
noDialog = true;
|
||||||
@ -278,7 +271,7 @@ public class StatusFragment extends Fragment implements CallbackHandler.EventLis
|
|||||||
private void updateSafetyNetUI() {
|
private void updateSafetyNetUI() {
|
||||||
int image, color;
|
int image, color;
|
||||||
safetyNetProgress.setVisibility(View.GONE);
|
safetyNetProgress.setVisibility(View.GONE);
|
||||||
switch (SNCheckResult) {
|
switch (Global.Info.SNCheckResult) {
|
||||||
case -3:
|
case -3:
|
||||||
color = colorNeutral;
|
color = colorNeutral;
|
||||||
image = R.drawable.ic_help;
|
image = R.drawable.ic_help;
|
||||||
|
@ -24,7 +24,7 @@ public class Module extends BaseModule {
|
|||||||
if (mName == null)
|
if (mName == null)
|
||||||
mName = mId;
|
mName = mId;
|
||||||
|
|
||||||
Logger.dev("Creating Module, id: " + mId);
|
Logger.dev("Creating Data, id: " + mId);
|
||||||
|
|
||||||
mEnable = !Utils.itemExist(mDisableFile);
|
mEnable = !Utils.itemExist(mDisableFile);
|
||||||
mRemove = Utils.itemExist(mRemoveFile);
|
mRemove = Utils.itemExist(mRemoveFile);
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package com.topjohnwu.magisk.utils;
|
package com.topjohnwu.magisk.module;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.support.annotation.NonNull;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
import com.topjohnwu.magisk.module.BaseModule;
|
import com.topjohnwu.magisk.Global;
|
||||||
import com.topjohnwu.magisk.module.Module;
|
import com.topjohnwu.magisk.utils.Logger;
|
||||||
import com.topjohnwu.magisk.module.Repo;
|
import com.topjohnwu.magisk.utils.Utils;
|
||||||
|
import com.topjohnwu.magisk.utils.ValueSortedMap;
|
||||||
|
import com.topjohnwu.magisk.utils.WebService;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
@ -17,42 +18,36 @@ import org.json.JSONObject;
|
|||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ModuleHelper {
|
public class ModuleHelper {
|
||||||
|
|
||||||
private static final String MAGISK_PATH = "/magisk";
|
private static final String MAGISK_PATH = "/magisk";
|
||||||
public static final String FILE_KEY = "RepoMap";
|
|
||||||
|
private static final int GSON_DB_VER = 1;
|
||||||
|
private static final String ETAG_KEY = "ETag";
|
||||||
|
private static final String VERSION_KEY = "version";
|
||||||
private static final String REPO_KEY = "repomap";
|
private static final String REPO_KEY = "repomap";
|
||||||
public static final String VERSION_KEY = "version";
|
private static final String FILE_KEY = "RepoMap";
|
||||||
public static final String ETAG_KEY = "ETag";
|
|
||||||
private static final int DATABASE_VER = 1;
|
|
||||||
|
|
||||||
private static ValueSortedMap<String, Repo> repoMap = new ValueSortedMap<>();
|
|
||||||
private static ValueSortedMap<String, Module> moduleMap = new ValueSortedMap<>();
|
|
||||||
|
|
||||||
|
|
||||||
public static void createModuleMap() {
|
public static void createModuleMap() {
|
||||||
Logger.dev("ModuleHelper: Loading modules");
|
Logger.dev("ModuleHelper: Loading modules");
|
||||||
|
|
||||||
moduleMap.clear();
|
Global.Data.moduleMap.clear();
|
||||||
|
|
||||||
for (String path : Utils.getModList(MAGISK_PATH)) {
|
for (String path : Utils.getModList(MAGISK_PATH)) {
|
||||||
Logger.dev("ModuleHelper: Adding modules from " + path);
|
Logger.dev("ModuleHelper: Adding modules from " + path);
|
||||||
Module module;
|
Module module;
|
||||||
try {
|
try {
|
||||||
module = new Module(path);
|
module = new Module(path);
|
||||||
moduleMap.put(module.getId(), module);
|
Global.Data.moduleMap.put(module.getId(), module);
|
||||||
} catch (BaseModule.CacheModException ignored) {}
|
} catch (BaseModule.CacheModException ignored) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger.dev("ModuleHelper: Module load done");
|
Logger.dev("ModuleHelper: Data load done");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createRepoMap(Context context) {
|
public static void createRepoMap(Context context) {
|
||||||
@ -60,13 +55,13 @@ public class ModuleHelper {
|
|||||||
|
|
||||||
SharedPreferences prefs = context.getSharedPreferences(FILE_KEY, Context.MODE_PRIVATE);
|
SharedPreferences prefs = context.getSharedPreferences(FILE_KEY, Context.MODE_PRIVATE);
|
||||||
|
|
||||||
repoMap.clear();
|
Global.Data.repoMap.clear();
|
||||||
|
|
||||||
Gson gson = new Gson();
|
Gson gson = new Gson();
|
||||||
String jsonString;
|
String jsonString;
|
||||||
|
|
||||||
int cachedVersion = prefs.getInt(VERSION_KEY, 0);
|
int cachedVersion = prefs.getInt(VERSION_KEY, 0);
|
||||||
if (cachedVersion != DATABASE_VER) {
|
if (cachedVersion != GSON_DB_VER) {
|
||||||
// Ignore incompatible cached database
|
// Ignore incompatible cached database
|
||||||
jsonString = null;
|
jsonString = null;
|
||||||
} else {
|
} else {
|
||||||
@ -123,7 +118,7 @@ public class ModuleHelper {
|
|||||||
repo.update(updatedDate);
|
repo.update(updatedDate);
|
||||||
}
|
}
|
||||||
if (repo.getId() != null) {
|
if (repo.getId() != null) {
|
||||||
repoMap.put(id, repo);
|
Global.Data.repoMap.put(id, repo);
|
||||||
}
|
}
|
||||||
} catch (BaseModule.CacheModException ignored) {}
|
} catch (BaseModule.CacheModException ignored) {}
|
||||||
}
|
}
|
||||||
@ -133,12 +128,12 @@ public class ModuleHelper {
|
|||||||
} else {
|
} else {
|
||||||
// Use cached if no internet or no updates
|
// Use cached if no internet or no updates
|
||||||
Logger.dev("ModuleHelper: No updates, use cached");
|
Logger.dev("ModuleHelper: No updates, use cached");
|
||||||
repoMap.putAll(cached);
|
Global.Data.repoMap.putAll(cached);
|
||||||
}
|
}
|
||||||
|
|
||||||
prefs.edit()
|
prefs.edit()
|
||||||
.putInt(VERSION_KEY, DATABASE_VER)
|
.putInt(VERSION_KEY, GSON_DB_VER)
|
||||||
.putString(REPO_KEY, gson.toJson(repoMap))
|
.putString(REPO_KEY, gson.toJson(Global.Data.repoMap))
|
||||||
.putString(ETAG_KEY, etag)
|
.putString(ETAG_KEY, etag)
|
||||||
.apply();
|
.apply();
|
||||||
|
|
||||||
@ -147,15 +142,15 @@ public class ModuleHelper {
|
|||||||
|
|
||||||
public static void getModuleList(List<Module> moduleList) {
|
public static void getModuleList(List<Module> moduleList) {
|
||||||
moduleList.clear();
|
moduleList.clear();
|
||||||
moduleList.addAll(moduleMap.values());
|
moduleList.addAll(Global.Data.moduleMap.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getRepoLists(List<Repo> update, List<Repo> installed, List<Repo> others) {
|
public static void getRepoLists(List<Repo> update, List<Repo> installed, List<Repo> others) {
|
||||||
update.clear();
|
update.clear();
|
||||||
installed.clear();
|
installed.clear();
|
||||||
others.clear();
|
others.clear();
|
||||||
for (Repo repo : repoMap.values()) {
|
for (Repo repo : Global.Data.repoMap.values()) {
|
||||||
Module module = moduleMap.get(repo.getId());
|
Module module = Global.Data.moduleMap.get(repo.getId());
|
||||||
if (module != null) {
|
if (module != null) {
|
||||||
if (repo.getVersionCode() > module.getVersionCode()) {
|
if (repo.getVersionCode() > module.getVersionCode()) {
|
||||||
update.add(repo);
|
update.add(repo);
|
||||||
@ -168,36 +163,4 @@ public class ModuleHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ValueSortedMap<K, V extends Comparable<? super V>> extends HashMap<K, V> {
|
|
||||||
|
|
||||||
private List<V> sorted = new ArrayList<>();
|
|
||||||
|
|
||||||
@NonNull
|
|
||||||
@Override
|
|
||||||
public Collection<V> values() {
|
|
||||||
if (sorted.isEmpty()) {
|
|
||||||
sorted.addAll(super.values());
|
|
||||||
Collections.sort(sorted);
|
|
||||||
}
|
|
||||||
return sorted;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public V put(K key, V value) {
|
|
||||||
sorted.clear();
|
|
||||||
return super.put(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void putAll(Map<? extends K, ? extends V> m) {
|
|
||||||
sorted.clear();
|
|
||||||
super.putAll(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public V remove(Object key) {
|
|
||||||
sorted.clear();
|
|
||||||
return super.remove(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -3,7 +3,7 @@ package com.topjohnwu.magisk.receivers;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
import com.topjohnwu.magisk.StatusFragment;
|
import com.topjohnwu.magisk.Global;
|
||||||
import com.topjohnwu.magisk.utils.Async;
|
import com.topjohnwu.magisk.utils.Async;
|
||||||
import com.topjohnwu.magisk.utils.Shell;
|
import com.topjohnwu.magisk.utils.Shell;
|
||||||
import com.topjohnwu.magisk.utils.ZipUtils;
|
import com.topjohnwu.magisk.utils.ZipUtils;
|
||||||
@ -56,7 +56,7 @@ public class MagiskDlReceiver extends DownloadReceiver {
|
|||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
Shell.su("setprop magisk.version "
|
Shell.su("setprop magisk.version "
|
||||||
+ String.valueOf(StatusFragment.remoteMagiskVersion));
|
+ String.valueOf(Global.Info.remoteMagiskVersion));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}.exec();
|
}.exec();
|
||||||
|
@ -28,6 +28,7 @@ import butterknife.ButterKnife;
|
|||||||
|
|
||||||
public class SuRequestActivity extends AppCompatActivity {
|
public class SuRequestActivity extends AppCompatActivity {
|
||||||
|
|
||||||
|
private static final int[] timeoutList = {0, -1, 10, 20, 30, 60};
|
||||||
private final static int SU_PROTOCOL_PARAM_MAX = 20;
|
private final static int SU_PROTOCOL_PARAM_MAX = 20;
|
||||||
private final static int SU_PROTOCOL_NAME_MAX = 20;
|
private final static int SU_PROTOCOL_NAME_MAX = 20;
|
||||||
private final static int SU_PROTOCOL_VALUE_MAX = 256;
|
private final static int SU_PROTOCOL_VALUE_MAX = 256;
|
||||||
@ -49,8 +50,6 @@ public class SuRequestActivity extends AppCompatActivity {
|
|||||||
private String appName, packageName;
|
private String appName, packageName;
|
||||||
private CountDownTimer timer;
|
private CountDownTimer timer;
|
||||||
|
|
||||||
private int[] timeoutList = {0, -1, 10, 20, 30, 60};
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
@ -11,12 +11,10 @@ import android.provider.OpenableColumns;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.topjohnwu.magisk.InstallFragment;
|
import com.topjohnwu.magisk.Global;
|
||||||
import com.topjohnwu.magisk.MagiskHideFragment;
|
import com.topjohnwu.magisk.MagiskHideFragment;
|
||||||
import com.topjohnwu.magisk.ModulesFragment;
|
|
||||||
import com.topjohnwu.magisk.R;
|
import com.topjohnwu.magisk.R;
|
||||||
import com.topjohnwu.magisk.ReposFragment;
|
import com.topjohnwu.magisk.module.ModuleHelper;
|
||||||
import com.topjohnwu.magisk.StatusFragment;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
@ -60,16 +58,16 @@ public class Async {
|
|||||||
try {
|
try {
|
||||||
JSONObject json = new JSONObject(jsonStr);
|
JSONObject json = new JSONObject(jsonStr);
|
||||||
JSONObject magisk = json.getJSONObject("magisk");
|
JSONObject magisk = json.getJSONObject("magisk");
|
||||||
StatusFragment.remoteMagiskVersion = magisk.getDouble("versionCode");
|
Global.Info.remoteMagiskVersion = magisk.getDouble("versionCode");
|
||||||
StatusFragment.magiskLink = magisk.getString("link");
|
Global.Info.magiskLink = magisk.getString("link");
|
||||||
StatusFragment.releaseNoteLink = magisk.getString("note");
|
Global.Info.releaseNoteLink = magisk.getString("note");
|
||||||
} catch (JSONException ignored) {}
|
} catch (JSONException ignored) {}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void v) {
|
protected void onPostExecute(Void v) {
|
||||||
StatusFragment.updateCheckDone.trigger();
|
Global.Events.updateCheckDone.trigger();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,8 +75,8 @@ public class Async {
|
|||||||
new SafetyNetHelper(context) {
|
new SafetyNetHelper(context) {
|
||||||
@Override
|
@Override
|
||||||
public void handleResults(int i) {
|
public void handleResults(int i) {
|
||||||
StatusFragment.SNCheckResult = i;
|
Global.Info.SNCheckResult = i;
|
||||||
StatusFragment.safetyNetDone.trigger();
|
Global.Events.safetyNetDone.trigger();
|
||||||
}
|
}
|
||||||
}.requestTest();
|
}.requestTest();
|
||||||
}
|
}
|
||||||
@ -93,7 +91,7 @@ public class Async {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void v) {
|
protected void onPostExecute(Void v) {
|
||||||
ModulesFragment.moduleLoadDone.trigger();
|
Global.Events.moduleLoadDone.trigger();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,7 +111,7 @@ public class Async {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void v) {
|
protected void onPostExecute(Void v) {
|
||||||
ReposFragment.repoLoadDone.trigger();
|
Global.Events.repoLoadDone.trigger();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +128,7 @@ public class Async {
|
|||||||
List<ApplicationInfo> listApps = pm.getInstalledApplications(PackageManager.GET_META_DATA);
|
List<ApplicationInfo> listApps = pm.getInstalledApplications(PackageManager.GET_META_DATA);
|
||||||
for (Iterator<ApplicationInfo> i = listApps.iterator(); i.hasNext(); ) {
|
for (Iterator<ApplicationInfo> i = listApps.iterator(); i.hasNext(); ) {
|
||||||
ApplicationInfo info = i.next();
|
ApplicationInfo info = i.next();
|
||||||
if (MagiskHideFragment.BLACKLIST.contains(info.packageName) || !info.enabled)
|
if (MagiskHideFragment.HIDEBLACKLIST.contains(info.packageName) || !info.enabled)
|
||||||
i.remove();
|
i.remove();
|
||||||
}
|
}
|
||||||
Collections.sort(listApps, (a, b) -> a.loadLabel(pm).toString().toLowerCase()
|
Collections.sort(listApps, (a, b) -> a.loadLabel(pm).toString().toLowerCase()
|
||||||
@ -141,7 +139,7 @@ public class Async {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Result result) {
|
protected void onPostExecute(Result result) {
|
||||||
MagiskHideFragment.packageLoadDone.trigger(result);
|
Global.Events.packageLoadDone.trigger(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Result {
|
public static class Result {
|
||||||
@ -289,7 +287,7 @@ public class Async {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void onSuccess() {
|
protected void onSuccess() {
|
||||||
StatusFragment.updateCheckDone.trigger();
|
Global.Events.updateCheckDone.trigger();
|
||||||
new LoadModules().exec();
|
new LoadModules().exec();
|
||||||
|
|
||||||
Utils.getAlertDialogBuilder(mContext)
|
Utils.getAlertDialogBuilder(mContext)
|
||||||
@ -324,9 +322,9 @@ public class Async {
|
|||||||
@Override
|
@Override
|
||||||
protected Void doInBackground(Void... params) {
|
protected Void doInBackground(Void... params) {
|
||||||
if (Shell.rootAccess()) {
|
if (Shell.rootAccess()) {
|
||||||
InstallFragment.blockList = Shell.su("ls /dev/block | grep mmc");
|
Global.Data.blockList = Shell.su("ls /dev/block | grep mmc");
|
||||||
if (InstallFragment.bootBlock == null) {
|
if (Global.Info.bootBlock == null) {
|
||||||
InstallFragment.bootBlock = Utils.detectBootImage();
|
Global.Info.bootBlock = Utils.detectBootImage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -334,7 +332,7 @@ public class Async {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(Void aVoid) {
|
protected void onPostExecute(Void aVoid) {
|
||||||
InstallFragment.blockDetectionDone.trigger();
|
Global.Events.blockDetectionDone.trigger();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.topjohnwu.magisk;
|
package com.topjohnwu.magisk.utils;
|
||||||
|
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
@ -0,0 +1,43 @@
|
|||||||
|
package com.topjohnwu.magisk.utils;
|
||||||
|
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ValueSortedMap<K, V extends Comparable<? super V>> extends HashMap<K, V> {
|
||||||
|
|
||||||
|
private List<V> sorted = new ArrayList<>();
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
@Override
|
||||||
|
public Collection<V> values() {
|
||||||
|
if (sorted.isEmpty()) {
|
||||||
|
sorted.addAll(super.values());
|
||||||
|
Collections.sort(sorted);
|
||||||
|
}
|
||||||
|
return sorted;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public V put(K key, V value) {
|
||||||
|
sorted.clear();
|
||||||
|
return super.put(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void putAll(Map<? extends K, ? extends V> m) {
|
||||||
|
sorted.clear();
|
||||||
|
super.putAll(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public V remove(Object key) {
|
||||||
|
sorted.clear();
|
||||||
|
return super.remove(key);
|
||||||
|
}
|
||||||
|
}
|
@ -47,7 +47,7 @@
|
|||||||
android:layout_gravity="bottom|center_horizontal"
|
android:layout_gravity="bottom|center_horizontal"
|
||||||
android:layout_marginEnd="113dp"
|
android:layout_marginEnd="113dp"
|
||||||
android:layout_marginBottom="10dp"
|
android:layout_marginBottom="10dp"
|
||||||
app:layout_behavior=".FABBehavior"
|
app:layout_behavior=".utils.FABBehavior"
|
||||||
fab:menu_fab_size="normal"
|
fab:menu_fab_size="normal"
|
||||||
fab:menu_showShadow="true"
|
fab:menu_showShadow="true"
|
||||||
fab:menu_shadowColor="#66000000"
|
fab:menu_shadowColor="#66000000"
|
||||||
|
Loading…
Reference in New Issue
Block a user