diff --git a/res/layout/about.xml b/res/layout/about.xml
index 2f7a96a78..bd486b308 100644
--- a/res/layout/about.xml
+++ b/res/layout/about.xml
@@ -3,6 +3,19 @@
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:paddingLeft="5px">
+
+
+
+
+
+
+
+
@@ -15,23 +28,24 @@
-
-
+ android:textSize="16px" android:textColor="#ffffff" />
+ android:autoLink="email" android:layout_width="wrap_content"
+ android:layout_height="wrap_content" />
-
+
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 8455cc4e5..0ec4983b4 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2,10 +2,11 @@
FDroid
About FDroid
- Based on Aptoide.\nReleased under the GNU GPL v2
+ Originally based on Aptoide.\nReleased under the GNU GPL v2
license.
Home:
- e-Mail:
+ Email:
+ Version:
Web Site
@@ -44,20 +45,8 @@
Download
Getting application from
-
-
-
-
-
-
-
-
-
-
Repository URL
-
-
Installed:
Install
diff --git a/src/org/fdroid/fdroid/DB.java b/src/org/fdroid/fdroid/DB.java
index f7ec3853a..990165e70 100644
--- a/src/org/fdroid/fdroid/DB.java
+++ b/src/org/fdroid/fdroid/DB.java
@@ -88,7 +88,7 @@ public class DB {
// explicitly ignored. (We're currently not using the database
// field for this - we make the decision on the fly in getApps().
public boolean hasUpdates;
-
+
// Used internally for tracking during repo updates.
public boolean updated;
@@ -399,6 +399,7 @@ public class DB {
}
private Vector updateApps = null;
+ private int updateNewUpdates;
// Called before a repo update starts.
public void beginUpdate() {
@@ -409,6 +410,7 @@ public class DB {
// TODO: Need to ensure that UI and UpdateService can't both be doing
// an update at the same time.
updateApps = getApps(null, null, true);
+ updateNewUpdates = 0;
Log.d("FDroid", "AppUpdate: " + updateApps.size()
+ " apps before starting.");
}
@@ -416,7 +418,9 @@ public class DB {
// Called when a repo update ends. Any applications that have not been
// updated (by a call to updateApplication) are assumed to be no longer
// in the repos.
- public void endUpdate() {
+ // Returns the number of new updates (installed applications for which
+ // there is a new version available)
+ public int endUpdate() {
for (App app : updateApps) {
if (!app.updated) {
// The application hasn't been updated, so it's no longer
@@ -442,10 +446,12 @@ public class DB {
Log.d("FDroid", "AppUpdate: " + updateApps.size()
+ " apps on completion.");
updateApps = null;
+ return updateNewUpdates;
}
// Called during update to supply new details for an application (or
- // details of a completely new one).
+ // details of a completely new one). Calls to this must be wrapped by
+ // a call to beginUpdate and a call to endUpdate.
public void updateApplication(App upapp) {
if (updateApps == null) {
@@ -479,6 +485,8 @@ public class DB {
updateApkIfDifferent(null, upapk);
upapk.updated = true;
app.apks.add(upapk);
+ if(!app.hasUpdates)
+ updateNewUpdates++;
app.hasUpdates = true;
}
}
diff --git a/src/org/fdroid/fdroid/FDroid.java b/src/org/fdroid/fdroid/FDroid.java
index b85bab5aa..bfae9dcea 100644
--- a/src/org/fdroid/fdroid/FDroid.java
+++ b/src/org/fdroid/fdroid/FDroid.java
@@ -34,6 +34,8 @@ import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
@@ -240,12 +242,24 @@ public class FDroid extends TabActivity implements OnItemClickListener {
case PREFERENCES:
Intent prefs = new Intent(getBaseContext(), Preferences.class);
- startActivityForResult(prefs,REQUEST_PREFS);
+ startActivityForResult(prefs, REQUEST_PREFS);
return true;
case ABOUT:
LayoutInflater li = LayoutInflater.from(this);
View view = li.inflate(R.layout.about, null);
+
+ // Fill in the version...
+ TextView tv = (TextView) view.findViewById(R.id.version);
+ PackageManager pm = getPackageManager();
+ PackageInfo pi;
+ try {
+ pi = pm.getPackageInfo(
+ getApplicationContext().getPackageName(), 0);
+ tv.setText(pi.versionName);
+ } catch (Exception e) {
+ }
+
Builder p = new AlertDialog.Builder(this).setView(view);
final AlertDialog alrt = p.create();
alrt.setIcon(R.drawable.icon);
@@ -303,8 +317,10 @@ public class FDroid extends TabActivity implements OnItemClickListener {
}
break;
case REQUEST_PREFS:
- // The automatic update settings may have changed, so reschedule (or unschedule) the
- // service accordingly. It's cheap, so no need to check if the particular setting has
+ // The automatic update settings may have changed, so reschedule (or
+ // unschedule) the
+ // service accordingly. It's cheap, so no need to check if the
+ // particular setting has
// actually been changed.
UpdateService.schedule(getBaseContext());
populateLists(false);
@@ -414,7 +430,6 @@ public class FDroid extends TabActivity implements OnItemClickListener {
}
}
-
/*
* Handlers for thread functions that need to access GUI
*/
@@ -427,7 +442,6 @@ public class FDroid extends TabActivity implements OnItemClickListener {
}
};
-
// Handler for a click on one of the items in an application list. Pops
// up a dialog that shows the details of the application and all its
// available versions, with buttons to allow installation etc.
diff --git a/src/org/fdroid/fdroid/RepoXMLHandler.java b/src/org/fdroid/fdroid/RepoXMLHandler.java
index d34d2f662..953191f7b 100644
--- a/src/org/fdroid/fdroid/RepoXMLHandler.java
+++ b/src/org/fdroid/fdroid/RepoXMLHandler.java
@@ -184,7 +184,8 @@ public class RepoXMLHandler extends DefaultHandler {
private static String LOCAL_PATH = "/sdcard/.fdroid";
private static String XML_PATH = LOCAL_PATH + "/repotemp.xml";
- public static void doUpdates(DB db) {
+ // Returns the number of applications with updates.
+ public static int doUpdates(DB db) {
db.beginUpdate();
Vector repos = db.getRepos();
for (DB.Repo repo : repos) {
@@ -234,7 +235,7 @@ public class RepoXMLHandler extends DefaultHandler {
}
}
- db.endUpdate();
+ return db.endUpdate();
}
diff --git a/src/org/fdroid/fdroid/UpdateService.java b/src/org/fdroid/fdroid/UpdateService.java
index a5330dace..19d551a35 100644
--- a/src/org/fdroid/fdroid/UpdateService.java
+++ b/src/org/fdroid/fdroid/UpdateService.java
@@ -19,6 +19,8 @@
package org.fdroid.fdroid;
import android.app.AlarmManager;
+import android.app.Notification;
+import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
import android.content.Context;
@@ -104,7 +106,28 @@ public class UpdateService extends Service {
DB db = null;
try {
db = new DB(getBaseContext());
- RepoXMLHandler.doUpdates(db);
+ int updateNum = RepoXMLHandler.doUpdates(db);
+
+ if (updateNum != 0) {
+ // We have updates.
+ if (prefs.getBoolean("updateNotify", false)) {
+ // And the user wants to know.
+ NotificationManager n = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
+ Notification notification = new Notification(
+ R.drawable.icon,
+ "FDroid Updates Available", System
+ .currentTimeMillis());
+ Context context = getApplicationContext();
+ CharSequence contentTitle = "FDroid";
+ CharSequence contentText = "Updates are available.";
+ Intent notificationIntent = new Intent(UpdateService.this, FDroid.class);
+ PendingIntent contentIntent = PendingIntent.getActivity(UpdateService.this, 0, notificationIntent, 0);
+ notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
+ notification.flags |= Notification.FLAG_AUTO_CANCEL;
+ n.notify(1, notification);
+ }
+ }
+
} catch (Exception e) {
Log.d("FDroid", "Exception during handleCommand() - "
+ e.getMessage());