mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-11-28 04:25:27 +00:00
Reduce unnecessary code
This commit is contained in:
parent
04a4265ef3
commit
834c16485c
@ -351,17 +351,16 @@ public class MagiskFragment extends Fragment
|
|||||||
private void updateUI() {
|
private void updateUI() {
|
||||||
((MainActivity) getActivity()).checkHideSection();
|
((MainActivity) getActivity()).checkHideSection();
|
||||||
|
|
||||||
final int ROOT = 0x1, NETWORK = 0x2, UPTODATE = 0x4;
|
boolean hasNetwork = Utils.checkNetworkStatus(getActivity());
|
||||||
int status = 0;
|
boolean hasRoot = Shell.rootAccess();
|
||||||
status |= Shell.rootAccess() ? ROOT : 0;
|
boolean isUpToDate = magiskManager.magiskVersionCode > 1300;
|
||||||
status |= Utils.checkNetworkStatus(magiskManager) ? NETWORK : 0;
|
|
||||||
status |= magiskManager.magiskVersionCode >= 1300 ? UPTODATE : 0;
|
magiskUpdateCard.setVisibility(hasNetwork ? View.VISIBLE : View.GONE);
|
||||||
magiskUpdateCard.setVisibility(Utils.checkBits(status, NETWORK) ? View.VISIBLE : View.GONE);
|
safetyNetCard.setVisibility(hasNetwork ? View.VISIBLE : View.GONE);
|
||||||
safetyNetCard.setVisibility(Utils.checkBits(status, NETWORK) ? View.VISIBLE : View.GONE);
|
bootImageCard.setVisibility(hasNetwork && hasRoot ? View.VISIBLE : View.GONE);
|
||||||
bootImageCard.setVisibility(Utils.checkBits(status, NETWORK, ROOT) ? View.VISIBLE : View.GONE);
|
installOptionCard.setVisibility(hasNetwork ? View.VISIBLE : View.GONE);
|
||||||
installOptionCard.setVisibility(Utils.checkBits(status, NETWORK) ? View.VISIBLE : View.GONE);
|
installButton.setVisibility(hasNetwork ? View.VISIBLE : View.GONE);
|
||||||
installButton.setVisibility(Utils.checkBits(status, NETWORK) ? View.VISIBLE : View.GONE);
|
uninstallButton.setVisibility(isUpToDate && hasRoot ? View.VISIBLE : View.GONE);
|
||||||
uninstallButton.setVisibility(Utils.checkBits(status, UPTODATE, ROOT) ? View.VISIBLE : View.GONE);
|
|
||||||
|
|
||||||
int image, color;
|
int image, color;
|
||||||
|
|
||||||
|
@ -185,14 +185,6 @@ public class Utils {
|
|||||||
return networkInfo != null && networkInfo.isConnected();
|
return networkInfo != null && networkInfo.isConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkBits(int bits, int... masks) {
|
|
||||||
for (int mask : masks) {
|
|
||||||
if ((bits & mask) == 0)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void showMagiskUpdate(MagiskManager magiskManager) {
|
public static void showMagiskUpdate(MagiskManager magiskManager) {
|
||||||
NotificationCompat.Builder builder = new NotificationCompat.Builder(magiskManager, MagiskManager.NOTIFICATION_CHANNEL);
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(magiskManager, MagiskManager.NOTIFICATION_CHANNEL);
|
||||||
builder.setSmallIcon(R.drawable.ic_magisk)
|
builder.setSmallIcon(R.drawable.ic_magisk)
|
||||||
|
Loading…
Reference in New Issue
Block a user