From 8ec3f4835c386c796e9b396f5c99062820b8a16a Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 9 Feb 2021 14:19:40 +0100 Subject: [PATCH] take accent color into consideration at shared theme --- app/build.gradle | 2 +- .../dbhelpers/MyContentProviderDbHelper.kt | 15 ++++++++++----- build.gradle | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index ff200b9..115d214 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -55,5 +55,5 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.32.13' + implementation 'com.simplemobiletools:commons:5.33.22' } diff --git a/app/src/main/kotlin/com/simplemobiletools/thankyou/dbhelpers/MyContentProviderDbHelper.kt b/app/src/main/kotlin/com/simplemobiletools/thankyou/dbhelpers/MyContentProviderDbHelper.kt index 11ce87b..2e6d4b8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/thankyou/dbhelpers/MyContentProviderDbHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/thankyou/dbhelpers/MyContentProviderDbHelper.kt @@ -7,6 +7,7 @@ import android.database.sqlite.SQLiteDatabase import android.database.sqlite.SQLiteOpenHelper import com.simplemobiletools.commons.R import com.simplemobiletools.commons.helpers.INVALID_NAVIGATION_BAR_COLOR +import com.simplemobiletools.commons.helpers.MyContentProvider.Companion.COL_ACCENT_COLOR import com.simplemobiletools.commons.helpers.MyContentProvider.Companion.COL_APP_ICON_COLOR import com.simplemobiletools.commons.helpers.MyContentProvider.Companion.COL_BACKGROUND_COLOR import com.simplemobiletools.commons.helpers.MyContentProvider.Companion.COL_ID @@ -15,7 +16,6 @@ import com.simplemobiletools.commons.helpers.MyContentProvider.Companion.COL_NAV import com.simplemobiletools.commons.helpers.MyContentProvider.Companion.COL_PRIMARY_COLOR import com.simplemobiletools.commons.helpers.MyContentProvider.Companion.COL_TEXT_COLOR import com.simplemobiletools.commons.helpers.MyContentProvider.Companion.fillThemeContentValues -import com.simplemobiletools.commons.helpers.mydebug import com.simplemobiletools.commons.models.SharedTheme import com.simplemobiletools.thankyou.extensions.config @@ -24,7 +24,7 @@ class MyContentProviderDbHelper private constructor(private val context: Context companion object { private const val DB_NAME = "Commons.db" - private const val DB_VERSION = 3 + private const val DB_VERSION = 4 private const val TABLE_NAME = "commons_colors" private const val THEME_ID = 1 // for now we are storing just 1 theme @@ -34,7 +34,7 @@ class MyContentProviderDbHelper private constructor(private val context: Context override fun onCreate(db: SQLiteDatabase) { db.execSQL("CREATE TABLE $TABLE_NAME ($COL_ID INTEGER PRIMARY KEY AUTOINCREMENT, $COL_TEXT_COLOR INTEGER DEFAULT 0, $COL_BACKGROUND_COLOR INTEGER DEFAULT 0," + " $COL_PRIMARY_COLOR INTEGER DEFAULT 0, $COL_APP_ICON_COLOR INTEGER DEFAULT 0, $COL_NAVIGATION_BAR_COLOR INTEGER DEFAULT $INVALID_NAVIGATION_BAR_COLOR," + - " $COL_LAST_UPDATED_TS INTEGER DEFAULT 0)") + " $COL_LAST_UPDATED_TS INTEGER DEFAULT 0, $COL_ACCENT_COLOR INTEGER DEFAULT 0)") } override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) { @@ -45,12 +45,17 @@ class MyContentProviderDbHelper private constructor(private val context: Context if (oldVersion < 3) { db.execSQL("ALTER TABLE $TABLE_NAME ADD COLUMN $COL_NAVIGATION_BAR_COLOR INTEGER DEFAULT $INVALID_NAVIGATION_BAR_COLOR") } + + if (oldVersion < 4) { + db.execSQL("ALTER TABLE $TABLE_NAME ADD COLUMN $COL_ACCENT_COLOR INTEGER DEFAULT 0") + } } private fun insertDefaultTheme() { val resources = context.resources val theme = SharedTheme(resources.getColor(R.color.theme_dark_text_color), resources.getColor(R.color.theme_dark_background_color), - resources.getColor(R.color.color_primary), resources.getColor(R.color.color_primary), INVALID_NAVIGATION_BAR_COLOR) + resources.getColor(R.color.color_primary), resources.getColor(R.color.color_primary), INVALID_NAVIGATION_BAR_COLOR, 0, + resources.getColor(R.color.color_primary)) insertTheme(theme, mDb) } @@ -87,7 +92,7 @@ class MyContentProviderDbHelper private constructor(private val context: Context return null } - val cols = arrayOf(COL_TEXT_COLOR, COL_BACKGROUND_COLOR, COL_PRIMARY_COLOR, COL_APP_ICON_COLOR, COL_NAVIGATION_BAR_COLOR, COL_LAST_UPDATED_TS) + val cols = arrayOf(COL_TEXT_COLOR, COL_BACKGROUND_COLOR, COL_PRIMARY_COLOR, COL_APP_ICON_COLOR, COL_NAVIGATION_BAR_COLOR, COL_LAST_UPDATED_TS, COL_ACCENT_COLOR) val selection = "$COL_ID = ?" val selectionArgs = arrayOf(THEME_ID.toString()) return mDb.query(TABLE_NAME, cols, selection, selectionArgs, null, null, null) diff --git a/build.gradle b/build.gradle index c44eed2..db03aed 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:4.1.1' + classpath 'com.android.tools.build:gradle:4.1.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong