Skip to content

Commit 09685a4

Browse files
committed
Merge remote-tracking branch 'origin/dconeybe/CountFromDFE' into dconeybe/CountFromDFE
2 parents e95066c + df05424 commit 09685a4

File tree

60 files changed

+1390
-383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+1390
-383
lines changed

buildSrc/src/main/java/com/google/firebase/gradle/plugins/license/ThirdPartyLicensesExtension.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package com.google.firebase.gradle.plugins.license;
1616

17+
import java.io.File;
1718
import java.io.Serializable;
1819
import java.net.URI;
1920
import java.util.ArrayList;
@@ -27,18 +28,25 @@ public class ThirdPartyLicensesExtension {
2728
* supported
2829
*/
2930
public void add(String name, String... licenseUris) {
30-
customLicenses.add(new CustomLicense(name, licenseUris));
31+
customLicenses.add(CustomLicense.buildFromStrings(name, licenseUris));
3132
}
3233

3334
static class CustomLicense implements Serializable {
3435
final String name;
35-
final List<URI> licenseUris = new ArrayList<>();
36+
final List<URI> licenseUris;
3637

37-
CustomLicense(String name, String[] licenseUris) {
38+
CustomLicense(String name, List<URI> licenseUris) {
3839
this.name = name;
40+
this.licenseUris = licenseUris;
41+
}
42+
43+
static CustomLicense buildFromStrings(String name, String[] licenseUris) {
44+
List<URI> uris = new ArrayList<>();
3945
for (String s : licenseUris) {
40-
this.licenseUris.add(URI.create(s));
46+
File file = new File(s);
47+
uris.add(file.toURI());
4148
}
49+
return new CustomLicense(name, uris);
4250
}
4351
}
4452

buildSrc/src/main/java/com/google/firebase/gradle/plugins/publish/PublishingPlugin.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import com.google.common.collect.ImmutableMap;
1818
import com.google.firebase.gradle.plugins.FirebaseLibraryExtension;
1919
import digital.wup.android_maven_publish.AndroidMavenPublishPlugin;
20-
import java.net.URI;
20+
import java.io.File;
2121
import java.util.Arrays;
2222
import java.util.Set;
2323
import java.util.stream.Collectors;
@@ -118,11 +118,9 @@ public void apply(Project project) {
118118
repos ->
119119
repos.maven(
120120
repo -> {
121-
repo.setUrl(
122-
URI.create(
123-
"file://"
124-
+ sub.getRootProject().getBuildDir()
125-
+ "/m2repository"));
121+
String s = sub.getRootProject().getBuildDir() + "/m2repository";
122+
File file = new File(s);
123+
repo.setUrl(file.toURI());
126124
repo.setName("BuildDir");
127125
}));
128126
publishing.publications(

buildSrc/src/test/kotlin/com/google/firebase/gradle/plugins/LicenseResolverPluginTests.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ class LicenseResolverPluginTests {
7979
android.compileSdkVersion = 26
8080
8181
thirdPartyLicenses {
82-
add 'customLib', "file:///${File("non_existent_path.txt").absolutePath}"
82+
add 'customLib', "${File("non_existent_path.txt").absolutePath}"
8383
}
8484
""")
8585

@@ -141,7 +141,7 @@ class LicenseResolverPluginTests {
141141
}
142142
143143
thirdPartyLicenses {
144-
add 'customLib1', "file:///${File("src/test/fixtures/license.txt").absolutePath}"
144+
add 'customLib1', "${File("src/test/fixtures/license.txt").absolutePath}"
145145
}
146146
"""
147147
}

firebase-appdistribution-api/api.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ package com.google.firebase.appdistribution {
1515

1616
public interface FirebaseAppDistribution {
1717
method @NonNull public com.google.android.gms.tasks.Task<com.google.firebase.appdistribution.AppDistributionRelease> checkForNewRelease();
18+
method public void collectAndSendFeedback();
1819
method @NonNull public static com.google.firebase.appdistribution.FirebaseAppDistribution getInstance();
1920
method public boolean isTesterSignedIn();
2021
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> signInTester();

firebase-appdistribution-api/src/main/java/com/google/firebase/appdistribution/FirebaseAppDistribution.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,20 @@ public interface FirebaseAppDistribution {
109109
@NonNull
110110
UpdateTask updateApp();
111111

112+
/**
113+
* Takes a screenshot, and starts an activity to collect and submit feedback from the tester.
114+
*
115+
* <p>Performs the following actions:
116+
*
117+
* <ol>
118+
* <li>Takes a screenshot of the current activity
119+
* <li>If tester is not signed in, presents the tester with a Google Sign-in UI
120+
* <li>Looks up the currently installed App Distribution release
121+
* <li>Starts a full screen activity for the tester to compose and submit the feedback
122+
* </ol>
123+
*/
124+
void collectAndSendFeedback();
125+
112126
/** Gets the singleton {@link FirebaseAppDistribution} instance. */
113127
@NonNull
114128
static FirebaseAppDistribution getInstance() {

firebase-appdistribution-api/src/main/java/com/google/firebase/appdistribution/UpdateProgress.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ public interface UpdateProgress {
2424
* @returns the number of bytes downloaded, or -1 if called when updating to an AAB or if no new
2525
* release is available.
2626
*/
27-
@NonNull
2827
long getApkBytesDownloaded();
2928

3029
/**
@@ -33,7 +32,6 @@ public interface UpdateProgress {
3332
* @returns the file size in bytes, or -1 if called when updating to an AAB or if no new release
3433
* is available.
3534
*/
36-
@NonNull
3735
long getApkFileTotalBytes();
3836

3937
/** Returns the current {@link UpdateStatus} of the update. */

firebase-appdistribution-api/src/main/java/com/google/firebase/appdistribution/internal/FirebaseAppDistributionProxy.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,9 @@ public synchronized Task<AppDistributionRelease> checkForNewRelease() {
7171
public UpdateTask updateApp() {
7272
return delegate.updateApp();
7373
}
74+
75+
@Override
76+
public void collectAndSendFeedback() {
77+
delegate.collectAndSendFeedback();
78+
}
7479
}

firebase-appdistribution-api/src/main/java/com/google/firebase/appdistribution/internal/FirebaseAppDistributionStub.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ public UpdateTask updateApp() {
7373
return new NotImplementedUpdateTask();
7474
}
7575

76+
@Override
77+
public void collectAndSendFeedback() {
78+
return;
79+
}
80+
7681
private static <TResult> Task<TResult> getNotImplementedTask() {
7782
return Tasks.forException(
7883
new FirebaseAppDistributionException(

firebase-appdistribution/firebase-appdistribution.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,5 @@ dependencies {
6363
annotationProcessor 'com.google.auto.value:auto-value:1.6.5'
6464
implementation 'androidx.appcompat:appcompat:1.3.0'
6565
implementation "androidx.browser:browser:1.3.0"
66+
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
6667
}

firebase-appdistribution/src/main/AndroidManifest.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
android:name="com.google.firebase.components:com.google.firebase.appdistribution.impl.FirebaseAppDistributionRegistrar"
3030
android:value="com.google.firebase.components.ComponentRegistrar" />
3131
</service>
32+
3233
<!-- The launch mode for Install Activity is singleTask to ensure that after the unknown sources UI
3334
or the installation flow is complete, the Install Activity does not get recreated which causes loss of state
3435
See here for more info - https://developer.android.com/guide/components/activities/tasks-and-back-stack#ManifestForTasks -->
@@ -45,6 +46,11 @@
4546
</intent-filter>
4647
</activity>
4748

49+
<activity
50+
android:name=".FeedbackActivity"
51+
android:exported="false"
52+
android:theme="@style/Theme.AppCompat.Light.NoActionBar" />
53+
4854
<provider
4955
android:name="com.google.firebase.appdistribution.impl.FirebaseAppDistributionFileProvider"
5056
android:authorities="${applicationId}.FirebaseAppDistributionFileProvider"

firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/impl/ErrorMessages.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ErrorMessages {
2626
"Failed to authenticate the tester. The tester was either not signed in, or something went wrong. Try signing in again.";
2727

2828
static final String AUTHORIZATION_ERROR =
29-
"Failed to authorize the tester. The tester is not authorized to test this app. Verify that the tester has accepted an invitation to test this app.";
29+
"Failed to authorize the tester. The tester does not have access to this resource (or it may not exist).";
3030

3131
static final String AUTHENTICATION_CANCELED = "Tester canceled the authentication flow.";
3232

@@ -46,7 +46,7 @@ class ErrorMessages {
4646
"Download URL not found. This was a most likely due to a transient condition and may be corrected by retrying.";
4747

4848
static final String HOST_ACTIVITY_INTERRUPTED =
49-
"Host activity interrupted while dialog was showing. Try calling updateIfNewReleaseAvailable() again.";
49+
"Host activity interrupted while dialog was showing. Try calling the API again.";
5050

5151
static final String APK_INSTALLATION_FAILED =
5252
"The APK failed to install or installation was canceled by the tester.";
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.firebase.appdistribution.impl;
16+
17+
import android.graphics.Bitmap;
18+
import android.os.Bundle;
19+
import android.view.View;
20+
import android.widget.EditText;
21+
import android.widget.Toast;
22+
import androidx.appcompat.app.AppCompatActivity;
23+
24+
/** Activity for tester to compose and submit feedback. */
25+
public class FeedbackActivity extends AppCompatActivity {
26+
27+
private static final String TAG = "FeedbackActivity";
28+
29+
public static final String RELEASE_NAME_EXTRA_KEY =
30+
"com.google.firebase.appdistribution.FeedbackActivity.RELEASE_NAME";
31+
public static final String SCREENSHOT_EXTRA_KEY =
32+
"com.google.firebase.appdistribution.FeedbackActivity.SCREENSHOT";
33+
34+
private FeedbackSender feedbackSender;
35+
private String releaseName;
36+
private Bitmap screenshot;
37+
38+
@Override
39+
protected void onCreate(Bundle savedInstanceState) {
40+
super.onCreate(savedInstanceState);
41+
releaseName = getIntent().getStringExtra(RELEASE_NAME_EXTRA_KEY);
42+
screenshot = getIntent().getParcelableExtra(SCREENSHOT_EXTRA_KEY);
43+
feedbackSender = FeedbackSender.getInstance();
44+
setContentView(R.layout.activity_feedback);
45+
}
46+
47+
public void submitFeedback(View view) {
48+
setSubmittingStateEnabled(true);
49+
EditText feedbackText = (EditText) findViewById(R.id.feedbackText);
50+
feedbackSender
51+
.sendFeedback(releaseName, feedbackText.getText().toString(), screenshot)
52+
.addOnSuccessListener(
53+
unused -> {
54+
LogWrapper.getInstance().i(TAG, "Feedback submitted");
55+
Toast.makeText(this, "Feedback submitted", Toast.LENGTH_LONG).show();
56+
finish();
57+
})
58+
.addOnFailureListener(
59+
e -> {
60+
LogWrapper.getInstance().e(TAG, "Failed to submit feedback", e);
61+
Toast.makeText(this, "Error submitting feedback", Toast.LENGTH_LONG).show();
62+
setSubmittingStateEnabled(false);
63+
});
64+
}
65+
66+
public void setSubmittingStateEnabled(boolean loading) {
67+
findViewById(R.id.submitButton).setVisibility(loading ? View.INVISIBLE : View.VISIBLE);
68+
findViewById(R.id.loadingLabel).setVisibility(loading ? View.VISIBLE : View.INVISIBLE);
69+
}
70+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright 2022 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package com.google.firebase.appdistribution.impl;
16+
17+
import android.graphics.Bitmap;
18+
import com.google.android.gms.tasks.Task;
19+
import com.google.firebase.FirebaseApp;
20+
21+
/** Sends tester feedback to the Tester API. */
22+
class FeedbackSender {
23+
24+
private final FirebaseAppDistributionTesterApiClient testerApiClient;
25+
26+
FeedbackSender(FirebaseAppDistributionTesterApiClient testerApiClient) {
27+
this.testerApiClient = testerApiClient;
28+
}
29+
30+
/** Get an instance of FeedbackSender. */
31+
static FeedbackSender getInstance() {
32+
return FirebaseApp.getInstance().get(FeedbackSender.class);
33+
}
34+
35+
/** Send feedback text and screenshot to the Tester API for the given release. */
36+
Task<Void> sendFeedback(String releaseName, String feedbackText, Bitmap screenshot) {
37+
return testerApiClient
38+
.createFeedback(releaseName, feedbackText)
39+
.onSuccessTask(feedbackName -> testerApiClient.attachScreenshot(feedbackName, screenshot))
40+
.onSuccessTask(testerApiClient::commitFeedback);
41+
}
42+
}

0 commit comments

Comments
 (0)