Update notifications, and version number on the about box
This commit is contained in:
parent
6477be4c6c
commit
f3eca41937
@ -3,6 +3,19 @@
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:orientation="vertical" android:paddingLeft="5px">
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView android:text="@string/about_version"
|
||||
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||
android:textSize="16px" android:textColor="#ffffff" />
|
||||
|
||||
<TextView android:id="@+id/version" android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent" android:orientation="horizontal">
|
||||
|
||||
@ -15,23 +28,24 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView android:id="@+id/not" android:text=" "
|
||||
android:layout_width="wrap_content" android:layout_height="wrap_content" />
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView android:id="@+id/mail" android:text="@string/about_mail"
|
||||
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
||||
android:textSize="16px" android:autoLink="email" android:textColor="#ffffff" />
|
||||
android:textSize="16px" android:textColor="#ffffff" />
|
||||
|
||||
<TextView android:id="@+id/mailc" android:text="admin@f-droid.org"
|
||||
android:layout_width="wrap_content" android:layout_height="wrap_content" />
|
||||
android:autoLink="email" android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView android:id="@+id/about11" android:text="@string/about_desc"
|
||||
<TextView android:id="@+id/not" android:text=" "
|
||||
android:layout_width="wrap_content" android:layout_height="wrap_content" />
|
||||
|
||||
<TextView android:text="@string/about_desc"
|
||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||
android:textSize="16px" />
|
||||
|
||||
|
@ -2,10 +2,11 @@
|
||||
<resources>
|
||||
<string name="app_name">FDroid</string>
|
||||
<string name="about_title">About FDroid</string>
|
||||
<string name="about_desc">Based on Aptoide.\nReleased under the GNU GPL v2
|
||||
<string name="about_desc">Originally based on Aptoide.\nReleased under the GNU GPL v2
|
||||
license.</string>
|
||||
<string name="about_site">Home: </string>
|
||||
<string name="about_mail">e-Mail: </string>
|
||||
<string name="about_mail">Email: </string>
|
||||
<string name="about_version">Version: </string>
|
||||
<string name="about_website">Web Site</string>
|
||||
|
||||
|
||||
@ -44,20 +45,8 @@
|
||||
<string name="download">Download</string>
|
||||
<string name="download_server">Getting application from</string>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<string name="repo_add_url">Repository URL</string>
|
||||
|
||||
|
||||
|
||||
<string name="isinst">Installed: </string>
|
||||
|
||||
<string name="install">Install </string>
|
||||
|
@ -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<App> 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;
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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<DB.Repo> repos = db.getRepos();
|
||||
for (DB.Repo repo : repos) {
|
||||
@ -234,7 +235,7 @@ public class RepoXMLHandler extends DefaultHandler {
|
||||
|
||||
}
|
||||
}
|
||||
db.endUpdate();
|
||||
return db.endUpdate();
|
||||
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user