From 21c56fe260516ad2c91e3021ed98514164b06beb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Tue, 7 May 2013 19:36:46 +0200 Subject: [PATCH 1/4] Make notifications translatable, add updates count --- res/values/strings.xml | 3 +++ src/org/fdroid/fdroid/UpdateService.java | 21 ++++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 6aaea9f89..d14d63846 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -65,6 +65,9 @@ Available Updates Updates available + 1 update is available. + %d updates are available. + F-Droid Updates Available Please Wait Updating application list... Could not connect to the network. diff --git a/src/org/fdroid/fdroid/UpdateService.java b/src/org/fdroid/fdroid/UpdateService.java index 8b02eb6d0..9228bad0f 100644 --- a/src/org/fdroid/fdroid/UpdateService.java +++ b/src/org/fdroid/fdroid/UpdateService.java @@ -254,20 +254,27 @@ public class UpdateService extends IntentService implements ProgressListener { Log.d("FDroid", "Notifying updates. Apps before:" + prevUpdates + ", apps after: " + newUpdates); if (newUpdates > prevUpdates) { - NotificationManager n = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); - Notification notification = new Notification( - R.drawable.icon, "F-Droid Updates Available", + NotificationManager n = (NotificationManager) getSystemService( + Context.NOTIFICATION_SERVICE); + Notification notification = new Notification(R.drawable.icon, + getString(R.string.fdroid_updates_available), System.currentTimeMillis()); Context context = getApplicationContext(); - CharSequence contentTitle = "F-Droid"; - CharSequence contentText = "Updates are available."; Intent notificationIntent = new Intent(UpdateService.this, FDroid.class); notificationIntent.putExtra(FDroid.EXTRA_TAB_UPDATE, true); PendingIntent contentIntent = PendingIntent.getActivity( UpdateService.this, 0, notificationIntent, 0); - notification.setLatestEventInfo(context, contentTitle, - contentText, contentIntent); + CharSequence notification_text; + if (newUpdates > 1) + notification_text = getString( + R.string.many_updates_available, newUpdates); + else + notification_text = getString( + R.string.one_update_available); + notification.setLatestEventInfo(context, + getString(R.string.app_name), + notification_text, contentIntent); notification.flags |= Notification.FLAG_AUTO_CANCEL; n.notify(1, notification); } From f4a7aa7ced9a0c1aab1a9e892d1ea27f2d3fe626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Tue, 7 May 2013 19:55:08 +0200 Subject: [PATCH 2/4] Use vercodes, not version strings! Different versions might have the same names, but different codes. That doesn't happen often, but could happen. --- src/org/fdroid/fdroid/AppDetails.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/org/fdroid/fdroid/AppDetails.java b/src/org/fdroid/fdroid/AppDetails.java index acf560e24..f0819cdf0 100644 --- a/src/org/fdroid/fdroid/AppDetails.java +++ b/src/org/fdroid/fdroid/AppDetails.java @@ -473,8 +473,8 @@ public class AppDetails extends ListActivity { @Override protected void onListItemClick(ListView l, View v, int position, long id) { curapk = app.apks.get(position - l.getHeaderViewsCount()); - if (app.installedVersion != null - && app.installedVersion.equals(curapk.version)) { + if (app.installedVerCode != 0 + && app.installedVerCode == curapk.vercode) { removeApk(app.id); } else { install(); From 24c2b9731c2b3d339fa8fd808365f1b306377bbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Tue, 7 May 2013 20:08:11 +0200 Subject: [PATCH 3/4] toast lengths, no need to check vercode != 0 --- src/org/fdroid/fdroid/AppDetails.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/org/fdroid/fdroid/AppDetails.java b/src/org/fdroid/fdroid/AppDetails.java index f0819cdf0..2b0882beb 100644 --- a/src/org/fdroid/fdroid/AppDetails.java +++ b/src/org/fdroid/fdroid/AppDetails.java @@ -473,12 +473,10 @@ public class AppDetails extends ListActivity { @Override protected void onListItemClick(ListView l, View v, int position, long id) { curapk = app.apks.get(position - l.getHeaderViewsCount()); - if (app.installedVerCode != 0 - && app.installedVerCode == curapk.vercode) { + if (app.installedVerCode == curapk.vercode) removeApk(app.id); - } else { + else install(); - } } @Override @@ -539,7 +537,7 @@ public class AppDetails extends ListActivity { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(s))); } catch (android.content.ActivityNotFoundException e) { Toast toast = Toast.makeText(this, - getString(R.string.no_handler_app, s), 4); + getString(R.string.no_handler_app, s), Toast.LENGTH_LONG); toast.show(); } } From f5dc1ddc96b72b7db02ae67f6de911f99beba7a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Mart=C3=AD?= Date: Thu, 9 May 2013 11:42:20 +0200 Subject: [PATCH 4/4] Alert before trying to downgrade --- res/values/strings.xml | 1 + src/org/fdroid/fdroid/AppDetails.java | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index d14d63846..0fae56971 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -5,6 +5,7 @@ No applications were found matching \'%s\' The new version is signed with a different key to the old one. To install the new version, the old one must be uninstalled first. Please do this and try again. (Note that uninstalling will erase any internal data stored by the application) Android says this package is not compatible with your device. Do you want to try and install it anyway? + You are trying to downgrade this application. Doing so might get it to malfunction and even lose your data. Do you want to try and downgrade it anyway? Version %d versions available %d version available diff --git a/src/org/fdroid/fdroid/AppDetails.java b/src/org/fdroid/fdroid/AppDetails.java index 2b0882beb..b5e301171 100644 --- a/src/org/fdroid/fdroid/AppDetails.java +++ b/src/org/fdroid/fdroid/AppDetails.java @@ -475,7 +475,26 @@ public class AppDetails extends ListActivity { curapk = app.apks.get(position - l.getHeaderViewsCount()); if (app.installedVerCode == curapk.vercode) removeApk(app.id); - else + else if (app.installedVerCode > curapk.vercode) { + AlertDialog.Builder ask_alrt = new AlertDialog.Builder(this); + ask_alrt.setMessage(getString(R.string.installDowngrade)); + ask_alrt.setPositiveButton(getString(R.string.yes), + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int whichButton) { + install(); + } + }); + ask_alrt.setNegativeButton(getString(R.string.no), + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int whichButton) { + return; + } + }); + AlertDialog alert = ask_alrt.create(); + alert.show(); + } else install(); }