-
Notifications
You must be signed in to change notification settings - Fork 13
/
integration-android.html
807 lines (747 loc) · 39.3 KB
/
integration-android.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="images/favicon.png">
<title>Countly Code Generator</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="css/ie10-viewport-bug-workaround.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/style.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="jumbotron top">
<div class="container">
<div id="logo">
<span class="image"></span>
<span class="text">Code Generator</span>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="col-md-12">
<div style="overflow: auto">
<div class="btn-group" style="float: left">
<a href="integration.html" id="back" class="btn btn-default">← Back</a>
<a href="events.html?sdk=android" id="next" class="btn btn-default">Next: Create Event
→</a>
</div>
<div id="buttons" class="btn-group" role="group" style="float: right">
</div>
</div>
<h2 class="text-center">Integrating Android SDK</h2>
</div>
</div>
<div class='section configuration'>
<span class='label'>Provide configuration settings</span>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for='server-url'>Server URL:</label>
<input type="url" class="form-control" id='server-url' placeholder="https://try.count.ly">
</div>
</div><!-- /.col-lg-6 -->
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="app_key">App Key:</label>
<input type="text" class="form-control" id="app_key"
placeholder="f399aa0a6305c2bd51d304ca666418ae8d93d9bc">
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
</div>
<div class='section ide radio'>
<span class='label'>Choose your environment/IDE</span>
<div class="row">
<div class="col-md-12">
<label>
<input type="radio" name='ide' value='studio'> Android Studio
</label>
</div><!-- /.col-lg-6 -->
</div>
<div class="row">
<div class="col-md-12">
<label>
<input type="radio" name='ide' value='eclipse'> Eclipse
</label>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
</div>
<div class='section device_id radio'>
<span class='label'>Choose a way to generate device Id</span>
<div class="row">
<div class="col-md-12">
<label>
<input type="radio" name='device_id' value='DeviceId.Type.ADVERTISING_ID'> use Advertising ID
</label>
</div><!-- /.col-lg-6 -->
</div>
<div class="row">
<div class="col-md-12">
<label>
<input type="radio" name='device_id' value='DeviceId.Type.OPEN_UDID'> use OpenUDID
</label>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
</div>
<div class='section features checkbox'>
<span class='label'>Choose features you want to use</span>
<div class="row">
<div class="col-md-12">
<label>
<input type="checkbox" class='feature' id='push_feature' value='push'> Send push notifications
to your users
</label>
</div><!-- /.col-lg-6 -->
</div>
<div class="row">
<div class="col-md-12">
<label>
<input type="checkbox" class='feature' value='view'> Track views your users visit
</label>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<label>
<input type="checkbox" class='feature' value='crash'> Track app crashes
</label>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<label>
<input type="checkbox" class='feature' value='attribution'> Track campaigns and attribution
</label>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<p> </p>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<label>
<input type="checkbox" id="allfeatures"> I want all features
</label>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
</div>
<div class='section push-settings hidden'>
<span class='label'>Provide push specific settings</span>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="push_activity">Name of your main activity (the one specified in Android
Manifest):</label>
<input type="text" class="form-control" id="push_activity" placeholder="MainActivity">
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="push_package">Name of your app package (the one specified in Android
Manifest):</label>
<input type="text" class="form-control" id="push_package"
placeholder="ly.count.android.demo.messaging">
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label for="push_project">Project Number from Google Developers Console (<a
href='http://resources.count.ly/docs/countly-sdk-for-android#section-registering-at-google'
target='_blank'>More information</a>):</label>
<input type="text" class="form-control" id="push_project" placeholder="640228892478">
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row checkbox">
<div class="col-md-12">
<label>
<input type="checkbox" id='push_test' value='test'> Use push for test users
</label>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
</div>
<div class='section advanced'>
<span class='label'>
<span id="dropdown-icon" style="display: inline-block;"></span>
<span id="dropdown-icon-2" style="display: none;"></span>
Advanced Configuration</span>
<div class='advanced-list'>
<fieldset>
<legend>Location</legend>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Provide country code of your user (will try to determine from IP address if not
provided)</label>
<input type="text" class="form-control optinit" id='country' placeholder="US" />
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Provide city of your user (will try to determine from IP address if not
provided)</label>
<input type="text" class="form-control optinit" id='city' placeholder="San Francisco" />
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Provide geolocation of your user (will try to determine from IP address if not
provided)</label>
<input type="text" class="form-control optinit" id='location'
placeholder="56.42345,123.45325" />
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Provide the secret salt. Must be same with the one provided on server to prevent
changing request data</label>
<input type="text" class="form-control" id='enableParameterTamperingProtection'
placeholder="secret" />
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
</fieldset>
<fieldset>
<legend>Limits</legend>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Send events when you reach this limit without waiting for next sync</label>
<input type="text" class="form-control" id='setEventQueueSizeToSend' placeholder="10" />
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Provide the Star Rating dialog title</label>
<input type="text" class="form-control star" id='starRatingTitle'
placeholder="App rating" />
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Provide the Star Rating dialog message</label>
<input type="text" class="form-control star" id='starRatingMessage'
placeholder="Please rate this app" />
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Provide title for cancel button in Star Rating dialog</label>
<input type="text" class="form-control star" id='starRatingDismissButtonTitle'
placeholder="Cancel" />
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Show Star rating dialog after this amount of sessions</label>
<input type="text" class="form-control" id='setAutomaticStarRatingSessionLimit'
placeholder="10" />
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
</fieldset>
<fieldset>
<legend>Optional</legend>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>
<input type="checkbox" id='setIfStarRatingShownAutomatically' value='false'> Disable
Asking Star rating completely
</label>
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>
<input type="checkbox" id='setStarRatingDisableAskingForEachAppVersion'
value='false'> Disable Asking Star rating for each version
</label>
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>
<input type="checkbox" id='setLoggingEnabled' value='true'> Enable Debug logging
</label>
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>
<input type="checkbox" id='setHttpPostForced' value='true'> Force using POST only
</label>
</div>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
</fieldset>
</div>
</div>
<div class="row">
<div class="col-md-12">
<p class='text-center'><button type="button" class="btn btn-success" id="generate">Generate
code</button></p>
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<footer>
<p><a href='http://count.ly'>Count.ly</a></p>
</footer>
</div> <!-- /container -->
<div class="modal fade" id="end-modal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
aria-hidden="true">×</span></button>
<h4 class="modal-title">Integrate Android SDK</h4>
</div>
<div class="modal-body">
<div class="tabbable"> <!-- Only required for left/right tabs -->
<ul class="nav nav-tabs">
<li class="active"><a href="#adding" data-toggle="tab">Adding SDK files</a></li>
<li><a href="#activity" data-toggle="tab">Main Activity</a></li>
<li><a href="#manifest" data-toggle="tab">Android Manifest</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="adding">
<div class='studio hidden'>
<p>Add Maven repository and dependency to your app's level
<strong>build.gradle</strong> file
</p>
<p><textarea id='gradle-code' class='code' readonly onclick="this.select();">
buildscript {
repositories {
maven {
url "http://dl.bintray.com/countly/maven"
}
}
}
dependencies {
compile 'ly.count.android:sdk:version'
}
</textarea></p>
<p class='text-center'>
<button type="button" class="btn btn-success copy"
data-clipboard-target="#gradle-code">Copy</button>
<button type="button" class="btn btn-success"
id="download-gradle">Download</button>
<button type="button" class="btn btn-primary gotit">Close</button>
</p>
</div>
<div class='eclipse hidden'>
<div class='well'>
Eclipse users can download JARs (sdk.jar or sdk.jar & sdk-messaging.jar
depending on whether you need Countly Push support or not) from <a
href='https://github.com/Countly/countly-sdk-android/releases'
target='_blank'>Github Releases</a> page.
</div>
<p>Another option for Eclipse users is to use sources instead of jars. To do that,
just create packages and put sources from Github repository into corresponding
packages:</p>
<table class="table">
<tr>
<th>Component</th>
<th>Package name</th>
<th>Path at Github repo</th>
</tr>
<tr>
<td>Countly SDK</td>
<td>ly.count.android.sdk</td>
<td>countly-sdk-android/sdk/src/main/java/ly/count/android/sdk</td>
</tr>
<tr class='openudid-package hidden'>
<td>OpenUDID</td>
<td>org.openudid</td>
<td>countly-sdk-android/sdk/src/main/java/org/openudid</td>
</tr>
<tr class='push-package hidden'>
<td>Countly Push SDK</td>
<td>ly.count.android.sdk.messaging</td>
<td>countly-sdk-android/sdk/src/main/java/ly/count/android/sdk/messaging
</td>
</tr>
</table>
<p class='text-center'>
<button type="button" class="btn btn-primary gotit">Close</button>
</p>
</div>
</div>
<div class="tab-pane" id="activity">
<p>Insert this snippet (or modify it to include provided code in same methods) to your
main activity, which is the first to launch and is specified in your Android
manifest</p>
<p id='push' class='well'><a
href="http://resources.count.ly/docs/countly-sdk-for-android#setting-up-push-notifications"
target="_blank">More information on setting up push notifications on server</a>
</p>
<p><textarea id='end-code' class='code' readonly onclick="this.select();"></textarea>
</p>
<p class='text-center'>
<button type="button" class="btn btn-success copy"
data-clipboard-target="#end-code">Copy</button>
<button type="button" class="btn btn-success" id="download">Download</button>
<button type="button" class="btn btn-primary gotit">Close</button>
</p>
</div>
<div class="tab-pane" id="manifest">
<p>Insert this snippet to in your <strong>AndroidManifest.xml</strong>, or modify it to
include provided tags in same xmls structure</p>
<p><textarea id='manifest-code' class='code' readonly
onclick="this.select();"></textarea></p>
<p class='text-center'>
<button type="button" class="btn btn-success copy"
data-clipboard-target="#manifest-code">Copy</button>
<button type="button" class="btn btn-success"
id="download-manifest">Download</button>
<button type="button" class="btn btn-primary gotit">Close</button>
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/jquery.min.js"><\/script>')</script>
<script src="https://global.localizecdn.com/localize.js"></script>
<script src="js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="js/ie10-viewport-bug-workaround.js"></script>
<script src="js/sdks.js"></script>
<script src="js/common.js"></script>
<script src="js/Blob.js"></script>
<script src="js/FileSaver.min.js"></script>
<script src="js/clipboard.min.js"></script>
<script>
$(document).ready(function () {
new Clipboard('.copy');
var sdk = sdks.android;
$("#gradle-code").val($("#gradle-code").val().replace(":version", ":" + sdk.version));
$("#buttons").append('<a href="' + sdk.docs + '" target="_blank" class="btn btn-default">Documentation</a>');
$("#buttons").append('<a href="' + sdk.download + '" target="_blank" class="btn btn-default">Download</a>');
$("#buttons").append('<a href="' + sdk.repo + '" target="_blank" class="btn btn-default">Repository</a>');
var params = parseParams(location.search);
if (params.server) {
$("#server-url").val(params.server);
}
if (params.app_key) {
$("#app_key").val(params.app_key);
}
if (params.server && params.app_key) {
$(".configuration").hide();
}
$('#push_feature').change(function () {
if ($(this).is(':checked')) {
$(".push-settings").removeClass("hidden");
} else {
$(".push-settings").addClass("hidden");
}
});
var template = "@Override\n" +
"public void onCreate(Bundle savedInstanceState) {\n" +
" super.onCreate(savedInstanceState);\n" +
" \n" +
" Countly.sharedInstance().init(this, \"YOUR_SERVER\", \"YOUR_APP_KEY\", null, DeviceId);\n" +
"[options]\n" +
"[features]\n" +
"}\n" +
"\n" +
"@Override\n" +
"public void onStart()\n" +
"{\n" +
" super.onStart();\n" +
" Countly.sharedInstance().onStart(this);\n" +
"}\n" +
"\n" +
"@Override\n" +
"public void onStop()\n" +
"{\n" +
" Countly.sharedInstance().onStop();\n" +
" super.onStop();\n" +
"}\n";
$("#generate").click(function () {
var pushPermission = "<permission android:name=\"ly.count.android.demo.messaging.permission.C2D_MESSAGE\" android:protectionLevel=\"signature\" />\n" +
"<uses-permission android:name=\"ly.count.android.demo.messaging.permission.C2D_MESSAGE\" />\n";
var attribution =
" <receiver android:name=\"ly.count.android.sdk.ReferrerReceiver\" android:exported=\"true\">\n" +
" <intent-filter>\n" +
" <action android:name=\"com.android.vending.INSTALL_REFERRER\" />\n" +
" </intent-filter>\n" +
" </receiver>\n";
var openudid =
" <service android:name=\"org.openudid.OpenUDID_service\">\n" +
" <intent-filter>\n" +
" <action android:name=\"org.openudid.GETUDID\" />\n" +
" </intent-filter>\n" +
" </service>\n";
var manifest = "<uses-permission android:name=\"android.permission.INTERNET\"/>\n" +
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>\n" +
"\n";
var manifestApplication = [];
$(".alert").remove();
var data = {};
data.url = $("#server-url").val();
if (data.url == "") {
$("#server-url").parent().prepend('<div class="alert alert-danger" role="alert">Please provide server URL</div>');
return;
}
if (data.url.indexOf("http") != 0) {
$("#server-url").parent().prepend('<div class="alert alert-danger" role="alert">Your server URL should start with http:// or https://</div>');
return;
}
data.app_key = $("#app_key").val();
if (data.app_key == "") {
$("#app_key").parent().prepend('<div class="alert alert-danger" role="alert">Please provide App Key</div>');
return;
}
data.ide = $("input:radio[name=ide]:checked").val();
if (!data.ide || data.ide == "") {
$(".ide").prepend('<div class="alert alert-danger" role="alert">Please select one tool/IDE you will be using</div>');
return;
}
else {
if (data.ide == "studio") {
$(".studio").removeClass("hidden");
$(".eclipse").addClass("hidden");
}
else if (data.ide == "eclipse") {
$(".studio").addClass("hidden");
$(".eclipse").removeClass("hidden");
}
}
data.device_id = $("input:radio[name=device_id]:checked").val();
if (!data.device_id || data.device_id == "") {
$(".device_id").prepend('<div class="alert alert-danger" role="alert">Please select one way to generate device Id</div>');
return;
}
if (data.device_id == "DeviceId.Type.OPEN_UDID") {
$(".studio").before('<div class="alert alert-danger" role="alert">If you are using Proguard, add this line to your <strong>proguard-rules.pro</strong><div calss="well">-keep class org.openudid.** { *; }</div></div>');
$(".openudid-package").removeClass("hidden");
manifestApplication.push(openudid);
}
var features = $(".feature:checked").map(function (feature) {
return this.value;
}).get();
data.features = "";
if (features.length) {
for (var i = 0; i < features.length; i++) {
if (features[i] == "push") {
var activity = $("#push_activity").val();
if (activity == "") {
$("#push_activity").parent().prepend('<div class="alert alert-danger" role="alert">Please provide name of the main activity. You can find it in your Android Manifest</div>');
return;
}
var pack = $("#push_package").val();
if (pack == "") {
$("#push_package").parent().prepend('<div class="alert alert-danger" role="alert">Please provide package name of your app. You can find it in your Android Manifest</div>');
return;
}
var project = $("#push_project").val();
if (project == "") {
$("#push_project").parent().prepend('<div class="alert alert-danger" role="alert">Please provide project number. You can find it in your Google Console</div>');
return;
}
pushPermission = pushPermission
.replace(new RegExp("ly.count.android.demo.messaging", 'g'), pack);
manifest = pushPermission + manifest;
pushFeature = " Countly.sharedInstance().initMessaging(this, CountlyActivity.class, \"PROJECT_NUMBER\", Countly.CountlyMessagingMode.PRODUCTION);\n";
pushFeature = pushFeature
.replace("CountlyActivity", activity)
.replace("PROJECT_NUMBER", project);
if ($("#push_test").is(':checked')) {
pushFeature = pushFeature.replace("Countly.CountlyMessagingMode.PRODUCTION", "Countly.CountlyMessagingMode.TEST");
}
data.features += pushFeature;
$("#gradle-code").val($("#gradle-code").val().replace("ly.count.android:sdk:", "ly.count.android:sdk-messaging:"));
$(".push-package").removeClass("hidden");
}
else if (features[i] == "view") {
data.features += " Countly.sharedInstance().setViewTracking(true);\n";
}
else if (features[i] == "crash") {
data.features += " Countly.sharedInstance().enableCrashReporting();\n";
}
else if (features[i] == "attribution") {
manifestApplication.push(attribution);
}
}
if (features.indexOf("push") == -1) {
$("push").hide();
}
}
data.options = $(".advanced-list input").map(function (el) {
if (this.type == "text") {
if ($(this).hasClass("arr") && this.value.replace(/^\s+|\s+$/gm, '') != "") {
var arr = this.value.split(",");
for (var i = 0; i < arr.length; i++) {
arr[i] = '"' + arr[i].replace(/^\s+|\s+$/gm, '') + '"';
}
return { id: this.id, value: '[' + arr.join(",") + ']' };
}
else if ($(this).hasClass("optinit") || $(this).hasClass("star")) {
return { id: this.id, value: "" };
}
else if (isNaN(this.value))
return { id: this.id, value: '"' + (($(this).hasClass("context")) ? "context, " : "") + this.value + '"' };
else
return { id: this.id, value: (($(this).hasClass("context")) ? "context, " : "") + this.value };
}
else if (this.type == "checkbox" && this.checked)
return { id: this.id, value: (($(this).hasClass("context")) ? "context, " : "") + this.value };
else
return { id: this.id, value: "" };
}).get().filter(function (el) {
if (el.value.length && el.value != '""')
return true;
return false;
}).map(function (el) {
return " Countly.sharedInstance()." + el.id + '(' + el.value + ');';
});
//process star rating
var hasOptStar = false;
var optinit = $(".advanced-list input.star").map(function (el) {
if (this.value != "") {
hasOptStar = true;
return '"' + this.value + '"';
}
return "null";
}).get().join(", ");
if (hasOptStar) {
data.options.unshift(" Countly.sharedInstance().setStarRatingDialogTexts(" + optinit + ")");
}
//process optional init
var hasOptInit = false;
var optinit = $(".advanced-list input.optinit").map(function (el) {
if (this.value != "") {
hasOptInit = true;
return '"' + this.value + '"';
}
return "null";
}).get().join(", ");
if (hasOptInit) {
data.options.unshift(" Countly.sharedInstance().setOptionalParametersForInitialization(" + optinit + ")");
}
if (data.options.length) {
data.options = data.options.join("\n") + "\n";
}
else {
data.options = "";
}
var code = template.replace("YOUR_SERVER", data.url)
.replace("YOUR_APP_KEY", data.app_key)
.replace("DeviceId", data.device_id)
.replace("[options]", data.options)
.replace("[features]", data.features);
if (features.indexOf("CLYMessaging") > -1) {
code = code.replace(" // your code\n", pushHandling);
code += "\n" + pushMethods;
}
if (manifestApplication.length) {
var application = "<application>";
if (data.ide == "studio") {
application = "<application tools:replace=\"android:label\">";
}
manifest = manifest + "\n" + application + "\n\n" + manifestApplication.join("\n") + "\n</application>\n";
}
$("#end-code").val(code);
$("#manifest-code").val(manifest);
$('#end-modal').modal();
});
$("#allfeatures").change(function () {
$(".feature").prop('checked', $(this).prop("checked"));
if ($(this).is(':checked')) {
$(".push-settings").removeClass("hidden");
} else {
$(".push-settings").addClass("hidden");
}
});
$(".gotit").click(function () {
$('#end-modal').modal('hide');
});
$("#download").click(function () {
var data = $("#end-code").val();
try {
var blob = new Blob([data], { type: "text/plain;charset=utf-8" });
saveAs(blob, "android-sdk.txt");
} catch (e) {
alert(data);
}
});
$("#download-graddle").click(function () {
var data = $("#gradle-code").val();
try {
var blob = new Blob([data], { type: "text/plain;charset=utf-8" });
saveAs(blob, "build.gradle.txt");
} catch (e) {
alert(data);
}
});
$(".advanced span.label").on('click', function () {
var downArrow = document.getElementById('dropdown-icon').style.display;
if (downArrow === 'inline-block') {
$(this).parent().find("#dropdown-icon-2").attr('style', 'display: inline-block');
}
else {
$(this).parent().find("#dropdown-icon-2").attr('style', 'display: none');
}
$(this).parent().find("#dropdown-icon").toggle();
});
$("#download-manifest").click(function () {
var data = $("#manifest-code").val();
try {
var blob = new Blob([data], { type: "text/plain;charset=utf-8" });
saveAs(blob, "AndroidManifest.txt");
} catch (e) {
alert(data);
}
});
});
</script>
</body>
</html>