Skip to content

Commit 8d9b701

Browse files
committed
Some improvements to firebase-appdistribution/test-app (#4330)
1 parent 4e09f65 commit 8d9b701

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
@@ -19,7 +19,6 @@ import androidx.core.widget.doOnTextChanged
1919
import com.google.android.gms.tasks.Task
2020
import com.google.android.material.textfield.TextInputLayout
2121
import com.google.firebase.appdistribution.AppDistributionRelease
22-
import com.google.firebase.appdistribution.FirebaseAppDistributionException
2322
import com.google.firebase.appdistribution.InterruptionLevel
2423
import com.google.firebase.appdistribution.UpdateProgress
2524
import com.google.firebase.appdistribution.ktx.appDistribution
@@ -73,7 +72,6 @@ class MainActivity : AppCompatActivity() {
7372
feedbackTriggerMenu = findViewById(R.id.feedbackTriggerMenu)
7473
val items = listOf(
7574
FeedbackTrigger.NONE.label,
76-
FeedbackTrigger.SDK_NOTIFICATION.label,
7775
FeedbackTrigger.CUSTOM_NOTIFICATION.label,
7876
FeedbackTrigger.SHAKE.label,
7977
FeedbackTrigger.SCREENSHOT.label,
@@ -88,12 +86,6 @@ class MainActivity : AppCompatActivity() {
8886
FeedbackTrigger.NONE.label -> {
8987
disableAllFeedbackTriggers()
9088
}
91-
FeedbackTrigger.SDK_NOTIFICATION.label -> {
92-
disableAllFeedbackTriggers()
93-
Log.i(TAG, "Enabling notification trigger (SDK)")
94-
firebaseAppDistribution.showFeedbackNotification(
95-
R.string.feedbackInfoText, InterruptionLevel.HIGH)
96-
}
9789
FeedbackTrigger.CUSTOM_NOTIFICATION.label -> {
9890
disableAllFeedbackTriggers()
9991
startActivity(Intent(this, CustomNotificationActivity::class.java))
@@ -109,6 +101,9 @@ class MainActivity : AppCompatActivity() {
109101
}
110102
}
111103
}
104+
105+
firebaseAppDistribution.showFeedbackNotification(
106+
R.string.feedbackInfoText, InterruptionLevel.HIGH)
112107
}
113108

114109
override fun onDestroy() {
@@ -118,13 +113,15 @@ class MainActivity : AppCompatActivity() {
118113

119114
private fun disableAllFeedbackTriggers() {
120115
Log.i(TAG, "Disabling all feedback triggers")
121-
firebaseAppDistribution.cancelFeedbackNotification()
122116
ShakeDetectionFeedbackTrigger.disable(application)
123117
}
124118

125119
override fun onCreateOptionsMenu(menu: Menu): Boolean {
126120
val inflater: MenuInflater = menuInflater
127121
inflater.inflate(R.menu.action_menu, menu)
122+
if (BuildConfig.FLAVOR == "beta") {
123+
menu.findItem(R.id.startFeedbackMenuItem).isVisible = true
124+
}
128125
return true
129126
}
130127

@@ -263,11 +260,11 @@ class MainActivity : AppCompatActivity() {
263260
}
264261

265262
private fun failureListener(exception: Exception) {
266-
val ex = exception as FirebaseAppDistributionException
267-
Log.d("FirebaseAppDistribution", "MAINACTIVITY:ERROR ERROR. CODE: " + exception.errorCode)
263+
val ex = exception as com.google.firebase.appdistribution.FirebaseAppDistributionException
264+
Log.d("MainActivity", "Task failed with an error (${ex.errorCode}): ${ex.message}")
268265
AlertDialog.Builder(this)
269-
.setTitle("Error updating to new release")
270-
.setMessage("${ex.message}: ${ex.errorCode}")
266+
.setTitle("Task failed")
267+
.setMessage("${ex.message}\n\nCode: ${ex.errorCode}")
271268
.setNeutralButton("Okay") { dialog, _ -> dialog.dismiss() }
272269
.show()
273270
}
@@ -323,7 +320,6 @@ class MainActivity : AppCompatActivity() {
323320
NONE("None"),
324321
SHAKE("Shake the device"),
325322
SCREENSHOT("Take a screenshot"),
326-
SDK_NOTIFICATION("Tap a notification (SDK)"),
327323
CUSTOM_NOTIFICATION("Tap a notification (custom)")
328324
}
329325
}
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)