diff --git a/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java b/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java index b436d30..bb6340a 100644 --- a/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java +++ b/app/src/main/java/com/fox2code/mmm/androidacy/AndroidacyRepoData.java @@ -65,18 +65,6 @@ public final class AndroidacyRepoData extends RepoData { public AndroidacyRepoData(File cacheRoot, SharedPreferences cachedPreferences, boolean testMode) { super(testMode ? RepoManager.ANDROIDACY_TEST_MAGISK_REPO_ENDPOINT : RepoManager.ANDROIDACY_MAGISK_REPO_ENDPOINT, cacheRoot, cachedPreferences); - // make sure the modules.json exists - File modulesJson = new File(cacheRoot, "modules.json"); - if (!modulesJson.exists()) { - try { - if (!modulesJson.createNewFile()) { - throw new IOException("Failed to create modules.json"); - } - } catch ( - IOException e) { - e.printStackTrace(); - } - } this.defaultName = "Androidacy Modules Repo"; this.defaultWebsite = RepoManager.ANDROIDACY_MAGISK_REPO_HOMEPAGE; this.defaultSupport = "https://t.me/androidacy_discussions"; diff --git a/app/src/main/java/com/fox2code/mmm/repo/RepoData.java b/app/src/main/java/com/fox2code/mmm/repo/RepoData.java index 6804f36..fad9c9d 100644 --- a/app/src/main/java/com/fox2code/mmm/repo/RepoData.java +++ b/app/src/main/java/com/fox2code/mmm/repo/RepoData.java @@ -13,6 +13,7 @@ import com.fox2code.mmm.MainApplication; import com.fox2code.mmm.R; import com.fox2code.mmm.XRepo; import com.fox2code.mmm.manager.ModuleInfo; +import com.fox2code.mmm.utils.db.ModuleCache; import com.fox2code.mmm.utils.io.Files; import com.fox2code.mmm.utils.io.PropUtils; @@ -47,7 +48,8 @@ public class RepoData extends XRepo { this.id = RepoManager.internalIdOfUrl(url); this.cacheRoot = cacheRoot; this.cachedPreferences = cachedPreferences; - this.metaDataCache = new File(cacheRoot, "modules.json"); + assert ModuleCache.getInstance() != null; + this.metaDataCache = ModuleCache.getInstance().moduleDao(); this.moduleHashMap = new HashMap<>(); this.defaultName = url; // Set url as default name this.forceHide = AppUpdateManager.shouldForceHide(this.id); @@ -59,6 +61,11 @@ public class RepoData extends XRepo { throw new RuntimeException("Failed to create cache directory"); } } else { + // ensure module cache db is created + ModuleCache.getInstance().moduleDao(); + // get all modules from the db as a json object + //JSONObject modules = new JSONObject(); + // TODO: migrate this to db format. Storing the cache in a json file is a bad idea if (this.metaDataCache.exists()) { this.lastUpdate = metaDataCache.lastModified(); if (this.lastUpdate > System.currentTimeMillis()) { diff --git a/app/src/main/java/com/fox2code/mmm/utils/db/ModuleCache.java b/app/src/main/java/com/fox2code/mmm/utils/db/ModuleCache.java index e569981..5654c6a 100644 --- a/app/src/main/java/com/fox2code/mmm/utils/db/ModuleCache.java +++ b/app/src/main/java/com/fox2code/mmm/utils/db/ModuleCache.java @@ -28,4 +28,9 @@ public abstract class ModuleCache extends RoomDatabase { // db structure is: internal name, pretty name, repo url, enabled // create the database public abstract ModuleDao moduleDao(); + + // returns the instance + public static ModuleCache getInstance() { + return null; + } } diff --git a/app/src/main/res/values/attrs.xml b/app/src/main/res/values/attrs.xml new file mode 100644 index 0000000..422b4db --- /dev/null +++ b/app/src/main/res/values/attrs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 3cce4fe..74feaae 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,8 +15,8 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8 -XX:+UseParallelGC -XX:Reserv # Android operating system, and which are packaged with your app"s APK # https://developer.android.com/topic/libraries/support-library/androidx-rn android.useAndroidX=true -# Automatically convert third-party libraries to use AndroidX -# android.enableJetifier=true +# Automatically convert third-` 1party libraries to use AndroidX +android.enableJetifier=true # Fox builds props mods org.gradle.parallel=true