From 15086d0a335e6d9f461dcef59c441c1031d3f1c9 Mon Sep 17 00:00:00 2001 From: tibbi Date: Tue, 23 Jul 2019 11:53:28 +0200 Subject: [PATCH] update commons, gradle, kotlin --- app/build.gradle | 2 +- .../dbhelpers/MyContentProviderDbHelper.kt | 15 +++++++++++---- build.gradle | 4 ++-- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 7f3b031..2b4c99a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -50,5 +50,5 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:5.10.0' + implementation 'com.simplemobiletools:commons:5.15.6' } 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 b8d63ff..10bb6a9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/thankyou/dbhelpers/MyContentProviderDbHelper.kt +++ b/app/src/main/kotlin/com/simplemobiletools/thankyou/dbhelpers/MyContentProviderDbHelper.kt @@ -6,10 +6,12 @@ import android.database.Cursor 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_APP_ICON_COLOR import com.simplemobiletools.commons.helpers.MyContentProvider.Companion.COL_BACKGROUND_COLOR import com.simplemobiletools.commons.helpers.MyContentProvider.Companion.COL_ID import com.simplemobiletools.commons.helpers.MyContentProvider.Companion.COL_LAST_UPDATED_TS +import com.simplemobiletools.commons.helpers.MyContentProvider.Companion.COL_NAVIGATION_BAR_COLOR 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 @@ -20,7 +22,7 @@ class MyContentProviderDbHelper private constructor(private val context: Context companion object { private const val DB_NAME = "Commons.db" - private const val DB_VERSION = 2 + private const val DB_VERSION = 3 private const val TABLE_NAME = "commons_colors" private const val THEME_ID = 1 // for now we are storing just 1 theme @@ -29,19 +31,24 @@ 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_LAST_UPDATED_TS 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)") } override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) { if (oldVersion == 1) { db.execSQL("ALTER TABLE $TABLE_NAME ADD COLUMN $COL_APP_ICON_COLOR INTEGER DEFAULT 0") } + + if (oldVersion < 3) { + db.execSQL("ALTER TABLE $TABLE_NAME ADD COLUMN $COL_NAVIGATION_BAR_COLOR INTEGER DEFAULT $INVALID_NAVIGATION_BAR_COLOR") + } } 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)) + resources.getColor(R.color.color_primary), resources.getColor(R.color.color_primary), INVALID_NAVIGATION_BAR_COLOR) insertTheme(theme, mDb) } @@ -74,7 +81,7 @@ class MyContentProviderDbHelper private constructor(private val context: Context } fun getSharedTheme(): Cursor? { - val cols = arrayOf(COL_TEXT_COLOR, COL_BACKGROUND_COLOR, COL_PRIMARY_COLOR, COL_APP_ICON_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) 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 bfe902f..cfaef4a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,7 +1,7 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.3.40' + ext.kotlin_version = '1.3.41' repositories { google() @@ -9,7 +9,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.4.1' + classpath 'com.android.tools.build:gradle:3.4.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong