Skip to content

refact: add prefix alg_ to android resources #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ org.gradle.jvmargs=-Xmx1536m

# POM
GROUP=com.algolia.instantsearch
VERSION_NAME=1.1.0
VERSION_NAME=1.2.0
POM_DESCRIPTION=An overlay that gets your user's voice permission and input as text
POM_URL=https://github.com/algolia/voice-overlay-android
POM_SCM_URL=https://github.com/algolia/voice-overlay-android
Expand Down
2 changes: 2 additions & 0 deletions voice/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ android {
kotlinOptions {
freeCompilerArgs += '-Xexplicit-api=strict'
}

resourcePrefix = "alg_"
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import android.view.View
import com.algolia.instantsearch.voice.R

/** A View displaying a ripple effect. */
public class RippleView : View {
public class AlgRippleView : View {

public enum class State {
None,
Expand Down Expand Up @@ -91,12 +91,12 @@ public class RippleView : View {

@SuppressLint("Recycle")
private fun init(attrs: AttributeSet) {
context.obtainStyledAttributes(attrs, R.styleable.RippleView, 0, 0).also {
val drawable = it.getDrawable(R.styleable.RippleView_drawable)!!
delay = it.getInt(R.styleable.RippleView_delay, 500).toLong()
duration = it.getInt(R.styleable.RippleView_duration, 500).toLong()
size = it.getDimensionPixelSize(R.styleable.RippleView_size, 0)
radius = it.getFloat(R.styleable.RippleView_radius_value, 1f)
context.obtainStyledAttributes(attrs, R.styleable.AlgRippleView, 0, 0).also {
val drawable = it.getDrawable(R.styleable.AlgRippleView_alg_drawable)!!
delay = it.getInt(R.styleable.AlgRippleView_alg_delay, 500).toLong()
duration = it.getInt(R.styleable.AlgRippleView_alg_duration, 500).toLong()
size = it.getDimensionPixelSize(R.styleable.AlgRippleView_alg_size, 0)
radius = it.getFloat(R.styleable.AlgRippleView_alg_radius, 1f)
circleCount = duration / delay

circles = (0 until circleCount).map { DrawableSprite(drawable, size, Opacity.p0) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public object Voice {
whyAllow: CharSequence? = null,
buttonAllow: CharSequence? = null
) {
val whyText = whyAllow ?: getString(R.string.permission_rationale)
val buttonText = (buttonAllow ?: getString(R.string.permission_button_again))
val whyText = whyAllow ?: getString(R.string.alg_permission_rationale)
val buttonText = (buttonAllow ?: getString(R.string.alg_permission_button_again))
Snackbar.make(anchor, whyText, Snackbar.LENGTH_LONG)
.setAction(buttonText) { requestRecordingPermission() }.show()
}
Expand All @@ -98,9 +98,9 @@ public object Voice {
howEnable: CharSequence? = null
) {
val context = anchor.context
val whyText = (whyEnable ?: context.getText(R.string.permission_enable_rationale))
val buttonText = (buttonEnable ?: context.getText(R.string.permission_button_enable))
val howText = (howEnable ?: context.getText(R.string.permission_enable_instructions))
val whyText = (whyEnable ?: context.getText(R.string.alg_permission_enable_rationale))
val buttonText = (buttonEnable ?: context.getText(R.string.alg_permission_button_enable))
val howText = (howEnable ?: context.getText(R.string.alg_permission_enable_instructions))

val snackbar = Snackbar.make(anchor, whyText, Snackbar.LENGTH_LONG).setAction(buttonText) {
Snackbar.make(anchor, howText, Snackbar.LENGTH_SHORT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ public class VoiceAndroidView(
private val View.subtitle: TextView get() = findViewById(R.id.subtitle)
private val View.suggestions: TextView? get() = findViewById(R.id.suggestions)
private val View.hint: TextView get() = findViewById(R.id.hint)
private val View.ripple: RippleView get() = findViewById(R.id.ripple)
private val View.ripple: AlgRippleView get() = findViewById(R.id.ripple)

override val formatterSuggestion: (String) -> String = { suggestion: String ->
context.getString(R.string.format_voice_suggestion_html, suggestion)
context.getString(R.string.alg_format_voice_suggestion_html, suggestion)
}

override fun setOnClickListenerClose(onClickListener: View.OnClickListener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class VoiceInputDialogFragment : DialogFragment() {
// region Lifecycle
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NORMAL, R.style.VoiceDialogTheme)
setStyle(STYLE_NORMAL, R.style.AlgVoiceDialogTheme)
speechRecognizer = VoiceSpeechRecognizer(requireContext())
suggestions = arguments?.getStringArray(Field.Suggestions.name)
}
Expand All @@ -61,7 +61,7 @@ public class VoiceInputDialogFragment : DialogFragment() {
container: ViewGroup?,
savedInstanceState: Bundle?
): View? =
inflater.inflate(R.layout.voice_input, container, false)
inflater.inflate(R.layout.alg_voice_input, container, false)

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Expand All @@ -86,7 +86,7 @@ public class VoiceInputDialogFragment : DialogFragment() {
}
suggestions?.let {
androidView.setSuggestions(it)
androidView.setSubtitle(resources.getString(R.string.input_subtitle_listening))
androidView.setSubtitle(resources.getString(R.string.alg_input_subtitle_listening))
}
speechRecognizer.setRecognitionListener(presenter)
speechRecognizer.stateListener = presenter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class VoiceMicrophone(context: Context, attrs: AttributeSet) : AppCompatI
Deactivated
}

private val white = ContextCompat.getColor(context, R.color.white)
private val blue = ContextCompat.getColor(context, R.color.blue_dark)
private val white = ContextCompat.getColor(context, R.color.alg_white)
private val blue = ContextCompat.getColor(context, R.color.alg_blue_dark)

public var state: State = State.Deactivated
set(value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ public class VoicePermissionDialogFragment : DialogFragment() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setStyle(STYLE_NORMAL, R.style.VoiceDialogTheme)
setStyle(STYLE_NORMAL, R.style.AlgVoiceDialogTheme)
}

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
return inflater.inflate(R.layout.voice_permission, container, false)
return inflater.inflate(R.layout.alg_voice_permission, container, false)
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ public interface VoiceUI {
public val formatterSuggestion: (String) -> String

public enum class Title(public val resource: Int) {
Listen(R.string.input_title_listening),
Error(R.string.input_title_error)
Listen(R.string.alg_input_title_listening),
Error(R.string.alg_input_title_error)
}

public enum class Subtitle(public val resource: Int) {
Error(R.string.input_subtitle_error),
Listen(R.string.input_subtitle_listening)
Error(R.string.alg_input_subtitle_error),
Listen(R.string.alg_input_subtitle_listening)
}

public fun setOnClickListenerClose(onClickListener: View.OnClickListener)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?attr/colorControlHighlight">

<item android:drawable="@drawable/button_negative_background"/>
<item android:drawable="@drawable/alg_button_negative_background"/>
</ripple>
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?attr/colorControlHighlight">

<item android:drawable="@drawable/button_positive_background"/>
<item android:drawable="@drawable/alg_button_positive_background"/>
</ripple>
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
xmlns:android="http://schemas.android.com/apk/res/android"
android:color="?attr/colorControlHighlight">

<item android:drawable="@drawable/microphone_background"/>
<item android:drawable="@drawable/alg_microphone_background"/>
</ripple>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

<stroke
android:width="1dp"
android:color="@color/white"/>
android:color="@color/alg_white"/>

</shape>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/button_positive_background" />
<item android:drawable="@drawable/alg_button_negative_background"/>
</selector>
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

<gradient
android:angle="180"
android:endColor="@color/blue_light"
android:startColor="@color/blue_dark"
android:endColor="@color/alg_blue_light"
android:startColor="@color/alg_blue_dark"
android:type="linear"/>

<corners android:radius="6dp"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/microphone_background" />
<item android:drawable="@drawable/alg_button_positive_background" />
</selector>
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<gradient
android:angle="270"
android:type="linear"
android:startColor="@color/blue_dark"
android:endColor="@color/blue_cyan"/>
android:startColor="@color/alg_blue_dark"
android:endColor="@color/alg_blue_cyan"/>
</shape>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/button_negative_background"/>
<item android:drawable="@drawable/alg_microphone_background" />
</selector>
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:shape="oval">
<gradient
android:angle="135"
android:endColor="@color/blue_dark"
android:startColor="@color/blue_light"
android:endColor="@color/alg_blue_dark"
android:startColor="@color/alg_blue_light"
android:type="linear" />
</shape>
Loading