@@ -41,6 +41,11 @@ public class ASAPActivity extends AppCompatActivity implements
4141
4242 private ASAPApplication asapApplication ;
4343
44+ /**
45+ * Create a new activity object. Make sure your application object is fully
46+ * instantiated
47+ * @param asapApplication
48+ */
4449 public ASAPActivity (ASAPApplication asapApplication ) {
4550 this .asapApplication = asapApplication ;
4651 }
@@ -51,13 +56,17 @@ protected ASAPApplication getASAPApplication() {
5156
5257 /**
5358 * Create a closed asap channel. Ensure to call this method before ever sending a message into
54- * that channel.
55- * @param appName
56- * @param uri
57- * @param recipients
59+ * that channel. Any prior message would create an open channel with unrestricted recipient list.
60+ * (It sound worse than it is, though. Have a look at the concept description of ASAP.)
61+ * @param appName format / appName of your application and its ASAPEngine
62+ * @param uri describes content within your application
63+ * @param recipients list of recipients. Only peers on that list will even get this message.
64+ * This is more than setting access rights. It like a registered letter.
65+ * Peers which are not on the list will not even be aware of the existence
66+ * of this channel and it messages.
5867 * @throws ASAPException
5968 */
60- public void createClosedASAPChannel (CharSequence appName , CharSequence uri ,
69+ public final void createClosedASAPChannel (CharSequence appName , CharSequence uri ,
6170 Collection <CharSequence > recipients ) throws ASAPException {
6271
6372 ASAPServiceMessage createClosedChannelMessage =
@@ -69,13 +78,13 @@ public void createClosedASAPChannel(CharSequence appName, CharSequence uri,
6978 /**
7079 * Send asap message. If that channel does not exist: it will be created as open channel
7180 * (unrestricted recipient list). Closed channels must be created before
72- * @param appName
73- * @param uri
74- * @param message
81+ * @param appName format / appName of your application and its ASAPEngine
82+ * @param uri describes content within your application
83+ * @param message application specific message as bytes.
7584 * @param persistent keep in an asap store and resent in following asap sessions
7685 * @throws ASAPException
7786 */
78- public void sendASAPMessage (CharSequence appName , CharSequence uri ,
87+ public final void sendASAPMessage (CharSequence appName , CharSequence uri ,
7988 byte [] message , boolean persistent ) throws ASAPException {
8089
8190 Log .d (this .getLogStart (), "ask service to send: "
@@ -93,7 +102,13 @@ public void sendASAPMessage(CharSequence appName, CharSequence uri,
93102 // asap service requests //
94103 ///////////////////////////////////////////////////////////////////////////////////////
95104
105+ /**
106+ * Application developer should neither call nor overwrite this message. It is called
107+ * as result of a start bluetooth request. We will hide it behind an interface in later
108+ * version. Until than: Please, do not call this method.
109+ */
96110 @ Override
111+ @ CallSuper
97112 public void asapSrcRq_enableBluetooth () {
98113 // check if bt is enabled
99114 // get default bt adapter - there could be proprietary adapters
@@ -121,7 +136,13 @@ public void asapSrcRq_enableBluetooth() {
121136
122137 private int visibilityTime = 1 ;
123138
139+ /**
140+ * Application developer should neither call nor overwrite this message. It is called
141+ * as result of a start bluetooth request. We will hide it behind an interface in later
142+ * version. Until than: Please, do not call this method.
143+ */
124144 @ Override
145+ @ CallSuper
125146 public void asapSrcRq_startBTDiscoverable (int time ) {
126147 this .visibilityTime = time ;
127148 Log .d (this .getLogStart (), "going to make device bt visibile for seconds: "
@@ -135,6 +156,13 @@ public void asapSrcRq_startBTDiscoverable(int time) {
135156 this .startActivityForResult (discoverableIntent , MY_REQUEST_SET_BT_DISCOVERABLE );
136157 }
137158
159+ /**
160+ * Application developer should neither call nor overwrite this message. It is the callback
161+ * method that is called if a broadcast is received. We will hide it behind an
162+ * interface in later
163+ * version. Until than: Please, do not call this method.
164+ */
165+ @ CallSuper
138166 public void onActivityResult (int requestCode , int resultCode , Intent data ) {
139167 Log .d (this .getLogStart (),
140168 ".onActivityResult(): requestCode == " + requestCode +
@@ -189,31 +217,62 @@ protected String getLogStart() {
189217 // mac protocol stuff //
190218 /////////////////////////////////////////////////////////////////////////////////////
191219
220+ /**
221+ * Call this message to start Bluetooth.
222+ * asapNotifyBTEnvironmentStarted() is called later if BT could be started.
223+ */
192224 public void startBluetooth () {
193225 Log .d (this .getLogStart (), "send message to service: start BT" );
194226 this .sendMessage2Service (ASAPServiceMethods .START_BLUETOOTH );
195227 }
196228
229+ /**
230+ * Call this message to stop Bluetooth.
231+ * asapNotifyBTEnvironmentStopped() is called later if BT could be stopped
232+ */
197233 public void stopBluetooth () {
198234 Log .d (this .getLogStart (), "send message to service: stop BT" );
199235 this .sendMessage2Service (ASAPServiceMethods .STOP_BLUETOOTH );
200236 }
201237
238+ /**
239+ * Call this message to start Wifi direct.
240+ * Note: Wifi is not yet fully supported. Do not use this method yet.
241+ */
202242 public void startWifiP2P () {
203243 Log .d (this .getLogStart (), "send message to service: start Wifi P2P" );
204244 this .sendMessage2Service (ASAPServiceMethods .START_WIFI_DIRECT );
205245 }
206246
247+ /**
248+ * Call this message to stop Wifi direct.
249+ * Note: Wifi is not yet fully supported. Do not use this method yet.
250+ */
207251 public void stopWifiP2P () {
208252 Log .d (this .getLogStart (), "send message to service: stop Wifi P2P" );
209253 this .sendMessage2Service (ASAPServiceMethods .STOP_WIFI_DIRECT );
210254 }
211255
256+ /**
257+ * Call this message to make this device discoverable with Bluetooth.
258+ * asapNotifyBTDiscoverableStarted() is called later.
259+ * There is not matching stop method. Bluetooth discoverability is stopped after some time
260+ * from Android. asapNotifyBTDiscoverableStopped() is called in this case.
261+ *
262+ */
212263 public void startBluetoothDiscoverable () {
213264 Log .d (this .getLogStart (), "send message to service: start BT Discoverable" );
214265 this .sendMessage2Service (ASAPServiceMethods .START_BLUETOOTH_DISCOVERABLE );
215266 }
216267
268+ /**
269+ * Call this message to start Bluetooth discovery. This device will look for discoverable
270+ * Bluetooth devices.
271+ * asapNotifyBTDiscoveryStarted() is called later.
272+ * There is not matching stop method. Bluetooth discovery is stopped after some time
273+ * from Android. asapNotifyBTDiscoveryStopped() is called in this case.
274+ *
275+ */
217276 public void startBluetoothDiscovery () {
218277 Log .d (this .getLogStart (), "send message to service: start BT Discovery" );
219278 this .sendMessage2Service (ASAPServiceMethods .START_BLUETOOTH_DISCOVERY );
@@ -229,12 +288,12 @@ twice in the row (a.onStart() sometimes earlier, than b.onStart()) followed by
229288
230289 Solution: We only stop broadcasting if there if the last activity signs off.
231290 */
232- public void startASAPEngineBroadcasts () {
291+ private void startASAPEngineBroadcasts () {
233292 Log .d (this .getLogStart (), "send message to service: start ASAP Engine Broadcasts" );
234293 this .sendMessage2Service (ASAPServiceMethods .START_BROADCASTS );
235294 }
236295
237- public void stopASAPEngineBroadcasts () {
296+ private void stopASAPEngineBroadcasts () {
238297 if (this .getASAPApplication ().getNumberASAPActivities () == 1 ) {
239298 Log .d (this .getLogStart (), "send message to service: stop ASAP Engine Broadcasts" );
240299 this .sendMessage2Service (ASAPServiceMethods .STOP_BROADCASTS );
@@ -322,6 +381,7 @@ private void shutdownASAPChunkReceivedBroadcastReceiver() {
322381 */
323382
324383 /** currently, we have only two stats: on and off */
384+ @ CallSuper
325385 protected void onCreate (Bundle savedInstanceState ) {
326386 super .onCreate (savedInstanceState );
327387 Log .d (this .getLogStart (), "onCreate" );
@@ -435,37 +495,101 @@ public void onServiceDisconnected(ComponentName className) {
435495 }
436496 };
437497
498+ /**
499+ * Application developers can use this method like life-cycle methods in Android
500+ * (onStart() etc.). Overwrite this method to get informed about changes in environment.
501+ * Do not call this method yourself. Do not forget to call the super method if you overwrite.
502+ *
503+ * <br/><br/>
504+ * This method informs that this device is now a discoverable Bluetooth device
505+ */
438506 @ Override
507+ @ CallSuper
439508 public void asapNotifyBTDiscoverableStarted () {
440509 this .asapApplication .setBTDiscoverable (true );
441510 }
442511
512+ /**
513+ * Application developers can use this method like life-cycle methods in Android
514+ * (onStart() etc.). Overwrite this method to get informed about changes in environment.
515+ * Do not call this method yourself. Do not forget to call the super method if you overwrite.
516+ *
517+ * <br/><br/>
518+ * This method informs that this device is no longer a discoverable Bluetooth device
519+ */
443520 @ Override
521+ @ CallSuper
444522 public void asapNotifyBTDiscoverableStopped () {
445523 this .asapApplication .setBTDiscoverable (false );
446524 }
447525
526+ /**
527+ * Application developers can use this method like life-cycle methods in Android
528+ * (onStart() etc.). Overwrite this method to get informed about changes in environment.
529+ * Do not call this method yourself. Do not forget to call the super method if you overwrite.
530+ *
531+ * <br/><br/>
532+ * This method informs that bluetooth is enabled now.
533+ */
448534 @ Override
535+ @ CallSuper
449536 public void asapNotifyBTEnvironmentStarted () {
450537 this .asapApplication .setBTEnvironmentRunning (true );
451538 }
452539
540+ /**
541+ * Application developers can use this method like life-cycle methods in Android
542+ * (onStart() etc.). Overwrite this method to get informed about changes in environment.
543+ * Do not call this method yourself. Do not forget to call the super method if you overwrite.
544+ *
545+ * <br/><br/>
546+ * This method informs that bluetooth is disabled now.
547+ */
453548 @ Override
549+ @ CallSuper
454550 public void asapNotifyBTEnvironmentStopped () {
455551 this .asapApplication .setBTEnvironmentRunning (false );
456552 }
457553
554+ /**
555+ * Application developers can use this method like life-cycle methods in Android
556+ * (onStart() etc.). Overwrite this method to get informed about changes in environment.
557+ * Do not call this method yourself. Do not forget to call the super method if you overwrite.
558+ *
559+ * <br/><br/>
560+ * This method called whenever list of connected peers changed. This happens when
561+ * a connection is created or broken. The current list of peers comes as parameter.
562+ */
458563 @ Override
564+ @ CallSuper
459565 public void asapNotifyOnlinePeersChanged (List <CharSequence > peerList ) {
460566 this .asapApplication .setOnlinePeersList (peerList );
461567 }
462568
569+ /**
570+ * Application developers can use this method like life-cycle methods in Android
571+ * (onStart() etc.). Overwrite this method to get informed about changes in environment.
572+ * Do not call this method yourself. Do not forget to call the super method if you overwrite.
573+ *
574+ * <br/><br/>
575+ * This method informs that bluetooth discovery started.
576+ */
463577 @ Override
578+ @ CallSuper
464579 public void asapNotifyBTDiscoveryStarted () {
465580 this .asapApplication .setBTDiscovery (true );
466581 }
467582
583+ /**
584+ * Application developers can use this method like life-cycle methods in Android
585+ * (onStart() etc.). Overwrite this method to get informed about changes in environment.
586+ * Do not call this method yourself. Do not forget to call the super method if you overwrite.
587+ *
588+ * <br/><br/>
589+ * This method informs that bluetooth discovery stopped.
590+ */
468591 @ Override
592+ @ CallSuper
469593 public void asapNotifyBTDiscoveryStopped () {
470594 this .asapApplication .setBTDiscovery (false );
471595 }
@@ -474,14 +598,23 @@ public void asapNotifyBTDiscoveryStopped() {
474598 // status methods //
475599 ////////////////////////////////////////////////////////////////////////////////
476600
601+ /**
602+ * @return true if bluetooth environment is one.
603+ */
477604 public boolean isBluetoothEnvironmentOn () {
478605 return this .asapApplication .getBTEnvironmentRunning ();
479606 }
480607
608+ /**
609+ * @return true if this device is discoverable now.
610+ */
481611 public boolean isBluetoothDiscoverable () {
482612 return this .asapApplication .getBTDiscoverable ();
483613 }
484614
615+ /**
616+ * @return true if this device looking for other Bluetooth devices.
617+ */
485618 public boolean isBluetoothDiscovery () {
486619 return this .asapApplication .getBTDiscovery ();
487620 }
0 commit comments