Skip to content

Update apksize InAppMessaging test app to use OSS code. #793

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
Sep 13, 2019
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 @@ -29,10 +29,8 @@ android {
}
}
dependencies {
inappmessagingdisplayImplementation ("com.google.firebase:firebase-inappmessaging-display:19.0.0") {
exclude group: "com.google.firebase", module: "firebase-common"
}
inappmessagingdisplayImplementation ("com.google.firebase:firebase-inappmessaging:19.0.0") {
exclude group: "com.google.firebase", module: "firebase-common"
}
inappmessagingdisplayImplementation project(":firebase-inappmessaging-display")
inappmessagingdisplayImplementation project(":firebase-inappmessaging")

inappmessagingdisplayImplementation "com.google.android.gms:play-services-base:17.0.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.TaskCompletionSource;
import com.google.firebase.inappmessaging.FirebaseInAppMessagingDisplayCallbacks;
import com.google.firebase.inappmessaging.model.Action;
import com.google.firebase.inappmessaging.model.CampaignMetadata;
import com.google.firebase.inappmessaging.model.ModalMessage;
import com.google.firebase.inappmessaging.model.Text;
import com.google.firebase.inappmessaging.display.FirebaseInAppMessagingDisplay;
import androidx.annotation.NonNull;
import com.google.firebase.inappmessaging.model.InAppMessage;

public class InAppMessagingDisplay implements SampleCode {
private static final String SAMPLE_TEXT = "My sample text";
private static final String ACTION_URL = "https://www.example.com";
private static final String CAMPAIGN_ID = "my_campaign";
private static final String CAMPAIGN_NAME = "my_campaign_name";
private static final String TITLE = "Title";

public static class DisplayCallback implements FirebaseInAppMessagingDisplayCallbacks {
Expand All @@ -40,25 +46,25 @@ public Task<Void> messageDismissed(InAppMessagingDismissType dismissType) {
}

@Override
public Task<Void> messageClicked() {
public Task<Void> displayErrorEncountered(InAppMessagingErrorReason inAppMessagingErrorReason) {
return new TaskCompletionSource<Void>().getTask();
}

@Override
public Task<Void> displayErrorEncountered(InAppMessagingErrorReason InAppMessagingErrorReason) {
public Task<Void> messageClicked(@NonNull Action action) {
return new TaskCompletionSource<Void>().getTask();
}
}

@Override
public void runSample(Context context) {
CampaignMetadata metadata = new CampaignMetadata(CAMPAIGN_ID, CAMPAIGN_NAME, true);
InAppMessage message =
InAppMessage.builder()
.setBody(InAppMessage.Text.builder().setText(SAMPLE_TEXT).build())
.setAction(InAppMessage.Action.builder().setActionUrl(ACTION_URL).build())
.setCampaignId(CAMPAIGN_ID)
.setTitle(InAppMessage.Text.builder().setText(TITLE).build())
.build();
ModalMessage.builder()
.setBody(Text.builder().setText(SAMPLE_TEXT).build())
.setAction(Action.builder().setActionUrl(ACTION_URL).build())
.setTitle(Text.builder().setText(TITLE).build())
.build(metadata);

// NOTE: Context is *not guaranteed* to be an Activity. This is **fine** in this case because we
// only want to compile the APK to measure it size, and it will not be run.
Expand Down