mirror of
https://codeberg.org/NextPush/nextpush-android.git
synced 2025-01-28 01:59:44 +01:00
Move DB consts to companion
This commit is contained in:
parent
67a39da534
commit
c712f25cca
@ -7,26 +7,9 @@ import android.database.sqlite.SQLiteOpenHelper
|
|||||||
import org.unifiedpush.distributor.nextpush.services.RegistrationCountCache
|
import org.unifiedpush.distributor.nextpush.services.RegistrationCountCache
|
||||||
import java.util.concurrent.atomic.AtomicReference
|
import java.util.concurrent.atomic.AtomicReference
|
||||||
|
|
||||||
private const val DB_NAME = "apps_db"
|
|
||||||
private const val DB_VERSION = 2
|
|
||||||
|
|
||||||
class Database(val context: Context) :
|
class Database(val context: Context) :
|
||||||
SQLiteOpenHelper(context, DB_NAME, null, DB_VERSION) {
|
SQLiteOpenHelper(context, DB_NAME, null, DB_VERSION) {
|
||||||
|
|
||||||
private val TABLE_APPS = "apps"
|
|
||||||
private val FIELD_PACKAGE_NAME = "packageName"
|
|
||||||
private val FIELD_CONNECTOR_TOKEN = "connectorToken"
|
|
||||||
private val FIELD_APP_TOKEN = "appToken"
|
|
||||||
private val FIELD_NOTIFICATION_TITLE = "notificationTitle" // Used for non-UnifiedPush notif
|
|
||||||
private val CREATE_TABLE_APPS = "CREATE TABLE $TABLE_APPS (" +
|
|
||||||
"$FIELD_PACKAGE_NAME TEXT," +
|
|
||||||
"$FIELD_CONNECTOR_TOKEN TEXT," +
|
|
||||||
"$FIELD_APP_TOKEN TEXT," +
|
|
||||||
"$FIELD_NOTIFICATION_TITLE TEXT," +
|
|
||||||
"PRIMARY KEY ($FIELD_CONNECTOR_TOKEN));"
|
|
||||||
|
|
||||||
private val UPGRADE_1_2 = "ALTER TABLE $TABLE_APPS ADD COLUMN $FIELD_NOTIFICATION_TITLE TEXT"
|
|
||||||
|
|
||||||
override fun onCreate(db: SQLiteDatabase) {
|
override fun onCreate(db: SQLiteDatabase) {
|
||||||
db.execSQL(CREATE_TABLE_APPS)
|
db.execSQL(CREATE_TABLE_APPS)
|
||||||
}
|
}
|
||||||
@ -178,6 +161,23 @@ class Database(val context: Context) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
private const val DB_NAME = "apps_db"
|
||||||
|
private const val DB_VERSION = 3
|
||||||
|
|
||||||
|
private const val TABLE_APPS = "apps"
|
||||||
|
private const val FIELD_PACKAGE_NAME = "packageName"
|
||||||
|
private const val FIELD_CONNECTOR_TOKEN = "connectorToken"
|
||||||
|
private const val FIELD_APP_TOKEN = "appToken"
|
||||||
|
private const val FIELD_NOTIFICATION_TITLE = "notificationTitle" // Used for non-UnifiedPush notif
|
||||||
|
private const val CREATE_TABLE_APPS = "CREATE TABLE $TABLE_APPS (" +
|
||||||
|
"$FIELD_PACKAGE_NAME TEXT," +
|
||||||
|
"$FIELD_CONNECTOR_TOKEN TEXT," +
|
||||||
|
"$FIELD_APP_TOKEN TEXT," +
|
||||||
|
"$FIELD_NOTIFICATION_TITLE TEXT," +
|
||||||
|
"PRIMARY KEY ($FIELD_CONNECTOR_TOKEN));"
|
||||||
|
|
||||||
|
private const val UPGRADE_1_2 = "ALTER TABLE $TABLE_APPS ADD COLUMN $FIELD_NOTIFICATION_TITLE TEXT"
|
||||||
|
|
||||||
private val db: AtomicReference<Database?> = AtomicReference(null)
|
private val db: AtomicReference<Database?> = AtomicReference(null)
|
||||||
|
|
||||||
fun getDb(context: Context): Database {
|
fun getDb(context: Context): Database {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user