Skip to content

Commit d4019c2

Browse files
archie94opticod
authored andcommitted
Install from dialog (#408)
Add provision to install APK from Dialog window and Remove local notifications on APK generation
1 parent 6c95060 commit d4019c2

2 files changed

Lines changed: 10 additions & 28 deletions

File tree

source-code/app/src/main/java/org/buildmlearn/toolkit/activity/TemplateEditor.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,20 @@ public void onSuccess(final String path) {
194194
public void run() {
195195
AlertDialog dialog = new AlertDialog.Builder(TemplateEditor.this)
196196
.setTitle("Apk Generated")
197-
.setMessage("Apk file saved at " + path)
198-
.setPositiveButton("okay", new DialogInterface.OnClickListener() {
197+
.setMessage("Apk file saved at " + path + "\nFind it any time under Saved APKs\nInstall now?")
198+
.setNegativeButton("later", new DialogInterface.OnClickListener() {
199199
@Override
200200
public void onClick(DialogInterface dialog, int which) {
201201
dialog.dismiss();
202202
}
203+
}).setPositiveButton("install", new DialogInterface.OnClickListener(){
204+
@Override
205+
public void onClick(DialogInterface dialog, int which) {
206+
Intent intent = new Intent();
207+
intent.setAction(Intent.ACTION_VIEW);
208+
intent.setDataAndType(Uri.fromFile(new File(path)), "application/vnd.android.package-archive");
209+
startActivity(intent);
210+
}
203211
})
204212
.create();
205213
dialog.show();

source-code/app/src/main/java/org/buildmlearn/toolkit/utilities/SignerThread.java

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -244,12 +244,6 @@ public void run() {
244244
} else {
245245
Log.d(TAG, "Signing Complete");
246246
listener.onSuccess(finalApk);
247-
248-
if (toolkit.isExternalStorageAvailable()) {
249-
showNotification(context.getString(R.string.apk_file_saved));
250-
} else {
251-
showNotification(context.getString(R.string.sd_card_notfound));
252-
}
253247
}
254248

255249
} catch (AutoKeyException | UnrecoverableKeyException x) {
@@ -271,26 +265,6 @@ public void run() {
271265
}
272266
}
273267

274-
private void showNotification(String description) {
275-
Intent intent = new Intent();
276-
intent.setAction(Intent.ACTION_VIEW);
277-
File file = new File(finalApk);
278-
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
279-
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
280-
NotificationCompat.Builder mBuilder =
281-
new NotificationCompat.Builder(toolkit)
282-
.setSmallIcon(R.drawable.ic_stat_toggle_check_box)
283-
.setContentTitle(context.getString(R.string.apk_generated))
284-
.setContentText(description)
285-
.setContentIntent(pendingIntent)
286-
.setAutoCancel(true);
287-
288-
NotificationManager mNotificationManager =
289-
(NotificationManager) toolkit.getSystemService(Context.NOTIFICATION_SERVICE);
290-
// mId allows you to update the notification later on.
291-
mNotificationManager.notify(23, mBuilder.build());
292-
}
293-
294268
public interface OnSignComplete {
295269
void onSuccess(String path);
296270

0 commit comments

Comments
 (0)