|
|
|
@@ -31,16 +31,15 @@ public class StatusFragment extends Fragment implements CallbackEvent.Listener<V
|
|
|
|
|
private Unbinder unbinder;
|
|
|
|
|
@BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout;
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.magisk_status_container) View magiskStatusContainer;
|
|
|
|
|
@BindView(R.id.magisk_status_icon) ImageView magiskStatusIcon;
|
|
|
|
|
@BindView(R.id.magisk_version) TextView magiskVersionText;
|
|
|
|
|
@BindView(R.id.magisk_update_icon) ImageView magiskUpdateIcon;
|
|
|
|
|
@BindView(R.id.magisk_update_status) TextView magiskUpdateText;
|
|
|
|
|
@BindView(R.id.magisk_check_updates_progress) ProgressBar magiskCheckUpdatesProgress;
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.root_status_container) View rootStatusContainer;
|
|
|
|
|
@BindView(R.id.magisk_status_icon) ImageView magiskStatusIcon;
|
|
|
|
|
@BindView(R.id.magisk_version) TextView magiskVersionText;
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.root_status_icon) ImageView rootStatusIcon;
|
|
|
|
|
@BindView(R.id.root_status) TextView rootStatusText;
|
|
|
|
|
@BindView(R.id.root_info) TextView rootInfoText;
|
|
|
|
|
|
|
|
|
|
@BindView(R.id.safetyNet_container) View safetyNetContainer;
|
|
|
|
|
@BindView(R.id.safetyNet_icon) ImageView safetyNetIcon;
|
|
|
|
@@ -60,32 +59,31 @@ public class StatusFragment extends Fragment implements CallbackEvent.Listener<V
|
|
|
|
|
safetyNetContainer.setBackgroundColor(trans);
|
|
|
|
|
safetyNetIcon.setImageResource(0);
|
|
|
|
|
safetyNetStatusText.setText(R.string.checking_safetyNet_status);
|
|
|
|
|
Utils.checkSafetyNet(getApplication());
|
|
|
|
|
Utils.checkSafetyNet(magiskManager);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@OnClick(R.id.magisk_status_container)
|
|
|
|
|
public void gotoInstall() {
|
|
|
|
|
if (getApplication().remoteMagiskVersionCode > 0) {
|
|
|
|
|
if (magiskManager.remoteMagiskVersionCode > 0) {
|
|
|
|
|
((MainActivity) getActivity()).navigate(R.id.install);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int defaultColor;
|
|
|
|
|
private MagiskManager magiskManager;
|
|
|
|
|
|
|
|
|
|
@Nullable
|
|
|
|
|
@Override
|
|
|
|
|
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
|
|
|
|
View v = inflater.inflate(R.layout.fragment_status, container, false);
|
|
|
|
|
unbinder = ButterKnife.bind(this, v);
|
|
|
|
|
magiskManager = getApplication();
|
|
|
|
|
|
|
|
|
|
defaultColor = magiskUpdateText.getCurrentTextColor();
|
|
|
|
|
|
|
|
|
|
mSwipeRefreshLayout.setOnRefreshListener(() -> {
|
|
|
|
|
magiskStatusContainer.setBackgroundColor(trans);
|
|
|
|
|
magiskStatusIcon.setImageResource(0);
|
|
|
|
|
magiskUpdateText.setText(R.string.checking_for_updates);
|
|
|
|
|
magiskCheckUpdatesProgress.setVisibility(View.VISIBLE);
|
|
|
|
|
magiskUpdateText.setTextColor(defaultColor);
|
|
|
|
|
magiskUpdateIcon.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
|
|
safetyNetProgress.setVisibility(View.GONE);
|
|
|
|
|
safetyNetContainer.setBackgroundColor(colorNeutral);
|
|
|
|
@@ -93,14 +91,14 @@ public class StatusFragment extends Fragment implements CallbackEvent.Listener<V
|
|
|
|
|
safetyNetStatusText.setText(R.string.safetyNet_check_text);
|
|
|
|
|
safetyNetStatusText.setTextColor(defaultColor);
|
|
|
|
|
|
|
|
|
|
getApplication().safetyNetDone.isTriggered = false;
|
|
|
|
|
magiskManager.safetyNetDone.isTriggered = false;
|
|
|
|
|
noDialog = false;
|
|
|
|
|
|
|
|
|
|
updateUI();
|
|
|
|
|
new CheckUpdates(getActivity()).exec();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (getApplication().magiskVersionCode < 0 && Shell.rootAccess() && !noDialog) {
|
|
|
|
|
if (magiskManager.magiskVersionCode < 0 && Shell.rootAccess() && !noDialog) {
|
|
|
|
|
noDialog = true;
|
|
|
|
|
new AlertDialogBuilder(getActivity())
|
|
|
|
|
.setTitle(R.string.no_magisk_title)
|
|
|
|
@@ -113,9 +111,9 @@ public class StatusFragment extends Fragment implements CallbackEvent.Listener<V
|
|
|
|
|
|
|
|
|
|
updateUI();
|
|
|
|
|
|
|
|
|
|
if (getApplication().updateCheckDone.isTriggered)
|
|
|
|
|
if (magiskManager.updateCheckDone.isTriggered)
|
|
|
|
|
updateCheckUI();
|
|
|
|
|
if (getApplication().safetyNetDone.isTriggered)
|
|
|
|
|
if (magiskManager.safetyNetDone.isTriggered)
|
|
|
|
|
updateSafetyNetUI();
|
|
|
|
|
|
|
|
|
|
return v;
|
|
|
|
@@ -123,10 +121,10 @@ public class StatusFragment extends Fragment implements CallbackEvent.Listener<V
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onTrigger(CallbackEvent<Void> event) {
|
|
|
|
|
if (event == getApplication().updateCheckDone) {
|
|
|
|
|
if (event == magiskManager.updateCheckDone) {
|
|
|
|
|
Logger.dev("StatusFragment: Update Check UI refresh triggered");
|
|
|
|
|
updateCheckUI();
|
|
|
|
|
} else if (event == getApplication().safetyNetDone) {
|
|
|
|
|
} else if (event == magiskManager.safetyNetDone) {
|
|
|
|
|
Logger.dev("StatusFragment: SafetyNet UI refresh triggered");
|
|
|
|
|
updateSafetyNetUI();
|
|
|
|
|
}
|
|
|
|
@@ -135,15 +133,15 @@ public class StatusFragment extends Fragment implements CallbackEvent.Listener<V
|
|
|
|
|
@Override
|
|
|
|
|
public void onStart() {
|
|
|
|
|
super.onStart();
|
|
|
|
|
getApplication().updateCheckDone.register(this);
|
|
|
|
|
getApplication().safetyNetDone.register(this);
|
|
|
|
|
magiskManager.updateCheckDone.register(this);
|
|
|
|
|
magiskManager.safetyNetDone.register(this);
|
|
|
|
|
getActivity().setTitle(R.string.status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onStop() {
|
|
|
|
|
getApplication().updateCheckDone.unRegister(this);
|
|
|
|
|
getApplication().safetyNetDone.unRegister(this);
|
|
|
|
|
magiskManager.updateCheckDone.unRegister(this);
|
|
|
|
|
magiskManager.safetyNetDone.unRegister(this);
|
|
|
|
|
super.onStop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -156,29 +154,32 @@ public class StatusFragment extends Fragment implements CallbackEvent.Listener<V
|
|
|
|
|
private void updateUI() {
|
|
|
|
|
int image, color;
|
|
|
|
|
|
|
|
|
|
getApplication().updateMagiskInfo();
|
|
|
|
|
magiskManager.updateMagiskInfo();
|
|
|
|
|
|
|
|
|
|
if (getApplication().magiskVersionCode < 0) {
|
|
|
|
|
if (magiskManager.magiskVersionCode < 0) {
|
|
|
|
|
color = colorBad;
|
|
|
|
|
image = R.drawable.ic_cancel;
|
|
|
|
|
magiskVersionText.setText(R.string.magisk_version_error);
|
|
|
|
|
} else if (getApplication().disabled) {
|
|
|
|
|
magiskVersionText.setText(getString(R.string.magisk_version_core_only, getApplication().magiskVersionString));
|
|
|
|
|
} else {
|
|
|
|
|
magiskVersionText.setText(getString(R.string.magisk_version, getApplication().magiskVersionString));
|
|
|
|
|
color = colorOK;
|
|
|
|
|
image = R.drawable.ic_check_circle;
|
|
|
|
|
magiskVersionText.setText(getString(R.string.current_magisk_title, "v" + magiskManager.magiskVersionString));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
magiskStatusIcon.setImageResource(image);
|
|
|
|
|
magiskStatusIcon.setColorFilter(color);
|
|
|
|
|
|
|
|
|
|
switch (Shell.rootStatus) {
|
|
|
|
|
case 0:
|
|
|
|
|
color = colorBad;
|
|
|
|
|
image = R.drawable.ic_cancel;
|
|
|
|
|
rootStatusText.setText(R.string.not_rooted);
|
|
|
|
|
rootInfoText.setText(R.string.root_info_warning);
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
if (getApplication().suVersion != null) {
|
|
|
|
|
if (magiskManager.suVersion != null) {
|
|
|
|
|
color = colorOK;
|
|
|
|
|
image = R.drawable.ic_check_circle;
|
|
|
|
|
rootStatusText.setText(R.string.proper_root);
|
|
|
|
|
rootInfoText.setText(getApplication().suVersion);
|
|
|
|
|
rootStatusText.setText(magiskManager.suVersion);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case -1:
|
|
|
|
@@ -186,40 +187,28 @@ public class StatusFragment extends Fragment implements CallbackEvent.Listener<V
|
|
|
|
|
color = colorNeutral;
|
|
|
|
|
image = R.drawable.ic_help;
|
|
|
|
|
rootStatusText.setText(R.string.root_error);
|
|
|
|
|
rootInfoText.setText(R.string.root_info_warning);
|
|
|
|
|
}
|
|
|
|
|
rootStatusContainer.setBackgroundColor(color);
|
|
|
|
|
rootStatusText.setTextColor(color);
|
|
|
|
|
rootInfoText.setTextColor(color);
|
|
|
|
|
|
|
|
|
|
rootStatusIcon.setImageResource(image);
|
|
|
|
|
rootStatusIcon.setColorFilter(color);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateCheckUI() {
|
|
|
|
|
int image, color;
|
|
|
|
|
|
|
|
|
|
if (getApplication().remoteMagiskVersionCode < 0) {
|
|
|
|
|
if (magiskManager.remoteMagiskVersionCode < 0) {
|
|
|
|
|
color = colorNeutral;
|
|
|
|
|
image = R.drawable.ic_help;
|
|
|
|
|
magiskUpdateText.setText(R.string.cannot_check_updates);
|
|
|
|
|
} else if (getApplication().remoteMagiskVersionCode > getApplication().magiskVersionCode) {
|
|
|
|
|
color = colorInfo;
|
|
|
|
|
image = R.drawable.ic_update;
|
|
|
|
|
magiskUpdateText.setText(getString(R.string.magisk_update_available, getApplication().remoteMagiskVersionString));
|
|
|
|
|
} else {
|
|
|
|
|
color = colorOK;
|
|
|
|
|
image = R.drawable.ic_check_circle;
|
|
|
|
|
magiskUpdateText.setText(getString(R.string.up_to_date, getString(R.string.magisk)));
|
|
|
|
|
magiskUpdateText.setText(getString(R.string.install_magisk_title, "v" + magiskManager.remoteMagiskVersionString));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (getApplication().magiskVersionCode < 0) {
|
|
|
|
|
color = colorBad;
|
|
|
|
|
image = R.drawable.ic_cancel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
magiskStatusContainer.setBackgroundColor(color);
|
|
|
|
|
magiskVersionText.setTextColor(color);
|
|
|
|
|
magiskUpdateText.setTextColor(color);
|
|
|
|
|
magiskStatusIcon.setImageResource(image);
|
|
|
|
|
magiskUpdateIcon.setImageResource(image);
|
|
|
|
|
magiskUpdateIcon.setColorFilter(color);
|
|
|
|
|
magiskUpdateIcon.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
|
|
magiskCheckUpdatesProgress.setVisibility(View.GONE);
|
|
|
|
|
mSwipeRefreshLayout.setRefreshing(false);
|
|
|
|
@@ -228,7 +217,7 @@ public class StatusFragment extends Fragment implements CallbackEvent.Listener<V
|
|
|
|
|
private void updateSafetyNetUI() {
|
|
|
|
|
int image, color;
|
|
|
|
|
safetyNetProgress.setVisibility(View.GONE);
|
|
|
|
|
switch (getApplication().SNCheckResult) {
|
|
|
|
|
switch (magiskManager.SNCheckResult) {
|
|
|
|
|
case -3:
|
|
|
|
|
color = colorNeutral;
|
|
|
|
|
image = R.drawable.ic_help;
|
|
|
|
|