Skip to content

Commit 53d9f61

Browse files
authored
Add feedback button to app-distribution/test-app (#3924)
1 parent 0f24df5 commit 53d9f61

File tree

5 files changed

+55
-8
lines changed

5 files changed

+55
-8
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ buildscript {
3737
classpath 'digital.wup:android-maven-publish:3.6.3'
3838
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
3939
classpath 'org.jlleitschuh.gradle:ktlint-gradle:9.2.1'
40+
classpath 'com.google.firebase:firebase-appdistribution-gradle:3.0.2'
4041
}
4142
}
4243

firebase-appdistribution/test-app/README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,28 @@ and install the apk:
4747

4848
```
4949
firebase-android-sdk$ adb install firebase-appdistribution/test-app/build/outputs/apk/release/test-app-release.apk
50-
```
50+
```
51+
52+
## Test In-App Feedback Locally
53+
54+
In-App Feedback is currently tricky to test locally because it relies on the
55+
fact that a release exists with the same hash of the running binary.
56+
57+
To build the debug APK, upload it to App Distribution, and install it on the running emulator:
58+
1. Start an emulator
59+
2. Run the following command from the repo's root directory:
60+
61+
```
62+
./gradlew :firebase-appdistribution:test-app:build :firebase-appdistribution:test-app:appDistributionUploadDebug && adb install firebase-appdistribution/test-app/build/outputs/apk/debug/test-app-debug.apk
63+
```
64+
65+
After that, if you want to avoid having to do this every time you want to test
66+
locally:
67+
68+
1. Submit feedback in the locally running app, to generate some logs
69+
2. In the Logcat output, find the release name (i.e. "projects/1095562444941/installations/fCmpB677QTybkwfKbViGI-/releases/3prs96fui9kb0")
70+
3. Modify the body of `ReleaseIdentifier.identifyRelease()` to be:
71+
72+
```
73+
return Tasks.forResult("<your release name>");
74+
```

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import androidx.appcompat.widget.AppCompatButton
1313
import com.google.android.gms.tasks.Task
1414
import com.google.firebase.appdistribution.AppDistributionRelease
1515
import com.google.firebase.appdistribution.FirebaseAppDistribution
16+
import com.google.firebase.appdistribution.FirebaseAppDistributionException
1617
import com.google.firebase.appdistribution.UpdateProgress
1718
import java.util.concurrent.ExecutorService
1819
import java.util.concurrent.Executors
@@ -32,6 +33,7 @@ class MainActivity : AppCompatActivity() {
3233
lateinit var signOutButtonBackground: AppCompatButton
3334
lateinit var checkForUpdateButtonBackground: AppCompatButton
3435
lateinit var updateAppButtonBackground: AppCompatButton
36+
lateinit var feedbackButton: AppCompatButton
3537
lateinit var progressPercentage: TextView
3638
lateinit var signInStatus: TextView
3739
lateinit var progressPercent: TextView
@@ -51,6 +53,7 @@ class MainActivity : AppCompatActivity() {
5153
signOutButtonBackground = findViewById<AppCompatButton>(R.id.sign_out2)
5254
checkForUpdateButtonBackground = findViewById<AppCompatButton>(R.id.check_for_update2)
5355
updateAppButtonBackground = findViewById<AppCompatButton>(R.id.update_app2)
56+
feedbackButton = findViewById<AppCompatButton>(R.id.feedbackButton)
5457
progressPercentage = findViewById<TextView>(R.id.progress_percentage)
5558
signInStatus = findViewById<TextView>(R.id.sign_in_status)
5659
progressPercent = findViewById<TextView>(R.id.progress_percentage)
@@ -164,6 +167,10 @@ class MainActivity : AppCompatActivity() {
164167
firebaseAppDistribution.updateApp().addOnProgressListener { progressListener(it) }
165168
}
166169
}
170+
171+
feedbackButton.setOnClickListener {
172+
firebaseAppDistribution.collectAndSendFeedback()
173+
}
167174
}
168175

169176
fun startSecondActivity() {

firebase-appdistribution/test-app/src/main/res/layout/activity_main.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,14 @@
179179
app:layout_constraintLeft_toLeftOf="parent"
180180
app:layout_constraintRight_toRightOf="parent"
181181
app:layout_constraintTop_toBottomOf="@id/progress_percentage" />
182+
<Button
183+
android:id="@+id/feedbackButton"
184+
android:layout_width="wrap_content"
185+
android:layout_height="wrap_content"
186+
android:layout_marginTop="20dp"
187+
android:text="Send feedback"
188+
app:layout_constraintEnd_toEndOf="parent"
189+
app:layout_constraintStart_toStartOf="parent"
190+
app:layout_constraintTop_toBottomOf="@+id/sign_out" />
182191

183192
</androidx.constraintlayout.widget.ConstraintLayout>

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ plugins {
1515
id 'com.android.application'
1616
id 'kotlin-android'
1717
id 'com.google.gms.google-services'
18+
id 'com.google.firebase.appdistribution'
1819
}
1920

2021
android {
@@ -31,11 +32,18 @@ android {
3132
}
3233

3334
buildTypes {
34-
// This is so we can build the "release" variant for the "dev-app" (and the SDK) without
35-
// needing to have the app signed.
3635
release {
36+
// This is so we can build the "release" variant for the "dev-app" (and the SDK) without
37+
// needing to have the app signed.
3738
initWith debug
3839
}
40+
41+
debug {
42+
firebaseAppDistribution {
43+
releaseNotes "Debug variant of Android SDK test app"
44+
// testers "your email here"
45+
}
46+
}
3947
}
4048
compileOptions {
4149
sourceCompatibility JavaVersion.VERSION_1_8
@@ -50,13 +58,11 @@ dependencies {
5058
// TODO(rachelprince): Add flag to build with public version of SDK
5159
println("Building with HEAD version ':firebase-appdistribution' of SDK")
5260

53-
// Debug variant uses full SDK
54-
debugImplementation project(':firebase-appdistribution-api') // TODO(lkellogg): why doesn't this get picked up transitively?
61+
// Include the API in all variants
62+
implementation project(':firebase-appdistribution-api')
63+
// Only include the full SDK implementation in the debug variant
5564
debugImplementation project(':firebase-appdistribution')
5665

57-
// Release variant just uses the API, as if publishing to Play
58-
releaseImplementation project(':firebase-appdistribution-api')
59-
6066
implementation "com.google.android.gms:play-services-tasks:18.0.1"
6167

6268
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"

0 commit comments

Comments
 (0)