Skip to content

Commit 6acc83b

Browse files
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
1 parent 56d9fe4 commit 6acc83b

File tree

5 files changed

+34
-89
lines changed

5 files changed

+34
-89
lines changed

Branch-SDK/src/main/java/io/branch/referral/validators/LinkingValidatorConstants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public class LinkingValidatorConstants {
1414
public static final String linkingValidatorRow2Title = "Link using URI scheme";
1515
public static final String linkingValidatorRow3Title = "Web-only link";
1616
public static final String linkingValidatorRow4Title = "Link with missing data";
17+
public static final String linkingValidatorRow5Title = "Warm start use case";
18+
public static final String linkingValidatorRow6Title = "Foreground click use case";
1719

1820
public static final String infoButton1Copy = "Verifies that Universal Links / App Links are working correctly for your Branch domain";
1921
public static final String infoButton2Copy = "Verifies that URI schemes work correctly for your Branch domain";

Branch-SDK/src/main/java/io/branch/referral/validators/LinkingValidatorDialog.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ private enum ROUTING_TYPE { CANONICAL_URL, DEEPLINK_PATH, CUSTOM }
3737
private LinkingValidatorDialogRowItem row2;
3838
private LinkingValidatorDialogRowItem row3;
3939
private LinkingValidatorDialogRowItem row4;
40+
private LinkingValidatorDialogRowItem row5;
41+
private LinkingValidatorDialogRowItem row6;
4042

4143
public LinkingValidatorDialog(final Context context) {
4244
super(context);
@@ -79,6 +81,8 @@ public LinkingValidatorDialog(final Context context) {
7981
row2 = findViewById(R.id.linkingValidatorRow2);
8082
row3 = findViewById(R.id.linkingValidatorRow3);
8183
row4 = findViewById(R.id.linkingValidatorRow4);
84+
row5 = findViewById(R.id.linkingValidatorRow5);
85+
row6 = findViewById(R.id.linkingValidatorRow6);
8286
}
8387

8488
@Override
@@ -142,9 +146,11 @@ void GenerateBranchLinks() {
142146
routingValue = customValueEditText.getText().toString();
143147
}
144148

145-
row1.InitializeRow(LinkingValidatorConstants.linkingValidatorRow1Title, LinkingValidatorConstants.infoButton1Copy, LinkingValidatorConstants.debugButton1Copy, routingKey, routingValue, "regularBranchLink");
146-
row2.InitializeRow(LinkingValidatorConstants.linkingValidatorRow2Title, LinkingValidatorConstants.infoButton2Copy, LinkingValidatorConstants.debugButton2Copy, routingKey, routingValue, "uriFallbackBranchLink", "$uri_redirect_mode", "2");
147-
row3.InitializeRow(LinkingValidatorConstants.linkingValidatorRow3Title, LinkingValidatorConstants.infoButton3Copy, LinkingValidatorConstants.debugButton3Copy, routingKey, routingValue, "webOnlyBranchLink", "$web_only", "true");
148-
row4.InitializeRow(LinkingValidatorConstants.linkingValidatorRow4Title, LinkingValidatorConstants.infoButton4Copy, LinkingValidatorConstants.debugButton4Copy, routingKey, "", "missingDataBranchLink");
149+
row1.InitializeRow(LinkingValidatorConstants.linkingValidatorRow1Title, LinkingValidatorConstants.infoButton1Copy, LinkingValidatorConstants.debugButton1Copy, routingKey, routingValue, "regularBranchLink", true);
150+
row2.InitializeRow(LinkingValidatorConstants.linkingValidatorRow2Title, LinkingValidatorConstants.infoButton2Copy, LinkingValidatorConstants.debugButton2Copy, routingKey, routingValue, "uriFallbackBranchLink", true, "$uri_redirect_mode", "2");
151+
row3.InitializeRow(LinkingValidatorConstants.linkingValidatorRow3Title, LinkingValidatorConstants.infoButton3Copy, LinkingValidatorConstants.debugButton3Copy, routingKey, routingValue, "webOnlyBranchLink", true, "$web_only", "true");
152+
row4.InitializeRow(LinkingValidatorConstants.linkingValidatorRow4Title, LinkingValidatorConstants.infoButton4Copy, LinkingValidatorConstants.debugButton4Copy, routingKey, "", "missingDataBranchLink", true);
153+
row5.InitializeRow(LinkingValidatorConstants.linkingValidatorRow5Title, LinkingValidatorConstants.infoButton5Copy, LinkingValidatorConstants.debugButton5Copy, routingKey, routingValue, "warmStartUseCase", false);
154+
row6.InitializeRow(LinkingValidatorConstants.linkingValidatorRow6Title, LinkingValidatorConstants.infoButton6Copy, LinkingValidatorConstants.debugButton6Copy, routingKey, routingValue, "foregroundClickUseCase", false);
149155
}
150156
}

Branch-SDK/src/main/java/io/branch/referral/validators/LinkingValidatorDialogRowItem.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public class LinkingValidatorDialogRowItem extends LinearLayout {
2727
TextView titleText;
2828
Button infoButton;
2929
String infoText;
30-
Button shareButton;
30+
Button actionButton;
3131
HashMap<String, String> linkDataParams;
3232
String routingKey;
3333
String routingValue;
@@ -46,12 +46,12 @@ public LinkingValidatorDialogRowItem(Context context, AttributeSet attrs, int de
4646
this.context = context;
4747
}
4848

49-
public void InitializeRow(String title, String infoText, String debugText, String routingKey, String routingValue, String canonicalIdentifier, String... params) {
49+
public void InitializeRow(String title, String infoText, String debugText, String routingKey, String routingValue, String canonicalIdentifier, boolean isSharableLink, String... params) {
5050
View view = LayoutInflater.from(getContext()).inflate(R.layout.linking_validator_dialog_row_item, null);
5151
this.addView(view);
5252
titleText = view.findViewById(R.id.linkingValidatorRowTitleText);
5353
infoButton = view.findViewById(R.id.linkingValidatorRowInfoButton);
54-
shareButton = view.findViewById(R.id.linkingValidatorRowShareButton);
54+
actionButton = view.findViewById(R.id.linkingValidatorRowActionButton);
5555
debugButton = view.findViewById(R.id.linkingValidatorRowDebugButton);
5656

5757
titleText.setText(title);
@@ -71,13 +71,21 @@ public void InitializeRow(String title, String infoText, String debugText, Strin
7171
HandleInfoButtonClicked();
7272
});
7373

74-
shareButton.setOnClickListener(view2 -> {
75-
HandleShareButtonClicked();
76-
});
77-
7874
debugButton.setOnClickListener(view2 -> {
7975
HandleDebugButtonClicked();
8076
});
77+
78+
if(isSharableLink) {
79+
actionButton.setText("Share");
80+
81+
actionButton.setOnClickListener(view2 -> {
82+
HandleShareButtonClicked();
83+
});
84+
} else {
85+
actionButton.setText("Test");
86+
87+
88+
}
8189
}
8290

8391
private void HandleInfoButtonClicked() {

Branch-SDK/src/main/res/layout/dialog_linking_validator.xml

Lines changed: 6 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -211,91 +211,20 @@
211211
android:layout_height="30dp"
212212
android:layout_weight="0.5" />
213213

214-
<Space
215-
android:layout_width="0dp"
216-
android:layout_height="10dp" />
217-
218-
<LinearLayout
214+
<io.branch.referral.validators.LinkingValidatorDialogRowItem
215+
android:id="@+id/linkingValidatorRow5"
219216
android:layout_width="match_parent"
220-
android:layout_height="50dp"
221-
android:orientation="horizontal">
222-
223-
<TextView
224-
android:id="@+id/textView7"
225-
android:layout_width="0dp"
226-
android:layout_height="wrap_content"
227-
android:layout_weight="0.4"
228-
android:text="Warm Start"
229-
android:textSize="16sp" />
230-
231-
<Button
232-
android:id="@+id/button17"
233-
android:layout_width="0dp"
234-
android:layout_height="match_parent"
235-
android:layout_weight="0.15"
236-
android:text="Info"
237-
android:textSize="10sp" />
238-
239-
<Button
240-
android:id="@+id/button18"
241-
android:layout_width="0dp"
242-
android:layout_height="match_parent"
243-
android:layout_weight="0.3"
244-
android:text="Test"
245-
android:textSize="10sp" />
246-
247-
<Button
248-
android:id="@+id/button20"
249-
android:layout_width="0dp"
250-
android:layout_height="match_parent"
251-
android:layout_weight="0.15"
252-
android:text="Debug"
253-
android:textSize="10sp" />
254-
255-
</LinearLayout>
217+
android:layout_height="50dp" />
256218

257219
<Space
258220
android:layout_width="0dp"
259221
android:layout_height="10dp"
260222
android:layout_weight="0.5" />
261223

262-
<LinearLayout
224+
<io.branch.referral.validators.LinkingValidatorDialogRowItem
225+
android:id="@+id/linkingValidatorRow6"
263226
android:layout_width="match_parent"
264-
android:layout_height="50dp"
265-
android:orientation="horizontal">
266-
267-
<TextView
268-
android:id="@+id/textView8"
269-
android:layout_width="0dp"
270-
android:layout_height="wrap_content"
271-
android:layout_weight="0.4"
272-
android:text="Foreground click"
273-
android:textSize="16sp" />
274-
275-
<Button
276-
android:id="@+id/button21"
277-
android:layout_width="0dp"
278-
android:layout_height="match_parent"
279-
android:layout_weight="0.15"
280-
android:text="Info"
281-
android:textSize="10sp" />
282-
283-
<Button
284-
android:id="@+id/button22"
285-
android:layout_width="0dp"
286-
android:layout_height="match_parent"
287-
android:layout_weight="0.3"
288-
android:text="Test"
289-
android:textSize="10sp" />
290-
291-
<Button
292-
android:id="@+id/button23"
293-
android:layout_width="0dp"
294-
android:layout_height="match_parent"
295-
android:layout_weight="0.15"
296-
android:text="Debug"
297-
android:textSize="10sp" />
298-
</LinearLayout>
227+
android:layout_height="50dp" />
299228
</LinearLayout>
300229

301230
</androidx.constraintlayout.widget.ConstraintLayout>

Branch-SDK/src/main/res/layout/linking_validator_dialog_row_item.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
android:textSize="9sp" />
2727

2828
<Button
29-
android:id="@+id/linkingValidatorRowShareButton"
29+
android:id="@+id/linkingValidatorRowActionButton"
3030
android:layout_width="0dp"
3131
android:layout_height="match_parent"
3232
android:layout_weight="0.2"

0 commit comments

Comments
 (0)