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:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||||
android:orientation="vertical" android:paddingLeft="5px">
|
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"
|
<LinearLayout android:layout_width="fill_parent"
|
||||||
android:layout_height="fill_parent" android:orientation="horizontal">
|
android:layout_height="fill_parent" android:orientation="horizontal">
|
||||||
|
|
||||||
@ -15,23 +28,24 @@
|
|||||||
|
|
||||||
</LinearLayout>
|
</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"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
android:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||||
android:orientation="horizontal">
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView android:id="@+id/mail" android:text="@string/about_mail"
|
<TextView android:id="@+id/mail" android:text="@string/about_mail"
|
||||||
android:layout_width="wrap_content" android:layout_height="wrap_content"
|
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"
|
<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>
|
</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:layout_width="fill_parent" android:layout_height="fill_parent"
|
||||||
android:textSize="16px" />
|
android:textSize="16px" />
|
||||||
|
|
||||||
|
@ -2,10 +2,11 @@
|
|||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">FDroid</string>
|
<string name="app_name">FDroid</string>
|
||||||
<string name="about_title">About 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>
|
license.</string>
|
||||||
<string name="about_site">Home: </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>
|
<string name="about_website">Web Site</string>
|
||||||
|
|
||||||
|
|
||||||
@ -44,20 +45,8 @@
|
|||||||
<string name="download">Download</string>
|
<string name="download">Download</string>
|
||||||
<string name="download_server">Getting application from</string>
|
<string name="download_server">Getting application from</string>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<string name="repo_add_url">Repository URL</string>
|
<string name="repo_add_url">Repository URL</string>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<string name="isinst">Installed: </string>
|
<string name="isinst">Installed: </string>
|
||||||
|
|
||||||
<string name="install">Install </string>
|
<string name="install">Install </string>
|
||||||
|
@ -399,6 +399,7 @@ public class DB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Vector<App> updateApps = null;
|
private Vector<App> updateApps = null;
|
||||||
|
private int updateNewUpdates;
|
||||||
|
|
||||||
// Called before a repo update starts.
|
// Called before a repo update starts.
|
||||||
public void beginUpdate() {
|
public void beginUpdate() {
|
||||||
@ -409,6 +410,7 @@ public class DB {
|
|||||||
// TODO: Need to ensure that UI and UpdateService can't both be doing
|
// TODO: Need to ensure that UI and UpdateService can't both be doing
|
||||||
// an update at the same time.
|
// an update at the same time.
|
||||||
updateApps = getApps(null, null, true);
|
updateApps = getApps(null, null, true);
|
||||||
|
updateNewUpdates = 0;
|
||||||
Log.d("FDroid", "AppUpdate: " + updateApps.size()
|
Log.d("FDroid", "AppUpdate: " + updateApps.size()
|
||||||
+ " apps before starting.");
|
+ " apps before starting.");
|
||||||
}
|
}
|
||||||
@ -416,7 +418,9 @@ public class DB {
|
|||||||
// Called when a repo update ends. Any applications that have not been
|
// Called when a repo update ends. Any applications that have not been
|
||||||
// updated (by a call to updateApplication) are assumed to be no longer
|
// updated (by a call to updateApplication) are assumed to be no longer
|
||||||
// in the repos.
|
// 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) {
|
for (App app : updateApps) {
|
||||||
if (!app.updated) {
|
if (!app.updated) {
|
||||||
// The application hasn't been updated, so it's no longer
|
// The application hasn't been updated, so it's no longer
|
||||||
@ -442,10 +446,12 @@ public class DB {
|
|||||||
Log.d("FDroid", "AppUpdate: " + updateApps.size()
|
Log.d("FDroid", "AppUpdate: " + updateApps.size()
|
||||||
+ " apps on completion.");
|
+ " apps on completion.");
|
||||||
updateApps = null;
|
updateApps = null;
|
||||||
|
return updateNewUpdates;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called during update to supply new details for an application (or
|
// 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) {
|
public void updateApplication(App upapp) {
|
||||||
|
|
||||||
if (updateApps == null) {
|
if (updateApps == null) {
|
||||||
@ -479,6 +485,8 @@ public class DB {
|
|||||||
updateApkIfDifferent(null, upapk);
|
updateApkIfDifferent(null, upapk);
|
||||||
upapk.updated = true;
|
upapk.updated = true;
|
||||||
app.apks.add(upapk);
|
app.apks.add(upapk);
|
||||||
|
if(!app.hasUpdates)
|
||||||
|
updateNewUpdates++;
|
||||||
app.hasUpdates = true;
|
app.hasUpdates = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,8 @@ import android.app.AlertDialog.Builder;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
@ -240,12 +242,24 @@ public class FDroid extends TabActivity implements OnItemClickListener {
|
|||||||
|
|
||||||
case PREFERENCES:
|
case PREFERENCES:
|
||||||
Intent prefs = new Intent(getBaseContext(), Preferences.class);
|
Intent prefs = new Intent(getBaseContext(), Preferences.class);
|
||||||
startActivityForResult(prefs,REQUEST_PREFS);
|
startActivityForResult(prefs, REQUEST_PREFS);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case ABOUT:
|
case ABOUT:
|
||||||
LayoutInflater li = LayoutInflater.from(this);
|
LayoutInflater li = LayoutInflater.from(this);
|
||||||
View view = li.inflate(R.layout.about, null);
|
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);
|
Builder p = new AlertDialog.Builder(this).setView(view);
|
||||||
final AlertDialog alrt = p.create();
|
final AlertDialog alrt = p.create();
|
||||||
alrt.setIcon(R.drawable.icon);
|
alrt.setIcon(R.drawable.icon);
|
||||||
@ -303,8 +317,10 @@ public class FDroid extends TabActivity implements OnItemClickListener {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case REQUEST_PREFS:
|
case REQUEST_PREFS:
|
||||||
// The automatic update settings may have changed, so reschedule (or unschedule) the
|
// The automatic update settings may have changed, so reschedule (or
|
||||||
// service accordingly. It's cheap, so no need to check if the particular setting has
|
// unschedule) the
|
||||||
|
// service accordingly. It's cheap, so no need to check if the
|
||||||
|
// particular setting has
|
||||||
// actually been changed.
|
// actually been changed.
|
||||||
UpdateService.schedule(getBaseContext());
|
UpdateService.schedule(getBaseContext());
|
||||||
populateLists(false);
|
populateLists(false);
|
||||||
@ -414,7 +430,6 @@ public class FDroid extends TabActivity implements OnItemClickListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handlers for thread functions that need to access GUI
|
* 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
|
// 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
|
// up a dialog that shows the details of the application and all its
|
||||||
// available versions, with buttons to allow installation etc.
|
// 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 LOCAL_PATH = "/sdcard/.fdroid";
|
||||||
private static String XML_PATH = LOCAL_PATH + "/repotemp.xml";
|
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();
|
db.beginUpdate();
|
||||||
Vector<DB.Repo> repos = db.getRepos();
|
Vector<DB.Repo> repos = db.getRepos();
|
||||||
for (DB.Repo repo : repos) {
|
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;
|
package org.fdroid.fdroid;
|
||||||
|
|
||||||
import android.app.AlarmManager;
|
import android.app.AlarmManager;
|
||||||
|
import android.app.Notification;
|
||||||
|
import android.app.NotificationManager;
|
||||||
import android.app.PendingIntent;
|
import android.app.PendingIntent;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -104,7 +106,28 @@ public class UpdateService extends Service {
|
|||||||
DB db = null;
|
DB db = null;
|
||||||
try {
|
try {
|
||||||
db = new DB(getBaseContext());
|
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) {
|
} catch (Exception e) {
|
||||||
Log.d("FDroid", "Exception during handleCommand() - "
|
Log.d("FDroid", "Exception during handleCommand() - "
|
||||||
+ e.getMessage());
|
+ e.getMessage());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user