diff options
author | Helena Josol <helenajosol@google.com> | 2014-10-06 16:06:46 +0100 |
---|---|---|
committer | Helena Josol <helenajosol@google.com> | 2014-10-06 17:08:10 +0100 |
commit | 4fbbb3e3e0e135bc5b304bc63637bbc8b54fb5d8 (patch) | |
tree | 4383aa322228344f9ce6318d5d4c0d462730575e /src | |
parent | ebb2a66b79b2761ed29f2f8a3140217c126e448b (diff) | |
download | android_packages_apps_Trebuchet-4fbbb3e3e0e135bc5b304bc63637bbc8b54fb5d8.tar.gz android_packages_apps_Trebuchet-4fbbb3e3e0e135bc5b304bc63637bbc8b54fb5d8.tar.bz2 android_packages_apps_Trebuchet-4fbbb3e3e0e135bc5b304bc63637bbc8b54fb5d8.zip |
Create a central list of files the Launcher writes to the app directory
Replace hardcoded Launcher filenames with the defined constants.
Bug: 12753154
Change-Id: I072f202d9388a703b9e6851bde64ea7fafe4b10a
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 8 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherFiles.java | 27 | ||||
-rw-r--r-- | src/com/android/launcher3/LauncherProvider.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/WidgetPreviewLoader.java | 4 |
4 files changed, 34 insertions, 9 deletions
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; } |