From e69b99f0898e18cb646e199129f38ca882cf8465 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 19 May 2017 08:37:57 -0700 Subject: [PATCH] Update status UI --- app/build.gradle | 2 +- app/proguard-rules.pro | 5 - .../com/topjohnwu/magisk/InstallFragment.java | 1 - .../com/topjohnwu/magisk/MagiskManager.java | 1 - .../com/topjohnwu/magisk/SplashActivity.java | 1 - .../com/topjohnwu/magisk/StatusFragment.java | 89 ++++++------ .../magisk/asyncs/ProcessMagiskZip.java | 5 - app/src/main/jni/zipadjust.c | 1 - app/src/main/res/layout/fragment_status.xml | 127 +++++++++--------- build.gradle | 2 +- 10 files changed, 105 insertions(+), 129 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 03a182766..41b6cb4a1 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,6 +20,7 @@ android { buildTypes { release { minifyEnabled true + shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } @@ -51,7 +52,6 @@ repositories { dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') - compile 'com.android.support:recyclerview-v7:25.3.1' compile 'com.android.support:cardview-v7:25.3.1' compile 'com.android.support:design:25.3.1' diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index ef25ce585..0c233f802 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -16,11 +16,6 @@ # public *; #} --keep class android.support.v7.internal.** { *; } --keep interface android.support.v7.internal.** { *; } --keep class android.support.v7.** { *; } --keep interface android.support.v7.** { *; } - # SpongyCastle -keep class org.spongycastle.** { *; } -dontwarn javax.naming.** diff --git a/app/src/main/java/com/topjohnwu/magisk/InstallFragment.java b/app/src/main/java/com/topjohnwu/magisk/InstallFragment.java index 9f4af79c4..7cda18221 100644 --- a/app/src/main/java/com/topjohnwu/magisk/InstallFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/InstallFragment.java @@ -32,7 +32,6 @@ import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; -import java.util.Locale; import butterknife.BindView; import butterknife.ButterKnife; diff --git a/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java b/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java index 772c25074..36132e8fc 100644 --- a/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java +++ b/app/src/main/java/com/topjohnwu/magisk/MagiskManager.java @@ -13,7 +13,6 @@ import com.topjohnwu.magisk.module.Module; import com.topjohnwu.magisk.module.Repo; import com.topjohnwu.magisk.superuser.Policy; import com.topjohnwu.magisk.utils.CallbackEvent; -import com.topjohnwu.magisk.utils.Logger; import com.topjohnwu.magisk.utils.Shell; import com.topjohnwu.magisk.utils.Utils; import com.topjohnwu.magisk.utils.ValueSortedMap; diff --git a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java index f57993820..fca15e9cc 100644 --- a/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java +++ b/app/src/main/java/com/topjohnwu/magisk/SplashActivity.java @@ -12,7 +12,6 @@ import com.topjohnwu.magisk.asyncs.GetBootBlocks; import com.topjohnwu.magisk.asyncs.LoadApps; import com.topjohnwu.magisk.asyncs.LoadModules; import com.topjohnwu.magisk.asyncs.LoadRepos; -import com.topjohnwu.magisk.asyncs.MagiskHide; import com.topjohnwu.magisk.components.Activity; import com.topjohnwu.magisk.services.UpdateCheckService; diff --git a/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java b/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java index a0a1b6f2a..3a102ab46 100644 --- a/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java +++ b/app/src/main/java/com/topjohnwu/magisk/StatusFragment.java @@ -31,16 +31,15 @@ public class StatusFragment extends Fragment implements CallbackEvent.Listener 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 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 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 { diff --git a/app/src/main/jni/zipadjust.c b/app/src/main/jni/zipadjust.c index 90478fe4c..7ea20985b 100644 --- a/app/src/main/jni/zipadjust.c +++ b/app/src/main/jni/zipadjust.c @@ -1,7 +1,6 @@ #include #include #include -#include #include "zipadjust.h" size_t insize = 0, outsize = 0, alloc = 0; diff --git a/app/src/main/res/layout/fragment_status.xml b/app/src/main/res/layout/fragment_status.xml index 821abe153..26bfcfe7f 100644 --- a/app/src/main/res/layout/fragment_status.xml +++ b/app/src/main/res/layout/fragment_status.xml @@ -21,7 +21,6 @@ android:orientation="vertical"> + android:layout_height="match_parent" + android:gravity="center" + android:orientation="horizontal"> - + - - - - - - - + + android:layout_height="match_parent" + android:gravity="center" + android:orientation="horizontal"> + + + + + + + + + + + + + + - - - - - - - - + android:textStyle="bold" /> diff --git a/build.gradle b/build.gradle index 1ca6d708f..6681c9713 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { mavenCentral() } 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' // NOTE: Do not place your application dependencies here; they belong