(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("")) {
return;
}
SharedPreferences sharedPreferences = this.getSharedPreferences();
int lastFilled = 0;
for (int i = 0; i < MAX_CUSTOM_REPOS; i++) {
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 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;
}
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 realm = Realm.getInstance(realmConfiguration);
if (realm.isInTransaction()) {
realm.commitTransaction();
}
if (AUTO_RECOMPILE && (lastFilled + 1) != this.customReposCount) {
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 realm = Realm.getInstance(realmConfiguration);
if (realm.isInTransaction()) {
realm.commitTransaction();
}
realm.beginTransaction();
for (int i = 0; i < MAX_CUSTOM_REPOS; i++) {
if (this.customRepos[i] != null) {
// 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;
}
reposList.setUrl(this.customRepos[i]);
int i = 0;
@SuppressWarnings("MismatchedReadAndWriteOfArray") final int[] lastFilled = {0};
realm.executeTransaction(realm1 -> {
// find all repos that are not built-in
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();
if (!PropUtils.isNullString(repo) && !RepoManager.isBuiltInRepo(repo)) {
lastFilled[0] = i;
int index = AUTO_RECOMPILE ? this.customReposCount : i;
this.customRepos[index] = repo;
this.customReposCount++;
((CustomRepoData) this.repoManager.addOrGet(repo)).override = "custom_repo_" + index;
}
}
}
});
}
private SharedPreferences getSharedPreferences() {

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

Loading…
Cancel
Save