Skip to content

Commit

Permalink
Updated app version to v1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
polodarb authored Sep 28, 2023
2 parents df0c19e + 71294a1 commit acb9e54
Show file tree
Hide file tree
Showing 54 changed files with 2,123 additions and 205 deletions.
11 changes: 9 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ plugins {
id("org.jetbrains.kotlin.android")
id("com.google.devtools.ksp")
id("org.jetbrains.kotlin.plugin.serialization")
// id("kotlin-kapt")
}

android {
Expand All @@ -13,8 +14,8 @@ android {
applicationId = "ua.polodarb.gmsflags"
minSdk = 29
targetSdk = 33
versionCode = 4
versionName = "1.0.3"
versionCode = 5
versionName = "1.0.4"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
Expand Down Expand Up @@ -54,6 +55,12 @@ android {

dependencies {

// Room Database
val roomVersion = "2.5.2"
implementation("androidx.room:room-runtime:$roomVersion")
ksp("androidx.room:room-compiler:$roomVersion")
implementation("androidx.room:room-ktx:$roomVersion")

// KTOR
val ktorVersion = "2.3.4"
implementation("io.ktor:ktor-client-core:$ktorVersion")
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<application
android:name=".GMSApplication"
android:allowBackup="true"
android:allowBackup="false"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/aidl/ua/polodarb/gmsflags/IRootDatabase.aidl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ interface IRootDatabase {
String androidPackage(String pkgName);
List<String> getUsers();

void deleteAllOverriddenFlagsFromGMS();
void deleteAllOverriddenFlagsFromPlayStore();
void deleteRowByFlagName(String packageName, String name);
void deleteOverriddenFlagByPackage(String packageName);

Expand Down
4 changes: 3 additions & 1 deletion app/src/main/java/ua/polodarb/gmsflags/GMSApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import org.koin.core.context.startKoin
import org.koin.core.logger.Level
import ua.polodarb.gmsflags.data.databases.gms.RootDatabase
import ua.polodarb.gmsflags.di.appModule
import ua.polodarb.gmsflags.di.databaseModule
import ua.polodarb.gmsflags.di.repositoryModule
import ua.polodarb.gmsflags.di.viewModelsModule
import ua.polodarb.gmsflags.ui.CrashActivity
import ua.polodarb.gmsflags.ui.ExceptionHandler
Expand Down Expand Up @@ -52,7 +54,7 @@ class GMSApplication : Application() {
startKoin {
androidLogger(if (BuildConfig.DEBUG) Level.DEBUG else Level.NONE)
androidContext(this@GMSApplication)
modules(listOf(appModule, viewModelsModule))
modules(listOf(appModule, viewModelsModule, databaseModule, repositoryModule))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ class RootDatabase : RootService() {
override fun getListByPackages(pkgName: String): List<String> =
this@RootDatabase.getListByPackages(pkgName)

override fun deleteAllOverriddenFlagsFromGMS() =
this@RootDatabase.deleteAllOverriddenFlagsFromGMS()

override fun deleteAllOverriddenFlagsFromPlayStore() =
this@RootDatabase.deleteAllOverriddenFlagsFromPlayStore()

override fun deleteRowByFlagName(packageName: String, name: String) =
this@RootDatabase.deleteRowByFlagName(packageName, name)

Expand Down Expand Up @@ -171,6 +177,18 @@ class RootDatabase : RootService() {
return androidPackage
}

fun deleteAllOverriddenFlagsFromGMS() {
gmsDB.execSQL(
"DELETE FROM FlagOverrides;"
)
}

fun deleteAllOverriddenFlagsFromPlayStore() {
vendingDB.execSQL(
"DELETE FROM FlagOverrides;"
)
}

fun deleteRowByFlagName(
packageName: String,
name: String
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ua.polodarb.gmsflags.data.databases.local

import androidx.room.Database
import androidx.room.RoomDatabase
import ua.polodarb.gmsflags.data.databases.local.dao.FlagsDAO
import ua.polodarb.gmsflags.data.databases.local.dao.PackagesDAO
import ua.polodarb.gmsflags.data.databases.local.enities.SavedFlags
import ua.polodarb.gmsflags.data.databases.local.enities.SavedPackages


@Database(
entities = [SavedPackages::class, SavedFlags::class],
version = 1
)
abstract class AppDatabase : RoomDatabase() {

abstract fun packagesDao(): PackagesDAO

abstract fun flagsDao(): FlagsDAO

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package ua.polodarb.gmsflags.data.databases.local.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import kotlinx.coroutines.flow.Flow
import ua.polodarb.gmsflags.data.databases.local.enities.SavedFlags
import ua.polodarb.gmsflags.data.databases.local.enities.SavedPackages

@Dao
interface FlagsDAO {

@Query("SELECT * FROM saved_flags")
fun getSavedFlags(): Flow<List<SavedFlags>>

@Insert(entity = SavedFlags::class, onConflict = OnConflictStrategy.REPLACE)
suspend fun saveFlag(flagName: SavedFlags)

@Query("DELETE FROM saved_flags WHERE flag_name = :flagName AND pkg_name = :pkgName")
suspend fun deleteSavedFlag(flagName: String, pkgName: String)

@Query("DELETE FROM saved_flags")
fun deleteAllSavedFlags()

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package ua.polodarb.gmsflags.data.databases.local.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import kotlinx.coroutines.flow.Flow
import ua.polodarb.gmsflags.data.databases.local.enities.SavedPackages

@Dao
interface PackagesDAO {

@Query("SELECT * FROM saved_packages")
fun getSavedPackages(): Flow<List<String>>

@Insert(entity = SavedPackages::class, onConflict = OnConflictStrategy.REPLACE)
suspend fun savePackage(pkgName: SavedPackages)

@Query("DELETE FROM saved_packages WHERE pkg_name = :pkgName")
suspend fun deleteSavedPackage(pkgName: String)

@Query("DELETE FROM saved_packages")
fun deleteAllSavedPackages()

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package ua.polodarb.gmsflags.data.databases.local.enities

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey

@Entity(tableName = "saved_flags")
data class SavedFlags(
@ColumnInfo(name = "pkg_name") val pkgName: String,
@ColumnInfo(name = "flag_name") val flagName: String,
@ColumnInfo(name = "flag_type") val type: String,
@PrimaryKey(autoGenerate = true) val id: Int = 0
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package ua.polodarb.gmsflags.data.databases.local.enities

import androidx.room.ColumnInfo
import androidx.room.Entity
import androidx.room.PrimaryKey

@Entity(tableName = "saved_packages")
data class SavedPackages(
@PrimaryKey @ColumnInfo(name = "pkg_name") val pkgName: String
)
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package ua.polodarb.gmsflags.data.repo

import android.content.Context
import android.util.Log
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.flow
import ua.polodarb.gmsflags.GMSApplication
import ua.polodarb.gmsflags.ui.screens.flagChangeScreen.FlagChangeUiStates
import ua.polodarb.gmsflags.ui.screens.packagesScreen.ScreenUiStates

class DatabaseRepository(
class GmsDBRepository(
private val context: Context
) {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package ua.polodarb.gmsflags.data.repo

import android.util.Log
import kotlinx.coroutines.flow.flow
import ua.polodarb.gmsflags.data.databases.local.dao.FlagsDAO
import ua.polodarb.gmsflags.data.databases.local.dao.PackagesDAO
import ua.polodarb.gmsflags.data.databases.local.enities.SavedFlags
import ua.polodarb.gmsflags.data.databases.local.enities.SavedPackages

class RoomDBRepository(
private val savedPackagesDao: PackagesDAO,
private val savedFlagsDao: FlagsDAO
) {

suspend fun getSavedPackages() = flow<List<String>> {
savedPackagesDao.getSavedPackages().collect {
emit(it)
}
}

suspend fun deleteSavedPackage(pkgName: String) {
savedPackagesDao.deleteSavedPackage(pkgName)
}

suspend fun savePackage(pkgName: String) {
savedPackagesDao.savePackage(SavedPackages(pkgName))
}

suspend fun getSavedFlags() = flow {
savedFlagsDao.getSavedFlags().collect {
emit(it)
}
}

suspend fun deleteSavedFlag(flagName: String, pkgName: String) {
savedFlagsDao.deleteSavedFlag(flagName, pkgName)
}

suspend fun saveFlag(flagName: String, pkgName: String, flagType: String) {
savedFlagsDao.saveFlag(SavedFlags(pkgName, flagName, flagType))
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package ua.polodarb.gmsflags.data.repo

import android.content.Context
import ua.polodarb.gmsflags.GMSApplication
import ua.polodarb.gmsflags.data.databases.local.dao.FlagsDAO
import ua.polodarb.gmsflags.data.databases.local.dao.PackagesDAO

class SettingsRepository(
private val context: Context,
private val flagsDao: FlagsDAO,
private val packagesDAO: PackagesDAO
) {

private val gmsApplication = context as GMSApplication

// GMS Database
fun deleteAllOverriddenFlagsFromGMS() {
gmsApplication.getRootDatabase().deleteAllOverriddenFlagsFromGMS()
}

fun deleteAllOverriddenFlagsFromPlayStore() {
gmsApplication.getRootDatabase().deleteAllOverriddenFlagsFromPlayStore()
}

// Local Database
suspend fun deleteAllSavedFlags() {
flagsDao.deleteAllSavedFlags()
}

suspend fun deleteAllSavedPackages() {
packagesDAO.deleteAllSavedPackages()
}

}
14 changes: 2 additions & 12 deletions app/src/main/java/ua/polodarb/gmsflags/di/AppModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,12 @@ package ua.polodarb.gmsflags.di
import org.koin.android.ext.koin.androidApplication
import org.koin.dsl.module
import ua.polodarb.gmsflags.data.repo.AppsListRepository
import ua.polodarb.gmsflags.data.repo.DatabaseRepository
import ua.polodarb.gmsflags.data.repo.GmsDBRepository

val appModule = module {
single {
androidApplication().applicationContext
}

single {
DatabaseRepository(
context = get()
)
androidApplication().applicationContext
}

single {
AppsListRepository(
context = get()
)
}
}
30 changes: 30 additions & 0 deletions app/src/main/java/ua/polodarb/gmsflags/di/DatabaseModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package ua.polodarb.gmsflags.di

import androidx.room.Room
import org.koin.android.ext.koin.androidApplication
import org.koin.dsl.module
import ua.polodarb.gmsflags.data.databases.local.AppDatabase
import ua.polodarb.gmsflags.data.databases.local.dao.FlagsDAO
import ua.polodarb.gmsflags.data.databases.local.dao.PackagesDAO

val databaseModule = module {

single<AppDatabase> {
Room.databaseBuilder(
androidApplication().applicationContext,
AppDatabase::class.java,
"gms_flags_database"
).build()
}

single<PackagesDAO> {
val database = get<AppDatabase>()
database.packagesDao()
}

single<FlagsDAO> {
val database = get<AppDatabase>()
database.flagsDao()
}

}
38 changes: 38 additions & 0 deletions app/src/main/java/ua/polodarb/gmsflags/di/RepositoryModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package ua.polodarb.gmsflags.di

import org.koin.dsl.module
import ua.polodarb.gmsflags.data.repo.AppsListRepository
import ua.polodarb.gmsflags.data.repo.GmsDBRepository
import ua.polodarb.gmsflags.data.repo.RoomDBRepository
import ua.polodarb.gmsflags.data.repo.SettingsRepository

val repositoryModule = module {

single {
GmsDBRepository(
context = get()
)
}

single {
AppsListRepository(
context = get()
)
}

single {
RoomDBRepository(
savedPackagesDao = get(),
savedFlagsDao = get()
)
}

single {
SettingsRepository(
context = get(),
flagsDao = get(),
packagesDAO = get()
)
}

}
Loading

0 comments on commit acb9e54

Please sign in to comment.