From 78534deab6cb56e40256cdf0c899aeb5fdfb75c9 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Fri, 14 Sep 2018 23:00:39 -0400 Subject: [PATCH] Excessive obfuscation when building in release mode Close #606 --- app/build.gradle | 6 - app/proguard-rules.pro | 11 +- app/src/full/AndroidManifest.xml | 42 ++- app/src/full/java/a/a.java | 7 + app/src/full/java/a/b.java | 7 + app/src/full/java/a/c.java | 7 + app/src/full/java/a/d.java | 7 + app/src/full/java/a/e.java | 7 + app/src/full/java/a/f.java | 7 + app/src/full/java/a/h.java | 7 + app/src/full/java/a/i.java | 7 + app/src/full/java/a/j.java | 7 + app/src/full/java/a/k.java | 7 + app/src/full/java/a/l.java | 7 + app/src/full/java/a/m.java | 7 + app/src/full/java/a/n.java | 7 + app/src/full/java/a/o.java | 22 ++ .../com/topjohnwu/magisk/AboutActivity.java | 18 +- .../topjohnwu/magisk/DonationActivity.java | 10 +- .../com/topjohnwu/magisk/FlashActivity.java | 18 +- .../com/topjohnwu/magisk/MainActivity.java | 16 +- .../com/topjohnwu/magisk/SplashActivity.java | 7 +- .../java/com/topjohnwu/magisk/ViewBinder.java | 292 ++++++++++++++++++ .../magisk/adapters/ApplicationAdapter.java | 15 +- .../magisk/adapters/ModulesAdapter.java | 21 +- .../magisk/adapters/PolicyAdapter.java | 25 +- .../magisk/adapters/ReposAdapter.java | 27 +- .../magisk/adapters/SuLogAdapter.java | 29 +- .../magisk/components/AboutCardRow.java | 16 +- .../magisk/components/CustomAlertDialog.java | 17 +- .../components/ManagerInstallDialog.java | 4 +- .../magisk/fragments/LogFragment.java | 15 +- .../magisk/fragments/MagiskFragment.java | 86 +++--- .../magisk/fragments/MagiskHideFragment.java | 13 +- .../magisk/fragments/MagiskLogFragment.java | 18 +- .../magisk/fragments/ModulesFragment.java | 18 +- .../magisk/fragments/ReposFragment.java | 15 +- .../magisk/fragments/SuLogFragment.java | 13 +- .../magisk/fragments/SuperuserFragment.java | 14 +- .../magisk/receivers/BootReceiver.java | 4 +- .../magisk/receivers/ShortcutReceiver.java | 9 +- .../magisk/superuser/RequestActivity.java | 24 +- .../magisk/utils/ISafetyNetHelper.java | 5 - .../magisk/utils/NotificationMgr.java | 13 +- .../com/topjohnwu/magisk/utils/Utils.java | 5 +- app/src/full/res/layout/activity_about.xml | 12 +- app/src/full/res/layout/activity_donation.xml | 4 +- app/src/main/AndroidManifest.xml | 2 +- app/src/main/java/a/g.java | 7 + .../magisk/components/BaseActivity.java | 3 +- 50 files changed, 662 insertions(+), 305 deletions(-) create mode 100644 app/src/full/java/a/a.java create mode 100644 app/src/full/java/a/b.java create mode 100644 app/src/full/java/a/c.java create mode 100644 app/src/full/java/a/d.java create mode 100644 app/src/full/java/a/e.java create mode 100644 app/src/full/java/a/f.java create mode 100644 app/src/full/java/a/h.java create mode 100644 app/src/full/java/a/i.java create mode 100644 app/src/full/java/a/j.java create mode 100644 app/src/full/java/a/k.java create mode 100644 app/src/full/java/a/l.java create mode 100644 app/src/full/java/a/m.java create mode 100644 app/src/full/java/a/n.java create mode 100644 app/src/full/java/a/o.java create mode 100644 app/src/full/java/com/topjohnwu/magisk/ViewBinder.java create mode 100644 app/src/main/java/a/g.java diff --git a/app/build.gradle b/app/build.gradle index 98e16f5a0..e9c8f5e18 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -68,10 +68,6 @@ android { } } -repositories { - maven { url "https://oss.sonatype.org/content/repositories/snapshots" } -} - dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') fullImplementation project(':utils') @@ -83,6 +79,4 @@ dependencies { fullImplementation 'com.github.topjohnwu:libsu:2.0.2' fullImplementation 'com.atlassian.commonmark:commonmark:0.11.0' fullImplementation 'org.kamranzafar:jtar:2.3' - fullImplementation 'com.jakewharton:butterknife:9.0.0-SNAPSHOT' - fullAnnotationProcessor 'com.jakewharton:butterknife-compiler:9.0.0-SNAPSHOT' } diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index daeab7acb..f6f55fa8e 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -16,19 +16,20 @@ # public *; #} -# Don't obfuscate, we are open source anyway :) --dontobfuscate - # BouncyCastle -keep class org.bouncycastle.jcajce.provider.asymmetric.rsa.**SHA1** { *; } -keep class org.bouncycastle.jcajce.provider.asymmetric.RSA** { *; } -keep class org.bouncycastle.jcajce.provider.digest.SHA1** { *; } -dontwarn javax.naming.** -# Gson --keepattributes Signature +# Snet extention +-keepclassmembers class com.topjohnwu.magisk.utils.ISafetyNetHelper { *; } # Strip logging -assumenosideeffects class com.topjohnwu.magisk.utils.Logger { public *** debug(...); } + +# Excessive obfuscation +-repackageclasses 'a' +-allowaccessmodification diff --git a/app/src/full/AndroidManifest.xml b/app/src/full/AndroidManifest.xml index 82a320d2b..6b5b170f3 100644 --- a/app/src/full/AndroidManifest.xml +++ b/app/src/full/AndroidManifest.xml @@ -1,5 +1,6 @@ @@ -8,15 +9,18 @@ + android:name="a.a" + android:theme="@style/AppTheme" + tools:ignore="GoogleAppIndexingWarning"> + + @@ -26,19 +30,22 @@ + + + - + + + + - + - - - + + + + + diff --git a/app/src/full/java/a/a.java b/app/src/full/java/a/a.java new file mode 100644 index 000000000..d9444ecb7 --- /dev/null +++ b/app/src/full/java/a/a.java @@ -0,0 +1,7 @@ +package a; + +import com.topjohnwu.magisk.MagiskManager; + +public class a extends MagiskManager { + /* stub */ +} diff --git a/app/src/full/java/a/b.java b/app/src/full/java/a/b.java new file mode 100644 index 000000000..0e0409f89 --- /dev/null +++ b/app/src/full/java/a/b.java @@ -0,0 +1,7 @@ +package a; + +import com.topjohnwu.magisk.MainActivity; + +public class b extends MainActivity { + /* stub */ +} diff --git a/app/src/full/java/a/c.java b/app/src/full/java/a/c.java new file mode 100644 index 000000000..5e7bea238 --- /dev/null +++ b/app/src/full/java/a/c.java @@ -0,0 +1,7 @@ +package a; + +import com.topjohnwu.magisk.SplashActivity; + +public class c extends SplashActivity { + /* stub */ +} diff --git a/app/src/full/java/a/d.java b/app/src/full/java/a/d.java new file mode 100644 index 000000000..b536710ab --- /dev/null +++ b/app/src/full/java/a/d.java @@ -0,0 +1,7 @@ +package a; + +import com.topjohnwu.magisk.AboutActivity; + +public class d extends AboutActivity { + /* stub */ +} diff --git a/app/src/full/java/a/e.java b/app/src/full/java/a/e.java new file mode 100644 index 000000000..d986a03dd --- /dev/null +++ b/app/src/full/java/a/e.java @@ -0,0 +1,7 @@ +package a; + +import com.topjohnwu.magisk.DonationActivity; + +public class e extends DonationActivity { + /* stub */ +} diff --git a/app/src/full/java/a/f.java b/app/src/full/java/a/f.java new file mode 100644 index 000000000..a40a5c70f --- /dev/null +++ b/app/src/full/java/a/f.java @@ -0,0 +1,7 @@ +package a; + +import com.topjohnwu.magisk.FlashActivity; + +public class f extends FlashActivity { + /* stub */ +} diff --git a/app/src/full/java/a/h.java b/app/src/full/java/a/h.java new file mode 100644 index 000000000..91fff83fb --- /dev/null +++ b/app/src/full/java/a/h.java @@ -0,0 +1,7 @@ +package a; + +import com.topjohnwu.magisk.receivers.BootReceiver; + +public class h extends BootReceiver { + /* stub */ +} diff --git a/app/src/full/java/a/i.java b/app/src/full/java/a/i.java new file mode 100644 index 000000000..17feccd01 --- /dev/null +++ b/app/src/full/java/a/i.java @@ -0,0 +1,7 @@ +package a; + +import com.topjohnwu.magisk.receivers.PackageReceiver; + +public class i extends PackageReceiver { + /* stub */ +} diff --git a/app/src/full/java/a/j.java b/app/src/full/java/a/j.java new file mode 100644 index 000000000..0feec80eb --- /dev/null +++ b/app/src/full/java/a/j.java @@ -0,0 +1,7 @@ +package a; + +import com.topjohnwu.magisk.receivers.ManagerUpdate; + +public class j extends ManagerUpdate { + /* stub */ +} diff --git a/app/src/full/java/a/k.java b/app/src/full/java/a/k.java new file mode 100644 index 000000000..af3140a29 --- /dev/null +++ b/app/src/full/java/a/k.java @@ -0,0 +1,7 @@ +package a; + +import com.topjohnwu.magisk.receivers.RebootReceiver; + +public class k extends RebootReceiver { + /* stub */ +} diff --git a/app/src/full/java/a/l.java b/app/src/full/java/a/l.java new file mode 100644 index 000000000..a7cd44c3b --- /dev/null +++ b/app/src/full/java/a/l.java @@ -0,0 +1,7 @@ +package a; + +import com.topjohnwu.magisk.receivers.ShortcutReceiver; + +public class l extends ShortcutReceiver { + /* stub */ +} diff --git a/app/src/full/java/a/m.java b/app/src/full/java/a/m.java new file mode 100644 index 000000000..eb114751c --- /dev/null +++ b/app/src/full/java/a/m.java @@ -0,0 +1,7 @@ +package a; + +import com.topjohnwu.magisk.services.OnBootService; + +public class m extends OnBootService { + /* stub */ +} diff --git a/app/src/full/java/a/n.java b/app/src/full/java/a/n.java new file mode 100644 index 000000000..ad8fa0f07 --- /dev/null +++ b/app/src/full/java/a/n.java @@ -0,0 +1,7 @@ +package a; + +import com.topjohnwu.magisk.services.UpdateCheckService; + +public class n extends UpdateCheckService { + /* stub */ +} diff --git a/app/src/full/java/a/o.java b/app/src/full/java/a/o.java new file mode 100644 index 000000000..38f990a2a --- /dev/null +++ b/app/src/full/java/a/o.java @@ -0,0 +1,22 @@ +package a; + +import android.content.Context; +import android.util.AttributeSet; + +import com.topjohnwu.magisk.components.AboutCardRow; + +public class o extends AboutCardRow { + /* stub */ + + public o(Context context) { + super(context); + } + + public o(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public o(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } +} diff --git a/app/src/full/java/com/topjohnwu/magisk/AboutActivity.java b/app/src/full/java/com/topjohnwu/magisk/AboutActivity.java index 9ea365a49..46afa1f60 100644 --- a/app/src/full/java/com/topjohnwu/magisk/AboutActivity.java +++ b/app/src/full/java/com/topjohnwu/magisk/AboutActivity.java @@ -15,18 +15,16 @@ import java.util.Locale; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.Toolbar; -import butterknife.BindView; -import butterknife.ButterKnife; public class AboutActivity extends BaseActivity { - @BindView(R.id.toolbar) Toolbar toolbar; - @BindView(R.id.app_version_info) AboutCardRow appVersionInfo; - @BindView(R.id.app_changelog) AboutCardRow appChangelog; - @BindView(R.id.app_translators) AboutCardRow appTranslators; - @BindView(R.id.app_source_code) AboutCardRow appSourceCode; - @BindView(R.id.support_thread) AboutCardRow supportThread; - @BindView(R.id.follow_twitter) AboutCardRow twitter; + Toolbar toolbar; + AboutCardRow appVersionInfo; + AboutCardRow appChangelog; + AboutCardRow appTranslators; + AboutCardRow appSourceCode; + AboutCardRow supportThread; + AboutCardRow twitter; @Override public int getDarkTheme() { @@ -37,7 +35,7 @@ public class AboutActivity extends BaseActivity { protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_about); - ButterKnife.bind(this); + ViewBinder.bind(this); setSupportActionBar(toolbar); toolbar.setNavigationOnClickListener(view -> finish()); diff --git a/app/src/full/java/com/topjohnwu/magisk/DonationActivity.java b/app/src/full/java/com/topjohnwu/magisk/DonationActivity.java index 01b6d2c20..3386bb7a6 100644 --- a/app/src/full/java/com/topjohnwu/magisk/DonationActivity.java +++ b/app/src/full/java/com/topjohnwu/magisk/DonationActivity.java @@ -10,14 +10,12 @@ import com.topjohnwu.magisk.utils.Utils; import androidx.annotation.Nullable; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.Toolbar; -import butterknife.BindView; -import butterknife.ButterKnife; public class DonationActivity extends BaseActivity { - @BindView(R.id.toolbar) Toolbar toolbar; - @BindView(R.id.paypal) AboutCardRow paypal; - @BindView(R.id.patreon) AboutCardRow patreon; + Toolbar toolbar; + AboutCardRow paypal; + AboutCardRow patreon; @Override public int getDarkTheme() { @@ -28,7 +26,7 @@ public class DonationActivity extends BaseActivity { protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_donation); - ButterKnife.bind(this); + ViewBinder.bind(this); setSupportActionBar(toolbar); toolbar.setNavigationOnClickListener(view -> finish()); diff --git a/app/src/full/java/com/topjohnwu/magisk/FlashActivity.java b/app/src/full/java/com/topjohnwu/magisk/FlashActivity.java index 48217084d..9da5edd6c 100644 --- a/app/src/full/java/com/topjohnwu/magisk/FlashActivity.java +++ b/app/src/full/java/com/topjohnwu/magisk/FlashActivity.java @@ -31,31 +31,25 @@ import java.util.Locale; import androidx.appcompat.app.ActionBar; import androidx.appcompat.widget.Toolbar; -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.OnClick; public class FlashActivity extends BaseActivity { - @BindView(R.id.toolbar) Toolbar toolbar; - @BindView(R.id.txtLog) TextView flashLogs; - @BindView(R.id.button_panel) public LinearLayout buttonPanel; - @BindView(R.id.reboot) public Button reboot; - @BindView(R.id.scrollView) ScrollView sv; + Toolbar toolbar; + TextView flashLogs; + public LinearLayout buttonPanel; + public Button reboot; + ScrollView sv; private List logs; - @OnClick(R.id.no_thanks) void dismiss() { finish(); } - @OnClick(R.id.reboot) void reboot() { Shell.su("/system/bin/reboot").submit(); } - @OnClick(R.id.save_logs) void saveLogs() { runWithPermission(new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE}, () -> { Calendar now = Calendar.getInstance(); @@ -88,7 +82,7 @@ public class FlashActivity extends BaseActivity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_flash); - ButterKnife.bind(this); + ViewBinder.bind(this); setSupportActionBar(toolbar); ActionBar ab = getSupportActionBar(); if (ab != null) { diff --git a/app/src/full/java/com/topjohnwu/magisk/MainActivity.java b/app/src/full/java/com/topjohnwu/magisk/MainActivity.java index dcbd12dfc..776f7a7b2 100644 --- a/app/src/full/java/com/topjohnwu/magisk/MainActivity.java +++ b/app/src/full/java/com/topjohnwu/magisk/MainActivity.java @@ -26,8 +26,6 @@ import androidx.appcompat.widget.Toolbar; import androidx.drawerlayout.widget.DrawerLayout; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentTransaction; -import butterknife.BindView; -import butterknife.ButterKnife; public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener, Topic.Subscriber { @@ -36,9 +34,9 @@ public class MainActivity extends BaseActivity private int mDrawerItem; private static boolean fromShortcut = false; - @BindView(R.id.drawer_layout) DrawerLayout drawer; - @BindView(R.id.toolbar) public Toolbar toolbar; - @BindView(R.id.nav_view) public NavigationView navigationView; + public Toolbar toolbar; + DrawerLayout drawer; + NavigationView navigationView; private float toolbarElevation; @@ -50,13 +48,13 @@ public class MainActivity extends BaseActivity @Override protected void onCreate(final Bundle savedInstanceState) { if (!mm.hasInit) { - startActivity(new Intent(this, SplashActivity.class)); + startActivity(new Intent(this, a.c.class)); finish(); } super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - ButterKnife.bind(this); + ViewBinder.bind(this); setSupportActionBar(toolbar); @@ -196,11 +194,11 @@ public class MainActivity extends BaseActivity displayFragment(new SettingsFragment(), true); break; case R.id.app_about: - startActivity(new Intent(this, AboutActivity.class)); + startActivity(new Intent(this, a.d.class)); mDrawerItem = bak; break; case R.id.donation: - startActivity(new Intent(this, DonationActivity.class)); + startActivity(new Intent(this, a.e.class)); mDrawerItem = bak; break; } diff --git a/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java b/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java index 4abb7c85e..4eb1efc70 100644 --- a/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java +++ b/app/src/full/java/com/topjohnwu/magisk/SplashActivity.java @@ -10,12 +10,13 @@ import com.topjohnwu.magisk.asyncs.CheckUpdates; import com.topjohnwu.magisk.asyncs.UpdateRepos; import com.topjohnwu.magisk.components.BaseActivity; import com.topjohnwu.magisk.database.RepoDatabaseHelper; -import com.topjohnwu.magisk.receivers.ShortcutReceiver; import com.topjohnwu.magisk.utils.Download; import com.topjohnwu.magisk.utils.LocaleManager; import com.topjohnwu.magisk.utils.Utils; import com.topjohnwu.superuser.Shell; +import a.l; + public class SplashActivity extends BaseActivity { @Override @@ -44,7 +45,7 @@ public class SplashActivity extends BaseActivity { } // Setup shortcuts - sendBroadcast(new Intent(this, ShortcutReceiver.class)); + sendBroadcast(new Intent(this, l.class)); if (Download.checkNetworkStatus(this)) { // Fire update check @@ -58,7 +59,7 @@ public class SplashActivity extends BaseActivity { mm.hasInit = true; - Intent intent = new Intent(this, MainActivity.class); + Intent intent = new Intent(this, a.b.class); intent.putExtra(Const.Key.OPEN_SECTION, getIntent().getStringExtra(Const.Key.OPEN_SECTION)); intent.putExtra(BaseActivity.INTENT_PERM, getIntent().getStringExtra(BaseActivity.INTENT_PERM)); startActivity(intent); diff --git a/app/src/full/java/com/topjohnwu/magisk/ViewBinder.java b/app/src/full/java/com/topjohnwu/magisk/ViewBinder.java new file mode 100644 index 000000000..ebb7b32aa --- /dev/null +++ b/app/src/full/java/com/topjohnwu/magisk/ViewBinder.java @@ -0,0 +1,292 @@ +package com.topjohnwu.magisk; + +import android.content.Context; +import android.view.View; + +import com.topjohnwu.magisk.adapters.ApplicationAdapter; +import com.topjohnwu.magisk.adapters.ModulesAdapter; +import com.topjohnwu.magisk.adapters.PolicyAdapter; +import com.topjohnwu.magisk.adapters.ReposAdapter; +import com.topjohnwu.magisk.adapters.SuLogAdapter; +import com.topjohnwu.magisk.components.AboutCardRow; +import com.topjohnwu.magisk.components.CustomAlertDialog; +import com.topjohnwu.magisk.fragments.LogFragment; +import com.topjohnwu.magisk.fragments.MagiskFragment; +import com.topjohnwu.magisk.fragments.MagiskHideFragment; +import com.topjohnwu.magisk.fragments.MagiskLogFragment; +import com.topjohnwu.magisk.fragments.ModulesFragment; +import com.topjohnwu.magisk.fragments.ReposFragment; +import com.topjohnwu.magisk.fragments.SuLogFragment; +import com.topjohnwu.magisk.fragments.SuperuserFragment; +import com.topjohnwu.magisk.superuser.RequestActivity; + +import androidx.core.content.ContextCompat; + +public class ViewBinder { + + public static void bind(MainActivity target) { + target.drawer = target.findViewById(R.id.drawer_layout); + target.toolbar = target.findViewById(R.id.toolbar); + target.navigationView = target.findViewById(R.id.nav_view); + } + + public static void bind(AboutActivity target) { + target.toolbar = target.findViewById(R.id.toolbar); + target.appVersionInfo = target.findViewById(R.id.app_version_info); + target.appChangelog = target.findViewById(R.id.app_changelog); + target.appTranslators = target.findViewById(R.id.app_translators); + target.appSourceCode = target.findViewById(R.id.app_source_code); + target.supportThread = target.findViewById(R.id.support_thread); + target.twitter = target.findViewById(R.id.follow_twitter); + } + + public static void bind(DonationActivity target) { + target.toolbar = target.findViewById(R.id.toolbar); + target.paypal = target.findViewById(R.id.paypal); + target.patreon = target.findViewById(R.id.patreon); + } + + public static void bind(FlashActivity target) { + target.toolbar = target.findViewById(R.id.toolbar); + target.flashLogs = target.findViewById(R.id.txtLog); + target.buttonPanel = target.findViewById(R.id.button_panel); + target.findViewById(R.id.no_thanks).setOnClickListener(v -> target.finish()); + target.findViewById(R.id.reboot).setOnClickListener(v -> target.reboot()); + target.findViewById(R.id.save_logs).setOnClickListener(v -> target.saveLogs()); + } + + public static void bind(RequestActivity target) { + target.suPopup = target.findViewById(R.id.su_popup); + target.timeout = target.findViewById(R.id.timeout); + target.appIcon = target.findViewById(R.id.app_icon); + target.appNameView = target.findViewById(R.id.app_name); + target.packageNameView = target.findViewById(R.id.package_name); + target.grant_btn = target.findViewById(R.id.grant_btn); + target.deny_btn = target.findViewById(R.id.deny_btn); + target.fingerprintImg = target.findViewById(R.id.fingerprint); + target.warning = target.findViewById(R.id.warning); + } + + public static void bind(LogFragment target, View v) { + target.viewPager = v.findViewById(R.id.container); + target.tab = v.findViewById(R.id.tab); + } + + public static void unbind(LogFragment target) { + target.viewPager = null; + target.tab = null; + } + + public static void bind(MagiskFragment target, View v) { + target.mSwipeRefreshLayout = v.findViewById(R.id.swipeRefreshLayout); + target.coreOnlyNotice = v.findViewById(R.id.core_only_notice); + target.magiskUpdate = v.findViewById(R.id.magisk_update); + target.magiskUpdateIcon = v.findViewById(R.id.magisk_update_icon); + target.magiskUpdateText = v.findViewById(R.id.magisk_update_status); + target.magiskUpdateProgress = v.findViewById(R.id.magisk_update_progress); + target.magiskStatusIcon = v.findViewById(R.id.magisk_status_icon); + target.magiskVersionText = v.findViewById(R.id.magisk_version); + target.safetyNetCard = v.findViewById(R.id.safetyNet_card); + target.safetyNetRefreshIcon = v.findViewById(R.id.safetyNet_refresh); + target.safetyNetStatusText = v.findViewById(R.id.safetyNet_status); + target.safetyNetProgress = v.findViewById(R.id.safetyNet_check_progress); + target.expandLayout = v.findViewById(R.id.expand_layout); + target.ctsStatusIcon = v.findViewById(R.id.cts_status_icon); + target.ctsStatusText = v.findViewById(R.id.cts_status); + target.basicStatusIcon = v.findViewById(R.id.basic_status_icon); + target.basicStatusText = v.findViewById(R.id.basic_status); + target.installOptionCard = v.findViewById(R.id.install_option_card); + target.keepEncChkbox = v.findViewById(R.id.keep_force_enc); + target.keepVerityChkbox = v.findViewById(R.id.keep_verity); + target.installButton = v.findViewById(R.id.install_button); + target.installText = v.findViewById(R.id.install_text); + target.uninstallButton = v.findViewById(R.id.uninstall_button); + + v.findViewById(R.id.safetyNet_title).setOnClickListener(v1 -> target.safetyNet()); + v.findViewById(R.id.install_button).setOnClickListener(v1 -> target.install()); + v.findViewById(R.id.uninstall_button).setOnClickListener(v1 -> target.uninstall()); + + Context ctx = target.getContext(); + target.colorBad = ContextCompat.getColor(ctx, R.color.red500); + target.colorOK = ContextCompat.getColor(ctx, R.color.green500); + target.colorWarn = ContextCompat.getColor(ctx, R.color.yellow500); + target.colorNeutral = ContextCompat.getColor(ctx, R.color.grey500); + target.colorInfo = ContextCompat.getColor(ctx, R.color.blue500); + } + + public static void unbind(MagiskFragment target) { + target.mSwipeRefreshLayout = null; + target.coreOnlyNotice = null; + target.magiskUpdate = null; + target.magiskUpdateIcon = null; + target.magiskUpdateText = null; + target.magiskUpdateProgress = null; + target.magiskStatusIcon = null; + target.magiskVersionText = null; + target.safetyNetCard = null; + target.safetyNetRefreshIcon = null; + target.safetyNetStatusText = null; + target.safetyNetProgress = null; + target.expandLayout = null; + target.ctsStatusIcon = null; + target.ctsStatusText = null; + target.basicStatusIcon = null; + target.basicStatusText = null; + target.installOptionCard = null; + target.keepEncChkbox = null; + target.keepVerityChkbox = null; + target.installButton = null; + target.installText = null; + target.uninstallButton = null; + + View v = target.getView(); + v.findViewById(R.id.safetyNet_title).setOnClickListener(null); + v.findViewById(R.id.install_button).setOnClickListener(null); + v.findViewById(R.id.uninstall_button).setOnClickListener(null); + } + + public static void bind(MagiskHideFragment target, View v) { + target.mSwipeRefreshLayout = v.findViewById(R.id.swipeRefreshLayout); + target.recyclerView = v.findViewById(R.id.recyclerView); + } + + public static void unbind(MagiskHideFragment target) { + target.mSwipeRefreshLayout = null; + target.recyclerView = null; + } + + public static void bind(MagiskLogFragment target, View v) { + target.txtLog = v.findViewById(R.id.txtLog); + target.svLog = v.findViewById(R.id.svLog); + target.hsvLog = v.findViewById(R.id.hsvLog); + target.progressBar = v.findViewById(R.id.progressBar); + } + + public static void unbind(MagiskLogFragment target) { + target.txtLog = null; + target.svLog = null; + target.hsvLog = null; + target.progressBar = null; + } + + public static void bind(ModulesFragment target, View v) { + target.mSwipeRefreshLayout = v.findViewById(R.id.swipeRefreshLayout); + target.recyclerView = v.findViewById(R.id.recyclerView); + target.emptyRv = v.findViewById(R.id.empty_rv); + v.findViewById(R.id.fab).setOnClickListener(v1 -> target.selectFile()); + } + + public static void unbind(ModulesFragment target) { + target.mSwipeRefreshLayout = null; + target.recyclerView = null; + target.emptyRv = null; + View v = target.getView(); + v.findViewById(R.id.fab).setOnClickListener(null); + } + + public static void bind(ReposFragment target, View source) { + target.recyclerView = source.findViewById(R.id.recyclerView); + target.emptyRv = source.findViewById(R.id.empty_rv); + target.mSwipeRefreshLayout = source.findViewById(R.id.swipeRefreshLayout); + } + + public static void unbind(ReposFragment target) { + target.recyclerView = null; + target.emptyRv = null; + target.mSwipeRefreshLayout = null; + } + + public static void bind(SuLogFragment target, View source) { + target.emptyRv = source.findViewById(R.id.empty_rv); + target.recyclerView = source.findViewById(R.id.recyclerView); + } + + public static void unbind(SuLogFragment target) { + target.emptyRv = null; + target.recyclerView = null; + } + + public static void bind(SuperuserFragment target, View source) { + target.recyclerView = source.findViewById(R.id.recyclerView); + target.emptyRv = source.findViewById(R.id.empty_rv); + } + + public static void unbind(SuperuserFragment target) { + target.emptyRv = null; + target.recyclerView = null; + } + + public static void bind(CustomAlertDialog.ViewHolder target, View source) { + target.dialogLayout = source.findViewById(R.id.dialog_layout); + target.buttons = source.findViewById(R.id.button_panel); + target.messageView = source.findViewById(R.id.message); + target.negative = source.findViewById(R.id.negative); + target.positive = source.findViewById(R.id.positive); + target.neutral = source.findViewById(R.id.neutral); + } + + public static void bind(AboutCardRow target, View source) { + target.mTitle = source.findViewById(android.R.id.title); + target.mSummary = source.findViewById(android.R.id.summary); + target.mIcon = source.findViewById(android.R.id.icon); + target.mView = source.findViewById(R.id.container); + } + + public static void bind(ApplicationAdapter.ViewHolder target, View source) { + target.appIcon = source.findViewById(R.id.app_icon); + target.appName = source.findViewById(R.id.app_name); + target.appPackage = source.findViewById(R.id.package_name); + target.checkBox = source.findViewById(R.id.checkbox); + } + + public static void bind(ModulesAdapter.ViewHolder target, View source) { + target.title = source.findViewById(R.id.title); + target.versionName = source.findViewById(R.id.version_name); + target.description = source.findViewById(R.id.description); + target.notice = source.findViewById(R.id.notice); + target.checkBox = source.findViewById(R.id.checkbox); + target.author = source.findViewById(R.id.author); + target.delete = source.findViewById(R.id.delete); + } + + public static void bind(PolicyAdapter.ViewHolder target, View source) { + target.appName = source.findViewById(R.id.app_name); + target.packageName = source.findViewById(R.id.package_name); + target.appIcon = source.findViewById(R.id.app_icon); + target.masterSwitch = source.findViewById(R.id.master_switch); + target.notificationSwitch = source.findViewById(R.id.notification_switch); + target.loggingSwitch = source.findViewById(R.id.logging_switch); + target.expandLayout = source.findViewById(R.id.expand_layout); + target.delete = source.findViewById(R.id.delete); + target.moreInfo = source.findViewById(R.id.more_info); + } + + public static void bind(ReposAdapter.SectionHolder target, View source) { + target.sectionText = source.findViewById(R.id.section_text); + } + + public static void bind(ReposAdapter.RepoHolder target, View source) { + target.title = source.findViewById(R.id.title); + target.versionName = source.findViewById(R.id.version_name); + target.description = source.findViewById(R.id.description); + target.author = source.findViewById(R.id.author); + target.infoLayout = source.findViewById(R.id.info_layout); + target.downloadImage = source.findViewById(R.id.download); + target.updateTime = source.findViewById(R.id.update_time); + } + + public static void bind(SuLogAdapter.SectionHolder target, View source) { + target.date = source.findViewById(R.id.date); + target.arrow = source.findViewById(R.id.arrow); + } + + public static void bind(SuLogAdapter.LogViewHolder target, View source) { + target.appName = source.findViewById(R.id.app_name); + target.action = source.findViewById(R.id.action); + target.time = source.findViewById(R.id.time); + target.fromPid = source.findViewById(R.id.fromPid); + target.toUid = source.findViewById(R.id.toUid); + target.command = source.findViewById(R.id.command); + target.expandLayout = source.findViewById(R.id.expand_layout); + } +} diff --git a/app/src/full/java/com/topjohnwu/magisk/adapters/ApplicationAdapter.java b/app/src/full/java/com/topjohnwu/magisk/adapters/ApplicationAdapter.java index 11f432758..4a7382a85 100644 --- a/app/src/full/java/com/topjohnwu/magisk/adapters/ApplicationAdapter.java +++ b/app/src/full/java/com/topjohnwu/magisk/adapters/ApplicationAdapter.java @@ -17,6 +17,7 @@ import android.widget.TextView; import com.topjohnwu.magisk.Const; import com.topjohnwu.magisk.R; +import com.topjohnwu.magisk.ViewBinder; import com.topjohnwu.magisk.utils.LocaleManager; import com.topjohnwu.magisk.utils.Topic; import com.topjohnwu.superuser.Shell; @@ -28,8 +29,6 @@ import java.util.List; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; -import butterknife.BindView; -import butterknife.ButterKnife; public class ApplicationAdapter extends RecyclerView.Adapter { @@ -123,16 +122,16 @@ public class ApplicationAdapter extends RecyclerView.Adapter { @@ -102,19 +101,19 @@ public class ModulesAdapter extends RecyclerView.Adapter { @@ -120,24 +119,24 @@ public class PolicyAdapter extends RecyclerView.Adapter { @@ -159,29 +158,29 @@ public class ReposAdapter extends SectionedAdapter { @@ -117,32 +116,32 @@ public class SuLogAdapter extends SectionedAdapter activity.runWithPermission( new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, () -> { - Intent intent = new Intent(mm, ManagerUpdate.class); + Intent intent = new Intent(mm, j.class); intent.putExtra(Const.Key.INTENT_SET_LINK, Data.managerLink); intent.putExtra(Const.Key.INTENT_SET_FILENAME, filename); mm.sendBroadcast(intent); diff --git a/app/src/full/java/com/topjohnwu/magisk/fragments/LogFragment.java b/app/src/full/java/com/topjohnwu/magisk/fragments/LogFragment.java index 919e01ac2..0802ddf4c 100644 --- a/app/src/full/java/com/topjohnwu/magisk/fragments/LogFragment.java +++ b/app/src/full/java/com/topjohnwu/magisk/fragments/LogFragment.java @@ -11,27 +11,23 @@ import com.topjohnwu.magisk.Const; import com.topjohnwu.magisk.Data; import com.topjohnwu.magisk.MainActivity; import com.topjohnwu.magisk.R; +import com.topjohnwu.magisk.ViewBinder; import com.topjohnwu.magisk.adapters.TabFragmentAdapter; import com.topjohnwu.magisk.components.BaseFragment; import androidx.viewpager.widget.ViewPager; -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.Unbinder; public class LogFragment extends BaseFragment { - private Unbinder unbinder; - - @BindView(R.id.container) ViewPager viewPager; - @BindView(R.id.tab) TabLayout tab; + public ViewPager viewPager; + public TabLayout tab; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View v = inflater.inflate(R.layout.fragment_log, container, false); - unbinder = ButterKnife.bind(this, v); + ViewBinder.bind(this, v); ((MainActivity) requireActivity()).toolbar.setElevation(0); @@ -52,7 +48,6 @@ public class LogFragment extends BaseFragment { @Override public void onDestroyView() { super.onDestroyView(); - unbinder.unbind(); + ViewBinder.unbind(this); } - } diff --git a/app/src/full/java/com/topjohnwu/magisk/fragments/MagiskFragment.java b/app/src/full/java/com/topjohnwu/magisk/fragments/MagiskFragment.java index 45b35c0ad..32fb61bb1 100644 --- a/app/src/full/java/com/topjohnwu/magisk/fragments/MagiskFragment.java +++ b/app/src/full/java/com/topjohnwu/magisk/fragments/MagiskFragment.java @@ -20,6 +20,7 @@ import com.topjohnwu.magisk.Const; import com.topjohnwu.magisk.Data; import com.topjohnwu.magisk.MainActivity; import com.topjohnwu.magisk.R; +import com.topjohnwu.magisk.ViewBinder; import com.topjohnwu.magisk.asyncs.CheckSafetyNet; import com.topjohnwu.magisk.asyncs.CheckUpdates; import com.topjohnwu.magisk.components.BaseActivity; @@ -41,55 +42,48 @@ import androidx.annotation.Nullable; import androidx.annotation.StringRes; import androidx.cardview.widget.CardView; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; -import butterknife.BindColor; -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.OnClick; -import butterknife.Unbinder; public class MagiskFragment extends BaseFragment implements SwipeRefreshLayout.OnRefreshListener, ExpandableView, Topic.Subscriber { private Container expandableContainer = new Container(); - private Unbinder unbinder; private static boolean shownDialog = false; - @BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout; + public SwipeRefreshLayout mSwipeRefreshLayout; - @BindView(R.id.core_only_notice) CardView coreOnlyNotice; + public CardView coreOnlyNotice; - @BindView(R.id.magisk_update) RelativeLayout magiskUpdate; - @BindView(R.id.magisk_update_icon) ImageView magiskUpdateIcon; - @BindView(R.id.magisk_update_status) TextView magiskUpdateText; - @BindView(R.id.magisk_update_progress) ProgressBar magiskUpdateProgress; - @BindView(R.id.magisk_status_icon) ImageView magiskStatusIcon; - @BindView(R.id.magisk_version) TextView magiskVersionText; + public RelativeLayout magiskUpdate; + public ImageView magiskUpdateIcon; + public TextView magiskUpdateText; + public ProgressBar magiskUpdateProgress; + public ImageView magiskStatusIcon; + public TextView magiskVersionText; - @BindView(R.id.safetyNet_card) CardView safetyNetCard; - @BindView(R.id.safetyNet_refresh) ImageView safetyNetRefreshIcon; - @BindView(R.id.safetyNet_status) TextView safetyNetStatusText; - @BindView(R.id.safetyNet_check_progress) ProgressBar safetyNetProgress; - @BindView(R.id.expand_layout) LinearLayout expandLayout; - @BindView(R.id.cts_status_icon) ImageView ctsStatusIcon; - @BindView(R.id.cts_status) TextView ctsStatusText; - @BindView(R.id.basic_status_icon) ImageView basicStatusIcon; - @BindView(R.id.basic_status) TextView basicStatusText; + public CardView safetyNetCard; + public ImageView safetyNetRefreshIcon; + public TextView safetyNetStatusText; + public ProgressBar safetyNetProgress; + public LinearLayout expandLayout; + public ImageView ctsStatusIcon; + public TextView ctsStatusText; + public ImageView basicStatusIcon; + public TextView basicStatusText; - @BindView(R.id.install_option_card) CardView installOptionCard; - @BindView(R.id.keep_force_enc) CheckBox keepEncChkbox; - @BindView(R.id.keep_verity) CheckBox keepVerityChkbox; - @BindView(R.id.install_button) CardView installButton; - @BindView(R.id.install_text) TextView installText; - @BindView(R.id.uninstall_button) CardView uninstallButton; + public CardView installOptionCard; + public CheckBox keepEncChkbox; + public CheckBox keepVerityChkbox; + public CardView installButton; + public TextView installText; + public CardView uninstallButton; - @BindColor(R.color.red500) int colorBad; - @BindColor(R.color.green500) int colorOK; - @BindColor(R.color.yellow500) int colorWarn; - @BindColor(R.color.grey500) int colorNeutral; - @BindColor(R.color.blue500) int colorInfo; + public int colorBad; + public int colorOK; + public int colorWarn; + public int colorNeutral; + public int colorInfo; - @OnClick(R.id.safetyNet_title) - void safetyNet() { + public void safetyNet() { Runnable task = () -> { safetyNetProgress.setVisibility(View.VISIBLE); safetyNetRefreshIcon.setVisibility(View.GONE); @@ -112,8 +106,7 @@ public class MagiskFragment extends BaseFragment } - @OnClick(R.id.install_button) - void install() { + public void install() { shownDialog = true; // Show Manager update first @@ -126,8 +119,7 @@ public class MagiskFragment extends BaseFragment new MagiskInstallDialog((BaseActivity) getActivity()).show(); } - @OnClick(R.id.uninstall_button) - void uninstall() { + public void uninstall() { new UninstallDialog(requireActivity()).show(); } @@ -136,7 +128,7 @@ public class MagiskFragment extends BaseFragment public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_magisk, container, false); - unbinder = ButterKnife.bind(this, v); + ViewBinder.bind(this, v); requireActivity().setTitle(R.string.magisk); expandableContainer.expandLayout = expandLayout; @@ -153,6 +145,12 @@ public class MagiskFragment extends BaseFragment return v; } + @Override + public void onDestroyView() { + super.onDestroyView(); + ViewBinder.unbind(this); + } + @Override public void onRefresh() { Data.loadMagiskInfo(); @@ -196,12 +194,6 @@ public class MagiskFragment extends BaseFragment } } - @Override - public void onDestroyView() { - super.onDestroyView(); - unbinder.unbind(); - } - @Override public Container getContainer() { return expandableContainer; diff --git a/app/src/full/java/com/topjohnwu/magisk/fragments/MagiskHideFragment.java b/app/src/full/java/com/topjohnwu/magisk/fragments/MagiskHideFragment.java index 009821189..6d54293b9 100644 --- a/app/src/full/java/com/topjohnwu/magisk/fragments/MagiskHideFragment.java +++ b/app/src/full/java/com/topjohnwu/magisk/fragments/MagiskHideFragment.java @@ -9,6 +9,7 @@ import android.view.ViewGroup; import android.widget.SearchView; import com.topjohnwu.magisk.R; +import com.topjohnwu.magisk.ViewBinder; import com.topjohnwu.magisk.adapters.ApplicationAdapter; import com.topjohnwu.magisk.components.BaseFragment; import com.topjohnwu.magisk.utils.Topic; @@ -17,15 +18,11 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.recyclerview.widget.RecyclerView; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.Unbinder; public class MagiskHideFragment extends BaseFragment implements Topic.Subscriber { - private Unbinder unbinder; - @BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout; - @BindView(R.id.recyclerView) RecyclerView recyclerView; + public SwipeRefreshLayout mSwipeRefreshLayout; + public RecyclerView recyclerView; SearchView search; private ApplicationAdapter appAdapter; @@ -42,7 +39,7 @@ public class MagiskHideFragment extends BaseFragment implements Topic.Subscriber @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_magisk_hide, container, false); - unbinder = ButterKnife.bind(this, view); + ViewBinder.bind(this, view); appAdapter = new ApplicationAdapter(requireActivity()); recyclerView.setAdapter(appAdapter); @@ -79,7 +76,7 @@ public class MagiskHideFragment extends BaseFragment implements Topic.Subscriber @Override public void onDestroyView() { super.onDestroyView(); - unbinder.unbind(); + ViewBinder.unbind(this); } @Override diff --git a/app/src/full/java/com/topjohnwu/magisk/fragments/MagiskLogFragment.java b/app/src/full/java/com/topjohnwu/magisk/fragments/MagiskLogFragment.java index 5bf8309d1..77b293578 100644 --- a/app/src/full/java/com/topjohnwu/magisk/fragments/MagiskLogFragment.java +++ b/app/src/full/java/com/topjohnwu/magisk/fragments/MagiskLogFragment.java @@ -17,6 +17,7 @@ import android.widget.TextView; import com.google.android.material.snackbar.Snackbar; import com.topjohnwu.magisk.Const; import com.topjohnwu.magisk.R; +import com.topjohnwu.magisk.ViewBinder; import com.topjohnwu.magisk.components.BaseFragment; import com.topjohnwu.magisk.components.SnackbarMaker; import com.topjohnwu.magisk.utils.Download; @@ -28,24 +29,19 @@ import java.io.IOException; import java.util.Calendar; import androidx.annotation.Nullable; -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.Unbinder; public class MagiskLogFragment extends BaseFragment { - private Unbinder unbinder; - - @BindView(R.id.txtLog) TextView txtLog; - @BindView(R.id.svLog) ScrollView svLog; - @BindView(R.id.hsvLog) HorizontalScrollView hsvLog; - @BindView(R.id.progressBar) ProgressBar progressBar; + public TextView txtLog; + public ScrollView svLog; + public HorizontalScrollView hsvLog; + public ProgressBar progressBar; @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_magisk_log, container, false); - unbinder = ButterKnife.bind(this, view); + ViewBinder.bind(this, view); setHasOptionsMenu(true); txtLog.setTextIsSelectable(true); return view; @@ -66,7 +62,7 @@ public class MagiskLogFragment extends BaseFragment { @Override public void onDestroyView() { super.onDestroyView(); - unbinder.unbind(); + ViewBinder.unbind(this); } @Override diff --git a/app/src/full/java/com/topjohnwu/magisk/fragments/ModulesFragment.java b/app/src/full/java/com/topjohnwu/magisk/fragments/ModulesFragment.java index d47493f04..740638e20 100644 --- a/app/src/full/java/com/topjohnwu/magisk/fragments/ModulesFragment.java +++ b/app/src/full/java/com/topjohnwu/magisk/fragments/ModulesFragment.java @@ -15,6 +15,7 @@ import android.widget.TextView; import com.topjohnwu.magisk.Const; import com.topjohnwu.magisk.FlashActivity; import com.topjohnwu.magisk.R; +import com.topjohnwu.magisk.ViewBinder; import com.topjohnwu.magisk.adapters.ModulesAdapter; import com.topjohnwu.magisk.components.BaseFragment; import com.topjohnwu.magisk.container.Module; @@ -30,18 +31,13 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.recyclerview.widget.RecyclerView; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.OnClick; -import butterknife.Unbinder; public class ModulesFragment extends BaseFragment implements Topic.Subscriber { - private Unbinder unbinder; - @BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout; - @BindView(R.id.recyclerView) RecyclerView recyclerView; - @BindView(R.id.empty_rv) TextView emptyRv; - @OnClick(R.id.fab) + public SwipeRefreshLayout mSwipeRefreshLayout; + public RecyclerView recyclerView; + public TextView emptyRv; + public void selectFile() { runWithPermission(new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, () -> { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); @@ -56,7 +52,7 @@ public class ModulesFragment extends BaseFragment implements Topic.Subscriber { @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_modules, container, false); - unbinder = ButterKnife.bind(this, view); + ViewBinder.bind(this, view); setHasOptionsMenu(true); mSwipeRefreshLayout.setOnRefreshListener(() -> { @@ -104,7 +100,7 @@ public class ModulesFragment extends BaseFragment implements Topic.Subscriber { @Override public void onDestroyView() { super.onDestroyView(); - unbinder.unbind(); + ViewBinder.unbind(this); } @Override diff --git a/app/src/full/java/com/topjohnwu/magisk/fragments/ReposFragment.java b/app/src/full/java/com/topjohnwu/magisk/fragments/ReposFragment.java index b669e15c7..e7ae2b118 100644 --- a/app/src/full/java/com/topjohnwu/magisk/fragments/ReposFragment.java +++ b/app/src/full/java/com/topjohnwu/magisk/fragments/ReposFragment.java @@ -14,6 +14,7 @@ import android.widget.TextView; import com.topjohnwu.magisk.Const; import com.topjohnwu.magisk.Data; import com.topjohnwu.magisk.R; +import com.topjohnwu.magisk.ViewBinder; import com.topjohnwu.magisk.adapters.ReposAdapter; import com.topjohnwu.magisk.asyncs.UpdateRepos; import com.topjohnwu.magisk.components.BaseFragment; @@ -26,16 +27,12 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.recyclerview.widget.RecyclerView; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.Unbinder; public class ReposFragment extends BaseFragment implements Topic.Subscriber { - private Unbinder unbinder; - @BindView(R.id.recyclerView) RecyclerView recyclerView; - @BindView(R.id.empty_rv) TextView emptyRv; - @BindView(R.id.swipeRefreshLayout) SwipeRefreshLayout mSwipeRefreshLayout; + public RecyclerView recyclerView; + public TextView emptyRv; + public SwipeRefreshLayout mSwipeRefreshLayout; private ReposAdapter adapter; @@ -49,7 +46,7 @@ public class ReposFragment extends BaseFragment implements Topic.Subscriber { @Override public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_repos, container, false); - unbinder = ButterKnife.bind(this, view); + ViewBinder.bind(this, view); mSwipeRefreshLayout.setRefreshing(true); recyclerView.setVisibility(View.GONE); @@ -123,6 +120,6 @@ public class ReposFragment extends BaseFragment implements Topic.Subscriber { public void onDestroyView() { super.onDestroyView(); mm.repoDB.unregisterAdapter(); - unbinder.unbind(); + ViewBinder.unbind(this); } } diff --git a/app/src/full/java/com/topjohnwu/magisk/fragments/SuLogFragment.java b/app/src/full/java/com/topjohnwu/magisk/fragments/SuLogFragment.java index b5a3349d6..0c1891771 100644 --- a/app/src/full/java/com/topjohnwu/magisk/fragments/SuLogFragment.java +++ b/app/src/full/java/com/topjohnwu/magisk/fragments/SuLogFragment.java @@ -10,21 +10,18 @@ import android.view.ViewGroup; import android.widget.TextView; import com.topjohnwu.magisk.R; +import com.topjohnwu.magisk.ViewBinder; import com.topjohnwu.magisk.adapters.SuLogAdapter; import com.topjohnwu.magisk.components.BaseFragment; import androidx.annotation.Nullable; import androidx.recyclerview.widget.RecyclerView; -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.Unbinder; public class SuLogFragment extends BaseFragment { - @BindView(R.id.empty_rv) TextView emptyRv; - @BindView(R.id.recyclerView) RecyclerView recyclerView; + public TextView emptyRv; + public RecyclerView recyclerView; - private Unbinder unbinder; private SuLogAdapter adapter; @Override @@ -44,7 +41,7 @@ public class SuLogFragment extends BaseFragment { Bundle savedInstanceState) { // Inflate the layout for this fragment View v = inflater.inflate(R.layout.fragment_su_log, container, false); - unbinder = ButterKnife.bind(this, v); + ViewBinder.bind(this, v); adapter = new SuLogAdapter(mm.mDB); recyclerView.setAdapter(adapter); @@ -83,6 +80,6 @@ public class SuLogFragment extends BaseFragment { @Override public void onDestroyView() { super.onDestroyView(); - unbinder.unbind(); + ViewBinder.unbind(this); } } diff --git a/app/src/full/java/com/topjohnwu/magisk/fragments/SuperuserFragment.java b/app/src/full/java/com/topjohnwu/magisk/fragments/SuperuserFragment.java index 2773a6253..ee2b114e9 100644 --- a/app/src/full/java/com/topjohnwu/magisk/fragments/SuperuserFragment.java +++ b/app/src/full/java/com/topjohnwu/magisk/fragments/SuperuserFragment.java @@ -8,6 +8,7 @@ import android.view.ViewGroup; import android.widget.TextView; import com.topjohnwu.magisk.R; +import com.topjohnwu.magisk.ViewBinder; import com.topjohnwu.magisk.adapters.PolicyAdapter; import com.topjohnwu.magisk.components.BaseFragment; import com.topjohnwu.magisk.container.Policy; @@ -16,22 +17,19 @@ import java.util.List; import androidx.annotation.Nullable; import androidx.recyclerview.widget.RecyclerView; -import butterknife.BindView; -import butterknife.ButterKnife; -import butterknife.Unbinder; public class SuperuserFragment extends BaseFragment { - private Unbinder unbinder; + public RecyclerView recyclerView; + public TextView emptyRv; + private PackageManager pm; - @BindView(R.id.recyclerView) RecyclerView recyclerView; - @BindView(R.id.empty_rv) TextView emptyRv; @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_superuser, container, false); - unbinder = ButterKnife.bind(this, view); + ViewBinder.bind(this, view); pm = getActivity().getPackageManager(); return view; @@ -52,7 +50,7 @@ public class SuperuserFragment extends BaseFragment { @Override public void onDestroyView() { super.onDestroyView(); - unbinder.unbind(); + ViewBinder.unbind(this); } private void displayPolicyList() { diff --git a/app/src/full/java/com/topjohnwu/magisk/receivers/BootReceiver.java b/app/src/full/java/com/topjohnwu/magisk/receivers/BootReceiver.java index a80322072..11bb65b5f 100644 --- a/app/src/full/java/com/topjohnwu/magisk/receivers/BootReceiver.java +++ b/app/src/full/java/com/topjohnwu/magisk/receivers/BootReceiver.java @@ -5,14 +5,14 @@ import android.content.Context; import android.content.Intent; import android.text.TextUtils; -import com.topjohnwu.magisk.services.OnBootService; +import a.m; public class BootReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { if (TextUtils.equals(intent.getAction(), Intent.ACTION_BOOT_COMPLETED)) - OnBootService.enqueueWork(context); + m.enqueueWork(context); } } diff --git a/app/src/full/java/com/topjohnwu/magisk/receivers/ShortcutReceiver.java b/app/src/full/java/com/topjohnwu/magisk/receivers/ShortcutReceiver.java index ceb1b155b..2e625d17b 100644 --- a/app/src/full/java/com/topjohnwu/magisk/receivers/ShortcutReceiver.java +++ b/app/src/full/java/com/topjohnwu/magisk/receivers/ShortcutReceiver.java @@ -12,7 +12,6 @@ import com.topjohnwu.magisk.Const; import com.topjohnwu.magisk.Data; import com.topjohnwu.magisk.MagiskManager; import com.topjohnwu.magisk.R; -import com.topjohnwu.magisk.SplashActivity; import com.topjohnwu.superuser.Shell; import java.util.ArrayList; @@ -37,7 +36,7 @@ public class ShortcutReceiver extends BroadcastReceiver { Data.multiuserMode == Const.Value.MULTIUSER_MODE_OWNER_MANAGED)) { shortCuts.add(new ShortcutInfo.Builder(mm, "superuser") .setShortLabel(mm.getString(R.string.superuser)) - .setIntent(new Intent(mm, SplashActivity.class) + .setIntent(new Intent(mm, a.c.class) .putExtra(Const.Key.OPEN_SECTION, "superuser") .setAction(Intent.ACTION_VIEW) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)) @@ -49,7 +48,7 @@ public class ShortcutReceiver extends BroadcastReceiver { && mm.prefs.getBoolean(Const.Key.MAGISKHIDE, false)) { shortCuts.add(new ShortcutInfo.Builder(mm, "magiskhide") .setShortLabel(mm.getString(R.string.magiskhide)) - .setIntent(new Intent(mm, SplashActivity.class) + .setIntent(new Intent(mm, a.c.class) .putExtra(Const.Key.OPEN_SECTION, "magiskhide") .setAction(Intent.ACTION_VIEW) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)) @@ -60,7 +59,7 @@ public class ShortcutReceiver extends BroadcastReceiver { if (!mm.prefs.getBoolean(Const.Key.COREONLY, false) && root && Data.magiskVersionCode >= 0) { shortCuts.add(new ShortcutInfo.Builder(mm, "modules") .setShortLabel(mm.getString(R.string.modules)) - .setIntent(new Intent(mm, SplashActivity.class) + .setIntent(new Intent(mm, a.c.class) .putExtra(Const.Key.OPEN_SECTION, "modules") .setAction(Intent.ACTION_VIEW) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)) @@ -69,7 +68,7 @@ public class ShortcutReceiver extends BroadcastReceiver { .build()); shortCuts.add(new ShortcutInfo.Builder(mm, "downloads") .setShortLabel(mm.getString(R.string.download)) - .setIntent(new Intent(mm, SplashActivity.class) + .setIntent(new Intent(mm, a.c.class) .putExtra(Const.Key.OPEN_SECTION, "downloads") .setAction(Intent.ACTION_VIEW) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)) diff --git a/app/src/full/java/com/topjohnwu/magisk/superuser/RequestActivity.java b/app/src/full/java/com/topjohnwu/magisk/superuser/RequestActivity.java index 091238bd1..7dbedb57f 100644 --- a/app/src/full/java/com/topjohnwu/magisk/superuser/RequestActivity.java +++ b/app/src/full/java/com/topjohnwu/magisk/superuser/RequestActivity.java @@ -22,6 +22,7 @@ import android.widget.TextView; import com.topjohnwu.magisk.Const; import com.topjohnwu.magisk.Data; import com.topjohnwu.magisk.R; +import com.topjohnwu.magisk.ViewBinder; import com.topjohnwu.magisk.asyncs.ParallelTask; import com.topjohnwu.magisk.components.BaseActivity; import com.topjohnwu.magisk.container.Policy; @@ -30,20 +31,17 @@ import com.topjohnwu.magisk.utils.FingerprintHelper; import java.io.DataInputStream; import java.io.IOException; -import butterknife.BindView; -import butterknife.ButterKnife; - public class RequestActivity extends BaseActivity { - @BindView(R.id.su_popup) LinearLayout suPopup; - @BindView(R.id.timeout) Spinner timeout; - @BindView(R.id.app_icon) ImageView appIcon; - @BindView(R.id.app_name) TextView appNameView; - @BindView(R.id.package_name) TextView packageNameView; - @BindView(R.id.grant_btn) Button grant_btn; - @BindView(R.id.deny_btn) Button deny_btn; - @BindView(R.id.fingerprint) ImageView fingerprintImg; - @BindView(R.id.warning) TextView warning; + public LinearLayout suPopup; + public Spinner timeout; + public ImageView appIcon; + public TextView appNameView; + public TextView packageNameView; + public Button grant_btn; + public Button deny_btn; + public ImageView fingerprintImg; + public TextView warning; private String socketPath; private LocalSocket socket; @@ -117,7 +115,7 @@ public class RequestActivity extends BaseActivity { } setContentView(R.layout.activity_request); - ButterKnife.bind(this); + ViewBinder.bind(this); appIcon.setImageDrawable(policy.info.loadIcon(pm)); appNameView.setText(policy.appName); diff --git a/app/src/full/java/com/topjohnwu/magisk/utils/ISafetyNetHelper.java b/app/src/full/java/com/topjohnwu/magisk/utils/ISafetyNetHelper.java index ee4f4dad1..52b6f06c7 100644 --- a/app/src/full/java/com/topjohnwu/magisk/utils/ISafetyNetHelper.java +++ b/app/src/full/java/com/topjohnwu/magisk/utils/ISafetyNetHelper.java @@ -1,7 +1,5 @@ package com.topjohnwu.magisk.utils; -import androidx.annotation.Keep; - public interface ISafetyNetHelper { int RESPONSE_ERR = 0x01; @@ -10,14 +8,11 @@ public interface ISafetyNetHelper { int BASIC_PASS = 0x10; int CTS_PASS = 0x20; - @Keep void attest(); - @Keep int getVersion(); interface Callback { - @Keep void onResponse(int responseCode); } } diff --git a/app/src/full/java/com/topjohnwu/magisk/utils/NotificationMgr.java b/app/src/full/java/com/topjohnwu/magisk/utils/NotificationMgr.java index 4728f7a93..c62a485f2 100644 --- a/app/src/full/java/com/topjohnwu/magisk/utils/NotificationMgr.java +++ b/app/src/full/java/com/topjohnwu/magisk/utils/NotificationMgr.java @@ -9,10 +9,9 @@ import com.topjohnwu.magisk.Const; import com.topjohnwu.magisk.Data; import com.topjohnwu.magisk.MagiskManager; import com.topjohnwu.magisk.R; -import com.topjohnwu.magisk.SplashActivity; -import com.topjohnwu.magisk.receivers.ManagerUpdate; -import com.topjohnwu.magisk.receivers.RebootReceiver; +import a.j; +import a.k; import androidx.core.app.NotificationCompat; import androidx.core.app.TaskStackBuilder; @@ -21,10 +20,10 @@ public class NotificationMgr { public static void magiskUpdate() { MagiskManager mm = Data.MM(); - Intent intent = new Intent(mm, SplashActivity.class); + Intent intent = new Intent(mm, a.c.class); intent.putExtra(Const.Key.OPEN_SECTION, "magisk"); TaskStackBuilder stackBuilder = TaskStackBuilder.create(mm); - stackBuilder.addParentStack(SplashActivity.class); + stackBuilder.addParentStack(a.c.class); stackBuilder.addNextIntent(intent); PendingIntent pendingIntent = stackBuilder.getPendingIntent(Const.ID.MAGISK_UPDATE_NOTIFICATION_ID, PendingIntent.FLAG_UPDATE_CURRENT); @@ -47,7 +46,7 @@ public class NotificationMgr { String filename = Utils.fmt("MagiskManager-v%s(%d).apk", Data.remoteManagerVersionString, Data.remoteManagerVersionCode); - Intent intent = new Intent(mm, ManagerUpdate.class); + Intent intent = new Intent(mm, j.class); intent.putExtra(Const.Key.INTENT_SET_LINK, Data.managerLink); intent.putExtra(Const.Key.INTENT_SET_FILENAME, filename); PendingIntent pendingIntent = PendingIntent.getBroadcast(mm, @@ -69,7 +68,7 @@ public class NotificationMgr { public static void dtboPatched() { MagiskManager mm = Data.MM(); - Intent intent = new Intent(mm, RebootReceiver.class); + Intent intent = new Intent(mm, k.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(mm, Const.ID.DTBO_NOTIFICATION_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT); diff --git a/app/src/full/java/com/topjohnwu/magisk/utils/Utils.java b/app/src/full/java/com/topjohnwu/magisk/utils/Utils.java index 051a8ef94..950f72158 100644 --- a/app/src/full/java/com/topjohnwu/magisk/utils/Utils.java +++ b/app/src/full/java/com/topjohnwu/magisk/utils/Utils.java @@ -18,12 +18,13 @@ import com.topjohnwu.magisk.MagiskManager; import com.topjohnwu.magisk.R; import com.topjohnwu.magisk.container.Module; import com.topjohnwu.magisk.container.ValueSortedMap; -import com.topjohnwu.magisk.services.UpdateCheckService; import com.topjohnwu.superuser.io.SuFile; import java.util.Locale; import java.util.Map; +import a.n; + public class Utils { public static int getPrefsInt(SharedPreferences prefs, String key, int def) { @@ -77,7 +78,7 @@ public class Utils { if (mm.prefs.getBoolean(Const.Key.CHECK_UPDATES, true)) { if (scheduler.getAllPendingJobs().isEmpty() || Const.UPDATE_SERVICE_VER > mm.prefs.getInt(Const.Key.UPDATE_SERVICE_VER, -1)) { - ComponentName service = new ComponentName(mm, UpdateCheckService.class); + ComponentName service = new ComponentName(mm, n.class); JobInfo info = new JobInfo.Builder(Const.ID.UPDATE_SERVICE_ID, service) .setRequiredNetworkType(JobInfo.NETWORK_TYPE_ANY) .setPersisted(true) diff --git a/app/src/full/res/layout/activity_about.xml b/app/src/full/res/layout/activity_about.xml index 8e1fbdbb2..5b35c3900 100644 --- a/app/src/full/res/layout/activity_about.xml +++ b/app/src/full/res/layout/activity_about.xml @@ -54,42 +54,42 @@ android:textAppearance="@style/TextAppearance.AppCompat.Headline"/> - - - - - - - - + tools:ignore="GoogleAppIndexingWarning,UnusedAttribute">