Skip to content

Commit d654bd5

Browse files
authored
Moving from arrays to lists. Running upgraded kotlinter (#229)
1 parent 173464b commit d654bd5

42 files changed

Lines changed: 3592 additions & 3558 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/src/main/java/com/dessalines/thumbkey/ComposeKeyboardView.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ import kotlinx.coroutines.launch
1717
@SuppressLint("ViewConstructor")
1818
class ComposeKeyboardView(
1919
context: Context,
20-
private val settingsRepo: AppSettingsRepository
20+
private val settingsRepo: AppSettingsRepository,
2121
) :
2222
AbstractComposeView
23-
(context) {
23+
(context) {
2424

2525
@Composable
2626
override fun Content() {
@@ -29,7 +29,7 @@ class ComposeKeyboardView(
2929
val ctx = context as IMEService
3030

3131
ThumbkeyTheme(
32-
settings = settings
32+
settings = settings,
3333
) {
3434
KeyboardScreen(
3535
settings = settings,
@@ -60,7 +60,7 @@ class ComposeKeyboardView(
6060
val s2 = s.copy(position = nextPosition)
6161
settingsRepo.update(s2)
6262
}
63-
}
63+
},
6464
)
6565
}
6666
}

app/src/main/java/com/dessalines/thumbkey/IMEService.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@ package com.dessalines.thumbkey
33
import android.inputmethodservice.InputMethodService
44
import android.view.View
55
import android.view.inputmethod.EditorInfo
6-
import androidx.lifecycle.*
6+
import androidx.lifecycle.Lifecycle
7+
import androidx.lifecycle.LifecycleOwner
8+
import androidx.lifecycle.LifecycleRegistry
9+
import androidx.lifecycle.ViewModelStore
10+
import androidx.lifecycle.ViewModelStoreOwner
11+
import androidx.lifecycle.setViewTreeLifecycleOwner
12+
import androidx.lifecycle.setViewTreeViewModelStoreOwner
713
import androidx.savedstate.SavedStateRegistry
814
import androidx.savedstate.SavedStateRegistryController
915
import androidx.savedstate.SavedStateRegistryOwner

app/src/main/java/com/dessalines/thumbkey/MainActivity.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class MainActivity : AppCompatActivity() {
4949
}
5050
val thumbkeySelected = Settings.Secure.getString(
5151
ctx.contentResolver,
52-
Settings.Secure.DEFAULT_INPUT_METHOD
52+
Settings.Secure.DEFAULT_INPUT_METHOD,
5353
) == THUMBKEY_IME_NAME
5454

5555
val startDestination by remember {
@@ -58,46 +58,46 @@ class MainActivity : AppCompatActivity() {
5858
"setup"
5959
} else {
6060
intent.extras?.getString("startRoute") ?: "settings"
61-
}
61+
},
6262
)
6363
}
6464

6565
ThumbkeyTheme(
66-
settings = settings
66+
settings = settings,
6767
) {
6868
val navController = rememberNavController()
6969

7070
NavHost(
7171
navController = navController,
72-
startDestination = startDestination
72+
startDestination = startDestination,
7373
) {
7474
composable(
75-
route = "setup"
75+
route = "setup",
7676
) {
7777
SetupActivity(
7878
navController = navController,
7979
thumbkeyEnabled = thumbkeyEnabled,
80-
thumbkeySelected = thumbkeySelected
80+
thumbkeySelected = thumbkeySelected,
8181
)
8282
}
8383
composable(route = "settings") {
8484
SettingsActivity(
8585
navController = navController,
8686
thumbkeyEnabled = thumbkeyEnabled,
87-
thumbkeySelected = thumbkeySelected
87+
thumbkeySelected = thumbkeySelected,
8888
)
8989
}
9090
composable(route = "lookAndFeel") {
9191
LookAndFeelActivity(
9292
navController = navController,
93-
appSettingsViewModel = appSettingsViewModel
93+
appSettingsViewModel = appSettingsViewModel,
9494
)
9595
}
9696
composable(
97-
route = "about"
97+
route = "about",
9898
) {
9999
AboutActivity(
100-
navController = navController
100+
navController = navController,
101101
)
102102
}
103103
}

app/src/main/java/com/dessalines/thumbkey/db/AppDb.kt

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,15 @@ import androidx.lifecycle.LiveData
88
import androidx.lifecycle.ViewModel
99
import androidx.lifecycle.ViewModelProvider
1010
import androidx.lifecycle.viewModelScope
11-
import androidx.room.*
11+
import androidx.room.ColumnInfo
12+
import androidx.room.Dao
13+
import androidx.room.Database
14+
import androidx.room.Entity
15+
import androidx.room.PrimaryKey
16+
import androidx.room.Query
17+
import androidx.room.Room
18+
import androidx.room.RoomDatabase
19+
import androidx.room.Update
1220
import androidx.room.migration.Migration
1321
import androidx.sqlite.db.SupportSQLiteDatabase
1422
import kotlinx.coroutines.launch
@@ -37,89 +45,89 @@ data class AppSettings(
3745
@PrimaryKey(autoGenerate = true) val id: Int,
3846
@ColumnInfo(
3947
name = "key_size",
40-
defaultValue = DEFAULT_KEY_SIZE.toString()
48+
defaultValue = DEFAULT_KEY_SIZE.toString(),
4149
)
4250
val keySize: Int,
4351
@ColumnInfo(
4452
name = "animation_speed",
45-
defaultValue = DEFAULT_ANIMATION_SPEED.toString()
53+
defaultValue = DEFAULT_ANIMATION_SPEED.toString(),
4654
)
4755
val animationSpeed: Int,
4856
@ColumnInfo(
4957
name = "animation_helper_speed",
50-
defaultValue = DEFAULT_ANIMATION_HELPER_SPEED.toString()
58+
defaultValue = DEFAULT_ANIMATION_HELPER_SPEED.toString(),
5159
)
5260
val animationHelperSpeed: Int,
5361
@ColumnInfo(
5462
name = "position",
55-
defaultValue = DEFAULT_POSITION.toString()
63+
defaultValue = DEFAULT_POSITION.toString(),
5664
)
5765
val position: Int,
5866
@ColumnInfo(
5967
name = "auto_capitalize",
60-
defaultValue = DEFAULT_AUTO_CAPITALIZE.toString()
68+
defaultValue = DEFAULT_AUTO_CAPITALIZE.toString(),
6169
)
6270
val autoCapitalize: Int,
6371
@ColumnInfo(
6472
name = "keyboard_layout",
65-
defaultValue = DEFAULT_KEYBOARD_LAYOUT.toString()
73+
defaultValue = DEFAULT_KEYBOARD_LAYOUT.toString(),
6674
)
6775
val keyboardLayout: Int,
6876
@ColumnInfo(
6977
name = "vibrate_on_tap",
70-
defaultValue = DEFAULT_VIBRATE_ON_TAP.toString()
78+
defaultValue = DEFAULT_VIBRATE_ON_TAP.toString(),
7179
)
7280
val vibrateOnTap: Int,
7381
@ColumnInfo(
7482
name = "sound_on_tap",
75-
defaultValue = DEFAULT_SOUND_ON_TAP.toString()
83+
defaultValue = DEFAULT_SOUND_ON_TAP.toString(),
7684
)
7785
val soundOnTap: Int,
7886
@ColumnInfo(
7987
name = "theme",
80-
defaultValue = DEFAULT_THEME.toString()
88+
defaultValue = DEFAULT_THEME.toString(),
8189
)
8290
val theme: Int,
8391
@ColumnInfo(
8492
name = "theme_color",
85-
defaultValue = DEFAULT_THEME_COLOR.toString()
93+
defaultValue = DEFAULT_THEME_COLOR.toString(),
8694
)
8795
val themeColor: Int,
8896
@ColumnInfo(
8997
name = "viewed_changelog",
90-
defaultValue = "0"
98+
defaultValue = "0",
9199
)
92100
val viewedChangelog: Int,
93101
@ColumnInfo(
94102
name = "min_swipe_length",
95-
defaultValue = DEFAULT_MIN_SWIPE_LENGTH.toString()
103+
defaultValue = DEFAULT_MIN_SWIPE_LENGTH.toString(),
96104
)
97105
val minSwipeLength: Int,
98106
@ColumnInfo(
99107
name = "pushup_size",
100-
defaultValue = DEFAULT_PUSHUP_SIZE.toString()
108+
defaultValue = DEFAULT_PUSHUP_SIZE.toString(),
101109
)
102110
val pushupSize: Int,
103111
@ColumnInfo(
104112
name = "hide_letters",
105-
defaultValue = DEFAULT_HIDE_LETTERS.toString()
113+
defaultValue = DEFAULT_HIDE_LETTERS.toString(),
106114
)
107115
val hideLetters: Int,
108116
@ColumnInfo(
109117
name = "keyboard_layouts",
110-
defaultValue = "$DEFAULT_KEYBOARD_LAYOUT"
118+
defaultValue = "$DEFAULT_KEYBOARD_LAYOUT",
111119
)
112120
val keyboardLayouts: String,
113121
@ColumnInfo(
114122
name = "key_borders",
115-
defaultValue = DEFAULT_KEY_BORDERS.toString()
123+
defaultValue = DEFAULT_KEY_BORDERS.toString(),
116124
)
117125
val keyBorders: Int,
118126
@ColumnInfo(
119127
name = "spacebar_multitaps",
120-
defaultValue = DEFAULT_SPACEBAR_MULTITAPS.toString()
128+
defaultValue = DEFAULT_SPACEBAR_MULTITAPS.toString(),
121129
)
122-
val spacebarMultiTaps: Int
130+
val spacebarMultiTaps: Int,
123131
)
124132

125133
@Dao
@@ -156,55 +164,55 @@ class AppSettingsRepository(private val appSettingsDao: AppSettingsDao) {
156164
val MIGRATION_1_2 = object : Migration(1, 2) {
157165
override fun migrate(database: SupportSQLiteDatabase) {
158166
database.execSQL(
159-
"alter table AppSettings add column min_swipe_length INTEGER NOT NULL default $DEFAULT_MIN_SWIPE_LENGTH"
167+
"alter table AppSettings add column min_swipe_length INTEGER NOT NULL default $DEFAULT_MIN_SWIPE_LENGTH",
160168
)
161169
}
162170
}
163171

164172
val MIGRATION_2_3 = object : Migration(2, 3) {
165173
override fun migrate(database: SupportSQLiteDatabase) {
166174
database.execSQL(
167-
"alter table AppSettings add column pushup_size INTEGER NOT NULL default $DEFAULT_PUSHUP_SIZE"
175+
"alter table AppSettings add column pushup_size INTEGER NOT NULL default $DEFAULT_PUSHUP_SIZE",
168176
)
169177
}
170178
}
171179

172180
val MIGRATION_3_4 = object : Migration(3, 4) {
173181
override fun migrate(database: SupportSQLiteDatabase) {
174182
database.execSQL(
175-
"alter table AppSettings add column hide_letters INTEGER NOT NULL default $DEFAULT_HIDE_LETTERS"
183+
"alter table AppSettings add column hide_letters INTEGER NOT NULL default $DEFAULT_HIDE_LETTERS",
176184
)
177185
}
178186
}
179187

180188
val MIGRATION_4_5 = object : Migration(4, 5) {
181189
override fun migrate(database: SupportSQLiteDatabase) {
182190
database.execSQL(
183-
"alter table AppSettings add column keyboard_layouts TEXT NOT NULL default '$DEFAULT_KEYBOARD_LAYOUT'"
191+
"alter table AppSettings add column keyboard_layouts TEXT NOT NULL default '$DEFAULT_KEYBOARD_LAYOUT'",
184192
)
185193
}
186194
}
187195

188196
val MIGRATION_5_6 = object : Migration(5, 6) {
189197
override fun migrate(database: SupportSQLiteDatabase) {
190198
database.execSQL(
191-
"alter table AppSettings add column key_borders INTEGER NOT NULL default $DEFAULT_KEY_BORDERS"
199+
"alter table AppSettings add column key_borders INTEGER NOT NULL default $DEFAULT_KEY_BORDERS",
192200
)
193201
}
194202
}
195203

196204
val MIGRATION_6_7 = object : Migration(6, 7) {
197205
override fun migrate(database: SupportSQLiteDatabase) {
198206
database.execSQL(
199-
"alter table AppSettings add column spacebar_multitaps INTEGER NOT NULL default $DEFAULT_SPACEBAR_MULTITAPS"
207+
"alter table AppSettings add column spacebar_multitaps INTEGER NOT NULL default $DEFAULT_SPACEBAR_MULTITAPS",
200208
)
201209
}
202210
}
203211

204212
@Database(
205213
version = 7,
206214
entities = [AppSettings::class],
207-
exportSchema = true
215+
exportSchema = true,
208216
)
209217
abstract class AppDB : RoomDatabase() {
210218
abstract fun appSettingsDao(): AppSettingsDao
@@ -214,15 +222,15 @@ abstract class AppDB : RoomDatabase() {
214222
private var INSTANCE: AppDB? = null
215223

216224
fun getDatabase(
217-
context: Context
225+
context: Context,
218226
): AppDB {
219227
// if the INSTANCE is not null, then return it,
220228
// if it is, then create the database
221229
return INSTANCE ?: synchronized(this) {
222230
val instance = Room.databaseBuilder(
223231
context.applicationContext,
224232
AppDB::class.java,
225-
"thumbkey"
233+
"thumbkey",
226234
)
227235
.allowMainThreadQueries()
228236
.addMigrations(
@@ -231,7 +239,7 @@ abstract class AppDB : RoomDatabase() {
231239
MIGRATION_3_4,
232240
MIGRATION_4_5,
233241
MIGRATION_5_6,
234-
MIGRATION_6_7
242+
MIGRATION_6_7,
235243
)
236244
// Necessary because it can't insert data on creation
237245
.addCallback(object : Callback() {
@@ -243,7 +251,7 @@ abstract class AppDB : RoomDatabase() {
243251
CONFLICT_IGNORE, // Ensures it won't overwrite the existing data
244252
ContentValues(2).apply {
245253
put("id", 1)
246-
}
254+
},
247255
)
248256
}
249257
}

0 commit comments

Comments
 (0)