Skip to content

Commit 6cb976f

Browse files
committed
fix: minor lint fixes
1 parent ac620bf commit 6cb976f

File tree

5 files changed

+30
-23
lines changed

5 files changed

+30
-23
lines changed

voice/src/main/kotlin/com/algolia/instantsearch/voice/ui/RippleView.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import android.animation.AnimatorSet
44
import android.annotation.SuppressLint
55
import android.content.Context
66
import android.graphics.Canvas
7-
import android.os.Build
87
import android.util.AttributeSet
98
import android.view.View
109
import com.algolia.instantsearch.voice.R
@@ -24,17 +23,22 @@ class RippleView : View {
2423
init(attrs)
2524
}
2625

27-
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
26+
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(
27+
context,
28+
attrs,
29+
defStyleAttr
30+
) {
2831
init(attrs)
2932
}
3033

3134
/** All circles used in this RippleView, generated during [init]. */
3235
private var circles = listOf<DrawableSprite>()
33-
/** Current animations, filled when [State.Playing] triggers [animation] and emptied when [State.Stopped]. */
36+
37+
/** Current animations, filled when [State.Playing] triggers animation and emptied when [State.Stopped]. */
3438
private val animations = mutableMapOf<Int, AnimatorSet>()
3539

3640
/** This runnable invalidate the view at 60 fps. */
37-
private val runnableFps = object : java.lang.Runnable {
41+
private val runnableFps = object : Runnable {
3842

3943
override fun run() {
4044
invalidate()
@@ -118,8 +122,8 @@ class RippleView : View {
118122

119123
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
120124
super.onSizeChanged(w, h, oldw, oldh)
121-
circles.forEach {
122-
it.position.let {
125+
circles.forEach { drawableSprite ->
126+
drawableSprite.position.let {
123127
it.x = w / 2
124128
it.y = h / 2
125129
}

voice/src/main/kotlin/com/algolia/instantsearch/voice/ui/Voice.kt

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
package com.algolia.instantsearch.voice.ui
22

3-
import android.Manifest
43
import android.Manifest.permission.RECORD_AUDIO
54
import android.app.Activity
65
import android.content.Context
76
import android.content.Intent
87
import android.content.pm.PackageManager
98
import android.net.Uri
109
import android.provider.Settings
11-
import com.google.android.material.snackbar.BaseTransientBottomBar
12-
import com.google.android.material.snackbar.Snackbar
13-
import androidx.core.app.ActivityCompat
14-
import androidx.core.content.ContextCompat
1510
import android.view.View
1611
import android.widget.TextView
12+
import androidx.core.app.ActivityCompat
13+
import androidx.core.content.ContextCompat
1714
import com.algolia.instantsearch.voice.R
15+
import com.google.android.material.snackbar.BaseTransientBottomBar
16+
import com.google.android.material.snackbar.Snackbar
1817

1918
/** Helper functions for voice permission handling. */
2019
object Voice {
@@ -48,7 +47,7 @@ object Voice {
4847
*/
4948
@JvmStatic
5049
fun Activity.shouldExplainPermission() =
51-
ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.RECORD_AUDIO)
50+
ActivityCompat.shouldShowRequestPermissionRationale(this, RECORD_AUDIO)
5251

5352
/**
5453
* Requests the [recording permission][RECORD_AUDIO] from your activity.*/
@@ -60,8 +59,10 @@ object Voice {
6059
/** Opens the application's settings from a given context, so the user can enable the recording permission.*/
6160
@JvmStatic
6261
fun Context.openAppSettings() {
63-
startActivity(Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
64-
.setData(Uri.fromParts("package", packageName, null)))
62+
startActivity(
63+
Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS)
64+
.setData(Uri.fromParts("package", packageName, null))
65+
)
6566
}
6667

6768
/** Displays the rationale behind requesting the recording permission via a Snackbar.
@@ -78,7 +79,8 @@ object Voice {
7879
) {
7980
val whyText = whyAllow ?: getString(R.string.permission_rationale)
8081
val buttonText = (buttonAllow ?: getString(R.string.permission_button_again))
81-
Snackbar.make(anchor, whyText, Snackbar.LENGTH_LONG).setAction(buttonText) { requestRecordingPermission() }.show()
82+
Snackbar.make(anchor, whyText, Snackbar.LENGTH_LONG)
83+
.setAction(buttonText) { requestRecordingPermission() }.show()
8284
}
8385

8486
/** Guides the user to manually enable recording permission in the app's settings.
@@ -103,7 +105,8 @@ object Voice {
103105
val snackbar = Snackbar.make(anchor, whyText, Snackbar.LENGTH_LONG).setAction(buttonText) {
104106
Snackbar.make(anchor, howText, Snackbar.LENGTH_SHORT)
105107
.addCallback(object : BaseTransientBottomBar.BaseCallback<Snackbar>() {
106-
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) = context.openAppSettings()
108+
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) =
109+
context.openAppSettings()
107110
}).show()
108111
}
109112
snackbar.view.findViewById<TextView>(R.id.snackbar_text).maxLines = 2

voice/src/main/kotlin/com/algolia/instantsearch/voice/ui/VoiceInputDialogFragment.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class VoiceInputDialogFragment : DialogFragment() {
4949
// region Lifecycle
5050
override fun onCreate(savedInstanceState: Bundle?) {
5151
super.onCreate(savedInstanceState)
52-
setStyle(DialogFragment.STYLE_NORMAL, R.style.VoiceDialogTheme)
52+
setStyle(STYLE_NORMAL, R.style.VoiceDialogTheme)
5353
speechRecognizer = VoiceSpeechRecognizer(requireContext())
5454
suggestions = arguments?.getStringArray(Field.Suggestions.name)
5555
}
@@ -70,13 +70,13 @@ class VoiceInputDialogFragment : DialogFragment() {
7070
dismiss()
7171
}
7272

73-
androidView.setOnClickListenerClose(View.OnClickListener { dismiss() })
74-
androidView.setOnClickMicrophoneListener(View.OnClickListener {
73+
androidView.setOnClickListenerClose { dismiss() }
74+
androidView.setOnClickMicrophoneListener {
7575
when (androidView.getMicrophoneState()) {
7676
VoiceMicrophone.State.Activated -> speechRecognizer.stop()
7777
VoiceMicrophone.State.Deactivated -> speechRecognizer.start()
7878
}
79-
})
79+
}
8080
suggestions?.let {
8181
androidView.setSuggestions(it)
8282
androidView.setSubtitle(resources.getString(R.string.input_subtitle_listening))

voice/src/main/kotlin/com/algolia/instantsearch/voice/ui/VoicePermissionDialogFragment.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class VoicePermissionDialogFragment : DialogFragment() {
1616

1717
override fun onCreate(savedInstanceState: Bundle?) {
1818
super.onCreate(savedInstanceState)
19-
setStyle(DialogFragment.STYLE_NORMAL, R.style.VoiceDialogTheme)
19+
setStyle(STYLE_NORMAL, R.style.VoiceDialogTheme)
2020
}
2121

2222
override fun onCreateView(

voice/src/main/kotlin/com/algolia/instantsearch/voice/ui/VoicePresenter.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import android.os.Bundle
44
import android.speech.RecognitionListener
55
import com.algolia.instantsearch.voice.VoiceSpeechRecognizer
66
import com.algolia.instantsearch.voice.resultsRecognition
7-
7+
import java.util.Locale
88

99
class VoicePresenter(
1010
private val ui: VoiceUI,
@@ -23,7 +23,7 @@ class VoicePresenter(
2323

2424
ui.setSuggestionVisibility(false)
2525
ui.setTitle(VoiceUI.Title.Listen)
26-
matches.firstOrNull()?.capitalize()?.let(ui::setSubtitle)
26+
matches.firstOrNull()?.capitalize(Locale.ROOT)?.let(ui::setSubtitle)
2727
hasPartialResults = true
2828
}
2929

0 commit comments

Comments
 (0)