Skip to content

Commit

Permalink
Integration Validator 2.0 (#1223)
Browse files Browse the repository at this point in the history
* Added a popup dialog displaying the Integration Validator results with 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

* Got deep link validator dialog showing

Got deep link validator dialog showing

* Added spinner with the different choices of deep link keys used for routing

Added spinner with the different choices of deep link keys used for routing

* Next button loads the correct content for step 2 based on the user's choice

Next button loads the correct content for step 2 based on the user's choice

* Removed unneeded permissions

Removed unneeded permissions

* Used IBranchLoggingCallbacks to retrieve the Branch logs

Used IBranchLoggingCallbacks to retrieve the Branch logs

* Added code to generate the various types of Branch links for testing

Added code to generate the various types of Branch links for testing

* Laid out the UI for step 3 of the modal (link & use case testing)

Laid out the UI for step 3 of the modal (link & use case testing)

* Added constants and built out a deep link validator row class to encapsulate each row

Added constants and built out a deep link validator row class to encapsulate each row

* Got the info buttons showing the relevant tooltips

Got the info buttons showing the relevant tooltips

* Added share button functionality

Added share button functionality

* Added debug button functionality to show popup with how to fix deep link issue

Added debug button functionality to show popup with how to fix deep link issue

* Logic refactors so that each row uses uniform, modular code vs. hardcoded specifics

Logic refactors so that each row uses uniform, modular code vs. hardcoded specifics

* Added foreground click use case

Added foreground click use case

* Added warm start test case logic + some bugfixes

Added warm start test case logic + some bugfixes

* Params bugfixes

Params bugfixes

* Merged the Deep Linking Validator and the Integration Validator.

Merged the Deep Linking Validator and the Integration Validator.

* Refactors based on Gabe's PR feedback (1 of 2)

Refactors based on Gabe's PR feedback (1 of 2)

* Refactors based on Gabe's PR feedback (2/2)

Refactors based on Gabe's PR feedback (2/2)
  • Loading branch information
rob-gioia-branch authored Dec 10, 2024
1 parent 10f9960 commit 0ab54c5
Show file tree
Hide file tree
Showing 24 changed files with 1,630 additions and 196 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import io.branch.referral.util.LinkProperties;
import io.branch.referral.util.ProductCategory;
import io.branch.referral.util.ShareSheetStyle;
import io.branch.referral.validators.IntegrationValidator;

public class MainActivity extends Activity {
private EditText txtShortUrl;
Expand Down Expand Up @@ -713,7 +714,7 @@ protected void onStart() {
// Please look for "BranchSDK_Doctor" in the logcat to see the results.
// IMP : Do not make this call in your production app

//IntegrationValidator.validate(MainActivity.this);
IntegrationValidator.validate(MainActivity.this);
}


Expand Down
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package io.branch.referral.validators;

import static io.branch.referral.validators.IntegrationValidatorConstants.alternateDomainsMoreInfoDocsLink;

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 = alternateDomainsMoreInfoDocsLink;
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,50 @@
package io.branch.referral.validators;

import static io.branch.referral.validators.IntegrationValidatorConstants.appLinksMoreInfoDocsLink;

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 = appLinksMoreInfoDocsLink;
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,36 @@
package io.branch.referral.validators;

import static io.branch.referral.validators.IntegrationValidatorConstants.branchInstanceCreationMoreInfoDocsLink;

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 = branchInstanceCreationMoreInfoDocsLink;

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,32 @@
package io.branch.referral.validators;

import static io.branch.referral.validators.IntegrationValidatorConstants.branchKeysMoreInfoDocsLink;

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 = branchKeysMoreInfoDocsLink;

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,50 @@
package io.branch.referral.validators;

import static io.branch.referral.validators.IntegrationValidatorConstants.customDomainMoreInfoDocsLink;

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 = customDomainMoreInfoDocsLink;
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,50 @@
package io.branch.referral.validators;

import static io.branch.referral.validators.IntegrationValidatorConstants.defaultDomainsMoreInfoDocsLink;

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 = defaultDomainsMoreInfoDocsLink;
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 0ab54c5

Please sign in to comment.