Skip to content

Commit

Permalink
Added a popup dialog displaying the Integration Validator results wit…
Browse files Browse the repository at this point in the history
…h options to view more details and export the logs

Added a popup dialog displaying the Integration Validator results with options to view more details and export the logs
  • Loading branch information
rob-gioia-branch committed Sep 27, 2024
1 parent f7f7a20 commit fe16b68
Show file tree
Hide file tree
Showing 18 changed files with 896 additions and 195 deletions.
1 change: 1 addition & 0 deletions Branch-SDK/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation("androidx.annotation:annotation:1.4.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")

// --- optional dependencies -----
// Please note that the Branch SDK does not require any of the below optional dependencies to operate.
Expand Down
5 changes: 5 additions & 0 deletions Branch-SDK/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.READ_LOGS"
tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package io.branch.referral.validators;

import android.content.Context;
import android.text.TextUtils;

import org.json.JSONObject;

public class AlternateDomainsCheck extends IntegrationValidatorCheck {
String name = "Alt Domains";
String errorMessage = "Could not find intent filter to support alternate link domain. Please add intent filter for handling alternate link domain in your Android Manifest file";
String moreInfoLink = "<a href=\"https://help.branch.io/developers-hub/docs/android-basic-integration#:~:text=The%20%2Dalternate.app.link%20domain%20associated%20with%20your%20app\">More info</a>";
BranchIntegrationModel integrationModel;
JSONObject branchAppConfig;

public AlternateDomainsCheck(BranchIntegrationModel integrationModel, JSONObject branchAppConfig) {
super.name = name;
super.errorMessage = errorMessage;
super.moreInfoLink = moreInfoLink;
this.integrationModel = integrationModel;
this.branchAppConfig = branchAppConfig;
}

@Override
public boolean RunTests(Context context) {
String alternateAppLinkDomain = branchAppConfig.optString("alternate_short_url_domain");
return TextUtils.isEmpty(alternateAppLinkDomain) || checkIfIntentAddedForLinkDomain(alternateAppLinkDomain);
}

@Override
public String GetOutput(Context context, boolean didTestSucceed) {
didTestSucceed = RunTests(context);
return super.GetOutput(context, didTestSucceed);
}

private boolean checkIfIntentAddedForLinkDomain(String domainName) {
boolean foundIntentFilterMatchingDomainName = false;
if (!TextUtils.isEmpty(domainName)) {
for (String host : integrationModel.applinkScheme) {
if (domainName.equals(host)) {
foundIntentFilterMatchingDomainName = true;
break;
}
}
}
return foundIntentFilterMatchingDomainName;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.branch.referral.validators;

import android.content.Context;
import android.text.TextUtils;

import org.json.JSONObject;

public class AppLinksCheck extends IntegrationValidatorCheck {

String name = "App Links";
String errorMessage = "Could not find any App Link hosts to support Android AppLinks. Please add intent filter for handling AppLinks in your Android Manifest file";
String moreInfoLink = "<a href=\"https://help.branch.io/developers-hub/docs/android-basic-integration#:~:text=%3C!%2D%2D%20Branch%20App%20Links%20%2D%20Live,%3C/intent%2Dfilter%3E\">More info</a>";
BranchIntegrationModel integrationModel;
JSONObject branchAppConfig;

public AppLinksCheck(BranchIntegrationModel integrationModel, JSONObject branchAppConfig) {
super.name = name;
super.errorMessage = errorMessage;
super.moreInfoLink = moreInfoLink;
this.integrationModel = integrationModel;
this.branchAppConfig = branchAppConfig;
}

@Override
public boolean RunTests(Context context) {
String defAppLinkDomain = branchAppConfig.optString("default_short_url_domain");
return !integrationModel.applinkScheme.isEmpty() && !TextUtils.isEmpty(defAppLinkDomain) && checkIfIntentAddedForLinkDomain(defAppLinkDomain);
}

@Override
public String GetOutput(Context context, boolean didTestSucceed) {
didTestSucceed = RunTests(context);
return super.GetOutput(context, didTestSucceed);
}

private boolean checkIfIntentAddedForLinkDomain(String domainName) {
boolean foundIntentFilterMatchingDomainName = false;
if (!TextUtils.isEmpty(domainName) && integrationModel.applinkScheme != null) {
for (String host : integrationModel.applinkScheme) {
if (domainName.equals(host)) {
foundIntentFilterMatchingDomainName = true;
break;
}
}
}
return foundIntentFilterMatchingDomainName;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.branch.referral.validators;

import android.content.Context;

import io.branch.referral.Branch;

public class BranchInstanceCreationValidatorCheck extends IntegrationValidatorCheck {

String name = "Branch instance";
String errorMessage = "Branch is not initialised from your Application class. Please add `Branch.getAutoInstance(this);` to your Application#onCreate() method.";
String moreInfoLink = "<a href=\"https://help.branch.io/developers-hub/docs/android-basic-integration#:~:text=Branch.getAutoInstance(this)\">More info</a>";

public BranchInstanceCreationValidatorCheck() {
super.name = name;
super.errorMessage = errorMessage;
super.moreInfoLink = moreInfoLink;
}

@Override
public boolean RunTests(Context context) {
return Branch.getInstance() != null;
}

@Override
public String GetOutput(Context context, boolean didTestSucceed) {
didTestSucceed = RunTests(context);
return super.GetOutput(context, didTestSucceed);
}

@Override
public String GetMoreInfoLink() {
return moreInfoLink;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.branch.referral.validators;

import android.content.Context;
import android.text.TextUtils;

import io.branch.referral.BranchUtil;

public class BranchKeysValidatorCheck extends IntegrationValidatorCheck {

String name = "Branch Keys";
String errorMessage = "Unable to read Branch keys from your application. Did you forget to add Branch keys in your application?.";
String moreInfoLink = "<a href=\"https://help.branch.io/developers-hub/docs/android-basic-integration#:~:text=%3C!%2D%2D%20REPLACE%20%60BranchKey%60%20with,%22key_test_XXX%22%20/%3E\">More info</a>";

public BranchKeysValidatorCheck() {
super.name = name;
super.errorMessage = errorMessage;
super.moreInfoLink = moreInfoLink;
}

@Override
public boolean RunTests(Context context) {
return !TextUtils.isEmpty(BranchUtil.readBranchKey(context));
}

@Override
public String GetOutput(Context context, boolean didTestSucceed) {
didTestSucceed = RunTests(context);
return super.GetOutput(context, didTestSucceed);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.branch.referral.validators;

import android.content.Context;
import android.text.TextUtils;

import org.json.JSONObject;

public class CustomDomainCheck extends IntegrationValidatorCheck {

String name = "Custom Domain";
String errorMessage = "Could not find intent filter to support Branch default link domain. Please add intent filter for handling custom link domain in your Android Manifest file";
String moreInfoLink = "<a href=\"https://help.branch.io/developers-hub/docs/android-basic-integration#section-configure-app\">More info</a>";
BranchIntegrationModel integrationModel;
JSONObject branchAppConfig;

public CustomDomainCheck(BranchIntegrationModel integrationModel, JSONObject branchAppConfig) {
super.name = name;
super.errorMessage = errorMessage;
super.moreInfoLink = moreInfoLink;
this.integrationModel = integrationModel;
this.branchAppConfig = branchAppConfig;
}

@Override
public boolean RunTests(Context context) {
String customDomain = branchAppConfig.optString("short_url_domain");
return TextUtils.isEmpty(customDomain) || checkIfIntentAddedForLinkDomain(customDomain);
}

@Override
public String GetOutput(Context context, boolean didTestSucceed) {
didTestSucceed = RunTests(context);
return super.GetOutput(context, didTestSucceed);
}

private boolean checkIfIntentAddedForLinkDomain(String domainName) {
boolean foundIntentFilterMatchingDomainName = false;
if (!TextUtils.isEmpty(domainName)) {
for (String host : integrationModel.applinkScheme) {
if (domainName.equals(host)) {
foundIntentFilterMatchingDomainName = true;
break;
}
}
}
return foundIntentFilterMatchingDomainName;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package io.branch.referral.validators;

import android.content.Context;
import android.text.TextUtils;

import org.json.JSONObject;

public class DefaultDomainsCheck extends IntegrationValidatorCheck {

String name = "Default Domains";
String errorMessage = "Could not find any App Link hosts to support Android AppLinks. Please add intent filter for handling AppLinks in your Android Manifest file";
String moreInfoLink = "<a href=\"https://help.branch.io/developers-hub/docs/android-basic-integration#4-configure-app:~:text=%3C!%2D%2D%20Branch%20App%20Links%20%2D%20Live,%3C/intent%2Dfilter%3E\">More info</a>";
BranchIntegrationModel integrationModel;
JSONObject branchAppConfig;

public DefaultDomainsCheck(BranchIntegrationModel integrationModel, JSONObject branchAppConfig) {
super.name = name;
super.errorMessage = errorMessage;
super.moreInfoLink = moreInfoLink;
this.integrationModel = integrationModel;
this.branchAppConfig = branchAppConfig;
}

@Override
public boolean RunTests(Context context) {
String defAppLinkDomain = branchAppConfig.optString("default_short_url_domain");
return TextUtils.isEmpty(defAppLinkDomain) || checkIfIntentAddedForLinkDomain(defAppLinkDomain);
}

@Override
public String GetOutput(Context context, boolean didTestSucceed) {
didTestSucceed = RunTests(context);
return super.GetOutput(context, didTestSucceed);
}

private boolean checkIfIntentAddedForLinkDomain(String domainName) {
boolean foundIntentFilterMatchingDomainName = false;
if (!TextUtils.isEmpty(domainName)) {
for (String host : integrationModel.applinkScheme) {
if (domainName.equals(host)) {
foundIntentFilterMatchingDomainName = true;
break;
}
}
}
return foundIntentFilterMatchingDomainName;
}
}
Loading

0 comments on commit fe16b68

Please sign in to comment.