(misc) rework custom repos + tweak main layout

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/299/head
androidacy-user 1 year ago
parent 48b50a3bac
commit a96cee7e2e

@ -30,47 +30,26 @@ public class CustomRepoManager {
if (MainApplication.getPreferences("mmm").getString("last_shown_setup", "").equals("")) { if (MainApplication.getPreferences("mmm").getString("last_shown_setup", "").equals("")) {
return; return;
} }
SharedPreferences sharedPreferences = this.getSharedPreferences(); RealmConfiguration realmConfiguration = new RealmConfiguration.Builder().name("ReposList.realm").encryptionKey(MainApplication.getINSTANCE().getExistingKey()).allowQueriesOnUiThread(true).allowWritesOnUiThread(true).directory(MainApplication.getINSTANCE().getDataDirWithPath("realms")).schemaVersion(1).build();
int lastFilled = 0; Realm realm = Realm.getInstance(realmConfiguration);
for (int i = 0; i < MAX_CUSTOM_REPOS; i++) { if (realm.isInTransaction()) {
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder().name("ReposList.realm").encryptionKey(MainApplication.getINSTANCE().getExistingKey()).allowQueriesOnUiThread(true).allowWritesOnUiThread(true).directory(MainApplication.getINSTANCE().getDataDirWithPath("realms")).schemaVersion(1).build(); realm.commitTransaction();
Realm realm = Realm.getInstance(realmConfiguration);
if (realm.isInTransaction()) {
realm.commitTransaction();
}
realm.beginTransaction();
// find the matching entry for repo_0, repo_1, etc.
ReposList reposList = realm.where(ReposList.class).equalTo("id", "repo_" + i).findFirst();
if (reposList == null) {
continue;
}
String repo = reposList.getUrl();
if (!PropUtils.isNullString(repo) && !RepoManager.isBuiltInRepo(repo)) {
lastFilled = i;
int index = AUTO_RECOMPILE ? this.customReposCount : i;
this.customRepos[index] = repo;
this.customReposCount++;
((CustomRepoData) this.repoManager.addOrGet(repo)).override = "custom_repo_" + index;
}
} }
if (AUTO_RECOMPILE && (lastFilled + 1) != this.customReposCount) { int i = 0;
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder().name("ReposList.realm").encryptionKey(MainApplication.getINSTANCE().getExistingKey()).allowQueriesOnUiThread(true).allowWritesOnUiThread(true).directory(MainApplication.getINSTANCE().getDataDirWithPath("realms")).schemaVersion(1).build(); @SuppressWarnings("MismatchedReadAndWriteOfArray") final int[] lastFilled = {0};
Realm realm = Realm.getInstance(realmConfiguration); realm.executeTransaction(realm1 -> {
if (realm.isInTransaction()) { // find all repos that are not built-in
realm.commitTransaction(); for (ReposList reposList : realm1.where(ReposList.class).notEqualTo("id", "androidacy_repo").and().notEqualTo("id", "magisk_alt_repo").and().notEqualTo("id", "magisk_official_repo").findAll()) {
} String repo = reposList.getUrl();
realm.beginTransaction(); if (!PropUtils.isNullString(repo) && !RepoManager.isBuiltInRepo(repo)) {
for (int i = 0; i < MAX_CUSTOM_REPOS; i++) { lastFilled[0] = i;
if (this.customRepos[i] != null) { int index = AUTO_RECOMPILE ? this.customReposCount : i;
// find the matching entry for repo_0, repo_1, etc. this.customRepos[index] = repo;
ReposList reposList = realm.where(ReposList.class).equalTo("id", "repo_" + i).findFirst(); this.customReposCount++;
if (reposList == null) { ((CustomRepoData) this.repoManager.addOrGet(repo)).override = "custom_repo_" + index;
continue;
}
reposList.setUrl(this.customRepos[i]);
} }
} }
} });
} }
private SharedPreferences getSharedPreferences() { private SharedPreferences getSharedPreferences() {

@ -5,7 +5,8 @@
android:id="@+id/root_container" android:id="@+id/root_container"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:paddingVertical="0dp" android:padding="0dp"
app:fitsSystemWindowsInsets="start|end|bottom|top"
tools:context=".MainActivity"> tools:context=".MainActivity">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
@ -26,15 +27,13 @@
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/module_list" android:id="@+id/module_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content" />
app:edgeToEdge="true" />
<!-- online modules --> <!-- online modules -->
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/module_list_online" android:id="@+id/module_list_online"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone" android:visibility="gone" />
app:edgeToEdge="true" />
</FrameLayout> </FrameLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout> </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>

Loading…
Cancel
Save