Skip to content

Commit

Permalink
Move to another preferences library, upgrade deps. (#804)
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines committed Mar 13, 2024
1 parent e337204 commit 0ad343d
Show file tree
Hide file tree
Showing 9 changed files with 901 additions and 1,372 deletions.
15 changes: 7 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ dependencies {
implementation "com.github.jeziellago:compose-markdown:0.3.5"

implementation 'androidx.navigation:navigation-compose:2.7.7'
implementation 'com.github.alorma:compose-settings-ui-android:1.2.0'
implementation 'com.github.alorma:compose-settings-storage-disk:1.2.0'
implementation 'me.zhanghai.compose.preference:library:1.0.0'

// To use Kotlin annotation processing tool
ksp 'androidx.room:room-compiler:2.6.1'
Expand All @@ -92,16 +91,16 @@ dependencies {
implementation 'androidx.room:room-paging:2.6.1'

// LiveData
implementation 'androidx.compose.runtime:runtime-livedata:1.6.2'
implementation 'androidx.compose.runtime:runtime-livedata:1.6.3'
implementation "androidx.lifecycle:lifecycle-runtime-compose:2.7.0"

implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.9.22'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.compose.ui:ui:1.6.2'
implementation 'androidx.compose.material3:material3:1.2.0'
implementation 'androidx.compose.material:material-icons-extended-desktop:1.6.2'
implementation 'androidx.compose.material3:material3-window-size-class:1.2.0'
implementation 'androidx.compose.ui:ui-tooling:1.6.2'
implementation 'androidx.compose.ui:ui:1.6.3'
implementation 'androidx.compose.material3:material3:1.2.1'
implementation 'androidx.compose.material:material-icons-extended-desktop:1.6.3'
implementation 'androidx.compose.material3:material3-window-size-class:1.2.1'
implementation 'androidx.compose.ui:ui-tooling:1.6.3'
implementation 'androidx.activity:activity-compose:1.8.2'
implementation "com.louiscad.splitties:splitties-systemservices:3.0.0"
implementation "com.louiscad.splitties:splitties-views:3.0.0"
Expand Down
11 changes: 5 additions & 6 deletions app/src/main/java/com/dessalines/thumbkey/ComposeKeyboardView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ import androidx.lifecycle.lifecycleScope
import com.dessalines.thumbkey.db.AppSettingsRepository
import com.dessalines.thumbkey.ui.components.keyboard.KeyboardScreen
import com.dessalines.thumbkey.ui.theme.ThumbkeyTheme
import com.dessalines.thumbkey.utils.KeyboardLayout
import com.dessalines.thumbkey.utils.keyboardLayoutsSetFromString
import com.dessalines.thumbkey.utils.keyboardLayoutsSetFromDbIndexString
import kotlinx.coroutines.launch

@SuppressLint("ViewConstructor")
Expand All @@ -39,17 +38,17 @@ class ComposeKeyboardView(
val state = settingsState.value
state?.let { s ->

val layouts = keyboardLayoutsSetFromString(s.keyboardLayouts).toList()
val layouts = keyboardLayoutsSetFromDbIndexString(s.keyboardLayouts).toList()
val currentLayout = s.keyboardLayout
val index = layouts.indexOf(currentLayout)
val index = layouts.map { it.ordinal }.indexOf(currentLayout)
val nextIndex = (index + 1).mod(layouts.size)
val nextLayout = layouts.getOrNull(nextIndex)
nextLayout?.let { layout ->
val s2 = s.copy(keyboardLayout = layout)
val s2 = s.copy(keyboardLayout = layout.ordinal)
settingsRepo.update(s2)

// Display the new layout's name on the screen
val layoutName = KeyboardLayout.entries.find { it.ordinal == nextLayout }?.keyboardDefinition?.title
val layoutName = layout.keyboardDefinition.title
Toast.makeText(context, layoutName, Toast.LENGTH_SHORT).show()
}
}
Expand Down
5 changes: 1 addition & 4 deletions app/src/main/java/com/dessalines/thumbkey/db/AppDb.kt
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ data class AppSettings(
defaultValue = "$DEFAULT_KEYBOARD_LAYOUT",
)
val keyboardLayouts: String,
// TODO this needs to be gotten rid of in the next DB update
@ColumnInfo(
name = "key_borders",
defaultValue = DEFAULT_KEY_BORDERS.toString(),
Expand Down Expand Up @@ -261,10 +262,6 @@ data class LookAndFeelUpdate(
name = "hide_letters",
)
val hideLetters: Int,
@ColumnInfo(
name = "key_borders",
)
val keyBorders: Int,
@ColumnInfo(
name = "hide_symbols",
)
Expand Down

0 comments on commit 0ad343d

Please sign in to comment.