File tree Expand file tree Collapse file tree 13 files changed +202
-512
lines changed
Branch-SDK-TestBed/src/main
java/io/branch/branchandroiddemo
androidTest/java/io/branch/referral
main/java/io/branch/referral Expand file tree Collapse file tree 13 files changed +202
-512
lines changed Original file line number Diff line number Diff line change 5151 </activity >
5252
5353 <activity android : name =" io.branch.branchandroiddemo.CreditHistoryActivity" />
54+ <activity android : name =" .SettingsActivity" />
5455
5556 <activity android : name =" .AutoDeepLinkTestActivity" >
5657 <!-- Keys for auto deep linking this activity -->
Original file line number Diff line number Diff line change @@ -374,6 +374,14 @@ public void onClick(View view) {
374374 }
375375 });
376376
377+ findViewById (R .id .settings_btn ).setOnClickListener (new OnClickListener () {
378+ @ Override
379+ public void onClick (View v ) {
380+ Intent intent = new Intent (getApplicationContext (), SettingsActivity .class );
381+ startActivity (intent );
382+ }
383+ });
384+
377385 // Tracking events
378386 findViewById (R .id .cmdTrackCustomEvent ).setOnClickListener (new OnClickListener () {
379387 @ Override
Original file line number Diff line number Diff line change 1+ package io .branch .branchandroiddemo ;
2+
3+ import android .app .Activity ;
4+
5+ import android .os .Bundle ;
6+ import android .view .View ;
7+ import android .widget .Switch ;
8+
9+ import io .branch .referral .Branch ;
10+ import io .branch .referral .PrefHelper ;
11+
12+ public class SettingsActivity extends Activity {
13+
14+ @ Override
15+ protected void onCreate (Bundle savedInstanceState ) {
16+ super .onCreate (savedInstanceState );
17+ setContentView (R .layout .activity_settings );
18+
19+ setupDisableAdNetworkCalloutsSwitch ();
20+ }
21+
22+ void setupDisableAdNetworkCalloutsSwitch () {
23+ final Switch disableAdNetworkCalloutsSwitch = findViewById (R .id .disable_ad_network_callouts );
24+
25+ /*
26+ * Initialize switch state from SharedPreferences.
27+ */
28+ final PrefHelper prefHelper = PrefHelper .getInstance (this );
29+ disableAdNetworkCalloutsSwitch .setChecked (prefHelper .getAdNetworkCalloutsDisabled ());
30+
31+ /*
32+ * Update the setting whenever the switch changes state.
33+ */
34+ disableAdNetworkCalloutsSwitch .setOnClickListener (new View .OnClickListener () {
35+ @ Override
36+ public void onClick (View v ) {
37+ Branch .getInstance ().disableAdNetworkCallouts (disableAdNetworkCalloutsSwitch .isChecked ());
38+ }
39+ });
40+
41+ }
42+ }
Original file line number Diff line number Diff line change 149149 android : text =" Fire notif"
150150 android : layout_marginTop =" 20dp" />
151151
152+ <Button
153+ android : id =" @+id/settings_btn"
154+ style =" @style/testbed_button_style"
155+ android : layout_below =" @+id/notif_btn"
156+ android : layout_centerHorizontal =" true"
157+ android : text =" @string/settings"
158+ android : layout_marginTop =" 20dp" />
159+
152160 </RelativeLayout >
153161
154162 </ScrollView >
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
2+ <LinearLayout xmlns : android =" http://schemas.android.com/apk/res/android"
3+ android : layout_width =" match_parent"
4+ android : layout_height =" match_parent"
5+ android : orientation =" vertical" >
6+ <LinearLayout
7+ android : layout_width =" match_parent"
8+ android : layout_height =" wrap_content"
9+ android : orientation =" horizontal" >
10+ <TextView
11+ android : layout_width =" wrap_content"
12+ android : layout_height =" match_parent"
13+ android : text =" @string/disable_ad_network_callouts" />
14+ <Switch
15+ android : id =" @+id/disable_ad_network_callouts"
16+ android : layout_width =" match_parent"
17+ android : layout_height =" wrap_content" />
18+ </LinearLayout >
19+ </LinearLayout >
Original file line number Diff line number Diff line change 1111 <string name =" launch_mode_branch" >"Launched by Branch on auto deep linking!"</string >
1212 <string name =" launch_mode_normal" >"Launched by normal application flow"</string >
1313
14+ <string name =" disable_ad_network_callouts" >Disable ad network callouts</string >
15+ <string name =" settings" >Settings</string >
1416</resources >
Original file line number Diff line number Diff line change 66import org .junit .Assert ;
77import org .junit .Test ;
88
9-
109public class PrefHelperTest extends BranchTest {
1110
1211 void assertDefaultURL () {
@@ -53,4 +52,22 @@ public void testSetAPIUrl_InvalidEmpty() {
5352 PrefHelper .setAPIUrl ("" );
5453 assertDefaultURL ();
5554 }
55+
56+ @ Test
57+ public void testSetAdNetworkCalloutsDisabled () {
58+ Context context = getTestContext ();
59+ PrefHelper prefHelper = PrefHelper .getInstance (context );
60+ prefHelper .setAdNetworkCalloutsDisabled (true );
61+
62+ Assert .assertTrue (prefHelper .getAdNetworkCalloutsDisabled ());
63+ }
64+
65+ @ Test
66+ public void testSetAdNetworkCalloutsEnabled () {
67+ Context context = getTestContext ();
68+ PrefHelper prefHelper = PrefHelper .getInstance (context );
69+ prefHelper .setAdNetworkCalloutsDisabled (false );
70+
71+ Assert .assertFalse (prefHelper .getAdNetworkCalloutsDisabled ());
72+ }
5673}
You can’t perform that action at this time.
0 commit comments