Skip to content

Commit d5c9f6f

Browse files
committed
Address Kai's feedback
1 parent ef7766c commit d5c9f6f

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

firebase-appdistribution/test-app/src/main/java/com/googletest/firebase/appdistribution/testapp/MainActivity.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ import android.widget.ProgressBar
1717
import android.widget.TextView
1818
import androidx.appcompat.app.AppCompatActivity
1919
import androidx.appcompat.widget.AppCompatButton
20-
import androidx.core.content.ContentProviderCompat.requireContext
21-
import androidx.core.widget.addTextChangedListener
2220
import androidx.core.widget.doOnTextChanged
2321
import com.google.android.gms.tasks.Task
2422
import com.google.android.material.textfield.TextInputLayout
@@ -84,19 +82,19 @@ class MainActivity : AppCompatActivity() {
8482

8583
// Set up feedback trigger menu
8684
feedbackTriggerMenu = findViewById(R.id.feedbackTriggerMenu)
87-
val items = listOf(TRIGGER_NONE, TRIGGER_SHAKE)
85+
val items = listOf(FeedbackTrigger.NONE.label, FeedbackTrigger.SHAKE.label)
8886
val adapter = ArrayAdapter(this, R.layout.list_item, items)
8987
val autoCompleteTextView = feedbackTriggerMenu.editText!! as AutoCompleteTextView
9088
autoCompleteTextView.setAdapter(adapter)
91-
autoCompleteTextView.setText(TRIGGER_NONE, false)
89+
autoCompleteTextView.setText(FeedbackTrigger.NONE.label, false)
9290
autoCompleteTextView.doOnTextChanged { text, start, before, count ->
9391
// TODO: support enabling/disabling other triggers
9492
when(text.toString()) {
95-
TRIGGER_NONE -> {
93+
FeedbackTrigger.NONE.label -> {
9694
Log.i(TAG, "Disabling shake")
9795
ShakeForFeedback.disable(application)
9896
}
99-
TRIGGER_SHAKE -> {
97+
FeedbackTrigger.SHAKE.label -> {
10098
Log.i(TAG, "Enabling shake")
10199
ShakeForFeedback.enable(application, this)
102100
}
@@ -310,9 +308,12 @@ class MainActivity : AppCompatActivity() {
310308

311309
companion object {
312310
const val TAG = "MainActivity"
313-
const val TRIGGER_NONE = "None"
314-
const val TRIGGER_SHAKE = "Shake the device"
315-
const val TRIGGER_SCREENSHOT = "Take a screenshot"
316-
const val TRIGGER_NOTIFICATION = "Click the notification"
311+
312+
enum class FeedbackTrigger(val label: String) {
313+
NONE("None"),
314+
SHAKE("Shake the device"),
315+
SCREENSHOT("Take a screenshot"),
316+
NOTIFICATION("Click the notification")
317+
}
317318
}
318319
}

firebase-appdistribution/test-app/src/main/java/com/googletest/firebase/appdistribution/testapp/ShakeForFeedback.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ object ShakeForFeedback : ShakeDetector.Listener, Application.ActivityLifecycleC
1515
private val shakeDetector = ShakeDetector(this)
1616
private var isEnabled = false
1717

18-
fun enable(application: Application) = enable(application, null)
19-
20-
fun enable(application: Application, currentActivity: Activity?) {
18+
fun enable(application: Application, currentActivity: Activity? = null) {
2119
synchronized(this) {
2220
if (!isEnabled) {
2321
application.registerActivityLifecycleCallbacks(this)

0 commit comments

Comments
 (0)