give up on roomdb

i have a headache now, thanks

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/277/head
androidacy-user 1 year ago
parent 606ff7d778
commit 7865b62255

@ -1,6 +1,4 @@
plugins {
id 'kotlin-android'
id 'kotlin-kapt'
// Gradle doesn't allow conditionally enabling/disabling plugins
id "io.sentry.android.gradle" version "3.4.0"
id 'com.android.application'
@ -295,16 +293,17 @@ 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'
kapt "io.noties:prism4j-bundler:2.0.0"
annotationProcessor "io.noties:prism4j-bundler:2.0.0"
implementation "com.caverock:androidsvg:1.4"
// Icons
// implementation "com.mikepenz:iconics-core:3.2.5"
//implementation "androidx.appcompat:appcompat:${versions.appCompat}"
// db
def room_version = "2.4.3"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
implementation "androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-ktx:$room_version"
}
if (hasSentryConfig) {

@ -13,12 +13,9 @@ import android.view.WindowManager;
import androidx.appcompat.app.ActionBar;
import androidx.fragment.app.FragmentActivity;
import androidx.room.Room;
import com.fox2code.foxcompat.app.FoxActivity;
import com.fox2code.mmm.databinding.ActivitySetupBinding;
import com.fox2code.mmm.utils.db.ModuleCache;
import com.fox2code.mmm.utils.db.RepoList;
import com.fox2code.rosettax.LanguageActivity;
import com.fox2code.rosettax.LanguageSwitcher;
import com.google.android.material.button.MaterialButton;
@ -72,8 +69,6 @@ public class SetupActivity extends FoxActivity implements LanguageActivity {
View view = binding.setupBox;
// Make the setup_box linear layout the sole child of the root_container constraint layout
setContentView(view);
// create the database
createDatabases();
((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_background_update_check))).setChecked(BuildConfig.ENABLE_AUTO_UPDATER);
((MaterialSwitch) Objects.requireNonNull(view.findViewById(R.id.setup_crash_reporting))).setChecked(BuildConfig.DEFAULT_ENABLE_CRASH_REPORTING);
// Repos are a little harder, as the enabled_repos build config is an arraylist
@ -243,22 +238,4 @@ public class SetupActivity extends FoxActivity implements LanguageActivity {
startActivity(intent);
});
}
// creates the database for the modules and repos
private void createDatabases() {
// create the database
RepoList db = Room.databaseBuilder(getApplicationContext(), RepoList.class, "RepoList").build();
// create the repo list
db.getOpenHelper().getWritableDatabase();
// close the database
db.close();
// module cache for each repo, each repo gets its own table in the modules_cache database
// create the database
ModuleCache db2 = Room.databaseBuilder(getApplicationContext(), ModuleCache.class, "ModuleCache").build();
// create the repo list
db2.getOpenHelper().getWritableDatabase();
// close the database
db2.close();
}
}

@ -1,31 +0,0 @@
package com.fox2code.mmm.utils.db;
import androidx.room.ColumnInfo;
import androidx.room.PrimaryKey;
import androidx.room.RoomDatabase;
import java.math.BigInteger;
@SuppressWarnings("unused")
public abstract class ModuleCache extends RoomDatabase {
// table name
public static final String TABLE_NAME = "ModuleCache";
@PrimaryKey
public String id;
@ColumnInfo(name = "name")
public String name;
@ColumnInfo(name = "description")
public String description;
// next up is installed version (null if not installed), remote version (null if not found), and repo id (local if installed)
@ColumnInfo(name = "installed_version")
public BigInteger installedVersion;
@ColumnInfo(name = "remote_version")
public BigInteger remoteVersion;
@ColumnInfo(name = "repo_id")
public String repoId;
// db structure is: internal name, pretty name, repo url, enabled
// create the database
public abstract <ModuleDao> ModuleDao moduleDao();
}

@ -1,26 +0,0 @@
package com.fox2code.mmm.utils.db;
import androidx.room.ColumnInfo;
import androidx.room.Entity;
import androidx.room.PrimaryKey;
import androidx.room.RoomDatabase;
@SuppressWarnings("unused")
@Entity(tableName = "repos")
public abstract class RepoList extends RoomDatabase {
public static final String TABLE_NAME = "RepoList";
@PrimaryKey
public String id;
@ColumnInfo(name = "name")
public String name;
@ColumnInfo(name = "url")
public String url;
@ColumnInfo(name = "enabled")
public boolean enabled;
// db structure is: internal name, pretty name, repo url, enabled
// create the database
// dao object
public abstract <RepoDao> RepoDao repoDao();
}

@ -22,5 +22,3 @@ android.useAndroidX=true
org.gradle.parallel=true
android.enableR8.fullMode=true
org.gradle.unsafe.configuration-cache=true
android.defaults.buildfeatures.buildconfig=true

Loading…
Cancel
Save