Configured storage for direct boot mode
This commit is contained in:
parent
1b15a52fcb
commit
fc6bee9df7
|
@ -25,7 +25,6 @@
|
|||
|
||||
<activity
|
||||
android:name=".activities.SplashActivity"
|
||||
android:directBootAware="true"
|
||||
android:exported="false"
|
||||
android:theme="@style/SplashTheme" />
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.content.Context
|
|||
import androidx.room.Database
|
||||
import androidx.room.Room
|
||||
import androidx.room.RoomDatabase
|
||||
import com.simplemobiletools.commons.extensions.safeStorageContext
|
||||
import com.simplemobiletools.keyboard.interfaces.ClipsDao
|
||||
import com.simplemobiletools.keyboard.models.Clip
|
||||
|
||||
|
@ -20,7 +19,7 @@ abstract class ClipsDatabase : RoomDatabase() {
|
|||
if (db == null) {
|
||||
synchronized(ClipsDatabase::class) {
|
||||
if (db == null) {
|
||||
db = Room.databaseBuilder(context.applicationContext.safeStorageContext, ClipsDatabase::class.java, "clips.db").build()
|
||||
db = Room.databaseBuilder(context, ClipsDatabase::class.java, "clips.db").build()
|
||||
db!!.openHelper.setWriteAheadLoggingEnabled(true)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simplemobiletools.keyboard.extensions
|
|||
import android.content.ClipboardManager
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.os.IBinder
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
|
@ -21,9 +22,21 @@ import com.simplemobiletools.keyboard.databases.ClipsDatabase
|
|||
import com.simplemobiletools.keyboard.helpers.*
|
||||
import com.simplemobiletools.keyboard.interfaces.ClipsDao
|
||||
|
||||
val Context.config: Config get() = Config.newInstance(applicationContext.safeStorageContext)
|
||||
val Context.config: Config get() = Config.newInstance(applicationContext)
|
||||
|
||||
val Context.clipsDB: ClipsDao get() = ClipsDatabase.getInstance(applicationContext).ClipsDao()
|
||||
val Context.safeStorageContext: Context
|
||||
get() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
createDeviceProtectedStorageContext()
|
||||
} else {
|
||||
this
|
||||
}
|
||||
|
||||
val Context.clipsDB: ClipsDao
|
||||
get() = if (isDeviceLocked) {
|
||||
ClipsDatabase.getInstance(applicationContext.safeStorageContext).ClipsDao()
|
||||
} else {
|
||||
ClipsDatabase.getInstance(applicationContext).ClipsDao()
|
||||
}
|
||||
|
||||
fun Context.getCurrentClip(): String? {
|
||||
val clipboardManager = (getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager)
|
||||
|
|
|
@ -2,11 +2,12 @@ package com.simplemobiletools.keyboard.helpers
|
|||
|
||||
import android.content.Context
|
||||
import com.simplemobiletools.commons.helpers.BaseConfig
|
||||
import com.simplemobiletools.keyboard.extensions.safeStorageContext
|
||||
import java.util.*
|
||||
|
||||
class Config(context: Context) : BaseConfig(context) {
|
||||
companion object {
|
||||
fun newInstance(context: Context) = Config(context)
|
||||
fun newInstance(context: Context) = Config(context.safeStorageContext)
|
||||
}
|
||||
|
||||
var vibrateOnKeypress: Boolean
|
||||
|
|
Loading…
Reference in New Issue