diff --git a/src/org/fdroid/fdroid/AppDetails.java b/src/org/fdroid/fdroid/AppDetails.java index 3ddd1731e..6d9a70c4c 100644 --- a/src/org/fdroid/fdroid/AppDetails.java +++ b/src/org/fdroid/fdroid/AppDetails.java @@ -406,7 +406,7 @@ public class AppDetails extends ListActivity { // Set the icon... ImageView iv = (ImageView) findViewById(R.id.icon); - ImageLoader.getInstance().displayImage(app.repoAddress+"/icons/"+app.icon, iv); + ImageLoader.getInstance().displayImage(app.icon, iv); // Set the title and other header details... TextView tv = (TextView) findViewById(R.id.title); diff --git a/src/org/fdroid/fdroid/DB.java b/src/org/fdroid/fdroid/DB.java index 5ac435507..3aa3283f7 100644 --- a/src/org/fdroid/fdroid/DB.java +++ b/src/org/fdroid/fdroid/DB.java @@ -89,7 +89,7 @@ public class DB { private static final String TABLE_APP = "fdroid_app"; private static final String CREATE_TABLE_APP = "create table " + TABLE_APP + " ( " + "id text not null, " + "name text not null, " - + "summary text not null, " + "icon text, " + + "summary text not null, " + "description text not null, " + "license text not null, " + "webURL text, " + "trackerURL text, " + "sourceURL text, " + "curVersion text," + "curVercode integer," @@ -104,7 +104,7 @@ public class DB { public App() { name = "Unknown"; summary = "Unknown application"; - icon = "noicon.png"; + icon = null; id = "unknown"; license = "Unknown"; category = "Uncategorized"; @@ -124,7 +124,6 @@ public class DB { compatible = false; ignoreUpdates = false; filtered = false; - repoAddress = null; } // True when all the detail fields are populated, False otherwise. @@ -207,8 +206,6 @@ public class DB { // List of apks. public List apks; - public String repoAddress; - // Get the current version - this will be one of the Apks from 'apks'. // Can return null if there are no available versions. // This should be the 'current' version, as in the most recent stable @@ -426,7 +423,7 @@ public class DB { public String lastetag; // last etag we updated from, null forces update } - private final int DBVersion = 24; + private final int DBVersion = 25; private static void createAppApk(SQLiteDatabase db) { db.execSQL(CREATE_TABLE_APP); @@ -756,7 +753,7 @@ public class DB { try { String cols[] = new String[] { "antiFeatures", "requirements", - "id", "name", "summary", "icon", "license", "category", + "id", "name", "summary", "license", "category", "curVersion", "curVercode", "added", "lastUpdated", "compatible", "ignoreUpdates" }; c = db.query(TABLE_APP, cols, null, null, null, null, null); @@ -769,20 +766,19 @@ public class DB { app.id = c.getString(2); app.name = c.getString(3); app.summary = c.getString(4); - app.icon = c.getString(5); - app.license = c.getString(6); - app.category = c.getString(7); - app.curVersion = c.getString(8); - app.curVercode = c.getInt(9); - String sAdded = c.getString(10); + app.license = c.getString(5); + app.category = c.getString(6); + app.curVersion = c.getString(7); + app.curVercode = c.getInt(8); + String sAdded = c.getString(9); app.added = (sAdded == null || sAdded.length() == 0) ? null : mDateFormat.parse(sAdded); - String sLastUpdated = c.getString(11); + String sLastUpdated = c.getString(10); app.lastUpdated = (sLastUpdated == null || sLastUpdated .length() == 0) ? null : mDateFormat .parse(sLastUpdated); - app.compatible = c.getInt(12) == 1; - app.ignoreUpdates = c.getInt(13) == 1; + app.compatible = c.getInt(11) == 1; + app.ignoreUpdates = c.getInt(12) == 1; app.hasUpdates = false; if (getinstalledinfo && systemApks.containsKey(app.id)) { @@ -1221,7 +1217,6 @@ public class DB { values.put("id", upapp.id); values.put("name", upapp.name); values.put("summary", upapp.summary); - values.put("icon", upapp.icon); values.put("description", upapp.detail_description); values.put("license", upapp.license); values.put("category", upapp.category); diff --git a/src/org/fdroid/fdroid/FDroidApp.java b/src/org/fdroid/fdroid/FDroidApp.java index 58a97244c..3fc7f8d00 100644 --- a/src/org/fdroid/fdroid/FDroidApp.java +++ b/src/org/fdroid/fdroid/FDroidApp.java @@ -146,10 +146,18 @@ public class FDroidApp extends Application { try { DB db = DB.getDB(); apps = db.getApps(true); - for (DB.Repo repo : db.getRepos()) - for (DB.App app : apps) - if (repo.id == app.apks.get(0).repo) - app.repoAddress = repo.address; + + List repos = db.getRepos(); + for (DB.App app : apps) { + for (DB.Repo repo : repos) { + DB.Apk bestApk = app.apks.get(0); + if (repo.id == bestApk.repo) { + app.icon = repo.address + "/icons/" + + app.id + '.' + bestApk.vercode + ".png"; + break; + } + } + } } finally { DB.releaseDB(); @@ -158,6 +166,20 @@ public class FDroidApp extends Application { try { DB db = DB.getDB(); apps = db.refreshApps(apps, invalidApps); + + List repos = db.getRepos(); + for (DB.App app : apps) { + if (!invalidApps.contains(app.id)) continue; + for (DB.Repo repo : repos) { + DB.Apk bestApk = app.apks.get(0); + if (repo.id == bestApk.repo) { + app.icon = repo.address + "/icons/" + + app.id + '.' + bestApk.vercode + ".png"; + break; + } + } + } + invalidApps.clear(); } finally { DB.releaseDB(); diff --git a/src/org/fdroid/fdroid/RepoXMLHandler.java b/src/org/fdroid/fdroid/RepoXMLHandler.java index adcd64525..2861c5ad9 100644 --- a/src/org/fdroid/fdroid/RepoXMLHandler.java +++ b/src/org/fdroid/fdroid/RepoXMLHandler.java @@ -186,8 +186,6 @@ public class RepoXMLHandler extends DefaultHandler { curapp.id = str; } else if (curel.equals("name")) { curapp.name = str; - } else if (curel.equals("icon")) { - curapp.icon = str; } else if (curel.equals("description")) { // This is the old-style description. We'll read it // if present, to support old repos, but in newer diff --git a/src/org/fdroid/fdroid/views/AppListAdapter.java b/src/org/fdroid/fdroid/views/AppListAdapter.java index 79773158b..feb78a30c 100644 --- a/src/org/fdroid/fdroid/views/AppListAdapter.java +++ b/src/org/fdroid/fdroid/views/AppListAdapter.java @@ -75,7 +75,7 @@ abstract public class AppListAdapter extends BaseAdapter { summary.setText(app.summary); layoutSummary(summary); - ImageLoader.getInstance().displayImage(app.repoAddress+"/icons/"+app.icon, icon); + ImageLoader.getInstance().displayImage(app.icon, icon); int visibleOnCompact = compact ? View.VISIBLE : View.GONE; int notVisibleOnCompact = compact ? View.GONE : View.VISIBLE;