@@ -302,27 +302,7 @@ public void onClick(DialogInterface dialog, int id) {
302
302
saveProject ();
303
303
break ;
304
304
case R .id .share_apk :
305
- Uri fileUri = Uri .fromFile (new File (toolkit .getApkDir () + "FlashCardTemplateApp_v2.0.apk" ));
306
- try {
307
- ArrayList <Uri > uris = new ArrayList <Uri >();
308
- Intent sendIntent = new Intent (Intent .ACTION_SEND_MULTIPLE );
309
- sendIntent .setType ("application/vnd.android.package-archive" );
310
- uris .add (fileUri );
311
- sendIntent .putParcelableArrayListExtra (Intent .EXTRA_STREAM , uris );
312
- startActivity (Intent .createChooser (sendIntent , null ));
313
-
314
-
315
- } catch (Exception e ) {
316
-
317
- ArrayList <Uri > uris = new ArrayList <Uri >();
318
- Intent sendIntent = new Intent (Intent .ACTION_SEND_MULTIPLE );
319
- sendIntent .setType ("application/zip" );
320
- uris .add (fileUri );
321
- sendIntent .putParcelableArrayListExtra (Intent .EXTRA_STREAM , uris );
322
- startActivity (Intent .createChooser (sendIntent , null ));
323
- }
324
- break ;
325
- case R .id .save_apk :
305
+
326
306
String savedFilePath = saveProject ();
327
307
if (savedFilePath == null || savedFilePath .length () == 0 ) {
328
308
return ;
@@ -333,6 +313,65 @@ public void onClick(DialogInterface dialog, int id) {
333
313
KeyStoreDetails keyStoreDetails = new KeyStoreDetails ("TestKeyStore.jks" , keyPassword , aliasName , aliaspassword );
334
314
SignerThread signer = new SignerThread (getApplicationContext (), selectedTemplate .getApkFilePath (), saveProject (), keyStoreDetails , selectedTemplate .getAssetsFilePath (), selectedTemplate .getAssetsFileName ());
335
315
316
+ mApkGenerationDialog = new MaterialDialog .Builder (TemplateEditor .this )
317
+ .title (R .string .apk_progress_dialog )
318
+ .content (R .string .apk_msg )
319
+ .cancelable (false )
320
+ .progress (true , 0 )
321
+ .show ();
322
+
323
+ signer .setSignerThreadListener (new SignerThread .OnSignComplete () {
324
+ @ Override
325
+ public void onSuccess (final String path ) {
326
+ Log .d (TAG , "APK generated" );
327
+ mApkGenerationDialog .dismiss ();
328
+
329
+ Uri fileUri = Uri .fromFile (new File (path ));
330
+ try {
331
+ ArrayList <Uri > uris = new ArrayList <Uri >();
332
+ Intent sendIntent = new Intent (Intent .ACTION_SEND_MULTIPLE );
333
+ sendIntent .setType ("application/vnd.android.package-archive" );
334
+ uris .add (fileUri );
335
+ sendIntent .putParcelableArrayListExtra (Intent .EXTRA_STREAM , uris );
336
+ startActivity (Intent .createChooser (sendIntent , null ));
337
+
338
+
339
+ } catch (Exception e ) {
340
+
341
+ ArrayList <Uri > uris = new ArrayList <Uri >();
342
+ Intent sendIntent = new Intent (Intent .ACTION_SEND_MULTIPLE );
343
+ sendIntent .setType ("application/zip" );
344
+ uris .add (fileUri );
345
+ sendIntent .putParcelableArrayListExtra (Intent .EXTRA_STREAM , uris );
346
+ startActivity (Intent .createChooser (sendIntent , null ));
347
+ }
348
+
349
+ }
350
+
351
+ @ Override
352
+ public void onFail (Exception e ) {
353
+ if (e != null ) {
354
+ e .printStackTrace ();
355
+ mApkGenerationDialog .dismiss ();
356
+ Toast .makeText (TemplateEditor .this , "Build unsuccessful" , Toast .LENGTH_SHORT ).show ();
357
+ }
358
+ }
359
+ });
360
+
361
+ signer .start ();
362
+
363
+ break ;
364
+ case R .id .save_apk :
365
+ savedFilePath = saveProject ();
366
+ if (savedFilePath == null || savedFilePath .length () == 0 ) {
367
+ return ;
368
+ }
369
+ keyPassword = getString (R .string .key_password );
370
+ aliasName = getString (R .string .alias_name );
371
+ aliaspassword = getString (R .string .alias_password );
372
+ keyStoreDetails = new KeyStoreDetails ("TestKeyStore.jks" , keyPassword , aliasName , aliaspassword );
373
+ signer = new SignerThread (getApplicationContext (), selectedTemplate .getApkFilePath (), saveProject (), keyStoreDetails , selectedTemplate .getAssetsFilePath (), selectedTemplate .getAssetsFileName ());
374
+
336
375
mApkGenerationDialog = new MaterialDialog .Builder (TemplateEditor .this )
337
376
.title (R .string .apk_progress_dialog )
338
377
.content (R .string .apk_msg )
0 commit comments