diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index b4ae7cd49..9fb2fe575 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -407,9 +407,14 @@
+
+
+
diff --git a/app/src/main/java/org/fdroid/fdroid/AppDetails.java b/app/src/main/java/org/fdroid/fdroid/AppDetails.java
index 1e5001d54..c3c2ce1f3 100644
--- a/app/src/main/java/org/fdroid/fdroid/AppDetails.java
+++ b/app/src/main/java/org/fdroid/fdroid/AppDetails.java
@@ -574,7 +574,7 @@ public class AppDetails extends AppCompatActivity {
intent.getStringExtra(Installer.EXTRA_ERROR_MESSAGE);
if (!TextUtils.isEmpty(errorMessage)) {
- Log.e(TAG, "Installer aborted with errorMessage: " + errorMessage);
+ Log.e(TAG, "install aborted with errorMessage: " + errorMessage);
String title = String.format(
getString(R.string.install_error_notify_title),
@@ -629,7 +629,7 @@ public class AppDetails extends AppCompatActivity {
intent.getStringExtra(Installer.EXTRA_ERROR_MESSAGE);
if (!TextUtils.isEmpty(errorMessage)) {
- Log.e(TAG, "Installer aborted with errorMessage: " + errorMessage);
+ Log.e(TAG, "uninstall aborted with errorMessage: " + errorMessage);
AlertDialog.Builder alertBuilder = new AlertDialog.Builder(AppDetails.this);
alertBuilder.setTitle(R.string.uninstall_error_notify_title);
diff --git a/app/src/main/java/org/fdroid/fdroid/installer/ErrorDialogActivity.java b/app/src/main/java/org/fdroid/fdroid/installer/ErrorDialogActivity.java
new file mode 100644
index 000000000..9e38794e1
--- /dev/null
+++ b/app/src/main/java/org/fdroid/fdroid/installer/ErrorDialogActivity.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2016 Dominik Schürmann
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+
+package org.fdroid.fdroid.installer;
+
+import android.app.Activity;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v4.app.FragmentActivity;
+import android.support.v7.app.AlertDialog;
+import android.view.ContextThemeWrapper;
+
+import org.fdroid.fdroid.FDroidApp;
+
+public class ErrorDialogActivity extends FragmentActivity {
+
+ public static final String EXTRA_TITLE = "title";
+ public static final String EXTRA_MESSAGE = "message";
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ final Intent intent = getIntent();
+ final String title = intent.getStringExtra(EXTRA_TITLE);
+ final String message = intent.getStringExtra(EXTRA_MESSAGE);
+
+ // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
+ ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());
+
+ final AlertDialog.Builder builder = new AlertDialog.Builder(theme);
+ builder.setTitle(title);
+ builder.setNeutralButton(android.R.string.ok,
+ new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ setResult(Activity.RESULT_OK);
+ finish();
+ }
+ });
+ builder.setOnCancelListener(
+ new DialogInterface.OnCancelListener() {
+ @Override
+ public void onCancel(DialogInterface dialog) {
+ setResult(Activity.RESULT_CANCELED);
+ finish();
+ }
+ });
+ builder.setMessage(message);
+ builder.create().show();
+ }
+}
diff --git a/app/src/main/java/org/fdroid/fdroid/installer/InstallManagerService.java b/app/src/main/java/org/fdroid/fdroid/installer/InstallManagerService.java
index ee7df07db..9903ad188 100644
--- a/app/src/main/java/org/fdroid/fdroid/installer/InstallManagerService.java
+++ b/app/src/main/java/org/fdroid/fdroid/installer/InstallManagerService.java
@@ -284,9 +284,19 @@ public class InstallManagerService extends Service {
String errorMessage =
intent.getStringExtra(Installer.EXTRA_ERROR_MESSAGE);
+ // show notification if app details is not visible
if (!TextUtils.isEmpty(errorMessage)) {
App app = getAppFromActive(originatingUri.toString());
- notifyError(app, originatingUri.toString(), errorMessage, false);
+ String title = String.format(
+ getString(R.string.install_error_notify_title),
+ app.name);
+
+ // show notification if app details is not visible
+ if (AppDetails.isAppVisible(app.packageName)) {
+ cancelNotification(originatingUri.toString());
+ } else {
+ notifyError(originatingUri.toString(), title, errorMessage);
+ }
}
localBroadcastManager.unregisterReceiver(this);
@@ -379,19 +389,25 @@ public class InstallManagerService extends Service {
notificationManager.notify(downloadUrlId, notification);
}
- private void notifyError(App app, String urlString, String text, boolean uninstall) {
- String title;
- if (uninstall) {
- title = String.format(getString(R.string.uninstall_error_notify_title), app.name);
- } else {
- title = String.format(getString(R.string.install_error_notify_title), app.name);
- }
-
+ private void notifyError(String urlString, String title, String text) {
int downloadUrlId = urlString.hashCode();
+
+ Intent errorDialogIntent = new Intent(this, ErrorDialogActivity.class);
+ errorDialogIntent.putExtra(
+ ErrorDialogActivity.EXTRA_TITLE, title);
+ errorDialogIntent.putExtra(
+ ErrorDialogActivity.EXTRA_MESSAGE, text);
+ PendingIntent errorDialogPendingIntent = PendingIntent.getActivity(
+ getApplicationContext(),
+ downloadUrlId,
+ errorDialogIntent,
+ PendingIntent.FLAG_UPDATE_CURRENT);
+
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this)
.setAutoCancel(true)
.setContentTitle(title)
+ .setContentIntent(errorDialogPendingIntent)
.setSmallIcon(R.drawable.ic_issues)
.setContentText(text);
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);