upgrade agp and start work on db support

Signed-off-by: androidacy-user <opensource@androidacy.com>
pull/273/head
androidacy-user 1 year ago
parent e4fff6bb6e
commit d7f8c02302

@ -1,4 +1,6 @@
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'
@ -285,16 +287,14 @@ 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"
//implementation "androidx.appcompat:appcompat:${versions.appCompat}"
// implementation 'com.mikepenz:community-material-typeface:7.0.96.0-kotlin@aar'
// Test
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.4'
// db
def room_version = "2.4.3"
implementation "androidx.room:room-runtime:$room_version"
kapt "androidx.room:room-compiler:$room_version"
}
if (hasSentryConfig) {

@ -13,9 +13,12 @@ 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;
@ -69,6 +72,8 @@ 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
@ -238,4 +243,22 @@ 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();
}
}

@ -0,0 +1,31 @@
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();
}

@ -0,0 +1,26 @@
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();
}

@ -13,13 +13,14 @@ buildscript {
logLevel: "debug",
flavorAware: true
]
project.ext.kotlin_version = "1.7.20"
project.ext.kotlin_version = "1.8.0"
dependencies {
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'com.android.tools.build:gradle:8.0.0-alpha11'
classpath "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:${latestAboutLibsRelease}"
// 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"
}
}

@ -22,3 +22,5 @@ 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