Installed apps by application label by default, and sort order can be chosen.
Also prevented crash due to lack of applicationLabel field.
This commit is contained in:
parent
584152d2fa
commit
60f5a1441c
@ -97,7 +97,7 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||||||
+ InstalledAppProvider.DataColumns.APPLICATION_LABEL + " TEXT NOT NULL "
|
+ InstalledAppProvider.DataColumns.APPLICATION_LABEL + " TEXT NOT NULL "
|
||||||
+ " );";
|
+ " );";
|
||||||
|
|
||||||
private static final int DB_VERSION = 45;
|
private static final int DB_VERSION = 46;
|
||||||
|
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
@ -250,12 +250,11 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||||||
addLastUpdatedToRepo(db, oldVersion);
|
addLastUpdatedToRepo(db, oldVersion);
|
||||||
renameRepoId(db, oldVersion);
|
renameRepoId(db, oldVersion);
|
||||||
populateRepoNames(db, oldVersion);
|
populateRepoNames(db, oldVersion);
|
||||||
upgradeInstalledApp(db, oldVersion);
|
|
||||||
|
|
||||||
if (oldVersion < 43) createInstalledApp(db);
|
if (oldVersion < 43) createInstalledApp(db);
|
||||||
|
addAppLabelToInstalledCache(db, oldVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Migrate repo list to new structure. (No way to change primary
|
* Migrate repo list to new structure. (No way to change primary
|
||||||
* key in sqlite - table must be recreated).
|
* key in sqlite - table must be recreated).
|
||||||
*/
|
*/
|
||||||
@ -400,11 +399,14 @@ public class DBHelper extends SQLiteOpenHelper {
|
|||||||
db.execSQL(CREATE_TABLE_INSTALLED_APP);
|
db.execSQL(CREATE_TABLE_INSTALLED_APP);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void upgradeInstalledApp(SQLiteDatabase db, int oldVersion) {
|
private void addAppLabelToInstalledCache(SQLiteDatabase db, int oldVersion) {
|
||||||
if (oldVersion < 45) {
|
if (oldVersion < 45) {
|
||||||
Log.i(TAG, "upgradeInstalledApp");
|
Log.i(TAG, "Adding applicationLabel to installed app table. " +
|
||||||
// just wipe it out, so it'll get rebuilt from scratch
|
"Turns out we will need to repopulate the cache after doing this, " +
|
||||||
db.execSQL("DELETE FROM fdroid_installedApp;");
|
"so just dropping and recreating the table (instead of altering and adding a column). " +
|
||||||
|
"This will force the entire cache to be rebuilt, including app names.");
|
||||||
|
db.execSQL("DROP TABLE fdroid_installedApp;");
|
||||||
|
createInstalledApp(db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,6 +118,10 @@ public class InstalledAppProvider extends FDroidProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Cursor query(Uri uri, String[] projection, String customSelection, String[] selectionArgs, String sortOrder) {
|
public Cursor query(Uri uri, String[] projection, String customSelection, String[] selectionArgs, String sortOrder) {
|
||||||
|
if (sortOrder == null) {
|
||||||
|
sortOrder = DataColumns.APPLICATION_LABEL;
|
||||||
|
}
|
||||||
|
|
||||||
QuerySelection selection = new QuerySelection(customSelection, selectionArgs);
|
QuerySelection selection = new QuerySelection(customSelection, selectionArgs);
|
||||||
switch (matcher.match(uri)) {
|
switch (matcher.match(uri)) {
|
||||||
case CODE_LIST:
|
case CODE_LIST:
|
||||||
@ -133,7 +137,7 @@ public class InstalledAppProvider extends FDroidProvider {
|
|||||||
throw new UnsupportedOperationException(message);
|
throw new UnsupportedOperationException(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
Cursor cursor = read().query(getTableName(), projection, selection.getSelection(), selection.getArgs(), null, null, null);
|
Cursor cursor = read().query(getTableName(), projection, selection.getSelection(), selection.getArgs(), null, null, sortOrder);
|
||||||
cursor.setNotificationUri(getContext().getContentResolver(), uri);
|
cursor.setNotificationUri(getContext().getContentResolver(), uri);
|
||||||
return cursor;
|
return cursor;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user