Make notifications translatable, add updates count

This commit is contained in:
Daniel Martí 2013-05-07 19:36:46 +02:00
parent 445d6ca667
commit 21c56fe260
2 changed files with 17 additions and 7 deletions

View File

@ -65,6 +65,9 @@
<string name="tab_noninstalled">Available</string>
<string name="tab_updates">Updates</string>
<string name="update_available">Updates available</string>
<string name="one_update_available">1 update is available.</string>
<string name="many_updates_available">%d updates are available.</string>
<string name="fdroid_updates_available">F-Droid Updates Available</string>
<string name="process_wait_title">Please Wait</string>
<string name="process_update_msg">Updating application list...</string>
<string name="connection_error">Could not connect to the network.</string>

View File

@ -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);
}