Skip to content

Some improvements to firebase-appdistribution/test-app #4330

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

Merged
merged 1 commit into from
Nov 15, 2022
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class MainActivity : AppCompatActivity() {
feedbackTriggerMenu = findViewById(R.id.feedbackTriggerMenu)
val items = listOf(
FeedbackTrigger.NONE.label,
FeedbackTrigger.SDK_NOTIFICATION.label,
FeedbackTrigger.CUSTOM_NOTIFICATION.label,
FeedbackTrigger.SHAKE.label,
FeedbackTrigger.SCREENSHOT.label,
Expand All @@ -85,12 +84,6 @@ class MainActivity : AppCompatActivity() {
FeedbackTrigger.NONE.label -> {
disableAllFeedbackTriggers()
}
FeedbackTrigger.SDK_NOTIFICATION.label -> {
disableAllFeedbackTriggers()
Log.i(TAG, "Enabling notification trigger (SDK)")
firebaseAppDistribution.showFeedbackNotification(
R.string.feedbackInfoText, InterruptionLevel.HIGH)
}
FeedbackTrigger.CUSTOM_NOTIFICATION.label -> {
disableAllFeedbackTriggers()
startActivity(Intent(this, CustomNotificationActivity::class.java))
Expand All @@ -106,6 +99,9 @@ class MainActivity : AppCompatActivity() {
}
}
}

firebaseAppDistribution.showFeedbackNotification(
R.string.feedbackInfoText, InterruptionLevel.HIGH)
}

override fun onDestroy() {
Expand All @@ -115,13 +111,15 @@ class MainActivity : AppCompatActivity() {

private fun disableAllFeedbackTriggers() {
Log.i(TAG, "Disabling all feedback triggers")
firebaseAppDistribution.cancelFeedbackNotification()
ShakeDetectionFeedbackTrigger.disable(application)
}

override fun onCreateOptionsMenu(menu: Menu): Boolean {
val inflater: MenuInflater = menuInflater
inflater.inflate(R.menu.action_menu, menu)
if (BuildConfig.FLAVOR == "beta") {
menu.findItem(R.id.startFeedbackMenuItem).isVisible = true
}
return true
}

Expand Down Expand Up @@ -261,10 +259,10 @@ class MainActivity : AppCompatActivity() {

private fun failureListener(exception: Exception) {
val ex = exception as com.google.firebase.appdistribution.FirebaseAppDistributionException
Log.d("FirebaseAppDistribution", "MAINACTIVITY:ERROR ERROR. CODE: " + exception.errorCode)
Log.d("MainActivity", "Task failed with an error (${ex.errorCode}): ${ex.message}")
AlertDialog.Builder(this)
.setTitle("Error updating to new release")
.setMessage("${ex.message}: ${ex.errorCode}")
.setTitle("Task failed")
.setMessage("${ex.message}\n\nCode: ${ex.errorCode}")
.setNeutralButton("Okay") { dialog, _ -> dialog.dismiss() }
.show()
}
Expand Down Expand Up @@ -320,7 +318,6 @@ class MainActivity : AppCompatActivity() {
NONE("None"),
SHAKE("Shake the device"),
SCREENSHOT("Take a screenshot"),
SDK_NOTIFICATION("Tap a notification (SDK)"),
CUSTOM_NOTIFICATION("Tap a notification (custom)")
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/startFeedbackMenuItem"
android:title="@string/startFeedbackLabel"/>
android:title="@string/startFeedbackLabel"
android:visible="false"/>
</menu>
24 changes: 18 additions & 6 deletions firebase-appdistribution/test-app/test-app.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ android {
applicationId "com.googletest.firebase.appdistribution.testapp"
minSdkVersion 23
targetSdkVersion 33
versionName "2.1"
versionCode 3
versionName "3.1"
versionCode 6

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -37,10 +37,22 @@ android {
// needing to have the app signed.
initWith debug
}
}

flavorDimensions.add("environment")

productFlavors {
prod {
dimension "environment"
versionNameSuffix "-prod"
}

beta {
dimension "environment"
versionNameSuffix "-beta"

debug {
firebaseAppDistribution {
releaseNotes "Debug variant of Android SDK test app"
releaseNotes "Beta variant of Android SDK test app"
// testers "your email here"
}
}
Expand All @@ -67,8 +79,8 @@ dependencies {
implementation project(':firebase-common:ktx')
implementation "com.google.android.gms:play-services-tasks:18.0.2"

// Debug uses the full implementation
debugImplementation project(':firebase-appdistribution')
// Beta flavor uses the full implementation
betaImplementation project(':firebase-appdistribution')

// Other dependencies
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion"
Expand Down