diff options
5 files changed, 39 insertions, 13 deletions
diff --git a/WallpaperPicker/src/com/android/launcher3/SavedWallpaperImages.java b/WallpaperPicker/src/com/android/launcher3/SavedWallpaperImages.java index 2bdf8f1cd..9f92bc105 100644 --- a/WallpaperPicker/src/com/android/launcher3/SavedWallpaperImages.java +++ b/WallpaperPicker/src/com/android/launcher3/SavedWallpaperImages.java @@ -180,7 +180,6 @@ public class SavedWallpaperImages extends BaseAdapter implements ListAdapter { static class ImageDb extends SQLiteOpenHelper { final static int DB_VERSION = 1; - final static String DB_NAME = "saved_wallpaper_images.db"; final static String TABLE_NAME = "saved_wallpaper_images"; final static String COLUMN_ID = "id"; final static String COLUMN_IMAGE_THUMBNAIL_FILENAME = "image_thumbnail"; @@ -189,7 +188,8 @@ public class SavedWallpaperImages extends BaseAdapter implements ListAdapter { Context mContext; public ImageDb(Context context) { - super(context, context.getDatabasePath(DB_NAME).getPath(), null, DB_VERSION); + super(context, context.getDatabasePath(LauncherFiles.WALLPAPER_IMAGES_DB).getPath(), + null, DB_VERSION); // Store the context for later use mContext = context; } @@ -197,8 +197,9 @@ public class SavedWallpaperImages extends BaseAdapter implements ListAdapter { public static void moveFromCacheDirectoryIfNecessary(Context context) { // We used to store the saved images in the cache directory, but that meant they'd get // deleted sometimes-- move them to the data directory - File oldSavedImagesFile = new File(context.getCacheDir(), ImageDb.DB_NAME); - File savedImagesFile = context.getDatabasePath(ImageDb.DB_NAME); + File oldSavedImagesFile = new File(context.getCacheDir(), + LauncherFiles.WALLPAPER_IMAGES_DB); + File savedImagesFile = context.getDatabasePath(LauncherFiles.WALLPAPER_IMAGES_DB); if (oldSavedImagesFile.exists()) { oldSavedImagesFile.renameTo(savedImagesFile); } diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 678081286..4a39e0ae5 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -168,7 +168,6 @@ public class Launcher extends Activity static final int SCREEN_COUNT = 5; static final int DEFAULT_SCREEN = 2; - private static final String PREFERENCES = "launcher.preferences"; // To turn on these properties, type // adb shell setprop log.tag.PROPERTY_NAME [VERBOSE | SUPPRESS] static final String FORCE_ENABLE_ROTATION_PROPERTY = "launcher_force_rotate"; @@ -620,7 +619,7 @@ public class Launcher extends Activity private static void readConfiguration(Context context, LocaleConfiguration configuration) { DataInputStream in = null; try { - in = new DataInputStream(context.openFileInput(PREFERENCES)); + in = new DataInputStream(context.openFileInput(LauncherFiles.LAUNCHER_PREFS)); configuration.locale = in.readUTF(); configuration.mcc = in.readInt(); configuration.mnc = in.readInt(); @@ -642,7 +641,8 @@ public class Launcher extends Activity private static void writeConfiguration(Context context, LocaleConfiguration configuration) { DataOutputStream out = null; try { - out = new DataOutputStream(context.openFileOutput(PREFERENCES, MODE_PRIVATE)); + out = new DataOutputStream(context.openFileOutput( + LauncherFiles.LAUNCHER_PREFS, MODE_PRIVATE)); out.writeUTF(configuration.locale); out.writeInt(configuration.mcc); out.writeInt(configuration.mnc); @@ -651,7 +651,7 @@ public class Launcher extends Activity // Ignore } catch (IOException e) { //noinspection ResultOfMethodCallIgnored - context.getFileStreamPath(PREFERENCES).delete(); + context.getFileStreamPath(LauncherFiles.LAUNCHER_PREFS).delete(); } finally { if (out != null) { try { diff --git a/src/com/android/launcher3/LauncherFiles.java b/src/com/android/launcher3/LauncherFiles.java new file mode 100644 index 000000000..89600c2df --- /dev/null +++ b/src/com/android/launcher3/LauncherFiles.java @@ -0,0 +1,27 @@ +package com.android.launcher3; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * Central list of files the Launcher writes to the application data directory. + * + * To add a new Launcher file, create a String constant referring to the filename, and add it to + * ALL_FILES, as shown below. + */ +public class LauncherFiles { + + public static final String SHARED_PREFS = "com.android.launcher3.prefs.xml"; + public static final String LAUNCHER_DB = "launcher.db"; + public static final String LAUNCHER_PREFS = "launcher.preferences"; + public static final String WALLPAPER_IMAGES_DB = "saved_wallpaper_images.db"; + public static final String WIDGET_PREVIEWS_DB = "widgetpreviews.db"; + + public static final List<String> ALL_FILES = Collections.unmodifiableList(Arrays.asList( + SHARED_PREFS, + LAUNCHER_DB, + LAUNCHER_PREFS, + WALLPAPER_IMAGES_DB, + WIDGET_PREVIEWS_DB)); +} diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java index c0e648758..4b27837c4 100644 --- a/src/com/android/launcher3/LauncherProvider.java +++ b/src/com/android/launcher3/LauncherProvider.java @@ -73,8 +73,6 @@ public class LauncherProvider extends ContentProvider { private static final String TAG = "Launcher.LauncherProvider"; private static final boolean LOGD = false; - private static final String DATABASE_NAME = "launcher.db"; - private static final int DATABASE_VERSION = 20; static final String OLD_AUTHORITY = "com.android.launcher2.settings"; @@ -431,7 +429,7 @@ public class LauncherProvider extends ContentProvider { private boolean mNewDbCreated = false; DatabaseHelper(Context context) { - super(context, DATABASE_NAME, null, DATABASE_VERSION); + super(context, LauncherFiles.LAUNCHER_DB, null, DATABASE_VERSION); mContext = context; mPackageManager = context.getPackageManager(); mAppWidgetHost = new AppWidgetHost(context, Launcher.APPWIDGET_HOST_ID); diff --git a/src/com/android/launcher3/WidgetPreviewLoader.java b/src/com/android/launcher3/WidgetPreviewLoader.java index 184fd78eb..92d7c7d7f 100644 --- a/src/com/android/launcher3/WidgetPreviewLoader.java +++ b/src/com/android/launcher3/WidgetPreviewLoader.java @@ -287,7 +287,6 @@ public class WidgetPreviewLoader { static class CacheDb extends SQLiteOpenHelper { final static int DB_VERSION = 2; - final static String DB_NAME = "widgetpreviews.db"; final static String TABLE_NAME = "shortcut_and_widget_previews"; final static String COLUMN_NAME = "name"; final static String COLUMN_SIZE = "size"; @@ -295,7 +294,8 @@ public class WidgetPreviewLoader { Context mContext; public CacheDb(Context context) { - super(context, new File(context.getCacheDir(), DB_NAME).getPath(), null, DB_VERSION); + super(context, new File(context.getCacheDir(), + LauncherFiles.WIDGET_PREVIEWS_DB).getPath(), null, DB_VERSION); // Store the context for later use mContext = context; } |