Skip to content

Commit 2fbbda4

Browse files
committed
Some improvements to firebase-appdistribution/test-app (#4330)
1 parent 7fdcb1f commit 2fbbda4

File tree

3 files changed

+30
-21
lines changed

3 files changed

+30
-21
lines changed

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import androidx.core.widget.doOnTextChanged
3333
import com.google.android.gms.tasks.Task
3434
import com.google.android.material.textfield.TextInputLayout
3535
import com.google.firebase.appdistribution.AppDistributionRelease
36-
import com.google.firebase.appdistribution.FirebaseAppDistributionException
3736
import com.google.firebase.appdistribution.InterruptionLevel
3837
import com.google.firebase.appdistribution.UpdateProgress
3938
import com.google.firebase.appdistribution.ktx.appDistribution
@@ -87,7 +86,6 @@ class MainActivity : AppCompatActivity() {
8786
feedbackTriggerMenu = findViewById(R.id.feedbackTriggerMenu)
8887
val items = listOf(
8988
FeedbackTrigger.NONE.label,
90-
FeedbackTrigger.SDK_NOTIFICATION.label,
9189
FeedbackTrigger.CUSTOM_NOTIFICATION.label,
9290
FeedbackTrigger.SHAKE.label,
9391
FeedbackTrigger.SCREENSHOT.label,
@@ -102,12 +100,6 @@ class MainActivity : AppCompatActivity() {
102100
FeedbackTrigger.NONE.label -> {
103101
disableAllFeedbackTriggers()
104102
}
105-
FeedbackTrigger.SDK_NOTIFICATION.label -> {
106-
disableAllFeedbackTriggers()
107-
Log.i(TAG, "Enabling notification trigger (SDK)")
108-
firebaseAppDistribution.showFeedbackNotification(
109-
R.string.feedbackInfoText, InterruptionLevel.HIGH)
110-
}
111103
FeedbackTrigger.CUSTOM_NOTIFICATION.label -> {
112104
disableAllFeedbackTriggers()
113105
startActivity(Intent(this, CustomNotificationActivity::class.java))
@@ -123,6 +115,9 @@ class MainActivity : AppCompatActivity() {
123115
}
124116
}
125117
}
118+
119+
firebaseAppDistribution.showFeedbackNotification(
120+
R.string.feedbackInfoText, InterruptionLevel.HIGH)
126121
}
127122

128123
override fun onDestroy() {
@@ -132,13 +127,15 @@ class MainActivity : AppCompatActivity() {
132127

133128
private fun disableAllFeedbackTriggers() {
134129
Log.i(TAG, "Disabling all feedback triggers")
135-
firebaseAppDistribution.cancelFeedbackNotification()
136130
ShakeDetectionFeedbackTrigger.disable(application)
137131
}
138132

139133
override fun onCreateOptionsMenu(menu: Menu): Boolean {
140134
val inflater: MenuInflater = menuInflater
141135
inflater.inflate(R.menu.action_menu, menu)
136+
if (BuildConfig.FLAVOR == "beta") {
137+
menu.findItem(R.id.startFeedbackMenuItem).isVisible = true
138+
}
142139
return true
143140
}
144141

@@ -277,11 +274,11 @@ class MainActivity : AppCompatActivity() {
277274
}
278275

279276
private fun failureListener(exception: Exception) {
280-
val ex = exception as FirebaseAppDistributionException
281-
Log.d("FirebaseAppDistribution", "MAINACTIVITY:ERROR ERROR. CODE: " + exception.errorCode)
277+
val ex = exception as com.google.firebase.appdistribution.FirebaseAppDistributionException
278+
Log.d("MainActivity", "Task failed with an error (${ex.errorCode}): ${ex.message}")
282279
AlertDialog.Builder(this)
283-
.setTitle("Error updating to new release")
284-
.setMessage("${ex.message}: ${ex.errorCode}")
280+
.setTitle("Task failed")
281+
.setMessage("${ex.message}\n\nCode: ${ex.errorCode}")
285282
.setNeutralButton("Okay") { dialog, _ -> dialog.dismiss() }
286283
.show()
287284
}
@@ -337,7 +334,6 @@ class MainActivity : AppCompatActivity() {
337334
NONE("None"),
338335
SHAKE("Shake the device"),
339336
SCREENSHOT("Take a screenshot"),
340-
SDK_NOTIFICATION("Tap a notification (SDK)"),
341337
CUSTOM_NOTIFICATION("Tap a notification (custom)")
342338
}
343339
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<menu xmlns:android="http://schemas.android.com/apk/res/android">
33
<item android:id="@+id/startFeedbackMenuItem"
4-
android:title="@string/startFeedbackLabel"/>
4+
android:title="@string/startFeedbackLabel"
5+
android:visible="false"/>
56
</menu>

firebase-appdistribution/test-app/test-app.gradle

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ android {
2525
applicationId "com.googletest.firebase.appdistribution.testapp"
2626
minSdkVersion 23
2727
targetSdkVersion 33
28-
versionName "2.1"
29-
versionCode 3
28+
versionName "3.1"
29+
versionCode 6
3030

3131
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3232
}
@@ -37,10 +37,22 @@ android {
3737
// needing to have the app signed.
3838
initWith debug
3939
}
40+
}
41+
42+
flavorDimensions.add("environment")
43+
44+
productFlavors {
45+
prod {
46+
dimension "environment"
47+
versionNameSuffix "-prod"
48+
}
49+
50+
beta {
51+
dimension "environment"
52+
versionNameSuffix "-beta"
4053

41-
debug {
4254
firebaseAppDistribution {
43-
releaseNotes "Debug variant of Android SDK test app"
55+
releaseNotes "Beta variant of Android SDK test app"
4456
// testers "your email here"
4557
}
4658
}
@@ -67,8 +79,8 @@ dependencies {
6779
implementation project(':firebase-common:ktx')
6880
implementation "com.google.android.gms:play-services-tasks:18.0.2"
6981

70-
// Debug uses the full implementation
71-
debugImplementation project(':firebase-appdistribution')
82+
// Beta flavor uses the full implementation
83+
betaImplementation project(':firebase-appdistribution')
7284

7385
// Other dependencies
7486
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"

0 commit comments

Comments
 (0)