Skip to content

Commit

Permalink
Remove In-App Feedback functionality from firebase-appdistribution (f…
Browse files Browse the repository at this point in the history
…irebase#3926)

* Remove In-App Feedback functionality from firebase-appdistribution

* Update api.txt
  • Loading branch information
lfkellogg authored Jul 20, 2022
1 parent 5991287 commit 78d2888
Show file tree
Hide file tree
Showing 16 changed files with 3 additions and 929 deletions.
1 change: 0 additions & 1 deletion firebase-appdistribution-api/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ package com.google.firebase.appdistribution {

public interface FirebaseAppDistribution {
method @NonNull public com.google.android.gms.tasks.Task<com.google.firebase.appdistribution.AppDistributionRelease> checkForNewRelease();
method public void collectAndSendFeedback();
method @NonNull public static com.google.firebase.appdistribution.FirebaseAppDistribution getInstance();
method public boolean isTesterSignedIn();
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> signInTester();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,6 @@ public interface FirebaseAppDistribution {
@NonNull
UpdateTask updateApp();

/**
* Takes a screenshot, and starts an activity to collect and submit feedback from the tester.
*
* <p>Performs the following actions:
*
* <ol>
* <li>Takes a screenshot of the current activity
* <li>If tester is not signed in, presents the tester with a Google Sign-in UI
* <li>Looks up the currently installed App Distribution release
* <li>Starts a full screen activity for the tester to compose and submit the feedback
* </ol>
*/
void collectAndSendFeedback();

/** Gets the singleton {@link FirebaseAppDistribution} instance. */
@NonNull
static FirebaseAppDistribution getInstance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,4 @@ public synchronized Task<AppDistributionRelease> checkForNewRelease() {
public UpdateTask updateApp() {
return delegate.updateApp();
}

@Override
public void collectAndSendFeedback() {
delegate.collectAndSendFeedback();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ public UpdateTask updateApp() {
return new NotImplementedUpdateTask();
}

@Override
public void collectAndSendFeedback() {
return;
}

private static <TResult> Task<TResult> getNotImplementedTask() {
return Tasks.forException(
new FirebaseAppDistributionException(
Expand Down
5 changes: 0 additions & 5 deletions firebase-appdistribution/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,6 @@
</intent-filter>
</activity>

<activity
android:name=".FeedbackActivity"
android:exported="false"
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />

<provider
android:name="com.google.firebase.appdistribution.impl.FirebaseAppDistributionFileProvider"
android:authorities="${applicationId}.FirebaseAppDistributionFileProvider"
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,12 @@
import static com.google.firebase.appdistribution.FirebaseAppDistributionException.Status.AUTHENTICATION_FAILURE;
import static com.google.firebase.appdistribution.FirebaseAppDistributionException.Status.HOST_ACTIVITY_INTERRUPTED;
import static com.google.firebase.appdistribution.FirebaseAppDistributionException.Status.UPDATE_NOT_AVAILABLE;
import static com.google.firebase.appdistribution.impl.FeedbackActivity.RELEASE_NAME_EXTRA_KEY;
import static com.google.firebase.appdistribution.impl.FeedbackActivity.SCREENSHOT_FILENAME_EXTRA_KEY;
import static com.google.firebase.appdistribution.impl.TaskUtils.safeSetTaskException;
import static com.google.firebase.appdistribution.impl.TaskUtils.safeSetTaskResult;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.Intent;
import androidx.annotation.GuardedBy;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand All @@ -43,8 +40,6 @@
import com.google.firebase.appdistribution.UpdateProgress;
import com.google.firebase.appdistribution.UpdateStatus;
import com.google.firebase.appdistribution.UpdateTask;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

/**
* This class is the "real" implementation of the Firebase App Distribution API which should only be
Expand All @@ -61,8 +56,6 @@ class FirebaseAppDistributionImpl implements FirebaseAppDistribution {
private final ApkUpdater apkUpdater;
private final AabUpdater aabUpdater;
private final SignInStorage signInStorage;
private final ReleaseIdentifier releaseIdentifier;
private final ScreenshotTaker screenshotTaker;

private final Object updateIfNewReleaseTaskLock = new Object();

Expand Down Expand Up @@ -93,18 +86,14 @@ class FirebaseAppDistributionImpl implements FirebaseAppDistribution {
@NonNull ApkUpdater apkUpdater,
@NonNull AabUpdater aabUpdater,
@NonNull SignInStorage signInStorage,
@NonNull FirebaseAppDistributionLifecycleNotifier lifecycleNotifier,
@NonNull ReleaseIdentifier releaseIdentifier,
@NonNull ScreenshotTaker screenshotTaker) {
@NonNull FirebaseAppDistributionLifecycleNotifier lifecycleNotifier) {
this.firebaseApp = firebaseApp;
this.testerSignInManager = testerSignInManager;
this.newReleaseFetcher = newReleaseFetcher;
this.apkUpdater = apkUpdater;
this.aabUpdater = aabUpdater;
this.signInStorage = signInStorage;
this.releaseIdentifier = releaseIdentifier;
this.lifecycleNotifier = lifecycleNotifier;
this.screenshotTaker = screenshotTaker;
lifecycleNotifier.addOnActivityDestroyedListener(this::onActivityDestroyed);
lifecycleNotifier.addOnActivityPausedListener(this::onActivityPaused);
lifecycleNotifier.addOnActivityResumedListener(this::onActivityResumed);
Expand Down Expand Up @@ -305,43 +294,6 @@ private UpdateTask updateApp(boolean showDownloadInNotificationManager) {
}
}

@Override
public void collectAndSendFeedback() {
collectAndSendFeedback(Executors.newSingleThreadExecutor());
}

@VisibleForTesting
public void collectAndSendFeedback(Executor taskExecutor) {
screenshotTaker
.takeScreenshot()
.onSuccessTask(
taskExecutor,
screenshotFilename ->
testerSignInManager
.signInTester()
.addOnFailureListener(
taskExecutor,
e ->
LogWrapper.getInstance()
.e("Failed to sign in tester. Could not collect feedback.", e))
.onSuccessTask(taskExecutor, unused -> releaseIdentifier.identifyRelease())
.onSuccessTask(
taskExecutor,
releaseName -> launchFeedbackActivity(releaseName, screenshotFilename)))
.addOnFailureListener(
taskExecutor, e -> LogWrapper.getInstance().e("Failed to launch feedback flow", e));
}

private Task<Void> launchFeedbackActivity(String releaseName, String screenshotFilename) {
return lifecycleNotifier.consumeForegroundActivity(
activity -> {
Intent intent = new Intent(activity, FeedbackActivity.class);
intent.putExtra(RELEASE_NAME_EXTRA_KEY, releaseName);
intent.putExtra(SCREENSHOT_FILENAME_EXTRA_KEY, screenshotFilename);
activity.startActivity(intent);
});
}

@VisibleForTesting
void onActivityResumed(Activity activity) {
if (awaitingSignInDialogConfirmation()) {
Expand Down Expand Up @@ -386,13 +338,6 @@ void onActivityDestroyed(@NonNull Activity activity) {
if (activity == dialogHostActivity) {
dialogHostActivity = null;
}

// If the feedback activity finishes, clean up the screenshot that was taken before starting
// the activity. If this does not happen for some reason it will be cleaned up the next time
// before taking a new screenshot.
if (activity instanceof FeedbackActivity) {
screenshotTaker.deleteScreenshot();
}
}

@VisibleForTesting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,9 @@ public class FirebaseAppDistributionRegistrar implements ComponentRegistrar {
// activity lifecycle callbacks before the API is called
.alwaysEager()
.build(),
Component.builder(FeedbackSender.class)
.add(Dependency.required(FirebaseApp.class))
.add(Dependency.requiredProvider(FirebaseInstallationsApi.class))
.factory(this::buildFeedbackSender)
.build(),
LibraryVersionComponent.create("fire-appdistribution", BuildConfig.VERSION_NAME));
}

private FeedbackSender buildFeedbackSender(ComponentContainer container) {
FirebaseApp firebaseApp = container.get(FirebaseApp.class);
Provider<FirebaseInstallationsApi> firebaseInstallationsApiProvider =
container.getProvider(FirebaseInstallationsApi.class);
FirebaseAppDistributionTesterApiClient testerApiClient =
new FirebaseAppDistributionTesterApiClient(
firebaseApp, firebaseInstallationsApiProvider, new TesterApiHttpClient(firebaseApp));
return new FeedbackSender(testerApiClient);
}

private FirebaseAppDistribution buildFirebaseAppDistribution(ComponentContainer container) {
FirebaseApp firebaseApp = container.get(FirebaseApp.class);
Context context = firebaseApp.getApplicationContext();
Expand All @@ -90,9 +75,7 @@ private FirebaseAppDistribution buildFirebaseAppDistribution(ComponentContainer
new ApkUpdater(firebaseApp, new ApkInstaller()),
new AabUpdater(),
signInStorage,
lifecycleNotifier,
releaseIdentifier,
new ScreenshotTaker(firebaseApp, lifecycleNotifier));
lifecycleNotifier);

if (context instanceof Application) {
Application firebaseApplication = (Application) context;
Expand Down
Loading

0 comments on commit 78d2888

Please sign in to comment.