Add name and description to repo, bump DB to v21
This commit is contained in:
parent
2834a8966e
commit
925c7c08d1
@ -1,6 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
|
<string name="default_repo_name" formatted="false">F-Droid</string>
|
||||||
|
<string name="default_repo_name2" formatted="false">F-Droid Archive</string>
|
||||||
<string name="default_repo_address" formatted="false">https://f-droid.org/repo</string>
|
<string name="default_repo_address" formatted="false">https://f-droid.org/repo</string>
|
||||||
<string name="default_repo_address2" formatted="false">https://f-droid.org/archive</string>
|
<string name="default_repo_address2" formatted="false">https://f-droid.org/archive</string>
|
||||||
|
<string name="default_repo_description" formatted="false">The official FDroid repository. Applications in this repository are mostly built directory from the source code. Some are official binaries built by the original application developers - these will be replaced by source-built versions over time.</string>
|
||||||
|
<string name="default_repo_description2" formatted="false">The archive repository of the F-Droid client. This contains older versions of applications from the main repository.</string>
|
||||||
<string name="default_repo_pubkey" formatted="false">3082035e30820246a00302010202044c49cd00300d06092a864886f70d01010505003071310b300906035504061302554b3110300e06035504081307556e6b6e6f776e3111300f0603550407130857657468657262793110300e060355040a1307556e6b6e6f776e3110300e060355040b1307556e6b6e6f776e311930170603550403131043696172616e2047756c746e69656b73301e170d3130303732333137313032345a170d3337313230383137313032345a3071310b300906035504061302554b3110300e06035504081307556e6b6e6f776e3111300f0603550407130857657468657262793110300e060355040a1307556e6b6e6f776e3110300e060355040b1307556e6b6e6f776e311930170603550403131043696172616e2047756c746e69656b7330820122300d06092a864886f70d01010105000382010f003082010a028201010096d075e47c014e7822c89fd67f795d23203e2a8843f53ba4e6b1bf5f2fd0e225938267cfcae7fbf4fe596346afbaf4070fdb91f66fbcdf2348a3d92430502824f80517b156fab00809bdc8e631bfa9afd42d9045ab5fd6d28d9e140afc1300917b19b7c6c4df4a494cf1f7cb4a63c80d734265d735af9e4f09455f427aa65a53563f87b336ca2c19d244fcbba617ba0b19e56ed34afe0b253ab91e2fdb1271f1b9e3c3232027ed8862a112f0706e234cf236914b939bcf959821ecb2a6c18057e070de3428046d94b175e1d89bd795e535499a091f5bc65a79d539a8d43891ec504058acb28c08393b5718b57600a211e803f4a634e5c57f25b9b8c4422c6fd90203010001300d06092a864886f70d0101050500038201010008e4ef699e9807677ff56753da73efb2390d5ae2c17e4db691d5df7a7b60fc071ae509c5414be7d5da74df2811e83d3668c4a0b1abc84b9fa7d96b4cdf30bba68517ad2a93e233b042972ac0553a4801c9ebe07bf57ebe9a3b3d6d663965260e50f3b8f46db0531761e60340a2bddc3426098397fda54044a17e5244549f9869b460ca5e6e216b6f6a2db0580b480ca2afe6ec6b46eedacfa4aa45038809ece0c5978653d6c85f678e7f5a2156d1bedd8117751e64a4b0dcd140f3040b021821a8d93aed8d01ba36db6c82372211fed714d9a32607038cdfd565bd529ffc637212aaa2c224ef22b603eccefb5bf1e085c191d4b24fe742b17ab3f55d4e6f05ef</string>
|
<string name="default_repo_pubkey" formatted="false">3082035e30820246a00302010202044c49cd00300d06092a864886f70d01010505003071310b300906035504061302554b3110300e06035504081307556e6b6e6f776e3111300f0603550407130857657468657262793110300e060355040a1307556e6b6e6f776e3110300e060355040b1307556e6b6e6f776e311930170603550403131043696172616e2047756c746e69656b73301e170d3130303732333137313032345a170d3337313230383137313032345a3071310b300906035504061302554b3110300e06035504081307556e6b6e6f776e3111300f0603550407130857657468657262793110300e060355040a1307556e6b6e6f776e3110300e060355040b1307556e6b6e6f776e311930170603550403131043696172616e2047756c746e69656b7330820122300d06092a864886f70d01010105000382010f003082010a028201010096d075e47c014e7822c89fd67f795d23203e2a8843f53ba4e6b1bf5f2fd0e225938267cfcae7fbf4fe596346afbaf4070fdb91f66fbcdf2348a3d92430502824f80517b156fab00809bdc8e631bfa9afd42d9045ab5fd6d28d9e140afc1300917b19b7c6c4df4a494cf1f7cb4a63c80d734265d735af9e4f09455f427aa65a53563f87b336ca2c19d244fcbba617ba0b19e56ed34afe0b253ab91e2fdb1271f1b9e3c3232027ed8862a112f0706e234cf236914b939bcf959821ecb2a6c18057e070de3428046d94b175e1d89bd795e535499a091f5bc65a79d539a8d43891ec504058acb28c08393b5718b57600a211e803f4a634e5c57f25b9b8c4422c6fd90203010001300d06092a864886f70d0101050500038201010008e4ef699e9807677ff56753da73efb2390d5ae2c17e4db691d5df7a7b60fc071ae509c5414be7d5da74df2811e83d3668c4a0b1abc84b9fa7d96b4cdf30bba68517ad2a93e233b042972ac0553a4801c9ebe07bf57ebe9a3b3d6d663965260e50f3b8f46db0531761e60340a2bddc3426098397fda54044a17e5244549f9869b460ca5e6e216b6f6a2db0580b480ca2afe6ec6b46eedacfa4aa45038809ece0c5978653d6c85f678e7f5a2156d1bedd8117751e64a4b0dcd140f3040b021821a8d93aed8d01ba36db6c82372211fed714d9a32607038cdfd565bd529ffc637212aaa2c224ef22b603eccefb5bf1e085c191d4b24fe742b17ab3f55d4e6f05ef</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -347,19 +347,21 @@ public class DB {
|
|||||||
private static final String TABLE_REPO = "fdroid_repo";
|
private static final String TABLE_REPO = "fdroid_repo";
|
||||||
private static final String CREATE_TABLE_REPO = "create table "
|
private static final String CREATE_TABLE_REPO = "create table "
|
||||||
+ TABLE_REPO + " (id integer primary key, address text not null, "
|
+ TABLE_REPO + " (id integer primary key, address text not null, "
|
||||||
+ "inuse integer not null, " + "priority integer not null,"
|
+ "name text, description text, inuse integer not null, "
|
||||||
+ "pubkey text, lastetag text);";
|
+ "priority integer not null, pubkey text, lastetag text);";
|
||||||
|
|
||||||
public static class Repo {
|
public static class Repo {
|
||||||
public int id;
|
public int id;
|
||||||
public String address;
|
public String address;
|
||||||
|
public String name;
|
||||||
|
public String description;
|
||||||
public boolean inuse;
|
public boolean inuse;
|
||||||
public int priority;
|
public int priority;
|
||||||
public String pubkey; // null for an unsigned repo
|
public String pubkey; // null for an unsigned repo
|
||||||
public String lastetag; // last etag we updated from, null forces update
|
public String lastetag; // last etag we updated from, null forces update
|
||||||
}
|
}
|
||||||
|
|
||||||
private final int DBVersion = 20;
|
private final int DBVersion = 21;
|
||||||
|
|
||||||
private static void createAppApk(SQLiteDatabase db) {
|
private static void createAppApk(SQLiteDatabase db) {
|
||||||
db.execSQL(CREATE_TABLE_APP);
|
db.execSQL(CREATE_TABLE_APP);
|
||||||
@ -377,6 +379,12 @@ public class DB {
|
|||||||
createAppApk(db);
|
createAppApk(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean columnExists(SQLiteDatabase db,
|
||||||
|
String table, String column) {
|
||||||
|
return (db.rawQuery( "select * from " + table + " limit 0,1", null )
|
||||||
|
.getColumnIndex(column) != -1);
|
||||||
|
}
|
||||||
|
|
||||||
private class DBHelper extends SQLiteOpenHelper {
|
private class DBHelper extends SQLiteOpenHelper {
|
||||||
|
|
||||||
public DBHelper(Context context) {
|
public DBHelper(Context context) {
|
||||||
@ -392,6 +400,10 @@ public class DB {
|
|||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put("address",
|
values.put("address",
|
||||||
mContext.getString(R.string.default_repo_address));
|
mContext.getString(R.string.default_repo_address));
|
||||||
|
values.put("name",
|
||||||
|
mContext.getString(R.string.default_repo_name));
|
||||||
|
values.put("description",
|
||||||
|
mContext.getString(R.string.default_repo_description));
|
||||||
values.put("pubkey",
|
values.put("pubkey",
|
||||||
mContext.getString(R.string.default_repo_pubkey));
|
mContext.getString(R.string.default_repo_pubkey));
|
||||||
values.put("inuse", 1);
|
values.put("inuse", 1);
|
||||||
@ -402,6 +414,10 @@ public class DB {
|
|||||||
values = new ContentValues();
|
values = new ContentValues();
|
||||||
values.put("address",
|
values.put("address",
|
||||||
mContext.getString(R.string.default_repo_address2));
|
mContext.getString(R.string.default_repo_address2));
|
||||||
|
values.put("name",
|
||||||
|
mContext.getString(R.string.default_repo_name2));
|
||||||
|
values.put("description",
|
||||||
|
mContext.getString(R.string.default_repo_description2));
|
||||||
values.put("pubkey",
|
values.put("pubkey",
|
||||||
mContext.getString(R.string.default_repo_pubkey));
|
mContext.getString(R.string.default_repo_pubkey));
|
||||||
values.put("inuse", 0);
|
values.put("inuse", 0);
|
||||||
@ -447,6 +463,23 @@ public class DB {
|
|||||||
// fields which didn't always exist.
|
// fields which didn't always exist.
|
||||||
resetTransient(db);
|
resetTransient(db);
|
||||||
|
|
||||||
|
if (oldVersion < 21) {
|
||||||
|
if (!columnExists(db, TABLE_REPO, "name"))
|
||||||
|
db.execSQL("alter table " + TABLE_REPO + " add column name text");
|
||||||
|
if (!columnExists(db, TABLE_REPO, "description"))
|
||||||
|
db.execSQL("alter table " + TABLE_REPO + " add column description text");
|
||||||
|
ContentValues values = new ContentValues();
|
||||||
|
values.put("name", mContext.getString(R.string.default_repo_name));
|
||||||
|
values.put("description", mContext.getString(R.string.default_repo_description));
|
||||||
|
db.update(TABLE_REPO, values, "address = ?", new String[] {
|
||||||
|
mContext.getString(R.string.default_repo_address) });
|
||||||
|
values.clear();
|
||||||
|
values.put("name", mContext.getString(R.string.default_repo_name2));
|
||||||
|
values.put("description", mContext.getString(R.string.default_repo_description2));
|
||||||
|
db.update(TABLE_REPO, values, "address = ?", new String[] {
|
||||||
|
mContext.getString(R.string.default_repo_address2) });
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1029,18 +1062,20 @@ public class DB {
|
|||||||
public Repo getRepo(int id) {
|
public Repo getRepo(int id) {
|
||||||
Cursor c = null;
|
Cursor c = null;
|
||||||
try {
|
try {
|
||||||
c = db.query(TABLE_REPO, new String[] { "address, inuse",
|
c = db.query(TABLE_REPO, new String[] { "address", "name",
|
||||||
"priority", "pubkey", "lastetag" },
|
"description", "inuse", "priority", "pubkey", "lastetag" },
|
||||||
"id = " + Integer.toString(id), null, null, null, null);
|
"id = " + Integer.toString(id), null, null, null, null);
|
||||||
if (!c.moveToFirst())
|
if (!c.moveToFirst())
|
||||||
return null;
|
return null;
|
||||||
Repo repo = new Repo();
|
Repo repo = new Repo();
|
||||||
repo.id = id;
|
repo.id = id;
|
||||||
repo.address = c.getString(0);
|
repo.address = c.getString(0);
|
||||||
repo.inuse = (c.getInt(1) == 1);
|
repo.name = c.getString(1);
|
||||||
repo.priority = c.getInt(2);
|
repo.description = c.getString(2);
|
||||||
repo.pubkey = c.getString(3);
|
repo.inuse = (c.getInt(3) == 1);
|
||||||
repo.lastetag = c.getString(4);
|
repo.priority = c.getInt(4);
|
||||||
|
repo.pubkey = c.getString(5);
|
||||||
|
repo.lastetag = c.getString(6);
|
||||||
return repo;
|
return repo;
|
||||||
} finally {
|
} finally {
|
||||||
if (c != null)
|
if (c != null)
|
||||||
@ -1053,18 +1088,20 @@ public class DB {
|
|||||||
List<Repo> repos = new ArrayList<Repo>();
|
List<Repo> repos = new ArrayList<Repo>();
|
||||||
Cursor c = null;
|
Cursor c = null;
|
||||||
try {
|
try {
|
||||||
c = db.rawQuery(
|
c = db.rawQuery("select id, address, name, description, inuse, "
|
||||||
"select id, address, inuse, priority, pubkey, lastetag from "
|
+ "priority, pubkey, lastetag from " + TABLE_REPO
|
||||||
+ TABLE_REPO + " order by priority", null);
|
+ " order by priority", null);
|
||||||
c.moveToFirst();
|
c.moveToFirst();
|
||||||
while (!c.isAfterLast()) {
|
while (!c.isAfterLast()) {
|
||||||
Repo repo = new Repo();
|
Repo repo = new Repo();
|
||||||
repo.id = c.getInt(0);
|
repo.id = c.getInt(0);
|
||||||
repo.address = c.getString(1);
|
repo.address = c.getString(1);
|
||||||
repo.inuse = (c.getInt(2) == 1);
|
repo.name = c.getString(2);
|
||||||
repo.priority = c.getInt(3);
|
repo.description = c.getString(3);
|
||||||
repo.pubkey = c.getString(4);
|
repo.inuse = (c.getInt(4) == 1);
|
||||||
repo.lastetag = c.getString(5);
|
repo.priority = c.getInt(5);
|
||||||
|
repo.pubkey = c.getString(6);
|
||||||
|
repo.lastetag = c.getString(7);
|
||||||
repos.add(repo);
|
repos.add(repo);
|
||||||
c.moveToNext();
|
c.moveToNext();
|
||||||
}
|
}
|
||||||
@ -1085,6 +1122,8 @@ public class DB {
|
|||||||
|
|
||||||
public void updateRepoByAddress(Repo repo) {
|
public void updateRepoByAddress(Repo repo) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
|
values.put("name", repo.name);
|
||||||
|
values.put("description", repo.description);
|
||||||
values.put("inuse", repo.inuse);
|
values.put("inuse", repo.inuse);
|
||||||
values.put("priority", repo.priority);
|
values.put("priority", repo.priority);
|
||||||
values.put("pubkey", repo.pubkey);
|
values.put("pubkey", repo.pubkey);
|
||||||
@ -1100,10 +1139,12 @@ public class DB {
|
|||||||
new String[] { repo.address });
|
new String[] { repo.address });
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRepo(String address, int priority, String pubkey,
|
public void addRepo(String address, String name, String description,
|
||||||
boolean inuse) {
|
int priority, String pubkey, boolean inuse) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
values.put("address", address);
|
values.put("address", address);
|
||||||
|
values.put("name", name);
|
||||||
|
values.put("description", description);
|
||||||
values.put("inuse", inuse ? 1 : 0);
|
values.put("inuse", inuse ? 1 : 0);
|
||||||
values.put("priority", priority);
|
values.put("priority", priority);
|
||||||
values.put("pubkey", pubkey);
|
values.put("pubkey", pubkey);
|
||||||
|
@ -182,7 +182,7 @@ public class ManageRepo extends ListActivity {
|
|||||||
String uri_str = uri.getText().toString();
|
String uri_str = uri.getText().toString();
|
||||||
try {
|
try {
|
||||||
DB db = DB.getDB();
|
DB db = DB.getDB();
|
||||||
db.addRepo(uri_str, 10, null, true);
|
db.addRepo(uri_str, null, null, 10, null, true);
|
||||||
} finally {
|
} finally {
|
||||||
DB.releaseDB();
|
DB.releaseDB();
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,8 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
private StringBuilder curchars = new StringBuilder();
|
private StringBuilder curchars = new StringBuilder();
|
||||||
|
|
||||||
private String pubkey;
|
private String pubkey;
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
private String hashType;
|
private String hashType;
|
||||||
|
|
||||||
private int progressCounter = 0;
|
private int progressCounter = 0;
|
||||||
@ -85,6 +87,8 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
this.repo = repo;
|
this.repo = repo;
|
||||||
this.apps = apps;
|
this.apps = apps;
|
||||||
pubkey = null;
|
pubkey = null;
|
||||||
|
name = null;
|
||||||
|
description = null;
|
||||||
progressListener = listener;
|
progressListener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,6 +252,12 @@ public class RepoXMLHandler extends DefaultHandler {
|
|||||||
String pk = attributes.getValue("", "pubkey");
|
String pk = attributes.getValue("", "pubkey");
|
||||||
if (pk != null)
|
if (pk != null)
|
||||||
pubkey = pk;
|
pubkey = pk;
|
||||||
|
String nm = attributes.getValue("", "name");
|
||||||
|
if (nm != null)
|
||||||
|
name = nm;
|
||||||
|
String dc = attributes.getValue("", "description");
|
||||||
|
if (dc != null)
|
||||||
|
description = dc;
|
||||||
} else if (localName.equals("application") && curapp == null) {
|
} else if (localName.equals("application") && curapp == null) {
|
||||||
curapp = new DB.App();
|
curapp = new DB.App();
|
||||||
curapp.detail_Populated = true;
|
curapp.detail_Populated = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user