onto a new Realm

....realm database, anyway

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/277/head
androidacy-user 1 year ago
parent 5499ab0b43
commit e3734e15d6

@ -3,8 +3,12 @@ plugins {
id "io.sentry.android.gradle" version "3.4.0"
id 'com.android.application'
id 'com.mikepenz.aboutlibraries.plugin'
id 'org.jetbrains.kotlin.android'
id 'org.jetbrains.kotlin.kapt'
}
apply plugin: "realm-android"
android {
namespace "com.fox2code.mmm"
compileSdk 33
@ -35,11 +39,6 @@ android {
versionName "1.2.1"
signingConfig signingConfigs.release
archivesBaseName = "FoxMMM-v$versionName"
javaCompileOptions {
annotationProcessorOptions {
arguments += ["room.schemaLocation": "$projectDir/schemas".toString()]
}
}
}
splits {
@ -293,7 +292,7 @@ dependencies {
implementation "io.noties.markwon:image:4.6.2"
implementation "io.noties.markwon:syntax-highlight:4.6.2"
implementation 'com.google.net.cronet:cronet-okhttp:0.1.0'
annotationProcessor "io.noties:prism4j-bundler:2.0.0"
kapt "io.noties:prism4j-bundler:2.0.0"
implementation "com.caverock:androidsvg:1.4"
// Icons
// implementation "com.mikepenz:iconics-core:3.2.5"

@ -53,6 +53,7 @@ import io.noties.markwon.syntax.Prism4jThemeDefault;
import io.noties.markwon.syntax.SyntaxHighlightPlugin;
import io.noties.prism4j.Prism4j;
import io.noties.prism4j.annotations.PrismBundle;
import io.realm.Realm;
@PrismBundle(includeAll = true, grammarLocatorClassName = ".Prism4jGrammarLocator")
public class MainApplication extends FoxApplication implements androidx.work.Configuration.Provider {
@ -313,10 +314,17 @@ public class MainApplication extends FoxApplication implements androidx.work.Con
if (INSTANCE == null)
INSTANCE = this;
relPackageName = this.getPackageName();
super.onCreate();
if (BuildConfig.DEBUG) {
Log.d("MainApplication", "Starting FoxMMM version " + BuildConfig.VERSION_NAME + " (" + BuildConfig.VERSION_CODE + "), commit " + BuildConfig.COMMIT_HASH);
}
super.onCreate();
if (BuildConfig.DEBUG) {
Log.d("MainApplication", "FoxMMM is running in debug mode");
}
if (BuildConfig.DEBUG) {
Log.d("MainApplication", "Initializing Realm");
}
Realm.init(this);
// Determine if this is an official build based on the signature
try {
// Get the signature of the key used to sign the app

@ -25,6 +25,9 @@ import com.topjohnwu.superuser.internal.UiThreadHandler;
import java.util.Objects;
import io.realm.Realm;
import io.realm.RealmConfiguration;
public class SetupActivity extends FoxActivity implements LanguageActivity {
@SuppressLint({"ApplySharedPref", "RestrictedApi"})
@ -43,6 +46,7 @@ public class SetupActivity extends FoxActivity implements LanguageActivity {
actionBar.show();
}
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, 0);
createRealmDatabase();
// Set theme
SharedPreferences prefs = MainApplication.getSharedPreferences();
switch (prefs.getString("theme", "system")) {
@ -238,4 +242,16 @@ public class SetupActivity extends FoxActivity implements LanguageActivity {
startActivity(intent);
});
}
// creates the realm database
private void createRealmDatabase() {
// create the realm database for ModuleListCache
RealmConfiguration config = new RealmConfiguration.Builder().name("ModuleListCache.realm").schemaVersion(1).allowWritesOnUiThread(true).allowQueriesOnUiThread(true).build();
Realm.setDefaultConfiguration(config);
// do a dummy write to create the database
Realm realm = Realm.getDefaultInstance();
realm.executeTransaction(r -> {
});
realm.close();
}
}

@ -0,0 +1,75 @@
package com.fox2code.mmm.utils.realm;
import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
import io.realm.annotations.Required;
@SuppressWarnings({"FieldCanBeLocal", "unused"})
public class ModuleListCache extends RealmObject {
// supported properties for a module
//id=<string>
//name=<string>
//version=<string>
//versionCode=<int>
//author=<string>
//description=<string>
//minApi=<int>
//maxApi=<int>
//minMagisk=<int>
//needRamdisk=<boolean>
//support=<url>
//donate=<url>
//config=<package>
//changeBoot=<boolean>
//mmtReborn=<boolean>
// extra properties only useful for the database
//repoId=<string>
//installed=<boolean>
//installedVersionCode=<int> (only if installed)
// for compatibility, only id is required
@PrimaryKey
@Required
private String id;
private String name;
private String version;
private int versionCode;
private String author;
private String description;
private int minApi;
private int maxApi;
private int minMagisk;
private boolean needRamdisk;
private String support;
private String donate;
private String config;
private boolean changeBoot;
private boolean mmtReborn;
private String repoId;
private boolean installed;
private int installedVersionCode;
public ModuleListCache(String id, String name, String version, int versionCode, String author, String description, int minApi, int maxApi, int minMagisk, boolean needRamdisk, String support, String donate, String config, boolean changeBoot, boolean mmtReborn, String repoId, boolean installed, int installedVersionCode) {
this.id = id;
this.name = name;
this.version = version;
this.versionCode = versionCode;
this.author = author;
this.description = description;
this.minApi = minApi;
this.maxApi = maxApi;
this.minMagisk = minMagisk;
this.needRamdisk = needRamdisk;
this.support = support;
this.donate = donate;
this.config = config;
this.changeBoot = changeBoot;
this.mmtReborn = mmtReborn;
this.repoId = repoId;
this.installed = installed;
this.installedVersionCode = installedVersionCode;
}
public ModuleListCache() {
}
}

@ -243,7 +243,8 @@
<string name="alt_repo_info">This repo has less restrictions and reviews, which may lead to lower quality modules. Pretty barebones but has a lot of modules.</string>
<string name="install_terminal_reboot_now_message">You are about to reboot your device. If you\'ve saved your work, hit OK to continue. Otherwise, hit cancel.</string>
<string name="install_terminal_config_missing">Package %s is missing for module config, so we cannot launch it.</string>
<string name="clear_app_data">Clear app data</string><string name="clear_data_dialogue_title">Clear app data?</string>
<string name="clear_app_data">Clear app data</string>
<string name="clear_data_dialogue_title">Clear app data?</string>
<string name="clear_data_dialogue_message">You\'re about to clear the app data. Please confirm this action.</string>
<string name="debug_build">This is a debug build. Expect some bugs and worse performance.</string>
<string name="androidacy_repo_name">Androidacy Repo</string>
@ -267,7 +268,9 @@
<string name="theme_light">Light</string>
<string name="androidacy_update_needed">This app is outdated.</string>
<string name="androidacy_update_needed_message">Please update the app to the latest version.</string>
<string name="androidacy_webview_update_required">Your webview is outdated! Please update it.</string><string name="language_cta">Don\'t see your language?</string><string name="language_cta_desc">Help us by translating it! Tap here to find out more.</string>
<string name="androidacy_webview_update_required">Your webview is outdated! Please update it.</string>
<string name="language_cta">Don\'t see your language?</string>
<string name="language_cta_desc">Help us by translating it! Tap here to find out more.</string>
<string name="source_code_summary"><b>Commit</b> %1$s @ %2$s</string>
<string name="no_file_provided">No file was provided when trying to open zip.</string>
<string name="zip_load_failed">Could not load the zip file</string>
@ -283,5 +286,16 @@
<string name="setup_theme_title">Choose theme</string>
<string name="setup_language_button">Choose language</string>
<string name="title_activity_setup">Setup Wizard</string>
<string name="action_settings">Settings</string><string name="repo_update_failed_message">The following repos have failed to update:\\n\\n%s</string><string name="reset_api_key">Reset API keys</string><string name="upgrade_androidacy_promo">Upgrade to premium</string><string name="upgrade_androidacy_promo_desc">Upgrading to premium will remove ads, captchas, and downloads for the Androidacy Repository, and support Androidacy and the module authors.</string><string name="pref_category_contributors">Contributors</string><string name="fox2code_thanks_desc">Fox2Code is the original creator of the app. Without him, this would have never been possible.</string><string name="fox2code_thanks">Created by Fox2Code</string><string name="save_logs">Save logs to storage and share</string><string name="error_saving_logs">Could not save logs</string><string name="share_logs">Share FoxMMM logs</string><string name="not_official_build">Caution: You are running an unofficial and unsupported FoxMMM build.</string>
<string name="action_settings">Settings</string>
<string name="repo_update_failed_message">The following repos have failed to update:\\n\\n%s</string>
<string name="reset_api_key">Reset API keys</string>
<string name="upgrade_androidacy_promo">Upgrade to premium</string>
<string name="upgrade_androidacy_promo_desc">Upgrading to premium will remove ads, captchas, and downloads for the Androidacy Repository, and support Androidacy and the module authors.</string>
<string name="pref_category_contributors">Contributors</string>
<string name="fox2code_thanks_desc">Fox2Code is the original creator of the app. Without him, this would have never been possible.</string>
<string name="fox2code_thanks">Created by Fox2Code</string>
<string name="save_logs">Save logs to storage and share</string>
<string name="error_saving_logs">Could not save logs</string>
<string name="share_logs">Share FoxMMM logs</string>
<string name="not_official_build">Caution: You are running an unofficial and therefore unsupported FoxMMM build.</string>
</resources>

@ -21,6 +21,7 @@ buildscript {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.realm:realm-gradle-plugin:10.11.1"
}
}

Loading…
Cancel
Save