(misc) rework custom repos + tweak main layout

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/27/head
androidacy-user 3 years 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();
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(); 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); Realm realm = Realm.getInstance(realmConfiguration);
if (realm.isInTransaction()) { if (realm.isInTransaction()) {
realm.commitTransaction(); realm.commitTransaction();
} }
realm.beginTransaction(); int i = 0;
// find the matching entry for repo_0, repo_1, etc. @SuppressWarnings("MismatchedReadAndWriteOfArray") final int[] lastFilled = {0};
ReposList reposList = realm.where(ReposList.class).equalTo("id", "repo_" + i).findFirst(); realm.executeTransaction(realm1 -> {
if (reposList == null) { // find all repos that are not built-in
continue; 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(); String repo = reposList.getUrl();
if (!PropUtils.isNullString(repo) && !RepoManager.isBuiltInRepo(repo)) { if (!PropUtils.isNullString(repo) && !RepoManager.isBuiltInRepo(repo)) {
lastFilled = i; lastFilled[0] = i;
int index = AUTO_RECOMPILE ? this.customReposCount : i; int index = AUTO_RECOMPILE ? this.customReposCount : i;
this.customRepos[index] = repo; this.customRepos[index] = repo;
this.customReposCount++; this.customReposCount++;
((CustomRepoData) this.repoManager.addOrGet(repo)).override = "custom_repo_" + index; ((CustomRepoData) this.repoManager.addOrGet(repo)).override = "custom_repo_" + index;
} }
} }
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]);
}
}
}
} }
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