more work on trying to fix cache

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/284/head
androidacy-user 1 year ago
parent 40b1f4cb4c
commit f1a6c6a2bf

@ -545,7 +545,7 @@ public class MainActivity extends FoxActivity implements SwipeRefreshLayout.OnRe
NotificationType.NEED_CAPTCHA_ANDROIDACY.autoAdd(moduleViewListBuilder);
RepoManager.getINSTANCE().updateEnabledStates();
RepoManager.getINSTANCE().runAfterUpdate(moduleViewListBuilderOnline::appendRemoteModules);
this.moduleViewListBuilderOnline.applyTo(moduleList, moduleViewAdapter);
this.moduleViewListBuilderOnline.applyTo(moduleListOnline, moduleViewAdapterOnline);
}, "Repo update thread").start();
}

@ -359,6 +359,7 @@ public final class AndroidacyRepoData extends RepoData {
moduleInfo.mmtReborn = jsonObject.optBoolean("mmtReborn", false);
moduleInfo.support = filterURL(jsonObject.optString("support"));
moduleInfo.donate = filterURL(jsonObject.optString("donate"));
moduleInfo.safe = (jsonObject.has("vt_status") && jsonObject.getString("vt_status").equalsIgnoreCase("clean")) || jsonObject.optBoolean("safe", false);
String config = jsonObject.optString("config", "");
moduleInfo.config = config.isEmpty() ? null : config;
PropUtils.applyFallbacks(moduleInfo); // Apply fallbacks

@ -161,7 +161,10 @@ public class RepoData extends XRepo {
List<RepoModule> newModules = new ArrayList<>();
synchronized (this.populateLock) {
String name = jsonObject.getString("name").trim();
// if Official is present, remove it, or (Official), or [Official]. We don't want to show it in the UI
String nameForModules = name.endsWith(" (Official)") ? name.substring(0, name.length() - 11) : name;
nameForModules = nameForModules.endsWith(" [Official]") ? nameForModules.substring(0, nameForModules.length() - 11) : nameForModules;
nameForModules = nameForModules.contains("Official") ? nameForModules.replace("Official", "").trim() : nameForModules;
long lastUpdate = jsonObject.getLong("last_update");
for (RepoModule repoModule : this.moduleHashMap.values()) {
repoModule.processed = false;
@ -203,6 +206,8 @@ public class RepoData extends XRepo {
repoModule.propUrl = modulePropsUrl;
repoModule.zipUrl = moduleZipUrl;
repoModule.checksum = moduleChecksum;
// safety check must be overriden per repo. only androidacy repo has this flag currently
// repoModule.safe = module.optBoolean("safe", false);
if (!moduleStars.isEmpty()) {
try {
repoModule.qualityValue = Integer.parseInt(moduleStars);
@ -271,6 +276,8 @@ public class RepoData extends XRepo {
throw new RuntimeException("Failed to delete invalid metadata file");
}
}
} else {
Timber.d("Metadata file not found for %s", repoModule.id);
}
repoModule.moduleInfo.flags |= ModuleInfo.FLAG_METADATA_INVALID;
return false;

@ -305,6 +305,8 @@ public final class RepoManager extends SyncManager {
} else if (repoModule.moduleInfo.versionCode > registeredRepoModule.moduleInfo.versionCode) {
this.modules.put(repoModule.id, repoModule);
}
} else {
repoModule.moduleInfo.flags |= ModuleInfo.FLAG_METADATA_INVALID;
}
} catch (
Exception e) {

@ -18,6 +18,7 @@ public class RepoModule {
@StringRes
public int qualityText;
public int qualityValue;
public boolean safe;
public RepoModule(RepoData repoData, String id) {
this.repoData = repoData;
@ -25,5 +26,24 @@ public class RepoModule {
this.id = id;
this.moduleInfo.flags |=
ModuleInfo.FLAG_METADATA_INVALID;
this.safe = this.moduleInfo.safe;
}
// allows all fields to be set-
public RepoModule(RepoData repoData, String id, String name, String description, String author, String donate, String config, String support, String version, int versionCode) {
this.repoData = repoData;
this.moduleInfo = new ModuleInfo(id);
this.id = id;
this.moduleInfo.name = name;
this.moduleInfo.description = description;
this.moduleInfo.author = author;
this.moduleInfo.donate = donate;
this.moduleInfo.config = config;
this.moduleInfo.support = support;
this.moduleInfo.version = version;
this.moduleInfo.versionCode = versionCode;
this.moduleInfo.flags |=
ModuleInfo.FLAG_METADATA_INVALID;
this.safe = this.moduleInfo.safe;
}
}

@ -58,7 +58,7 @@ public class RepoUpdater {
this.toUpdate = Collections.emptyList();
this.toApply = new HashSet<>();
for (ModuleListCache moduleListCache : results) {
this.toApply.add(new RepoModule(this.repoData, moduleListCache.getId()));
this.toApply.add(new RepoModule(this.repoData, moduleListCache.getId(), moduleListCache.getName(), moduleListCache.getDescription(), moduleListCache.getAuthor(), moduleListCache.getDonate(), moduleListCache.getConfig(), moduleListCache.getSupport(), moduleListCache.getVersion(), moduleListCache.getVersionCode()));
}
Timber.d("Fetched %d modules from cache for %s, from %s records", this.toApply.size(), this.repoData.id, results.size());
// close realm

@ -379,7 +379,8 @@ public enum PropUtils {
|| moduleInfo.author == null || !TextUtils.isGraphic(moduleInfo.author)
|| isNullString(description = moduleInfo.description) || !TextUtils.isGraphic(description)
|| description.toLowerCase(Locale.ROOT).equals(moduleInfo.name.toLowerCase(Locale.ROOT))
|| (getFlagsForModule(moduleInfo.id) & FLAG_COMPAT_LOW_QUALITY) != 0;
|| (getFlagsForModule(moduleInfo.id) & FLAG_COMPAT_LOW_QUALITY) != 0
|| (moduleInfo.id.startsWith("."));
}
private static boolean isInvalidValue(String name) {

@ -65,7 +65,7 @@
<com.google.android.material.materialswitch.MaterialSwitch
android:id="@+id/switch_action"
android:layout_width="wrap_content"
android:layout_height="35dp" />
android:layout_height="wrap_content" />
<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/button_action"
@ -188,6 +188,14 @@
android:text="@string/loading"
android:visibility="gone"
app:chipIcon="@drawable/ic_baseline_error_24" />
<com.google.android.material.chip.Chip
android:id="@+id/button_action7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/loading"
android:visibility="gone"
app:chipIcon="@drawable/ic_baseline_error_24" />
</com.google.android.material.chip.ChipGroup>
</HorizontalScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

Loading…
Cancel
Save