1515import net .sharksystem .asap .ASAPEngine ;
1616import net .sharksystem .asap .ASAPEngineFS ;
1717import net .sharksystem .asap .ASAPException ;
18+ import net .sharksystem .asap .MultiASAPEngineFS ;
19+ import net .sharksystem .asap .MultiASAPEngineFS_Impl ;
1820import net .sharksystem .asap .android .ASAP ;
1921import net .sharksystem .asap .android .ASAPChunkReceivedBroadcastIntent ;
2022import net .sharksystem .asap .android .ASAPServiceCreationIntent ;
3638public class ASAPApplication extends BroadcastReceiver {
3739 private static final int MY_ASK_FOR_PERMISSIONS_REQUEST = 100 ;
3840 private static ASAPApplication singleton ;
41+ private final Collection <CharSequence > supportedFormats ;
3942 private CharSequence asapOwner ;
4043 private CharSequence rootFolder ;
4144 private boolean onlineExchange ;
@@ -54,16 +57,30 @@ public class ASAPApplication extends BroadcastReceiver {
5457 private List <CharSequence > onlinePeerList = new ArrayList <>();
5558
5659 /**
57- * setup application by calling getASAPOwner(), getFolderName(), getASAPOnlineExchange().
58- * Those messagen can and should be overwritten from actual implementations.
60+ * Setup application using default setting
61+ * @param supportedFormats ensure that asap engines using that formats are present -
62+ * create if necessary.
63+ */
64+ protected ASAPApplication (Collection <CharSequence > supportedFormats ) {
65+ this (supportedFormats , ASAP .UNKNOWN_USER , DEFAULT_ROOT_FOLDER_NAME ,
66+ ASAP .ONLINE_EXCHANGE_DEFAULT );
67+ }
68+
69+ /**
70+ * setup application without parameter. Use default for owner, root folder for asap storage
71+ * and online exchange behaviour. Don't setup any asap engine - take engines which are
72+ * already present when starting up.
5973 */
6074 protected ASAPApplication () {
61- this (ASAP .UNKNOWN_USER , DEFAULT_ROOT_FOLDER_NAME , ASAP .ONLINE_EXCHANGE_DEFAULT );
75+ this (null , ASAP .UNKNOWN_USER , DEFAULT_ROOT_FOLDER_NAME ,
76+ ASAP .ONLINE_EXCHANGE_DEFAULT );
6277 }
6378
64- protected ASAPApplication (CharSequence asapOwner ,
79+ protected ASAPApplication (Collection <CharSequence > supportedFormats ,
80+ CharSequence asapOwner ,
6581 CharSequence rootFolder ,
6682 boolean onlineExchange ) {
83+ this .supportedFormats = supportedFormats ;
6784 this .asapOwner = asapOwner ;
6885 this .rootFolder = rootFolder ;
6986 this .onlineExchange = onlineExchange ;
@@ -147,6 +164,10 @@ public CharSequence getASAPOwner() {
147164 return this .asapOwner ;
148165 }
149166
167+ public Collection <CharSequence > getSupportFormats () {
168+ return this .supportedFormats ;
169+ }
170+
150171 public static ASAPApplication getASAPApplication () {
151172 if (ASAPApplication .singleton == null ) {
152173 ASAPApplication .singleton = new ASAPApplication ();
@@ -155,6 +176,25 @@ public static ASAPApplication getASAPApplication() {
155176 return ASAPApplication .singleton ;
156177 }
157178
179+ public static ASAPApplication getASAPApplication (Collection <CharSequence > supportedFormats ) {
180+ if (ASAPApplication .singleton == null ) {
181+ ASAPApplication .singleton = new ASAPApplication (supportedFormats );
182+ }
183+
184+ return ASAPApplication .singleton ;
185+ }
186+
187+ public static ASAPApplication getASAPApplication (CharSequence supportedFormat ) {
188+
189+ if (ASAPApplication .singleton == null ) {
190+ Collection <CharSequence > formats = new HashSet <>();
191+ formats .add (supportedFormat );
192+ ASAPApplication .singleton = new ASAPApplication (formats );
193+ }
194+
195+ return ASAPApplication .singleton ;
196+ }
197+
158198 public String getApplicationRootFolder (String appName ) {
159199 return this .getASAPRootFolder () + "/" + appName ;
160200 }
0 commit comments