Update status UI

This commit is contained in:
topjohnwu 2017-05-19 08:37:57 -07:00
parent 55b8079e86
commit e69b99f089
10 changed files with 105 additions and 129 deletions

View File

@ -20,6 +20,7 @@ android {
buildTypes { buildTypes {
release { release {
minifyEnabled true minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
} }
@ -51,7 +52,6 @@ repositories {
dependencies { dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs') compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:recyclerview-v7:25.3.1' compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1' compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:design:25.3.1' compile 'com.android.support:design:25.3.1'

View File

@ -16,11 +16,6 @@
# public *; # public *;
#} #}
-keep class android.support.v7.internal.** { *; }
-keep interface android.support.v7.internal.** { *; }
-keep class android.support.v7.** { *; }
-keep interface android.support.v7.** { *; }
# SpongyCastle # SpongyCastle
-keep class org.spongycastle.** { *; } -keep class org.spongycastle.** { *; }
-dontwarn javax.naming.** -dontwarn javax.naming.**

View File

@ -32,7 +32,6 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale;
import butterknife.BindView; import butterknife.BindView;
import butterknife.ButterKnife; import butterknife.ButterKnife;

View File

@ -13,7 +13,6 @@ import com.topjohnwu.magisk.module.Module;
import com.topjohnwu.magisk.module.Repo; import com.topjohnwu.magisk.module.Repo;
import com.topjohnwu.magisk.superuser.Policy; import com.topjohnwu.magisk.superuser.Policy;
import com.topjohnwu.magisk.utils.CallbackEvent; import com.topjohnwu.magisk.utils.CallbackEvent;
import com.topjohnwu.magisk.utils.Logger;
import com.topjohnwu.magisk.utils.Shell; import com.topjohnwu.magisk.utils.Shell;
import com.topjohnwu.magisk.utils.Utils; import com.topjohnwu.magisk.utils.Utils;
import com.topjohnwu.magisk.utils.ValueSortedMap; import com.topjohnwu.magisk.utils.ValueSortedMap;

View File

@ -12,7 +12,6 @@ import com.topjohnwu.magisk.asyncs.GetBootBlocks;
import com.topjohnwu.magisk.asyncs.LoadApps; import com.topjohnwu.magisk.asyncs.LoadApps;
import com.topjohnwu.magisk.asyncs.LoadModules; import com.topjohnwu.magisk.asyncs.LoadModules;
import com.topjohnwu.magisk.asyncs.LoadRepos; import com.topjohnwu.magisk.asyncs.LoadRepos;
import com.topjohnwu.magisk.asyncs.MagiskHide;
import com.topjohnwu.magisk.components.Activity; import com.topjohnwu.magisk.components.Activity;
import com.topjohnwu.magisk.services.UpdateCheckService; import com.topjohnwu.magisk.services.UpdateCheckService;

View File

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

View File

@ -4,14 +4,9 @@ import android.app.Activity;
import android.app.ProgressDialog; import android.app.ProgressDialog;
import android.net.Uri; import android.net.Uri;
import com.topjohnwu.magisk.MagiskManager;
import com.topjohnwu.magisk.R; import com.topjohnwu.magisk.R;
import com.topjohnwu.magisk.utils.Logger;
import com.topjohnwu.magisk.utils.Shell; import com.topjohnwu.magisk.utils.Shell;
import com.topjohnwu.magisk.utils.Utils; import com.topjohnwu.magisk.utils.Utils;
import com.topjohnwu.magisk.utils.ZipUtils;
import java.io.File;
public class ProcessMagiskZip extends ParallelTask<Void, Void, Boolean> { public class ProcessMagiskZip extends ParallelTask<Void, Void, Boolean> {

View File

@ -1,7 +1,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <zlib.h> #include <zlib.h>
#include <string.h>
#include "zipadjust.h" #include "zipadjust.h"
size_t insize = 0, outsize = 0, alloc = 0; size_t insize = 0, outsize = 0, alloc = 0;

View File

@ -21,7 +21,6 @@
android:orientation="vertical"> android:orientation="vertical">
<android.support.v7.widget.CardView <android.support.v7.widget.CardView
android:id="@+id/magiskStatusView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
@ -33,44 +32,28 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/magisk_version"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center" android:gravity="center"
android:padding="6dp" android:orientation="horizontal">
android:textStyle="bold"/>
<FrameLayout
android:id="@+id/magisk_status_container"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="?android:attr/selectableItemBackground"
android:foregroundGravity="center"
android:orientation="vertical">
<ImageView
android:id="@+id/magisk_status_icon"
android:layout_width="84dp"
android:layout_height="84dp"
android:layout_gravity="center"/>
<ProgressBar <ProgressBar
android:id="@+id/magisk_check_updates_progress" android:id="@+id/magisk_check_updates_progress"
android:layout_width="wrap_content" android:layout_width="25dp"
android:layout_height="wrap_content" android:layout_height="25dp"
android:layout_gravity="center"/> android:layout_margin="15dp" />
</FrameLayout> <ImageView
android:id="@+id/magisk_update_icon"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_margin="15dp"
android:visibility="gone" />
<TextView <TextView
android:id="@+id/magisk_update_status" android:id="@+id/magisk_update_status"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minWidth="225dp"
android:layout_gravity="center" android:layout_gravity="center"
android:gravity="center" android:gravity="center"
android:padding="6dp" android:padding="6dp"
@ -82,7 +65,6 @@
</android.support.v7.widget.CardView> </android.support.v7.widget.CardView>
<android.support.v7.widget.CardView <android.support.v7.widget.CardView
android:id="@+id/rootStatusView"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginBottom="4dp" android:layout_marginBottom="4dp"
@ -94,38 +76,57 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:orientation="vertical"> android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/magisk_status_icon"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_margin="15dp" />
<TextView <TextView
android:id="@+id/root_status" android:id="@+id/magisk_version"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minWidth="225dp"
android:layout_gravity="center" android:layout_gravity="center"
android:gravity="center" android:gravity="center"
android:padding="6dp" android:padding="6dp"
android:textStyle="bold" /> android:textStyle="bold" />
<FrameLayout </LinearLayout>
android:id="@+id/root_status_container"
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="100dp" android:layout_height="wrap_content"
android:background="?android:attr/selectableItemBackground" android:layout_marginBottom="4dp"
android:foregroundGravity="center" android:layout_marginLeft="5dip"
android:orientation="vertical"> android:layout_marginRight="5dip"
android:layout_marginTop="6dp"
style="?attr/cardStyle"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="horizontal">
<ImageView <ImageView
android:id="@+id/root_status_icon" android:id="@+id/root_status_icon"
android:layout_width="84dp" android:layout_width="25dp"
android:layout_height="84dp" android:layout_height="25dp"
android:layout_gravity="center" /> android:layout_margin="15dp" />
</FrameLayout>
<TextView <TextView
android:id="@+id/root_info" android:id="@+id/root_status"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minWidth="225dp"
android:layout_gravity="center" android:layout_gravity="center"
android:gravity="center" android:gravity="center"
android:padding="6dp" android:padding="6dp"

View File

@ -6,7 +6,7 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:2.3.1' classpath 'com.android.tools.build:gradle:2.3.2'
classpath 'me.tatarka:gradle-retrolambda:3.6.0' classpath 'me.tatarka:gradle-retrolambda:3.6.0'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong