Skip to content

rebase fad/in-app-feedback onto fad/next #4106

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

Closed
Closed
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
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ buildscript {
classpath 'gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.9'
classpath 'com.google.gms:google-services:4.3.3'
classpath 'org.jlleitschuh.gradle:ktlint-gradle:9.2.1'
classpath 'com.google.firebase:firebase-appdistribution-gradle:3.0.2'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ abstract class GenerateDocumentationTask @Inject constructor(
"android" to "https://developer.android.com/reference/kotlin/",
"google" to "https://developers.google.com/android/reference/",
"firebase" to "https://firebase.google.com/docs/reference/kotlin/",
"coroutines" to "https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/"
"coroutines" to "https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/",
"kotlin" to "https://kotlinlang.org/api/latest/jvm/stdlib/"
)

return packageLists.get().map {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,26 +90,23 @@ tasks above). While we do not currently offer any configuration for the Dackka
plugin, this could change in the future as needed. Currently, the DackkaPlugin
provides sensible defaults to output directories, package lists, and so forth.

The DackkaPlugin also provides two extra tasks:
[cleanDackkaDocumentation][registerCleanDackkaDocumentation] and
[deleteDackkaGeneratedJavaReferences][registerDeleteDackkaGeneratedJavaReferencesTask].
The DackkaPlugin also provides three extra tasks:
[cleanDackkaDocumentation][registerCleanDackkaDocumentation],
[copyJavaDocToCommonDirectory][registerCopyJavaDocToCommonDirectoryTask] and
[copyKotlinDocToCommonDirectory][registerCopyKotlinDocToCommonDirectoryTask].

_cleanDackkaDocumentation_ is exactly what it sounds like, a task to clean up (delete)
the output of Dackka. This is useful when testing Dackka outputs itself- and
shouldn't be apart of the normal flow. The reasoning is that it would otherwise
invalidate the gradle cache.

_deleteDackkaGeneratedJavaReferences_ is a temporary addition. Dackka generates
two separate styles of docs for every source set: Java & Kotlin. Regardless of
whether the source is in Java or Kotlin. The Java output is how the source looks
from Java, and the Kotlin output is how the source looks from Kotlin. We publish
these under two separate categories, which you can see here:
[Java](https://firebase.google.com/docs/reference/android/packages)
or
[Kotlin](https://firebase.google.com/docs/reference/kotlin/packages).
Although, we do not currently publish Java packages with Dackka- and will wait
until we are more comfortable with the output of Dackka to do so. So until then,
this task will remove all generate Java references from the Dackka output.
_copyJavaDocToCommonDirectory_ copies the JavaDoc variant of the Dackka output for each sdk,
and pastes it in a common directory under the root project's build directory. This makes it easier
to zip the doc files for staging.

_copyKotlinDocToCommonDirectory_ copies the KotlinDoc variant of the Dackka output for each sdk,
and pastes it in a common directory under the root project's build directory. This makes it easier
to zip the doc files for staging.

Currently, the DackkaPlugin builds Java sources separate from Kotlin Sources. There is an open bug
for Dackka in which hidden parent classes and annotations do not hide themselves from children classes.
Expand All @@ -125,16 +122,16 @@ abstract class DackkaPlugin : Plugin<Project> {
val generateDocumentation = registerGenerateDackkaDocumentationTask(project)
val outputDirectory = generateDocumentation.flatMap { it.outputDirectory }
val firesiteTransform = registerFiresiteTransformTask(project, outputDirectory)
val deleteJavaReferences = registerDeleteDackkaGeneratedJavaReferencesTask(project, outputDirectory)
val copyOutputToCommonDirectory = registerCopyDackkaOutputToCommonDirectoryTask(project, outputDirectory)
val copyJavaDocToCommonDirectory = registerCopyJavaDocToCommonDirectoryTask(project, outputDirectory)
val copyKotlinDocToCommonDirectory = registerCopyKotlinDocToCommonDirectoryTask(project, outputDirectory)

project.tasks.register("kotlindoc") {
group = "documentation"
dependsOn(
generateDocumentation,
firesiteTransform,
deleteJavaReferences,
copyOutputToCommonDirectory
copyJavaDocToCommonDirectory,
copyKotlinDocToCommonDirectory
)
}
} else {
Expand Down Expand Up @@ -234,38 +231,44 @@ abstract class DackkaPlugin : Plugin<Project> {
// TODO(b/243833009): Make task cacheable
private fun registerFiresiteTransformTask(project: Project, outputDirectory: Provider<File>) =
project.tasks.register<FiresiteTransformTask>("firesiteTransform") {
mustRunAfter("generateDackkaDocumentation")

dackkaFiles.set(outputDirectory)
}

// If we decide to publish java variants, we'll need to address the generated format as well
// TODO(b/243833009): Make task cacheable
private fun registerDeleteDackkaGeneratedJavaReferencesTask(project: Project, outputDirectory: Provider<File>) =
project.tasks.register<Delete>("deleteDackkaGeneratedJavaReferences") {
mustRunAfter("generateDackkaDocumentation")

val filesWeDoNotNeed = listOf(
"reference/client",
"reference/com"
)
val filesToDelete = outputDirectory.map { dir ->
filesWeDoNotNeed.map {
project.files("${dir.path}/$it")
}
// TODO(b/246593212): Migrate doc files to single directory
private fun registerCopyJavaDocToCommonDirectoryTask(project: Project, outputDirectory: Provider<File>) =
project.tasks.register<Copy>("copyJavaDocToCommonDirectory") {
/**
* This is not currently cache compliant. The need for this property is
* temporary while we test it alongside the current javaDoc task. Since it's such a
* temporary behavior, losing cache compliance is fine for now.
*/
if (project.rootProject.findProperty("dackkaJavadoc") == "true") {
mustRunAfter("firesiteTransform")

val outputFolder = project.file("${project.rootProject.buildDir}/firebase-kotlindoc/android")
val clientFolder = outputDirectory.map { project.file("${it.path}/reference/client") }
val comFolder = outputDirectory.map { project.file("${it.path}/reference/com") }

fromDirectory(clientFolder)
fromDirectory(comFolder)

into(outputFolder)
}

delete(filesToDelete)
}

private fun registerCopyDackkaOutputToCommonDirectoryTask(project: Project, outputDirectory: Provider<File>) =
project.tasks.register<Copy>("copyDackkaOutputToCommonDirectory") {
mustRunAfter("deleteDackkaGeneratedJavaReferences")
// TODO(b/246593212): Migrate doc files to single directory
private fun registerCopyKotlinDocToCommonDirectoryTask(project: Project, outputDirectory: Provider<File>) =
project.tasks.register<Copy>("copyKotlinDocToCommonDirectory") {
mustRunAfter("firesiteTransform")

val referenceFolder = outputDirectory.map { project.file("${it.path}/reference") }
val outputFolder = project.file("${project.rootProject.buildDir}/firebase-kotlindoc")
val kotlinFolder = outputDirectory.map { project.file("${it.path}/reference/kotlin") }

fromDirectory(kotlinFolder)

from(referenceFolder)
destinationDir = outputFolder
into(outputFolder)
}

// Useful for local testing, but may not be desired for standard use (that's why it's not depended on)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.google.firebase.gradle.plugins

import java.io.File
import org.gradle.api.provider.Provider
import org.gradle.api.tasks.Copy

fun Copy.fromDirectory(directory: Provider<File>) =
from(directory) {
into(directory.map { it.name })
}
2 changes: 2 additions & 0 deletions firebase-appdistribution-api/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package com.google.firebase.appdistribution {
method public boolean isTesterSignedIn();
method @NonNull public com.google.android.gms.tasks.Task<java.lang.Void> signInTester();
method public void signOutTester();
method public void startFeedback(int);
method public void startFeedback(@NonNull CharSequence);
method @NonNull public com.google.firebase.appdistribution.UpdateTask updateApp();
method @NonNull public com.google.firebase.appdistribution.UpdateTask updateIfNewReleaseAvailable();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,38 @@ 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>Starts a full screen activity for the tester to compose and submit the feedback
* </ol>
*
* @param infoTextResourceId string resource ID of text to display to the tester before collecting
* feedback data (e.g. Terms and Conditions)
*/
void startFeedback(int infoTextResourceId);

/**
* 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>Starts a full screen activity for the tester to compose and submit the feedback
* </ol>
*
* @param infoText text to display to the tester before collecting feedback data (e.g. Terms and
* Conditions)
*/
void startFeedback(@NonNull CharSequence infoText);

/** 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,4 +71,14 @@ public synchronized Task<AppDistributionRelease> checkForNewRelease() {
public UpdateTask updateApp() {
return delegate.updateApp();
}

@Override
public void startFeedback(int infoTextResourceId) {
delegate.startFeedback(infoTextResourceId);
}

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

@Override
public void startFeedback(int infoTextResourceId) {
return;
}

@Override
public void startFeedback(@NonNull CharSequence infoText) {
return;
}

private static <TResult> Task<TResult> getNotImplementedTask() {
return Tasks.forException(
new FirebaseAppDistributionException(
Expand Down
12 changes: 10 additions & 2 deletions firebase-appdistribution/firebase-appdistribution.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,22 @@ dependencies {
testImplementation "org.robolectric:robolectric:4.8.1"
testImplementation "com.google.truth:truth:$googleTruthVersion"
testImplementation 'org.mockito:mockito-inline:3.4.0'
androidTestImplementation "org.mockito:mockito-android:3.4.0"
testImplementation 'androidx.test:core:1.2.0'

implementation 'com.google.android.gms:play-services-tasks:18.0.1'

compileOnly 'com.google.auto.value:auto-value-annotations:1.6.5'
annotationProcessor 'com.google.auto.value:auto-value:1.6.5'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation "androidx.browser:browser:1.3.0"
implementation "androidx.constraintlayout:constraintlayout:2.1.4"

androidTestImplementation project(':integ-testing')
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation "com.google.truth:truth:$googleTruthVersion"
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation "androidx.annotation:annotation:1.0.0"
androidTestImplementation 'org.mockito:mockito-core:2.25.0'
androidTestImplementation 'org.mockito:mockito-inline:2.25.0'
}
26 changes: 26 additions & 0 deletions firebase-appdistribution/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2022 Google LLC -->
<!-- -->
<!-- Licensed under the Apache License, Version 2.0 (the "License"); -->
<!-- you may not use this file except in compliance with the License. -->
<!-- You may obtain a copy of the License at -->
<!-- -->
<!-- http://www.apache.org/licenses/LICENSE-2.0 -->
<!-- -->
<!-- Unless required by applicable law or agreed to in writing, software -->
<!-- distributed under the License is distributed on an "AS IS" BASIS, -->
<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
<!-- See the License for the specific language governing permissions and -->
<!-- limitations under the License. -->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.firebase.installations">

<application>
<uses-library android:name="android.test.runner"/>
</application>

<instrumentation
android:name="androidx.test.runner.AndroidJUnitRunner"
android:targetPackage="com.google.firebase.appdistribution" />
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.firebase.appdistribution;

import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.appdistribution.internal.FirebaseAppDistributionProxy;
import com.google.firebase.testing.integ.StrictModeRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

@RunWith(AndroidJUnit4.class)
public class StrictModeTest {

@Rule public StrictModeRule strictMode = new StrictModeRule();

@Test
public void initializingFirebaseAppdistribution_shouldNotViolateStrictMode() {
strictMode.runOnMainThread(
() -> {
FirebaseApp app =
FirebaseApp.initializeApp(
ApplicationProvider.getApplicationContext(),
new FirebaseOptions.Builder()
.setApiKey("api")
.setProjectId("123")
.setApplicationId("appId")
.build(),
"hello");
app.get(FirebaseAppDistribution.class);
app.get(FirebaseAppDistributionProxy.class);
});
}
}
5 changes: 5 additions & 0 deletions firebase-appdistribution/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
</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
Loading