Added the ability to have the actual apk file sourced from elsewhere

This commit is contained in:
Ciaran Gultnieks 2010-11-14 20:05:17 +00:00
parent a2c1b3da17
commit 55c06a203e
3 changed files with 32 additions and 16 deletions

View File

@ -401,8 +401,13 @@ public class AppDetails extends ListActivity {
// it...
if (apk_file == null) {
String remotefile = curapk.server + "/"
String remotefile;
if (curapk.apkSource == null) {
remotefile = curapk.server + "/"
+ apkname.replace(" ", "%20");
} else {
remotefile = curapk.apkSource;
}
Log.d("FDroid", "Downloading apk from " + remotefile);
Message msg = new Message();

View File

@ -31,7 +31,6 @@ import android.content.pm.PackageManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.util.Log;
public class DB {
@ -121,8 +120,7 @@ public class DB {
}
// The TABLE_APK table stores details of all the application versions we
// know
// about. Each relates directly back to an entry in TABLE_APP.
// know about. Each relates directly back to an entry in TABLE_APP.
// This information is retrieved from the repositories.
private static final String TABLE_APK = "fdroid_apk";
private static final String CREATE_TABLE_APK = "create table " + TABLE_APK
@ -136,6 +134,7 @@ public class DB {
public Apk() {
updated = false;
size = 0;
apkSource = null;
}
public String id;
@ -146,6 +145,11 @@ public class DB {
public String hash;
public String apkName;
// If null, the apk comes from the same server as the repo index.
// Otherwise
// this is the complete URL to download the apk from.
public String apkSource;
// Used internally for tracking during repo updates.
public boolean updated;
@ -186,7 +190,10 @@ public class DB {
// Version 2...
{ "alter table " + TABLE_APP + " add marketVersion text",
"alter table " + TABLE_APP + " add marketVercode integer" }
"alter table " + TABLE_APP + " add marketVercode integer" },
// Version 3...
{ "alter table " + TABLE_APK + " add apkSource text" }
};
@ -236,8 +243,8 @@ public class DB {
db = null;
}
// Delete the database, which should cause it to be re-created next time it's
// used.
// Delete the database, which should cause it to be re-created next time
// it's used.
public static void delete(Context ctx) {
try {
ctx.deleteDatabase(DATABASE_NAME);
@ -301,6 +308,7 @@ public class DB {
apk.hash = c2.getString(c2.getColumnIndex("hash"));
apk.size = c2.getInt(c2.getColumnIndex("size"));
apk.apkName = c2.getString(c2.getColumnIndex("apkName"));
apk.apkSource = c2.getString(c2.getColumnIndex("apkSource"));
app.apks.add(apk);
c2.moveToNext();
}
@ -522,6 +530,7 @@ public class DB {
values.put("hash", upapk.hash);
values.put("size", upapk.size);
values.put("apkName", upapk.apkName);
values.put("apkSource", upapk.apkSource);
if (oldapk != null) {
db.update(TABLE_APK, values, "id = '" + oldapk.id
+ "' and version = '" + oldapk.version + "'", null);

View File

@ -104,6 +104,8 @@ public class RepoXMLHandler extends DefaultHandler {
curapk.hash = str;
} else if (curel == "apkname") {
curapk.apkName = str;
} else if (curel == "apksource") {
curapk.apkSource = str;
}
} else if (curapp != null && str != null) {
if (curel == "id") {