Skip to content
This repository was archived by the owner on May 4, 2023. It is now read-only.

Commit eae09bf

Browse files
hide search on scroll down
fixes #313 Signed-off-by: androidacy-user <opensource@androidacy.com>
1 parent b9986b3 commit eae09bf

File tree

11 files changed

+68
-26
lines changed

11 files changed

+68
-26
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
### Developed by Androidacy. Find us on the web [here](https://www.androidacy.com/?utm_source=fox-readme&utm_medium=web&utm_campagin=github).
44

5+
_If you're seeing this at the Fox2Code repo, the new repo is at [Androidacy/AndroidacyModuleManager](https://github.com/Androidacy/AndroidacyModuleManager)! The old repo may not receive consistent updates anymore!_
6+
57
## About
68

79
The official Magisk Manager app has dropped it's support for downloading online modules, leaving users without a way to easily search for and download them. This app was created to help users download and install modules, and manage their own modules.
@@ -10,8 +12,6 @@ The official Magisk Manager app has dropped it's support for downloading online
1012

1113
**The modules shown in this app are not affiliated with this app or Magisk**.
1214

13-
_If you're seeing this at the Fox2Code repo, the new repo is at [Androidacy/AndroidacyModuleManager](https://github.com/Androidacy/AndroidacyModuleManager)!_
14-
1515
## Features
1616
- Download and install modules
1717
- Manage your own modules

app/src/main/java/com/fox2code/mmm/MainActivity.java

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import android.view.View;
2424
import android.view.ViewGroup;
2525
import android.view.WindowManager;
26+
import android.view.animation.AccelerateInterpolator;
27+
import android.view.animation.DecelerateInterpolator;
2628
import android.view.inputmethod.EditorInfo;
2729
import android.widget.CheckBox;
2830
import android.widget.Toast;
@@ -71,6 +73,8 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
7173
private static final int PRECISION = 10000;
7274
public static boolean doSetupNowRunning = true;
7375
public static boolean doSetupRestarting = false;
76+
public static List<LocalModuleInfo> localModuleInfoList = new ArrayList<>();
77+
public static List<RepoModule> onlineModuleInfoList = new ArrayList<>();
7478
public final ModuleViewListBuilder moduleViewListBuilder;
7579
public final ModuleViewListBuilder moduleViewListBuilderOnline;
7680
public LinearProgressIndicator progressIndicator;
@@ -87,8 +91,6 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
8791
private CardView searchCard;
8892
private SearchView searchView;
8993
private boolean initMode;
90-
public static List<LocalModuleInfo> localModuleInfoList = new ArrayList<>();
91-
public static List<RepoModule> onlineModuleInfoList = new ArrayList<>();
9294

9395
public MainActivity() {
9496
this.moduleViewListBuilder = new ModuleViewListBuilder(this);
@@ -178,6 +180,40 @@ protected void onCreate(Bundle savedInstanceState) {
178180
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
179181
if (newState != RecyclerView.SCROLL_STATE_IDLE)
180182
MainActivity.this.searchView.clearFocus();
183+
// hide search view when scrolling
184+
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
185+
MainActivity.this.searchCard.animate().translationY(-MainActivity.this.searchCard.getHeight()).setInterpolator(new AccelerateInterpolator(2)).start();
186+
}
187+
}
188+
189+
@Override
190+
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
191+
super.onScrolled(recyclerView, dx, dy);
192+
// if the user scrolled up, show the search bar
193+
if (dy < 0) {
194+
MainActivity.this.searchCard.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
195+
}
196+
}
197+
});
198+
// same for online
199+
this.moduleListOnline.addOnScrollListener(new RecyclerView.OnScrollListener() {
200+
@Override
201+
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
202+
if (newState != RecyclerView.SCROLL_STATE_IDLE)
203+
MainActivity.this.searchView.clearFocus();
204+
// hide search view when scrolling
205+
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
206+
MainActivity.this.searchCard.animate().translationY(-MainActivity.this.searchCard.getHeight()).setInterpolator(new AccelerateInterpolator(2)).start();
207+
}
208+
}
209+
210+
@Override
211+
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
212+
super.onScrolled(recyclerView, dx, dy);
213+
// if the user scrolled up, show the search bar
214+
if (dy < 0) {
215+
MainActivity.this.searchCard.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2)).start();
216+
}
181217
}
182218
});
183219
this.searchCard.setRadius(this.searchCard.getHeight() / 2F);
@@ -596,6 +632,7 @@ public void onRefresh() {
596632
});
597633
NotificationType.NEED_CAPTCHA_ANDROIDACY.autoAdd(moduleViewListBuilder);
598634
RepoManager.getINSTANCE().updateEnabledStates();
635+
RepoManager.getINSTANCE().runAfterUpdate(moduleViewListBuilder::appendInstalledModules);
599636
RepoManager.getINSTANCE().runAfterUpdate(moduleViewListBuilderOnline::appendRemoteModules);
600637
this.moduleViewListBuilder.applyTo(moduleList, moduleViewAdapter);
601638
this.moduleViewListBuilderOnline.applyTo(moduleListOnline, moduleViewAdapterOnline);
@@ -763,7 +800,7 @@ private void checkShowInitialSetup() {
763800
if (BuildConfig.DEBUG) Timber.i("Checking if we need to run setup");
764801
// Check if this is the first launch using prefs and if doSetupRestarting was passed in the intent
765802
SharedPreferences prefs = MainApplication.getSharedPreferences("mmm");
766-
boolean firstLaunch = !Objects.equals(prefs.getString("last_shown_setup", null), "v1");
803+
boolean firstLaunch = !Objects.equals(prefs.getString("last_shown_setup", null), "v2");
767804
// First launch
768805
// this is intentionally separate from the above if statement, because it needs to be checked even if the first launch check is true due to some weird edge cases
769806
if (getIntent().getBooleanExtra("doSetupRestarting", false)) {

app/src/main/java/com/fox2code/mmm/SetupActivity.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,9 @@ protected void onCreate(Bundle savedInstanceState) {
153153
// Set up the buttons
154154
// Setup button
155155
BottomNavigationItemView setupButton = view.findViewById(R.id.setup_finish);
156-
// enable finish button when user scrolls to the bottom
157-
findViewById(R.id.setupNestedScrollView).setOnScrollChangeListener((v, scrollX, scrollY, oldScrollX, oldScrollY) -> {
158-
if (scrollY > oldScrollY) {
159-
setupButton.setEnabled(true);
160-
}
161-
});
156+
// on clicking setup_agree_eula, enable the setup button if it's checked, if it's not, disable it
157+
MaterialSwitch agreeEula = view.findViewById(R.id.setup_agree_eula);
158+
agreeEula.setOnCheckedChangeListener((buttonView, isChecked) -> setupButton.setEnabled(isChecked));
162159
setupButton.setOnClickListener(v -> {
163160
Timber.i("Setup button clicked");
164161
// get instance of editor
@@ -200,7 +197,7 @@ protected void onCreate(Bundle savedInstanceState) {
200197
r.close();
201198
Timber.d("Realm transaction committed");
202199
});
203-
editor.putString("last_shown_setup", "v1");
200+
editor.putString("last_shown_setup", "v2");
204201
// Commit the changes
205202
editor.commit();
206203
// sleep to allow the realm transaction to finish

app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyUtil.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import com.fox2code.mmm.BuildConfig;
99

10+
import java.util.Objects;
11+
1012
public enum AndroidacyUtil {
1113
;
1214
public static final String REFERRER = "utm_source=FoxMMM&utm_medium=app";
@@ -21,13 +23,13 @@ public static boolean isAndroidacyLink(@Nullable String url) {
2123

2224
static boolean isAndroidacyLink(@NonNull String url, @NonNull Uri uri) {
2325
int i; // Check both string and Uri to mitigate parse exploit
24-
return url.startsWith("https://") && (i = url.indexOf("/", 8)) != -1 && url.substring(8, i).endsWith("api.androidacy.com") && uri.getHost().endsWith("api.androidacy.com");
26+
return url.startsWith("https://") && (i = url.indexOf("/", 8)) != -1 && url.substring(8, i).endsWith("api.androidacy.com") && Objects.requireNonNull(uri.getHost()).endsWith("api.androidacy.com");
2527
}
2628

2729
public static boolean isAndroidacyFileUrl(@Nullable String url) {
2830
if (url == null)
2931
return false;
30-
for (String prefix : new String[]{"https://production-api.androidacy.com/magisk/file/", "https://staging-api.androidacy.com/magisk/file/"}) { // Make both staging and non staging act the same
32+
for (String prefix : new String[]{"https://production-api.androidacy.com/downloads/", "https://production-api.androidacy.com/magisk/file/", "https://staging-api.androidacy.com/magisk/file/"}) { // Make both staging and non staging act the same
3133
if (url.startsWith(prefix))
3234
return true;
3335
}

app/src/main/java/com/fox2code/mmm/background/BackgroundUpdateChecker.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ static void doCheck(Context context) {
100100
// check if wifi is connected
101101
ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
102102
Network networkInfo = connectivityManager.getActiveNetwork();
103-
if (networkInfo == null || !connectivityManager.getNetworkCapabilities(networkInfo).hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED)) {
103+
if (networkInfo == null || !Objects.requireNonNull(connectivityManager.getNetworkCapabilities(networkInfo)).hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED)) {
104104
Timber.w("Background update check: wifi not connected but required");
105105
return;
106106
}
@@ -136,7 +136,7 @@ static void doCheck(Context context) {
136136
if ("twrp-keep".equals(localModuleInfo.id)) continue;
137137
// exclude all modules with id's stored in the pref pref_background_update_check_excludes
138138
try {
139-
if (MainApplication.getSharedPreferences("mmm").getStringSet("pref_background_update_check_excludes", null).contains(localModuleInfo.id))
139+
if (Objects.requireNonNull(MainApplication.getSharedPreferences("mmm").getStringSet("pref_background_update_check_excludes", null)).contains(localModuleInfo.id))
140140
continue;
141141
} catch (Exception ignored) {
142142
}
@@ -213,7 +213,7 @@ public static void postNotification(Context context, HashMap<String, String> upd
213213

214214
public static void onMainActivityCreate(Context context) {
215215
// Refuse to run if first_launch pref is not false
216-
if (!Objects.equals(MainApplication.getSharedPreferences("mmm").getString("last_shown_setup", null), "v1"))
216+
if (!Objects.equals(MainApplication.getSharedPreferences("mmm").getString("last_shown_setup", null), "v2"))
217217
return;
218218
// create notification channel group
219219
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {

app/src/main/java/com/fox2code/mmm/manager/ModuleManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public static boolean isModuleActive(String moduleId) {
5757
}
5858

5959
protected void scanInternal(@NonNull UpdateListener updateListener) {
60-
// if last_shown_setup is not "v1", then refuse to continue
61-
if (!MainApplication.getSharedPreferences("mmm").getString("last_shown_setup", "").equals("v1")) {
60+
// if last_shown_setup is not "v2", then refuse to continue
61+
if (!MainApplication.getSharedPreferences("mmm").getString("last_shown_setup", "").equals("v2")) {
6262
return;
6363
}
6464
boolean firstScan = this.bootPrefs.getBoolean("mm_first_scan", true);

app/src/main/java/com/fox2code/mmm/repo/RepoManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,8 @@ public static boolean isAndroidacyRepoEnabled() {
149149

150150
@SuppressWarnings("StatementWithEmptyBody")
151151
private void populateDefaultCache(RepoData repoData) {
152-
// if last_shown_setup is not "v1", them=n refuse to continue
153-
if (!MainApplication.getSharedPreferences("mmm").getString("last_shown_setup", "").equals("v1")) {
152+
// if last_shown_setup is not "v2", them=n refuse to continue
153+
if (!MainApplication.getSharedPreferences("mmm").getString("last_shown_setup", "").equals("v2")) {
154154
return;
155155
}
156156
// make sure repodata is not null

app/src/main/java/com/fox2code/mmm/utils/sentry/SentryMain.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static void initialize(final MainApplication mainApplication) {
6161
});
6262
// If first_launch pref is not false, refuse to initialize Sentry
6363
SharedPreferences sharedPreferences = MainApplication.getSharedPreferences("mmm");
64-
if (!Objects.equals(sharedPreferences.getString("last_shown_setup", null), "v1")) {
64+
if (!Objects.equals(sharedPreferences.getString("last_shown_setup", null), "v2")) {
6565
return;
6666
}
6767
sentryEnabled = sharedPreferences.getBoolean("pref_crash_reporting_enabled", false);

app/src/main/res/layout/activity_setup.xml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@
4848
android:id="@+id/setup_scroll_down"
4949
android:layout_width="match_parent"
5050
android:layout_height="wrap_content"
51-
android:layout_margin="2dp"
52-
android:text="@string/setup_scroll_down"
51+
android:layout_marginHorizontal="2dp"
52+
android:layout_marginVertical="4dp"
53+
android:text="@string/setup_scroll_down_v2"
5354
android:textAppearance="@style/TextAppearance.Material3.BodyMedium" />
5455

5556
<!-- Theme radio select. Options are system, light, dark, black, transparent_light -->
@@ -284,14 +285,16 @@
284285
android:text="@string/other_section"
285286
android:textAppearance="@android:style/TextAppearance.Material.Headline" />
286287

287-
<com.google.android.material.textview.MaterialTextView
288+
<com.google.android.material.materialswitch.MaterialSwitch
288289
android:layout_width="match_parent"
289290
android:layout_height="wrap_content"
290291
android:autoLink="web"
292+
android:checked="false"
293+
android:id="@+id/setup_agree_eula"
291294
android:layout_marginHorizontal="2dp"
292295
android:layout_marginVertical="4dp"
293296
android:textColorLink="@color/blue"
294-
android:text="@string/eula_agree"
297+
android:text="@string/eula_agree_v2"
295298
android:textAppearance="@android:style/TextAppearance.Material.Small"
296299
android:drawableStart="@drawable/baseline_library_add_check_24"
297300
android:drawablePadding="8dp" />

app/src/main/res/menu/setup_bottom_nav.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<item
66
android:id="@+id/cancel_setup"
77
android:checked="false"
8+
android:enabled="true"
89
android:icon="@drawable/baseline_close_24"
910
android:title="@string/cancel"
1011
app:showAsAction="ifRoom" />

0 commit comments

Comments
 (0)