Skip to content

Commit

Permalink
Refactors based on Gabe's PR feedback (1 of 2)
Browse files Browse the repository at this point in the history
Refactors based on Gabe's PR feedback (1 of 2)
  • Loading branch information
rob-gioia-branch committed Nov 26, 2024
1 parent b96c9f3 commit ce0517d
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ public void onClick(View view) {
.setContentIntent(pendingIntent)
.setAutoCancel(true);
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(MainActivity.this);
//notificationManager.notify(1, builder.build());
notificationManager.notify(1, builder.build());
Log.d("BranchSDK_Tester", "Sent notification");
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,49 +65,49 @@ private void doValidateWithAppConfig(JSONObject branchAppConfig) {
// 1. Verify Branch Auto instance
BranchInstanceCreationValidatorCheck branchInstanceCreationValidatorCheck = new BranchInstanceCreationValidatorCheck();
boolean result = branchInstanceCreationValidatorCheck.RunTests(context);
integrationValidatorDialog.setTestResult(1, branchInstanceCreationValidatorCheck.GetTestName(), result, branchInstanceCreationValidatorCheck.GetOutput(context, result), branchInstanceCreationValidatorCheck.GetMoreInfoLink());
integrationValidatorDialog.SetTestResultForRowItem(1, branchInstanceCreationValidatorCheck.GetTestName(), result, branchInstanceCreationValidatorCheck.GetOutput(context, result), branchInstanceCreationValidatorCheck.GetMoreInfoLink());
logOutputForTest(result, "1. Verifying Branch instance creation", "Branch is not initialised from your Application class. Please add `Branch.getAutoInstance(this);` to your Application#onCreate() method.", "https://help.branch.io/developers-hub/docs/android-basic-integration#section-load-branch");

// 2. Verify Branch Keys
BranchKeysValidatorCheck branchKeysValidatorCheck = new BranchKeysValidatorCheck();
result = branchKeysValidatorCheck.RunTests(context);
integrationValidatorDialog.setTestResult(2, branchKeysValidatorCheck.GetTestName(), result, branchKeysValidatorCheck.GetOutput(context, result), branchKeysValidatorCheck.GetMoreInfoLink());
integrationValidatorDialog.SetTestResultForRowItem(2, branchKeysValidatorCheck.GetTestName(), result, branchKeysValidatorCheck.GetOutput(context, result), branchKeysValidatorCheck.GetMoreInfoLink());
logOutputForTest(result, "2. Checking Branch keys", "Unable to read Branch keys from your application. Did you forget to add Branch keys in your application?.", "https://help.branch.io/developers-hub/docs/android-basic-integration#section-configure-app");

// 3. Verify the package name of app with Branch dash board settings
PackageNameCheck packageNameCheck = new PackageNameCheck(integrationModel, branchAppConfig);
result = packageNameCheck.RunTests(context);
integrationValidatorDialog.setTestResult(3, packageNameCheck.GetTestName(), result, packageNameCheck.GetOutput(context, result), packageNameCheck.GetMoreInfoLink());
integrationValidatorDialog.SetTestResultForRowItem(3, packageNameCheck.GetTestName(), result, packageNameCheck.GetOutput(context, result), packageNameCheck.GetMoreInfoLink());
logOutputForTest(result, "3. Verifying application package name", packageNameCheck.errorMessage, "https://help.branch.io/developers-hub/docs/android-basic-integration#section-configure-branch-dashboard");

// 4. Verify the URI scheme setup
URISchemeCheck uriSchemeCheck = new URISchemeCheck(integrationModel, branchAppConfig);
result = uriSchemeCheck.RunTests(context);
integrationValidatorDialog.setTestResult(4, uriSchemeCheck.GetTestName(), result, uriSchemeCheck.GetOutput(context, result), uriSchemeCheck.GetMoreInfoLink());
integrationValidatorDialog.SetTestResultForRowItem(4, uriSchemeCheck.GetTestName(), result, uriSchemeCheck.GetOutput(context, result), uriSchemeCheck.GetMoreInfoLink());
logOutputForTest(result, "4. Checking Android Manifest for URI based deep link config", uriSchemeCheck.errorMessage, "https://help.branch.io/developers-hub/docs/android-basic-integration#section-configure-app");

//5. Check AndroidManifest for AppLink config
AppLinksCheck appLinksCheck = new AppLinksCheck(integrationModel, branchAppConfig);
result = appLinksCheck.RunTests(context);
integrationValidatorDialog.setTestResult(5, appLinksCheck.GetTestName(), result, appLinksCheck.GetOutput(context, result), appLinksCheck.GetMoreInfoLink());
integrationValidatorDialog.SetTestResultForRowItem(5, appLinksCheck.GetTestName(), result, appLinksCheck.GetOutput(context, result), appLinksCheck.GetMoreInfoLink());
logOutputForTest(result, "5. Checking AndroidManifest for AppLink config.", "Could not find any App Link hosts to support Android AppLinks. Please add intent filter for handling AppLinks in your Android Manifest file", "https://help.branch.io/using-branch/docs/android-app-links#section-add-intent-filter-to-manifest");

//6. Look for any custom domains specified in the dash board and has matching intent filter
CustomDomainCheck customDomainCheck = new CustomDomainCheck(integrationModel, branchAppConfig);
result = customDomainCheck.RunTests(context);
integrationValidatorDialog.setTestResult(6, customDomainCheck.GetTestName(), result, customDomainCheck.GetOutput(context, result), customDomainCheck.GetMoreInfoLink());
integrationValidatorDialog.SetTestResultForRowItem(6, customDomainCheck.GetTestName(), result, customDomainCheck.GetOutput(context, result), customDomainCheck.GetMoreInfoLink());
logOutputForTest(result, "6. Verifying any supported custom link domains.", String.format("Could not find intent filter to support custom link domain '%s'. Please add intent filter for handling custom link domain in your Android Manifest file ", branchAppConfig.optString("short_url_domain")), "https://help.branch.io/developers-hub/docs/android-basic-integration#section-configure-app");

// 7. Check for matching intent filter for default app link domains
DefaultDomainsCheck defaultDomainsCheck = new DefaultDomainsCheck(integrationModel, branchAppConfig);
result = defaultDomainsCheck.RunTests(context);
integrationValidatorDialog.setTestResult(7, defaultDomainsCheck.GetTestName(), result, defaultDomainsCheck.GetOutput(context, result), defaultDomainsCheck.GetMoreInfoLink());
integrationValidatorDialog.SetTestResultForRowItem(7, defaultDomainsCheck.GetTestName(), result, defaultDomainsCheck.GetOutput(context, result), defaultDomainsCheck.GetMoreInfoLink());
logOutputForTest(result, "7. Verifying default link domains integrations.", String.format("Could not find intent filter to support Branch default link domain '%s'. Please add intent filter for handling custom link domain in your Android Manifest file ", branchAppConfig.optString("default_short_url_domain")), "https://help.branch.io/developers-hub/docs/android-basic-integration#section-configure-app");

// 8. Check for matching intent filter for alternate app link domains
AlternateDomainsCheck alternateDomainsCheck = new AlternateDomainsCheck(integrationModel, branchAppConfig);
result = alternateDomainsCheck.RunTests(context);
integrationValidatorDialog.setTestResult(8, alternateDomainsCheck.GetTestName(), result, alternateDomainsCheck.GetOutput(context, result), alternateDomainsCheck.GetMoreInfoLink());
integrationValidatorDialog.SetTestResultForRowItem(8, alternateDomainsCheck.GetTestName(), result, alternateDomainsCheck.GetOutput(context, result), alternateDomainsCheck.GetMoreInfoLink());
logOutputForTest(result, "8. Verifying alternate link domains integrations.", String.format("Could not find intent filter to support alternate link domain '%s'. Please add intent filter for handling custom link domain in your Android Manifest file ", branchAppConfig.optString("alternate_short_url_domain")), "https://help.branch.io/developers-hub/docs/android-basic-integration#section-configure-app");

finishTestingOutput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

public class IntegrationValidatorDialog extends Dialog {

IntegrationValidatorDialogRowItem test1RowItem;
IntegrationValidatorDialogRowItem test2RowItem;
IntegrationValidatorDialogRowItem test3RowItem;
IntegrationValidatorDialogRowItem test4RowItem;
IntegrationValidatorDialogRowItem test5RowItem;
IntegrationValidatorDialogRowItem test6RowItem;
IntegrationValidatorDialogRowItem test7RowItem;
IntegrationValidatorDialogRowItem test8RowItem;
IntegrationValidatorDialogRowItem autoInstanceValidatorRowItem;
IntegrationValidatorDialogRowItem verifyBranchKeysRowItem;
IntegrationValidatorDialogRowItem verifyPackageNameRowItem;
IntegrationValidatorDialogRowItem verifyURISchemeRowItem;
IntegrationValidatorDialogRowItem verifyAppLinksRowItem;
IntegrationValidatorDialogRowItem verifyCustomDomainRowItem;
IntegrationValidatorDialogRowItem domainIntentFiltersRowItem;
IntegrationValidatorDialogRowItem alternateDomainIntentFiltersRowItem;

Button exportLogsButton;
Button testDeepLinkingButton;
Expand All @@ -31,14 +31,14 @@ public IntegrationValidatorDialog(final Context context) {
TextView sdkVersionTextView = findViewById(R.id.sdk_version);
sdkVersionTextView.setText("SDK Version: " + Branch.getSdkVersionNumber());

test1RowItem = findViewById(R.id.test_1_auto_instance_validator_row);
test2RowItem = findViewById(R.id.test_2_verify_branch_keys);
test3RowItem = findViewById(R.id.test_3_verify_package_name);
test4RowItem = findViewById(R.id.test_4_verify_uri_scheme);
test5RowItem = findViewById(R.id.test_5_verify_app_links);
test6RowItem = findViewById(R.id.test_6_verify_custom_domain);
test7RowItem = findViewById(R.id.test_7_domain_intent_filters);
test8RowItem = findViewById(R.id.test_8_alternate_domain_intent_filters);
autoInstanceValidatorRowItem = findViewById(R.id.test_1_auto_instance_validator_row);
verifyBranchKeysRowItem = findViewById(R.id.test_2_verify_branch_keys);
verifyPackageNameRowItem = findViewById(R.id.test_3_verify_package_name);
verifyURISchemeRowItem = findViewById(R.id.test_4_verify_uri_scheme);
verifyAppLinksRowItem = findViewById(R.id.test_5_verify_app_links);
verifyCustomDomainRowItem = findViewById(R.id.test_6_verify_custom_domain);
domainIntentFiltersRowItem = findViewById(R.id.test_7_domain_intent_filters);
alternateDomainIntentFiltersRowItem = findViewById(R.id.test_8_alternate_domain_intent_filters);

exportLogsButton = findViewById(R.id.export_logs_button);
testDeepLinkingButton = findViewById(R.id.test_deep_linking_button);
Expand All @@ -52,31 +52,31 @@ public IntegrationValidatorDialog(final Context context) {
});
}

public void setTestResult(int testNumber, String name, boolean didTestPass, String detailsMessage, String moreInfoLink) {
public void SetTestResultForRowItem(int testNumber, String name, boolean didTestPass, String detailsMessage, String moreInfoLink) {
switch (testNumber) {
case 1:
setResult(test1RowItem, name, didTestPass, detailsMessage, moreInfoLink);
setResult(autoInstanceValidatorRowItem, name, didTestPass, detailsMessage, moreInfoLink);
break;
case 2:
setResult(test2RowItem, name, didTestPass, detailsMessage, moreInfoLink);
setResult(verifyBranchKeysRowItem, name, didTestPass, detailsMessage, moreInfoLink);
break;
case 3:
setResult(test3RowItem, name, didTestPass, detailsMessage, moreInfoLink);
setResult(verifyPackageNameRowItem, name, didTestPass, detailsMessage, moreInfoLink);
break;
case 4:
setResult(test4RowItem, name, didTestPass, detailsMessage, moreInfoLink);
setResult(verifyURISchemeRowItem, name, didTestPass, detailsMessage, moreInfoLink);
break;
case 5:
setResult(test5RowItem, name, didTestPass, detailsMessage, moreInfoLink);
setResult(verifyAppLinksRowItem, name, didTestPass, detailsMessage, moreInfoLink);
break;
case 6:
setResult(test6RowItem, name, didTestPass, detailsMessage, moreInfoLink);
setResult(verifyCustomDomainRowItem, name, didTestPass, detailsMessage, moreInfoLink);
break;
case 7:
setResult(test7RowItem, name, didTestPass, detailsMessage, moreInfoLink);
setResult(domainIntentFiltersRowItem, name, didTestPass, detailsMessage, moreInfoLink);
break;
case 8:
setResult(test8RowItem, name, didTestPass, detailsMessage, moreInfoLink);
setResult(alternateDomainIntentFiltersRowItem, name, didTestPass, detailsMessage, moreInfoLink);
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ public class LinkingValidatorConstants {
public static final String linkingValidatorRow5Title = "Warm start use case";
public static final String linkingValidatorRow6Title = "Foreground click use case";

public static final String infoButton1Copy = "Verifies that Universal Links / App Links are working correctly for your Branch domain";
public static final String infoButton2Copy = "Verifies that URI schemes work correctly for your Branch domain";
public static final String infoButton3Copy = "Verifies that web-only links are handled correctly to take you to the mobile web";
public static final String infoButton4Copy = "Verifies that your app gracefully handles Branch links missing deep link data";
public static final String infoButton5Copy = "Click the button to simulate a deep link click for the warm start use case";
public static final String infoButton6Copy = "Click the button to simulate a deep link click for the foreground use case";
public static final String infoButton1Text = "Verifies that Universal Links / App Links are working correctly for your Branch domain";
public static final String infoButton2Text = "Verifies that URI schemes work correctly for your Branch domain";
public static final String infoButton3Text = "Verifies that web-only links are handled correctly to take you to the mobile web";
public static final String infoButton4Text = "Verifies that your app gracefully handles Branch links missing deep link data";
public static final String infoButton5Text = "Click the button to simulate a deep link click for the warm start use case";
public static final String infoButton6Text = "Click the button to simulate a deep link click for the foreground use case";

public static final String debugButton1Copy = "Ensure you’ve entered the correct SHA 256s on the dashboard and added your Branch domains to the Android Manifest";
public static final String debugButton2Copy = "Ensure that you’ve added a unique Branch URI scheme to the dashboard and Android Manifest";
public static final String debugButton3Copy = "Ensure that your code checks for $web-only in the link data, and if it is true routes the user to the mobile web";
public static final String debugButton4Copy = "Ensure that your code gracefully handles missing or invalid deep link data like taking them to the home screen";
public static final String debugButton5Copy = "Ensure that you are initializing Branch inside of onStart() and that the code is called anytime the app enters the foreground";
public static final String debugButton6Copy = "Ensure that you are calling reInit() inside of onNewIntent() after checking if branch_force_new_session is true";
public static final String debugButton1Text = "Ensure you’ve entered the correct SHA 256s on the dashboard and added your Branch domains to the Android Manifest";
public static final String debugButton2Text = "Ensure that you’ve added a unique Branch URI scheme to the dashboard and Android Manifest";
public static final String debugButton3Text = "Ensure that your code checks for $web-only in the link data, and if it is true routes the user to the mobile web";
public static final String debugButton4Text = "Ensure that your code gracefully handles missing or invalid deep link data like taking them to the home screen";
public static final String debugButton5Text = "Ensure that you are initializing Branch inside of onStart() and that the code is called anytime the app enters the foreground";
public static final String debugButton6Text = "Ensure that you are calling reInit() inside of onNewIntent() after checking if branch_force_new_session is true";


}
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,12 @@ void GenerateBranchLinks() {
routingValue = customValueEditText.getText().toString();
}

row1.InitializeRow(LinkingValidatorConstants.linkingValidatorRow1Title, LinkingValidatorConstants.infoButton1Copy, LinkingValidatorConstants.debugButton1Copy, routingKey, routingValue, "regularBranchLink", true, 0);
row2.InitializeRow(LinkingValidatorConstants.linkingValidatorRow2Title, LinkingValidatorConstants.infoButton2Copy, LinkingValidatorConstants.debugButton2Copy, routingKey, routingValue, "uriFallbackBranchLink", true, 1, "$uri_redirect_mode", "2");
row3.InitializeRow(LinkingValidatorConstants.linkingValidatorRow3Title, LinkingValidatorConstants.infoButton3Copy, LinkingValidatorConstants.debugButton3Copy, routingKey, routingValue, "webOnlyBranchLink", true, 2, "$web_only", "true");
row4.InitializeRow(LinkingValidatorConstants.linkingValidatorRow4Title, LinkingValidatorConstants.infoButton4Copy, LinkingValidatorConstants.debugButton4Copy, routingKey, "", "missingDataBranchLink", true, 3);
row5.InitializeRow(LinkingValidatorConstants.linkingValidatorRow5Title, LinkingValidatorConstants.infoButton5Copy, LinkingValidatorConstants.debugButton5Copy, routingKey, routingValue, "warmStartUseCase", false, 4);
row6.InitializeRow(LinkingValidatorConstants.linkingValidatorRow6Title, LinkingValidatorConstants.infoButton6Copy, LinkingValidatorConstants.debugButton6Copy, routingKey, routingValue, "foregroundClickUseCase", false, 5);
row1.InitializeRow(LinkingValidatorConstants.linkingValidatorRow1Title, LinkingValidatorConstants.infoButton1Text, LinkingValidatorConstants.debugButton1Text, routingKey, routingValue, "regularBranchLink", true, 0);
row2.InitializeRow(LinkingValidatorConstants.linkingValidatorRow2Title, LinkingValidatorConstants.infoButton2Text, LinkingValidatorConstants.debugButton2Text, routingKey, routingValue, "uriFallbackBranchLink", true, 1, "$uri_redirect_mode", "2");
row3.InitializeRow(LinkingValidatorConstants.linkingValidatorRow3Title, LinkingValidatorConstants.infoButton3Text, LinkingValidatorConstants.debugButton3Text, routingKey, routingValue, "webOnlyBranchLink", true, 2, "$web_only", "true");
row4.InitializeRow(LinkingValidatorConstants.linkingValidatorRow4Title, LinkingValidatorConstants.infoButton4Text, LinkingValidatorConstants.debugButton4Text, routingKey, "", "missingDataBranchLink", true, 3);
row5.InitializeRow(LinkingValidatorConstants.linkingValidatorRow5Title, LinkingValidatorConstants.infoButton5Text, LinkingValidatorConstants.debugButton5Text, routingKey, routingValue, "warmStartUseCase", false, 4);
row6.InitializeRow(LinkingValidatorConstants.linkingValidatorRow6Title, LinkingValidatorConstants.infoButton6Text, LinkingValidatorConstants.debugButton6Text, routingKey, routingValue, "foregroundClickUseCase", false, 5);
}

private void CloseDialog() {
Expand Down

0 comments on commit ce0517d

Please sign in to comment.