Skip to content

Commit 8eb1344

Browse files
committed
./gradlew ktlintFormat and fix #67
1 parent 89e1f97 commit 8eb1344

29 files changed

Lines changed: 768 additions & 782 deletions

File tree

.editorconfig

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ indent_size = 4
66

77
[*.{kt,kts}]
88
max_line_length = 100
9+
ktlint_standard_indent = disabled
10+
ktlint_wrapping = disabled
911

10-
11-
[kotlin]
12-
kotlin_comments.indent_size = tab
13-
kotlin_comments.wrap_text = true

app/build.gradle.kts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,8 @@ dependencies {
8686
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
8787
}
8888

89-
ktlint {
89+
configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
90+
version.set("0.50.0")
9091
android.set(true)
9192
coloredOutput.set(false)
92-
enableExperimentalRules.set(true)
93-
disabledRules.set(
94-
setOf(
95-
"indent",
96-
"parameter-list-wrapping",
97-
"experimental:argument-list-wrapping"
98-
)
99-
)
100-
reporters {
101-
reporter(org.jlleitschuh.gradle.ktlint.reporter.ReporterType.PLAIN)
102-
}
10393
}

app/src/androidTest/java/com/fredhappyface/ewesticker/ScreenshotTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class ScreenshotTest {
8080
config.setLocale(locale)
8181
InstrumentationRegistry.getInstrumentation().targetContext.resources.updateConfiguration(
8282
config,
83-
null
83+
null,
8484
)
8585
}
8686

@@ -94,7 +94,7 @@ class ScreenshotTest {
9494
values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg")
9595
values.put(
9696
MediaStore.MediaColumns.RELATIVE_PATH,
97-
"${Environment.DIRECTORY_DCIM}/$subdirectory"
97+
"${Environment.DIRECTORY_DCIM}/$subdirectory",
9898
)
9999
values.put(MediaStore.Images.Media.IS_PENDING, 1) // Mark the image as pending
100100

app/src/main/java/com/fredhappyface/ewesticker/ImageKeyboard.kt

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,13 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
109109
// Constants
110110
this.internalDir = File(filesDir, "stickers")
111111
this.iconSize =
112-
(if (this.vertical) {
112+
(
113+
if (this.vertical) {
113114
(resources.displayMetrics.widthPixels - this.totalIconPadding) / this.iconsPerX.toFloat()
114115
} else {
115116
(this.sharedPreferences.getInt("iconSize", 80) * scale)
116-
})
117-
.toInt()
117+
}
118+
).toInt()
118119
this.toaster = Toaster(baseContext)
119120
// Load Packs
120121
this.loadedPacks = HashMap()
@@ -163,11 +164,13 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
163164
}
164165
this.packContent.layoutParams?.height = this.keyboardHeight
165166
this.fullIconSize =
166-
(min(
167+
(
168+
min(
167169
resources.displayMetrics.widthPixels,
168170
this.keyboardHeight -
169-
resources.getDimensionPixelOffset(R.dimen.text_size_body) * 2
170-
) * 0.95)
171+
resources.getDimensionPixelOffset(R.dimen.text_size_body) * 2,
172+
) * 0.95
173+
)
171174
.toInt()
172175
createPackIcons()
173176
return keyboardLayout
@@ -196,7 +199,7 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
196199
this.currentInputConnection,
197200
this.currentInputEditorInfo,
198201
this.compatCache,
199-
this.imageLoader
202+
this.imageLoader,
200203
)
201204
}
202205

@@ -220,7 +223,6 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
220223
* @param packName String
221224
*/
222225
private fun switchPackLayout(packName: String) {
223-
224226
this.activePack = packName
225227
for (packCard in this.packsList) {
226228
val packButton = packCard.findViewById<ImageButton>(R.id.stickerButton)
@@ -243,13 +245,12 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
243245
this,
244246
iconsPerX,
245247
if (vertical) RecyclerView.VERTICAL else RecyclerView.HORIZONTAL,
246-
false
248+
false,
247249
)
248250
recyclerView.layoutManager = layoutManager
249251
recyclerView.adapter = adapter
250252
packContent.removeAllViewsInLayout()
251253
packContent.addView(recyclerView)
252-
253254
}
254255

255256
private fun addPackButton(tag: Any): ImageButton {
@@ -296,9 +297,10 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
296297
if (SDK_INT >= 28) {
297298
this.switchToPreviousInputMethod()
298299
} else {
299-
(baseContext.getSystemService(INPUT_METHOD_SERVICE) as
300-
InputMethodManager)
301-
.showInputMethodPicker()
300+
(
301+
baseContext.getSystemService(INPUT_METHOD_SERVICE) as
302+
InputMethodManager
303+
).showInputMethodPicker()
302304
}
303305
}
304306

@@ -324,13 +326,14 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
324326
override fun onStickerLongClicked(sticker: File) {
325327
val fullStickerLayout =
326328
layoutInflater.inflate(R.layout.sticker_preview, this.keyboardRoot, false) as
327-
RelativeLayout
329+
RelativeLayout
328330
// Set dimens + load image
329331
fullStickerLayout.layoutParams.height =
330332
this.keyboardHeight +
331-
(resources.getDimension(R.dimen.pack_dimens) +
332-
resources.getDimension(R.dimen.sticker_padding) * 4)
333-
.toInt()
333+
(
334+
resources.getDimension(R.dimen.pack_dimens) +
335+
resources.getDimension(R.dimen.sticker_padding) * 4
336+
).toInt()
334337
val fSticker = fullStickerLayout.findViewById<ImageButton>(R.id.stickerButton)
335338
fSticker.layoutParams.height = this.fullIconSize
336339
fSticker.layoutParams.width = this.fullIconSize
@@ -389,7 +392,7 @@ class ImageKeyboard : InputMethodService(), StickerClickListener {
389392
e1: MotionEvent,
390393
e2: MotionEvent,
391394
velocityX: Float,
392-
velocityY: Float
395+
velocityY: Float,
393396
): Boolean {
394397
val diffX = e2.x - e1.x
395398
val diffY = e2.y - e1.y

app/src/main/java/com/fredhappyface/ewesticker/MainActivity.kt

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class MainActivity : AppCompatActivity() {
7676
val contentResolver = applicationContext.contentResolver
7777

7878
val takeFlags: Int = Intent.FLAG_GRANT_READ_URI_PERMISSION or
79-
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
79+
Intent.FLAG_GRANT_WRITE_URI_PERMISSION
8080
if (uri != null) {
8181
contentResolver.takePersistableUriPermission(uri, takeFlags)
8282
}
@@ -122,13 +122,14 @@ class MainActivity : AppCompatActivity() {
122122
*/
123123
fun reloadStickers(ignoredView: View) {
124124
val stickerDirPath = this.sharedPreferences.getString(
125-
"stickerDirPath", null
125+
"stickerDirPath",
126+
null,
126127
)
127128
if (stickerDirPath != null) {
128129
importStickers(stickerDirPath)
129130
} else {
130131
this.toaster.toast(
131-
getString(R.string.imported_034)
132+
getString(R.string.imported_034),
132133
)
133134
}
134135
}
@@ -153,7 +154,7 @@ class MainActivity : AppCompatActivity() {
153154
getString(R.string.imported_031, totalStickers),
154155
getString(R.string.imported_032, totalStickers),
155156
getString(R.string.imported_033, totalStickers),
156-
)
157+
),
157158
)
158159
val editor = sharedPreferences.edit()
159160
editor.putInt("numStickersImported", totalStickers)
@@ -178,7 +179,7 @@ class MainActivity : AppCompatActivity() {
178179
compoundButton: CompoundButton,
179180
sharedPrefKey: String,
180181
sharedPrefDefault: Boolean = false,
181-
callback: (Boolean) -> Unit
182+
callback: (Boolean) -> Unit,
182183
) {
183184
compoundButton.isChecked =
184185
this.sharedPreferences.getBoolean(sharedPrefKey, sharedPrefDefault)
@@ -207,7 +208,7 @@ class MainActivity : AppCompatActivity() {
207208
seekBarLabel: TextView,
208209
sharedPrefKey: String,
209210
sharedPrefDefault: Int,
210-
multiplier: Int = 1
211+
multiplier: Int = 1,
211212
) {
212213
seekBarLabel.text =
213214
this.sharedPreferences.getInt(sharedPrefKey, sharedPrefDefault).toString()
@@ -228,18 +229,19 @@ class MainActivity : AppCompatActivity() {
228229
editor.apply()
229230
showChangedPrefText()
230231
}
231-
})
232+
},
233+
)
232234
}
233235

234236
/** Reads saved sticker dir path from preferences */
235237
private fun refreshStickerDirPath() {
236238
findViewById<TextView>(R.id.stickerPackInfoPath).text =
237239
this.sharedPreferences.getString(
238-
"stickerDirPath", resources.getString(R.string.update_sticker_pack_info_path)
240+
"stickerDirPath", resources.getString(R.string.update_sticker_pack_info_path),
239241
)
240242
findViewById<TextView>(R.id.stickerPackInfoDate).text =
241243
this.sharedPreferences.getString(
242-
"lastUpdateDate", resources.getString(R.string.update_sticker_pack_info_date)
244+
"lastUpdateDate", resources.getString(R.string.update_sticker_pack_info_date),
243245
)
244246
findViewById<TextView>(R.id.stickerPackInfoTotal).text =
245247
this.sharedPreferences.getInt("numStickersImported", 0).toString()
@@ -248,7 +250,7 @@ class MainActivity : AppCompatActivity() {
248250
/** Reusable function to warn about changing preferences */
249251
private fun showChangedPrefText() {
250252
this.toaster.toast(
251-
getString(R.string.pref_000)
253+
getString(R.string.pref_000),
252254
)
253255
}
254256
}

app/src/main/java/com/fredhappyface/ewesticker/StickerImporter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import java.io.IOException
1818

1919
private const val MAX_FILES = 4096
2020
private const val MAX_PACK_SIZE = 128
21-
private const val BUFFER_SIZE = 64 * 1024 // 64 KB
21+
private const val BUFFER_SIZE = 64 * 1024 // 64 KB
2222

2323
/**
2424
* The StickerImporter class includes a helper function to import stickers from a user-selected

app/src/main/java/com/fredhappyface/ewesticker/utilities/StickerClickListener.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ import java.io.File
55
interface StickerClickListener {
66
fun onStickerClicked(sticker: File)
77
fun onStickerLongClicked(sticker: File)
8-
}
8+
}

app/src/main/java/com/fredhappyface/ewesticker/utilities/StickerSender.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class StickerSender(
7979
bitmap.compress(
8080
Bitmap.CompressFormat.PNG,
8181
90,
82-
FileOutputStream(compatSticker)
82+
FileOutputStream(compatSticker),
8383
)
8484
}
8585
.build()
@@ -112,7 +112,7 @@ class StickerSender(
112112
val uri = FileProvider.getUriForFile(
113113
context,
114114
"com.fredhappyface.ewesticker.inputcontent",
115-
file
115+
file,
116116
)
117117

118118
val shareIntent = Intent().apply {
@@ -150,10 +150,10 @@ class StickerSender(
150150
FileProvider.getUriForFile(
151151
context,
152152
"com.fredhappyface.ewesticker.inputcontent",
153-
file
153+
file,
154154
),
155155
ClipDescription(file.name, arrayOf(mimeType)),
156-
null
156+
null,
157157
)
158158

159159
if (currentInputConnection != null && currentInputEditorInfo != null) {
@@ -162,7 +162,7 @@ class StickerSender(
162162
currentInputEditorInfo,
163163
inputContentInfoCompat,
164164
InputConnectionCompat.INPUT_CONTENT_GRANT_READ_URI_PERMISSION,
165-
null
165+
null,
166166
)
167167
}
168168
}
@@ -176,7 +176,7 @@ class StickerSender(
176176
*/
177177
private fun isCommitContentSupported(editorInfo: EditorInfo?, mimeType: String?): Boolean {
178178
return editorInfo?.packageName != null && mimeType != null && currentInputConnection != null &&
179-
EditorInfoCompat.getContentMimeTypes(editorInfo)
180-
.any { ClipDescription.compareMimeTypes(mimeType, it) }
179+
EditorInfoCompat.getContentMimeTypes(editorInfo)
180+
.any { ClipDescription.compareMimeTypes(mimeType, it) }
181181
}
182182
}

app/src/main/java/com/fredhappyface/ewesticker/utilities/Toaster.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ class Toaster(private val context: Context) {
2121
*/
2222
fun toast(string: String) {
2323
Toast.makeText(
24-
this.context, string, if (string.length > 60) {
24+
this.context,
25+
string,
26+
if (string.length > 60) {
2527
Toast.LENGTH_LONG
2628
} else {
2729
Toast.LENGTH_SHORT
28-
}
30+
},
2931
)
3032
.show()
3133
}

app/src/main/java/com/fredhappyface/ewesticker/utilities/Utils.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ object Utils {
3030
"video/3gpp",
3131
"video/mp4",
3232
"video/x-matroska",
33-
"video/webm"
33+
"video/webm",
3434
)
3535
}
3636
}

0 commit comments

Comments
 (0)