diff --git a/app/src/main/java/com/fox2code/mmm/MainActivity.java b/app/src/main/java/com/fox2code/mmm/MainActivity.java
index 417fbe6..3bc9e6b 100644
--- a/app/src/main/java/com/fox2code/mmm/MainActivity.java
+++ b/app/src/main/java/com/fox2code/mmm/MainActivity.java
@@ -16,6 +16,7 @@ import android.os.Build;
import android.os.Bundle;
import android.provider.Settings;
import android.util.TypedValue;
+import android.view.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.view.inputmethod.EditorInfo;
@@ -63,9 +64,11 @@ import timber.log.Timber;
public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRefreshListener, SearchView.OnQueryTextListener, SearchView.OnCloseListener, OverScrollManager.OverScrollHelper {
private static final int PRECISION = 10000;
public static boolean doSetupNowRunning = true;
+ public static boolean doSetupRestarting = false;
public final ModuleViewListBuilder moduleViewListBuilder;
public LinearProgressIndicator progressIndicator;
private ModuleViewAdapter moduleViewAdapter;
+ private ModuleViewAdapter moduleViewAdapterOnline;
private SwipeRefreshLayout swipeRefreshLayout;
private int swipeRefreshLayoutOrigStartOffset;
private int swipeRefreshLayoutOrigEndOffset;
@@ -80,7 +83,6 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
private CardView searchCard;
private SearchView searchView;
private boolean initMode;
- public static boolean doSetupRestarting = false;
private boolean urlFactoryInstalled = false;
public MainActivity() {
@@ -127,18 +129,6 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
Toast.makeText(this, R.string.not_official_build, Toast.LENGTH_LONG).show();
}
setContentView(R.layout.activity_main);
- // on the bottom nav, there's a settings item. open the settings activity when it's clicked.
- BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
- bottomNavigationView.setOnItemSelectedListener(item -> {
- if (item.getItemId() == R.id.settings_menu_item) {
- startActivity(new Intent(MainActivity.this, SettingsActivity.class));
- }
- return true;
- });
- // set the selected item to the installed tab
- bottomNavigationView.setSelectedItemId(R.id.installed_menu_item);
- // set the bottom padding of the main layout to the height of the bottom nav
- findViewById(R.id.root_container).setPadding(0, 0, 0, bottomNavigationView.getHeight());
this.setTitle(R.string.app_name);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, 0);
setActionBarBackground(null);
@@ -161,8 +151,11 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
this.searchCard = findViewById(R.id.search_card);
this.searchView = findViewById(R.id.search_bar);
this.moduleViewAdapter = new ModuleViewAdapter();
+ this.moduleViewAdapterOnline = new ModuleViewAdapter();
this.moduleList.setAdapter(this.moduleViewAdapter);
+ this.moduleListOnline.setAdapter(this.moduleViewAdapterOnline);
this.moduleList.setLayoutManager(new LinearLayoutManager(this));
+ this.moduleListOnline.setLayoutManager(new LinearLayoutManager(this));
this.moduleList.setItemViewCacheSize(4); // Default is 2
this.swipeRefreshLayout.setOnRefreshListener(this);
this.actionBarBlur.setBackground(this.actionBarBackground);
@@ -195,6 +188,27 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
this.cardIconifyUpdate();
this.updateScreenInsets(this.getResources().getConfiguration());
+ // on the bottom nav, there's a settings item. open the settings activity when it's clicked.
+ BottomNavigationView bottomNavigationView = findViewById(R.id.bottom_navigation);
+ // set the bottom padding of the main layout to the height of the bottom nav
+ findViewById(R.id.root_container).setPadding(0, 0, 0, bottomNavigationView.getHeight());
+ bottomNavigationView.setSelectedItemId(R.id.installed_menu_item);
+ MenuItem installedMenuItem = bottomNavigationView.getMenu().findItem(R.id.installed_menu_item);
+ installedMenuItem.setChecked(true);
+ bottomNavigationView.setOnItemSelectedListener(item -> {
+ if (item.getItemId() == R.id.settings_menu_item) {
+ startActivity(new Intent(MainActivity.this, SettingsActivity.class));
+ } else if (item.getItemId() == R.id.online_menu_item) {
+ // set module_list_online as visible and module_list as gone
+ this.moduleList.setVisibility(View.GONE);
+ this.moduleListOnline.setVisibility(View.VISIBLE);
+ } else if (item.getItemId() == R.id.installed_menu_item) {
+ // set module_list_online as gone and module_list as visible
+ this.moduleList.setVisibility(View.VISIBLE);
+ this.moduleListOnline.setVisibility(View.GONE);
+ }
+ return true;
+ });
InstallerInitializer.tryGetMagiskPathAsync(new InstallerInitializer.Callback() {
@Override
public void onPathReceived(String path) {
@@ -244,19 +258,23 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
// Log all preferences changes
MainApplication.getSharedPreferences().registerOnSharedPreferenceChangeListener((prefs, key) -> Timber.i("onSharedPreferenceChanged: " + key + " = " + prefs.getAll().get(key)));
}
+
Timber.i("Scanning for modules!");
if (BuildConfig.DEBUG)
Timber.i("Initialize Update");
final int max = ModuleManager.getINSTANCE().getUpdatableModuleCount();
if (RepoManager.getINSTANCE().getCustomRepoManager().needUpdate()) {
- Timber.w("Need update on create?");
+ Timber.w("Need update on create");
}
+ // update compat metadata
if (BuildConfig.DEBUG)
Timber.i("Check Update Compat");
AppUpdateManager.getAppUpdateManager().checkUpdateCompat();
if (BuildConfig.DEBUG)
Timber.i("Check Update");
+ // update repos
RepoManager.getINSTANCE().update(value -> runOnUiThread(max == 0 ? () -> progressIndicator.setProgressCompat((int) (value * PRECISION), true) : () -> progressIndicator.setProgressCompat((int) (value * PRECISION * 0.75F), true)));
+ // various notifications
NotificationType.NEED_CAPTCHA_ANDROIDACY.autoAdd(moduleViewListBuilder);
// Add debug notification for debug builds
if (!NotificationType.DEBUG.shouldRemove()) {
@@ -278,7 +296,6 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
if (max != 0) {
int current = 0;
- // noodleDebug.push("");
for (LocalModuleInfo localModuleInfo : ModuleManager.getINSTANCE().getModules().values()) {
if (localModuleInfo.updateJson != null) {
if (BuildConfig.DEBUG)
@@ -307,9 +324,8 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
Timber.i("Apply");
RepoManager.getINSTANCE().runAfterUpdate(moduleViewListBuilder::appendRemoteModules);
- moduleViewListBuilder.applyTo(moduleList, moduleViewAdapter);
+ moduleViewListBuilder.applyTo(moduleListOnline, moduleViewAdapterOnline);
Timber.i("Finished app opening state!");
- // noodleDebug.unbind();
}
}, true);
ExternalHelper.INSTANCE.refreshHelper(this);
@@ -441,7 +457,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
Timber.i("Apply");
RepoManager.getINSTANCE().runAfterUpdate(moduleViewListBuilder::appendRemoteModules);
Timber.i("Common Before applyTo");
- moduleViewListBuilder.applyTo(moduleList, moduleViewAdapter);
+ moduleViewListBuilder.applyTo(moduleListOnline, moduleViewAdapterOnline);
Timber.i("Common After");
}
});
@@ -467,7 +483,6 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
// this.swipeRefreshLayout.setRefreshing(true); ??
new Thread(() -> {
Http.cleanDnsCache(); // Allow DNS reload from network
- // noodleDebug.push("Check Update");
final int max = ModuleManager.getINSTANCE().getUpdatableModuleCount();
RepoManager.getINSTANCE().update(value -> runOnUiThread(max == 0 ? () -> progressIndicator.setProgressCompat((int) (value * PRECISION), true) : () -> progressIndicator.setProgressCompat((int) (value * PRECISION * 0.75F), true)));
NotificationType.NEED_CAPTCHA_ANDROIDACY.autoAdd(moduleViewListBuilder);
@@ -608,7 +623,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
if (BuildConfig.DEBUG) {
// Log if granted via onRequestPermissionsResult
boolean granted = ContextCompat.checkSelfPermission(this, Manifest.permission.POST_NOTIFICATIONS) == PackageManager.PERMISSION_GRANTED;
- Timber.i( "Request Notification Permission Done. Result: %s", granted);
+ Timber.i("Request Notification Permission Done. Result: %s", granted);
}
doSetupNowRunning = false;
}
diff --git a/app/src/main/java/com/fox2code/mmm/UpdateActivity.java b/app/src/main/java/com/fox2code/mmm/UpdateActivity.java
index 590f370..41af9cb 100644
--- a/app/src/main/java/com/fox2code/mmm/UpdateActivity.java
+++ b/app/src/main/java/com/fox2code/mmm/UpdateActivity.java
@@ -160,38 +160,46 @@ public class UpdateActivity extends FoxActivity {
}
public void checkForUpdate() {
- LinearProgressIndicator progressIndicator = findViewById(R.id.update_progress);
- progressIndicator.setIndeterminate(true);
// get status text view
MaterialTextView statusTextView = findViewById(R.id.update_progress_text);
- // set status text to checking for update
- statusTextView.setText(R.string.checking_for_update);
- // set progress bar to indeterminate
- progressIndicator.setIndeterminate(true);
+ LinearProgressIndicator progressIndicator = findViewById(R.id.update_progress);
+ runOnUiThread(() -> {
+ progressIndicator.setIndeterminate(true);
+ // set status text to checking for update
+ statusTextView.setText(R.string.checking_for_update);
+ // set progress bar to indeterminate
+ progressIndicator.setIndeterminate(true);
+ });
// check for update
boolean shouldUpdate = AppUpdateManager.getAppUpdateManager().peekShouldUpdate();
// if shouldUpdate is true, then we have an update
if (shouldUpdate) {
- // set status text to update available
- statusTextView.setText(R.string.update_available);
- // set button text to download
- MaterialButton button = findViewById(R.id.update_button);
- button.setText(R.string.download_update);
+ runOnUiThread(() -> {
+ // set status text to update available
+ statusTextView.setText(R.string.update_available);
+ // set button text to download
+ MaterialButton button = findViewById(R.id.update_button);
+ button.setText(R.string.download_update);
+ });
// return
} else {
- // set status text to no update available
- statusTextView.setText(R.string.no_update_available);
+ runOnUiThread(() -> {
+ // set status text to no update available
+ statusTextView.setText(R.string.no_update_available);
+ });
// set progress bar to error
// return
}
- progressIndicator.setIndeterminate(false);
- progressIndicator.setProgressCompat(100, false);
+ runOnUiThread(() -> {
+ progressIndicator.setIndeterminate(false);
+ progressIndicator.setProgressCompat(100, false);
+ });
return;
}
public void downloadUpdate() throws JSONException {
LinearProgressIndicator progressIndicator = findViewById(R.id.update_progress);
- progressIndicator.setIndeterminate(true);
+ runOnUiThread(() -> progressIndicator.setIndeterminate(true));
// get status text view
MaterialTextView statusTextView = findViewById(R.id.update_progress_text);
byte[] lastestJSON = new byte[0];
@@ -201,9 +209,11 @@ public class UpdateActivity extends FoxActivity {
Exception e) {
// when logging, REMOVE the json from the log
Timber.e(e, "Error downloading update info");
- progressIndicator.setIndeterminate(false);
- progressIndicator.setProgressCompat(100, false);
- statusTextView.setText(R.string.error_download_update);
+ runOnUiThread(() -> {
+ progressIndicator.setIndeterminate(false);
+ progressIndicator.setProgressCompat(100, false);
+ statusTextView.setText(R.string.error_download_update);
+ });
}
// convert to JSON
JSONObject latestJSON = new JSONObject(new String(lastestJSON));
@@ -229,10 +239,12 @@ public class UpdateActivity extends FoxActivity {
// if asset is null, then we are in a bad state
if (Objects.isNull(asset)) {
// set status text to error
- statusTextView.setText(R.string.error_no_asset);
- // set progress bar to error
- progressIndicator.setIndeterminate(false);
- progressIndicator.setProgressCompat(100, false);
+ runOnUiThread(() -> {
+ statusTextView.setText(R.string.error_no_asset);
+ // set progress bar to error
+ progressIndicator.setIndeterminate(false);
+ progressIndicator.setProgressCompat(100, false);
+ });
// return
return;
}
diff --git a/app/src/main/java/com/fox2code/mmm/module/ModuleViewListBuilder.java b/app/src/main/java/com/fox2code/mmm/module/ModuleViewListBuilder.java
index 223f41b..d8ad41d 100644
--- a/app/src/main/java/com/fox2code/mmm/module/ModuleViewListBuilder.java
+++ b/app/src/main/java/com/fox2code/mmm/module/ModuleViewListBuilder.java
@@ -7,6 +7,7 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.fox2code.mmm.AppUpdateManager;
+import com.fox2code.mmm.BuildConfig;
import com.fox2code.mmm.MainApplication;
import com.fox2code.mmm.NotificationType;
import com.fox2code.mmm.installer.InstallerInitializer;
@@ -93,6 +94,9 @@ public class ModuleViewListBuilder {
}
public void appendRemoteModules() {
+ if (BuildConfig.DEBUG) {
+ Timber.i("appendRemoteModules() called");
+ }
synchronized (this.updateLock) {
boolean showIncompatible = MainApplication.isShowIncompatibleModules();
for (ModuleHolder moduleHolder : this.mappedModuleHolders.values()) {
diff --git a/app/src/main/res/values-v31/themes.xml b/app/src/main/res/values-v31/themes.xml
index 0527883..e7a9c98 100644
--- a/app/src/main/res/values-v31/themes.xml
+++ b/app/src/main/res/values-v31/themes.xml
@@ -36,10 +36,8 @@
- @color/system_accent2_700
- @color/system_accent2_700
-
+
+ - @style/Widget.Material.Chip.Choice.Dark