Replaced DBHelper.TABLE_APP with Schema.AppTable.NAME
This commit is contained in:
parent
14958d48e3
commit
d1ceb84af4
@ -14,6 +14,7 @@ import org.fdroid.fdroid.Preferences;
|
|||||||
import org.fdroid.fdroid.R;
|
import org.fdroid.fdroid.R;
|
||||||
import org.fdroid.fdroid.Utils;
|
import org.fdroid.fdroid.Utils;
|
||||||
import org.fdroid.fdroid.data.Schema.ApkTable;
|
import org.fdroid.fdroid.data.Schema.ApkTable;
|
||||||
|
import org.fdroid.fdroid.data.Schema.AppTable;
|
||||||
import org.fdroid.fdroid.data.Schema.AppTable.Cols;
|
import org.fdroid.fdroid.data.Schema.AppTable.Cols;
|
||||||
import org.fdroid.fdroid.data.Schema.RepoTable;
|
import org.fdroid.fdroid.data.Schema.RepoTable;
|
||||||
|
|
||||||
@ -165,7 +166,7 @@ public class AppProvider extends FDroidProvider {
|
|||||||
static final class UpgradeHelper {
|
static final class UpgradeHelper {
|
||||||
|
|
||||||
public static void updateIconUrls(Context context, SQLiteDatabase db) {
|
public static void updateIconUrls(Context context, SQLiteDatabase db) {
|
||||||
AppProvider.updateIconUrls(context, db, DBHelper.TABLE_APP, ApkTable.NAME);
|
AppProvider.updateIconUrls(context, db, AppTable.NAME, ApkTable.NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -523,7 +524,7 @@ public class AppProvider extends FDroidProvider {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String getTableName() {
|
protected String getTableName() {
|
||||||
return DBHelper.TABLE_APP;
|
return AppTable.NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getApkTableName() {
|
protected String getApkTableName() {
|
||||||
|
@ -10,6 +10,7 @@ import android.util.Log;
|
|||||||
import org.fdroid.fdroid.R;
|
import org.fdroid.fdroid.R;
|
||||||
import org.fdroid.fdroid.Utils;
|
import org.fdroid.fdroid.Utils;
|
||||||
import org.fdroid.fdroid.data.Schema.ApkTable;
|
import org.fdroid.fdroid.data.Schema.ApkTable;
|
||||||
|
import org.fdroid.fdroid.data.Schema.AppTable;
|
||||||
import org.fdroid.fdroid.data.Schema.RepoTable;
|
import org.fdroid.fdroid.data.Schema.RepoTable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -58,8 +59,7 @@ class DBHelper extends SQLiteOpenHelper {
|
|||||||
+ "primary key(id, vercode)"
|
+ "primary key(id, vercode)"
|
||||||
+ ");";
|
+ ");";
|
||||||
|
|
||||||
public static final String TABLE_APP = "fdroid_app";
|
private static final String CREATE_TABLE_APP = "CREATE TABLE " + AppTable.NAME
|
||||||
private static final String CREATE_TABLE_APP = "CREATE TABLE " + TABLE_APP
|
|
||||||
+ " ( "
|
+ " ( "
|
||||||
+ "id text not null, "
|
+ "id text not null, "
|
||||||
+ "name text not null, "
|
+ "name text not null, "
|
||||||
@ -456,19 +456,19 @@ class DBHelper extends SQLiteOpenHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addChangelogToApp(SQLiteDatabase db, int oldVersion) {
|
private void addChangelogToApp(SQLiteDatabase db, int oldVersion) {
|
||||||
if (oldVersion >= 48 || columnExists(db, TABLE_APP, "changelogURL")) {
|
if (oldVersion >= 48 || columnExists(db, AppTable.NAME, "changelogURL")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Utils.debugLog(TAG, "Adding changelogURL column to " + TABLE_APP);
|
Utils.debugLog(TAG, "Adding changelogURL column to " + AppTable.NAME);
|
||||||
db.execSQL("alter table " + TABLE_APP + " add column changelogURL text");
|
db.execSQL("alter table " + AppTable.NAME + " add column changelogURL text");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addIconUrlLargeToApp(SQLiteDatabase db, int oldVersion) {
|
private void addIconUrlLargeToApp(SQLiteDatabase db, int oldVersion) {
|
||||||
if (oldVersion >= 49 || columnExists(db, TABLE_APP, "iconUrlLarge")) {
|
if (oldVersion >= 49 || columnExists(db, AppTable.NAME, "iconUrlLarge")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Utils.debugLog(TAG, "Adding iconUrlLarge columns to " + TABLE_APP);
|
Utils.debugLog(TAG, "Adding iconUrlLarge columns to " + AppTable.NAME);
|
||||||
db.execSQL("alter table " + TABLE_APP + " add column iconUrlLarge text");
|
db.execSQL("alter table " + AppTable.NAME + " add column iconUrlLarge text");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateIconUrlLarge(SQLiteDatabase db, int oldVersion) {
|
private void updateIconUrlLarge(SQLiteDatabase db, int oldVersion) {
|
||||||
@ -484,13 +484,13 @@ class DBHelper extends SQLiteOpenHelper {
|
|||||||
if (oldVersion >= 53) {
|
if (oldVersion >= 53) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!columnExists(db, TABLE_APP, "author")) {
|
if (!columnExists(db, AppTable.NAME, "author")) {
|
||||||
Utils.debugLog(TAG, "Adding author column to " + TABLE_APP);
|
Utils.debugLog(TAG, "Adding author column to " + AppTable.NAME);
|
||||||
db.execSQL("alter table " + TABLE_APP + " add column author text");
|
db.execSQL("alter table " + AppTable.NAME + " add column author text");
|
||||||
}
|
}
|
||||||
if (!columnExists(db, TABLE_APP, "email")) {
|
if (!columnExists(db, AppTable.NAME, "email")) {
|
||||||
Utils.debugLog(TAG, "Adding email column to " + TABLE_APP);
|
Utils.debugLog(TAG, "Adding email column to " + AppTable.NAME);
|
||||||
db.execSQL("alter table " + TABLE_APP + " add column email text");
|
db.execSQL("alter table " + AppTable.NAME + " add column email text");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -540,7 +540,7 @@ class DBHelper extends SQLiteOpenHelper {
|
|||||||
}
|
}
|
||||||
context.getSharedPreferences("FDroid", Context.MODE_PRIVATE).edit()
|
context.getSharedPreferences("FDroid", Context.MODE_PRIVATE).edit()
|
||||||
.putBoolean("triedEmptyUpdate", false).commit();
|
.putBoolean("triedEmptyUpdate", false).commit();
|
||||||
db.execSQL("drop table " + TABLE_APP);
|
db.execSQL("drop table " + AppTable.NAME);
|
||||||
db.execSQL("drop table " + ApkTable.NAME);
|
db.execSQL("drop table " + ApkTable.NAME);
|
||||||
clearRepoEtags(db);
|
clearRepoEtags(db);
|
||||||
createAppApk(db);
|
createAppApk(db);
|
||||||
@ -548,7 +548,7 @@ class DBHelper extends SQLiteOpenHelper {
|
|||||||
|
|
||||||
private static void createAppApk(SQLiteDatabase db) {
|
private static void createAppApk(SQLiteDatabase db) {
|
||||||
db.execSQL(CREATE_TABLE_APP);
|
db.execSQL(CREATE_TABLE_APP);
|
||||||
db.execSQL("create index app_id on " + TABLE_APP + " (id);");
|
db.execSQL("create index app_id on " + AppTable.NAME + " (id);");
|
||||||
db.execSQL(CREATE_TABLE_APK);
|
db.execSQL(CREATE_TABLE_APK);
|
||||||
db.execSQL("create index apk_vercode on " + ApkTable.NAME + " (vercode);");
|
db.execSQL("create index apk_vercode on " + ApkTable.NAME + " (vercode);");
|
||||||
db.execSQL("create index apk_id on " + ApkTable.NAME + " (id);");
|
db.execSQL("create index apk_id on " + ApkTable.NAME + " (id);");
|
||||||
|
@ -11,7 +11,7 @@ public interface Schema {
|
|||||||
|
|
||||||
interface AppTable {
|
interface AppTable {
|
||||||
|
|
||||||
String NAME = DBHelper.TABLE_APP;
|
String NAME = "fdroid_app";
|
||||||
|
|
||||||
interface Cols {
|
interface Cols {
|
||||||
String _ID = "rowid as _id"; // Required for CursorLoaders
|
String _ID = "rowid as _id"; // Required for CursorLoaders
|
||||||
@ -76,7 +76,9 @@ public interface Schema {
|
|||||||
* This information is retrieved from the repositories.
|
* This information is retrieved from the repositories.
|
||||||
*/
|
*/
|
||||||
interface ApkTable {
|
interface ApkTable {
|
||||||
|
|
||||||
String NAME = "fdroid_apk";
|
String NAME = "fdroid_apk";
|
||||||
|
|
||||||
interface Cols extends BaseColumns {
|
interface Cols extends BaseColumns {
|
||||||
String _COUNT_DISTINCT_ID = "countDistinct";
|
String _COUNT_DISTINCT_ID = "countDistinct";
|
||||||
|
|
||||||
@ -112,7 +114,9 @@ public interface Schema {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface RepoTable {
|
interface RepoTable {
|
||||||
|
|
||||||
String NAME = "fdroid_repo";
|
String NAME = "fdroid_repo";
|
||||||
|
|
||||||
interface Cols extends BaseColumns {
|
interface Cols extends BaseColumns {
|
||||||
|
|
||||||
String ADDRESS = "address";
|
String ADDRESS = "address";
|
||||||
|
@ -8,6 +8,7 @@ import android.database.sqlite.SQLiteException;
|
|||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
|
||||||
import org.fdroid.fdroid.data.Schema.ApkTable;
|
import org.fdroid.fdroid.data.Schema.ApkTable;
|
||||||
|
import org.fdroid.fdroid.data.Schema.AppTable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class does all of its operations in a temporary sqlite table.
|
* This class does all of its operations in a temporary sqlite table.
|
||||||
@ -21,7 +22,7 @@ public class TempAppProvider extends AppProvider {
|
|||||||
|
|
||||||
private static final String PROVIDER_NAME = "TempAppProvider";
|
private static final String PROVIDER_NAME = "TempAppProvider";
|
||||||
|
|
||||||
private static final String TABLE_TEMP_APP = "temp_" + DBHelper.TABLE_APP;
|
private static final String TABLE_TEMP_APP = "temp_" + AppTable.NAME;
|
||||||
|
|
||||||
private static final String PATH_INIT = "init";
|
private static final String PATH_INIT = "init";
|
||||||
private static final String PATH_COMMIT = "commit";
|
private static final String PATH_COMMIT = "commit";
|
||||||
@ -129,7 +130,7 @@ public class TempAppProvider extends AppProvider {
|
|||||||
final SQLiteDatabase db = db();
|
final SQLiteDatabase db = db();
|
||||||
ensureTempTableDetached(db);
|
ensureTempTableDetached(db);
|
||||||
db.execSQL("ATTACH DATABASE ':memory:' AS " + DB);
|
db.execSQL("ATTACH DATABASE ':memory:' AS " + DB);
|
||||||
db.execSQL("CREATE TABLE " + DB + "." + getTableName() + " AS SELECT * FROM main." + DBHelper.TABLE_APP);
|
db.execSQL("CREATE TABLE " + DB + "." + getTableName() + " AS SELECT * FROM main." + AppTable.NAME);
|
||||||
db.execSQL("CREATE INDEX IF NOT EXISTS " + DB + ".app_id ON " + getTableName() + " (id);");
|
db.execSQL("CREATE INDEX IF NOT EXISTS " + DB + ".app_id ON " + getTableName() + " (id);");
|
||||||
db.execSQL("CREATE INDEX IF NOT EXISTS " + DB + ".app_upstreamVercode ON " + getTableName() + " (upstreamVercode);");
|
db.execSQL("CREATE INDEX IF NOT EXISTS " + DB + ".app_upstreamVercode ON " + getTableName() + " (upstreamVercode);");
|
||||||
db.execSQL("CREATE INDEX IF NOT EXISTS " + DB + ".app_compatible ON " + getTableName() + " (compatible);");
|
db.execSQL("CREATE INDEX IF NOT EXISTS " + DB + ".app_compatible ON " + getTableName() + " (compatible);");
|
||||||
@ -143,8 +144,8 @@ public class TempAppProvider extends AppProvider {
|
|||||||
final String tempApp = DB + "." + TempAppProvider.TABLE_TEMP_APP;
|
final String tempApp = DB + "." + TempAppProvider.TABLE_TEMP_APP;
|
||||||
final String tempApk = DB + "." + TempApkProvider.TABLE_TEMP_APK;
|
final String tempApk = DB + "." + TempApkProvider.TABLE_TEMP_APK;
|
||||||
|
|
||||||
db.execSQL("DELETE FROM " + DBHelper.TABLE_APP + " WHERE 1");
|
db.execSQL("DELETE FROM " + AppTable.NAME + " WHERE 1");
|
||||||
db.execSQL("INSERT INTO " + DBHelper.TABLE_APP + " SELECT * FROM " + tempApp);
|
db.execSQL("INSERT INTO " + AppTable.NAME + " SELECT * FROM " + tempApp);
|
||||||
|
|
||||||
db.execSQL("DELETE FROM " + ApkTable.NAME + " WHERE 1");
|
db.execSQL("DELETE FROM " + ApkTable.NAME + " WHERE 1");
|
||||||
db.execSQL("INSERT INTO " + ApkTable.NAME + " SELECT * FROM " + tempApk);
|
db.execSQL("INSERT INTO " + ApkTable.NAME + " SELECT * FROM " + tempApk);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user