am 48e725bd: (-s ours) am 56ca86b7: Merge remote-tracking branch \'goog/ub-now-lunchbox\' into lunchbox-release
* commit '48e725bdf4c92d3faf82c1788b56aa0491b566be':
Fix issue where clings didn't appear after set up wizard (issue 13077829)
Import translations. DO NOT MERGE
use restored icon for restored app shortcuts
Fix for Can't convert to dimension: type=0x12 Crash on JB deviecs.
diff --git a/WallpaperPicker/res/values-sw720dp-v19/styles.xml b/WallpaperPicker/res/values-sw720dp-v19/styles.xml
deleted file mode 100644
index 9107851..0000000
--- a/WallpaperPicker/res/values-sw720dp-v19/styles.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-* Copyright (C) 2013 The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
--->
-
-<resources>
- <style name="Theme" parent="android:Theme.Holo.Wallpaper.NoTitleBar">
- <item name="android:windowActionModeOverlay">true</item>
- <item name="android:windowTranslucentStatus">true</item>
- <item name="android:windowTranslucentNavigation">true</item>
- </style>
-</resources>
diff --git a/WallpaperPicker/res/values-sw720dp/styles.xml b/WallpaperPicker/res/values-sw720dp/styles.xml
index b489090..9107851 100644
--- a/WallpaperPicker/res/values-sw720dp/styles.xml
+++ b/WallpaperPicker/res/values-sw720dp/styles.xml
@@ -20,5 +20,7 @@
<resources>
<style name="Theme" parent="android:Theme.Holo.Wallpaper.NoTitleBar">
<item name="android:windowActionModeOverlay">true</item>
+ <item name="android:windowTranslucentStatus">true</item>
+ <item name="android:windowTranslucentNavigation">true</item>
</style>
</resources>
diff --git a/WallpaperPicker/res/values-v19/styles.xml b/WallpaperPicker/res/values-v19/styles.xml
deleted file mode 100644
index 85a989d..0000000
--- a/WallpaperPicker/res/values-v19/styles.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-/*
-* Copyright (C) 2013 The Android Open Source Project
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
--->
-
-<resources>
- <style name="Theme.WallpaperCropper" parent="@android:style/Theme.Holo">
- <item name="android:actionBarStyle">@style/WallpaperCropperActionBar</item>
- <item name="android:windowFullscreen">true</item>
- <item name="android:windowActionBarOverlay">true</item>
- <item name="android:windowTranslucentNavigation">true</item>
- </style>
-
- <style name="Theme" parent="@android:style/Theme.Holo.Wallpaper.NoTitleBar">
- <item name="android:windowTranslucentStatus">true</item>
- <item name="android:windowTranslucentNavigation">true</item>
- </style>
-</resources>
diff --git a/WallpaperPicker/res/values/styles.xml b/WallpaperPicker/res/values/styles.xml
index 6d600bc..0e48dda 100644
--- a/WallpaperPicker/res/values/styles.xml
+++ b/WallpaperPicker/res/values/styles.xml
@@ -22,6 +22,7 @@
<item name="android:actionBarStyle">@style/WallpaperCropperActionBar</item>
<item name="android:windowFullscreen">true</item>
<item name="android:windowActionBarOverlay">true</item>
+ <item name="android:windowTranslucentNavigation">true</item>
</style>
<style name="WallpaperCropperActionBar" parent="android:style/Widget.Holo.ActionBar">
@@ -30,5 +31,7 @@
</style>
<style name="Theme" parent="@android:style/Theme.Holo.Wallpaper.NoTitleBar">
+ <item name="android:windowTranslucentStatus">true</item>
+ <item name="android:windowTranslucentNavigation">true</item>
</style>
</resources>
diff --git a/res/layout/custom_workspace_cling.xml b/res/layout/custom_workspace_cling.xml
new file mode 100644
index 0000000..3744f2e
--- /dev/null
+++ b/res/layout/custom_workspace_cling.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2012 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- dummy layout, to be replaced in overlays -->
+<com.android.launcher3.Cling
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:launcher="http://schemas.android.com/apk/res-auto/com.android.launcher3"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ launcher:drawIdentifier="workspace_custom">
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="20dp"
+ android:textColor="@android:color/holo_blue_light"
+ android:text="@string/dummy_custom_cling_error_message"
+ android:gravity="start"
+ android:layout_gravity="bottom|start"
+ />
+</com.android.launcher3.Cling>
diff --git a/res/values-lo-rLA/strings.xml b/res/values-lo-rLA/strings.xml
index 5ced01a..4dbe9a8 100644
--- a/res/values-lo-rLA/strings.xml
+++ b/res/values-lo-rLA/strings.xml
@@ -95,6 +95,8 @@
<string name="migration_cling_use_default" msgid="2626475813981258626">"ເລີ່ມຕົ້ນໃໝ່"</string>
<string name="workspace_cling_title" msgid="5626202359865825661">"ຈັດການພື້ນທີ່ຂອງທ່ານ"</string>
<string name="workspace_cling_move_item" msgid="528201129978005352">"ແຕະຄ້າງໄວ້ທີ່ພາບພື້ນຫຼັງເພື່ອຈັດການພາບພື້ນຫຼັງ, ວິດເຈັດແລະການຕັ້ງຄ່າ."</string>
+ <string name="all_apps_cling_title" msgid="34929250753095858">"ເລືອກແອັບຯ"</string>
+ <string name="all_apps_cling_add_item" msgid="400866858451850784">"ເພື່ອເພີ່ມແອັບຯໃສ່ໜ້າຈໍຫຼັກຂອງທ່ານ, ໃຫ້ແຕະຄ້າງໄວ້."</string>
<string name="folder_cling_title" msgid="3894908818693254164">"ນີ້ແມ່ນໂຟນເດີ"</string>
<string name="folder_cling_create_folder" msgid="6158215559475836131">"ເພື່ອສ້າງອັນໃໝ່ແບບນີ້ ໃຫ້ແຕະຄ້າງໄວ້ທີ່ແອັບຯທີ່ຕ້ອງການຍ້າຍແລ້ວລາກມັນໄປຫາໂຕອື່ນ."</string>
<string name="cling_dismiss" msgid="8962359497601507581">"ຕົກລົງ"</string>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9cb6c29..2c6306a 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -252,6 +252,18 @@
<!-- Folder name format -->
<string name="folder_name_format">Folder: <xliff:g id="name" example="Games">%1$s</xliff:g></string>
+ <!-- Strings used in device overlays -->
+
+ <!-- Clings -->
+ <!-- Dummy string [CHAR_LIMIT=40] -->
+ <string name="custom_workspace_cling_title_1"></string>
+ <!-- Dummy string [CHAR_LIMIT=60] -->
+ <string name="custom_workspace_cling_description_1"></string>
+ <!-- Dummy string [CHAR_LIMIT=40] -->
+ <string name="custom_workspace_cling_title_2"></string>
+ <!-- Dummy string [CHAR_LIMIT=60] -->
+ <string name="custom_workspace_cling_description_2"></string>
+
<!-- Debug-only activity name. [DO NOT TRANSLATE] -->
<string name="debug_memory_activity">* HPROF</string>
diff --git a/src/com/android/launcher3/AllAppsList.java b/src/com/android/launcher3/AllAppsList.java
index 89b291f..b641eb5 100644
--- a/src/com/android/launcher3/AllAppsList.java
+++ b/src/com/android/launcher3/AllAppsList.java
@@ -32,7 +32,7 @@
*/
class AllAppsList {
public static final int DEFAULT_APPLICATIONS_NUMBER = 42;
-
+
/** The list off all apps. */
public ArrayList<AppInfo> data =
new ArrayList<AppInfo>(DEFAULT_APPLICATIONS_NUMBER);
@@ -115,7 +115,8 @@
data.remove(i);
}
}
- mIconCache.remove(packageName);
+ // This is more aggressive than it needs to be.
+ mIconCache.flush();
}
/**
diff --git a/src/com/android/launcher3/AppInfo.java b/src/com/android/launcher3/AppInfo.java
index da222f1..d5a7769 100644
--- a/src/com/android/launcher3/AppInfo.java
+++ b/src/com/android/launcher3/AppInfo.java
@@ -64,10 +64,6 @@
return intent;
}
- protected Intent getRestoredIntent() {
- return null;
- }
-
/**
* Must not hold the Context.
*/
diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java
index 827718b..a55fce0 100644
--- a/src/com/android/launcher3/IconCache.java
+++ b/src/com/android/launcher3/IconCache.java
@@ -16,8 +16,6 @@
package com.android.launcher3;
-import com.android.launcher3.backup.BackupProtos;
-
import android.app.ActivityManager;
import android.content.ComponentName;
import android.content.Context;
@@ -27,20 +25,10 @@
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
import android.graphics.Canvas;
-import android.graphics.Paint;
import android.graphics.drawable.Drawable;
-import android.util.Log;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
@@ -52,9 +40,6 @@
private static final String TAG = "Launcher.IconCache";
private static final int INITIAL_ICON_CACHE_CAPACITY = 50;
- private static final String RESOURCE_FILE_PREFIX = "icon_";
-
- private static final boolean DEBUG = true;
private static class CacheEntry {
public Bitmap icon;
@@ -130,7 +115,6 @@
return getFullResIcon(resources, iconId);
}
}
-
return getFullResDefaultActivityIcon();
}
@@ -156,21 +140,6 @@
}
/**
- * Remove any records for the supplied package name.
- */
- public void remove(String packageName) {
- HashSet<ComponentName> forDeletion = new HashSet<ComponentName>();
- for (ComponentName componentName: mCache.keySet()) {
- if (componentName.getPackageName().equals(packageName)) {
- forDeletion.add(componentName);
- }
- }
- for (ComponentName condemned: forDeletion) {
- remove(condemned);
- }
- }
-
- /**
* Empty out the cache.
*/
public void flush() {
@@ -208,22 +177,15 @@
}
public Bitmap getIcon(Intent intent) {
- return getIcon(intent, null);
- }
-
- public Bitmap getIcon(Intent intent, String title) {
synchronized (mCache) {
final ResolveInfo resolveInfo = mPackageManager.resolveActivity(intent, 0);
ComponentName component = intent.getComponent();
- if (component == null) {
+ if (resolveInfo == null || component == null) {
return mDefaultIcon;
}
CacheEntry entry = cacheLocked(component, resolveInfo, null);
- if (title != null) {
- entry.title = title;
- }
return entry.icon;
}
}
@@ -252,35 +214,21 @@
mCache.put(componentName, entry);
- if (info != null) {
- ComponentName key = LauncherModel.getComponentNameFromResolveInfo(info);
- if (labelCache != null && labelCache.containsKey(key)) {
- entry.title = labelCache.get(key).toString();
- } else {
- entry.title = info.loadLabel(mPackageManager).toString();
- if (labelCache != null) {
- labelCache.put(key, entry.title);
- }
- }
- if (entry.title == null) {
- entry.title = info.activityInfo.name;
- }
-
- entry.icon = Utilities.createIconBitmap(
- getFullResIcon(info), mContext);
+ ComponentName key = LauncherModel.getComponentNameFromResolveInfo(info);
+ if (labelCache != null && labelCache.containsKey(key)) {
+ entry.title = labelCache.get(key).toString();
} else {
- entry.title = "";
- Bitmap preloaded = getPreloadedIcon(componentName);
- if (preloaded != null) {
- if (DEBUG) Log.d(TAG, "using preloaded icon for " +
- componentName.toShortString());
- entry.icon = preloaded;
- } else {
- if (DEBUG) Log.d(TAG, "using default icon for " +
- componentName.toShortString());
- entry.icon = mDefaultIcon;
+ entry.title = info.loadLabel(mPackageManager).toString();
+ if (labelCache != null) {
+ labelCache.put(key, entry.title);
}
}
+ if (entry.title == null) {
+ entry.title = info.activityInfo.name;
+ }
+
+ entry.icon = Utilities.createIconBitmap(
+ getFullResIcon(info), mContext);
}
return entry;
}
@@ -295,137 +243,4 @@
return set;
}
}
-
- /**
- * Pre-load an icon into the persistent cache.
- *
- * <P>Queries for a component that does not exist in the package manager
- * will be answered by the persistent cache.
- *
- * @param context application context
- * @param componentName the icon should be returned for this component
- * @param icon the icon to be persisted
- * @param dpi the native density of the icon
- */
- public static void preloadIcon(Context context, ComponentName componentName, Bitmap icon,
- int dpi) {
- // TODO rescale to the correct native DPI
- try {
- PackageManager packageManager = context.getPackageManager();
- packageManager.getActivityIcon(componentName);
- // component is present on the system already, do nothing
- return;
- } catch (PackageManager.NameNotFoundException e) {
- // pass
- }
-
- final String key = componentName.flattenToString();
- FileOutputStream resourceFile = null;
- try {
- resourceFile = context.openFileOutput(getResourceFilename(componentName),
- Context.MODE_PRIVATE);
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- if (icon.compress(android.graphics.Bitmap.CompressFormat.PNG, 75, os)) {
- byte[] buffer = os.toByteArray();
- resourceFile.write(buffer, 0, buffer.length);
- } else {
- Log.w(TAG, "failed to encode cache for " + key);
- return;
- }
- } catch (FileNotFoundException e) {
- Log.w(TAG, "failed to pre-load cache for " + key, e);
- } catch (IOException e) {
- Log.w(TAG, "failed to pre-load cache for " + key, e);
- } finally {
- if (resourceFile != null) {
- try {
- resourceFile.close();
- } catch (IOException e) {
- Log.d(TAG, "failed to save restored icon for: " + key, e);
- }
- }
- }
- }
-
- /**
- * Read a pre-loaded icon from the persistent icon cache.
- *
- * @param componentName the component that should own the icon
- * @returns a bitmap if one is cached, or null.
- */
- private Bitmap getPreloadedIcon(ComponentName componentName) {
- final String key = componentName.flattenToShortString();
-
- if (DEBUG) Log.v(TAG, "looking for pre-load icon for " + key);
- Bitmap icon = null;
- FileInputStream resourceFile = null;
- try {
- resourceFile = mContext.openFileInput(getResourceFilename(componentName));
- byte[] buffer = new byte[1024];
- ByteArrayOutputStream bytes = new ByteArrayOutputStream();
- int bytesRead = 0;
- while(bytesRead >= 0) {
- bytes.write(buffer, 0, bytesRead);
- bytesRead = resourceFile.read(buffer, 0, buffer.length);
- }
- if (DEBUG) Log.d(TAG, "read " + bytes.size());
- icon = BitmapFactory.decodeByteArray(bytes.toByteArray(), 0, bytes.size());
- if (icon == null) {
- Log.w(TAG, "failed to decode pre-load icon for " + key);
- }
- } catch (FileNotFoundException e) {
- if (DEBUG) Log.d(TAG, "there is no restored icon for: " + key, e);
- } catch (IOException e) {
- Log.w(TAG, "failed to read pre-load icon for: " + key, e);
- } finally {
- if(resourceFile != null) {
- try {
- resourceFile.close();
- } catch (IOException e) {
- Log.d(TAG, "failed to manage pre-load icon file: " + key, e);
- }
- }
- }
-
- if (icon != null) {
- // TODO: handle alpha mask in the view layer
- Bitmap b = Bitmap.createBitmap(Math.max(icon.getWidth(), 1),
- Math.max(icon.getHeight(), 1),
- Bitmap.Config.ARGB_8888);
- Canvas c = new Canvas(b);
- Paint paint = new Paint();
- paint.setAlpha(127);
- c.drawBitmap(icon, 0, 0, paint);
- c.setBitmap(null);
- icon.recycle();
- icon = b;
- }
-
- return icon;
- }
-
- /**
- * Remove a pre-loaded icon from the persistent icon cache.
- *
- * @param componentName the component that should own the icon
- * @returns true on success
- */
- public boolean deletePreloadedIcon(ComponentName componentName) {
- if (componentName == null) {
- return false;
- }
- if (mCache.remove(componentName) != null) {
- if (DEBUG) Log.d(TAG, "removed pre-loaded icon from the in-memory cache");
- }
- boolean success = mContext.deleteFile(getResourceFilename(componentName));
- if (DEBUG && success) Log.d(TAG, "removed pre-loaded icon from persistent cache");
-
- return success;
- }
-
- private static String getResourceFilename(ComponentName component) {
- String resourceName = component.flattenToShortString();
- String filename = resourceName.replace(File.separatorChar, '_');
- return RESOURCE_FILE_PREFIX + filename;
- }
}
diff --git a/src/com/android/launcher3/InstallShortcutReceiver.java b/src/com/android/launcher3/InstallShortcutReceiver.java
index 28cef13..7ab4e04 100644
--- a/src/com/android/launcher3/InstallShortcutReceiver.java
+++ b/src/com/android/launcher3/InstallShortcutReceiver.java
@@ -304,7 +304,7 @@
// Add the new apps to the model and bind them
if (!addShortcuts.isEmpty()) {
LauncherAppState app = LauncherAppState.getInstance();
- app.getModel().addAndBindAddedWorkspaceApps(context, addShortcuts);
+ app.getModel().addAndBindAddedApps(context, addShortcuts, new ArrayList<AppInfo>());
}
}
}
diff --git a/src/com/android/launcher3/ItemInfo.java b/src/com/android/launcher3/ItemInfo.java
index 3dc92c9..36ba6c1 100644
--- a/src/com/android/launcher3/ItemInfo.java
+++ b/src/com/android/launcher3/ItemInfo.java
@@ -122,10 +122,6 @@
throw new RuntimeException("Unexpected Intent");
}
- protected Intent getRestoredIntent() {
- throw new RuntimeException("Unexpected Intent");
- }
-
/**
* Write the fields of this item to the DB
*
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index c87f9e2..1d9b627 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -3853,17 +3853,15 @@
}
// Add the new screens
- if (newScreens != null) {
- bindAddScreens(newScreens);
- }
+ bindAddScreens(newScreens);
// We add the items without animation on non-visible pages, and with
// animations on the new page (which we will try and snap to).
- if (addNotAnimated != null && !addNotAnimated.isEmpty()) {
+ if (!addNotAnimated.isEmpty()) {
bindItems(addNotAnimated, 0,
addNotAnimated.size(), false);
}
- if (addAnimated != null && !addAnimated.isEmpty()) {
+ if (!addAnimated.isEmpty()) {
bindItems(addAnimated, 0,
addAnimated.size(), true);
}
diff --git a/src/com/android/launcher3/LauncherBackupHelper.java b/src/com/android/launcher3/LauncherBackupHelper.java
index c706cf1..335028d 100644
--- a/src/com/android/launcher3/LauncherBackupHelper.java
+++ b/src/com/android/launcher3/LauncherBackupHelper.java
@@ -50,9 +50,7 @@
import android.util.Log;
import java.io.ByteArrayOutputStream;
-import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URISyntaxException;
@@ -138,8 +136,6 @@
private static final int SCREEN_RANK_INDEX = 2;
- private static IconCache mIconCache;
-
private final Context mContext;
private final boolean mRestoreEnabled;
@@ -197,7 +193,7 @@
Log.e(TAG, "launcher backup has failed", e);
}
- out.key = keys.toArray(new BackupProtos.Key[keys.size()]);
+ out.key = keys.toArray(BackupProtos.Key.emptyArray());
writeJournal(newState, out);
Log.v(TAG, "onBackup: wrote " + out.bytes + "b in " + out.rows + " rows.");
}
@@ -270,7 +266,7 @@
// will catch any changes the restore process might have made
Journal out = new Journal();
out.t = 0;
- out.key = mKeys.toArray(new BackupProtos.Key[mKeys.size()]);
+ out.key = mKeys.toArray(BackupProtos.Key.emptyArray());
writeJournal(newState, out);
Log.v(TAG, "onRestore: read " + mKeys.size() + " rows");
mKeys.clear();
@@ -445,12 +441,14 @@
private void backupIcons(Journal in, BackupDataOutput data, Journal out,
ArrayList<Key> keys) throws IOException {
// persist icons that haven't been persisted yet
- if (!initializeIconCache()) {
+ final LauncherAppState appState = LauncherAppState.getInstanceNoCreate();
+ if (appState == null) {
dataChanged(); // try again later
if (DEBUG) Log.d(TAG, "Launcher is not initialized, delaying icon backup");
return;
}
final ContentResolver cr = mContext.getContentResolver();
+ final IconCache iconCache = appState.getIconCache();
final int dpi = mContext.getResources().getDisplayMetrics().densityDpi;
// read the old ID set
@@ -489,9 +487,9 @@
if (DEBUG) Log.d(TAG, "I can count this high: " + out.rows);
if ((out.rows - startRows) < MAX_ICONS_PER_PASS) {
if (VERBOSE) Log.v(TAG, "saving icon " + backupKey);
- Bitmap icon = mIconCache.getIcon(intent);
+ Bitmap icon = iconCache.getIcon(intent);
keys.add(key);
- if (icon != null && !mIconCache.isDefaultIcon(icon)) {
+ if (icon != null && !iconCache.isDefaultIcon(icon)) {
byte[] blob = packIcon(dpi, icon);
writeRowToBackup(key, blob, out, data);
}
@@ -532,33 +530,25 @@
if (VERBOSE) Log.v(TAG, "unpacking icon " + key.id);
if (DEBUG) Log.d(TAG, "read (" + buffer.length + "): " +
Base64.encodeToString(buffer, 0, dataSize, Base64.NO_WRAP));
-
try {
Resource res = unpackIcon(buffer, 0, dataSize);
- if (DEBUG) {
- Log.d(TAG, "unpacked " + res.dpi + " dpi icon");
- }
- if (DEBUG_PAYLOAD) {
- Log.d(TAG, "read " +
- Base64.encodeToString(res.data, 0, res.data.length,
- Base64.NO_WRAP));
- }
+ if (DEBUG) Log.d(TAG, "unpacked " + res.dpi + " dpi icon");
+ if (DEBUG_PAYLOAD) Log.d(TAG, "read " +
+ Base64.encodeToString(res.data, 0, res.data.length,
+ Base64.NO_WRAP));
Bitmap icon = BitmapFactory.decodeByteArray(res.data, 0, res.data.length);
if (icon == null) {
Log.w(TAG, "failed to unpack icon for " + key.name);
}
if (!mRestoreEnabled) {
- if (VERBOSE) {
- Log.v(TAG, "restore not enabled: skipping database mutation");
- }
+ if (VERBOSE) Log.v(TAG, "restore not enabled: skipping database mutation");
return;
} else {
- IconCache.preloadIcon(mContext, ComponentName.unflattenFromString(key.name),
- icon, res.dpi);
+ // future site of icon cache mutation
}
- } catch (IOException e) {
- Log.d(TAG, "failed to save restored icon for: " + key.name, e);
+ } catch (InvalidProtocolBufferNanoException e) {
+ Log.e(TAG, "failed to decode icon", e);
}
}
@@ -576,13 +566,15 @@
ArrayList<Key> keys) throws IOException {
// persist static widget info that hasn't been persisted yet
final LauncherAppState appState = LauncherAppState.getInstanceNoCreate();
- if (appState == null || !initializeIconCache()) {
- Log.w(TAG, "Failed to get icon cache during restore");
+ if (appState == null) {
+ dataChanged(); // try again later
+ if (DEBUG) Log.d(TAG, "Launcher is not initialized, delaying widget backup");
return;
}
final ContentResolver cr = mContext.getContentResolver();
final WidgetPreviewLoader previewLoader = new WidgetPreviewLoader(mContext);
final PagedViewCellLayout widgetSpacingLayout = new PagedViewCellLayout(mContext);
+ final IconCache iconCache = appState.getIconCache();
final int dpi = mContext.getResources().getDisplayMetrics().densityDpi;
final DeviceProfile profile = appState.getDynamicGrid().getDeviceProfile();
if (DEBUG) Log.d(TAG, "cellWidthPx: " + profile.cellWidthPx);
@@ -625,7 +617,7 @@
if (VERBOSE) Log.v(TAG, "saving widget " + backupKey);
previewLoader.setPreviewSize(spanX * profile.cellWidthPx,
spanY * profile.cellHeightPx, widgetSpacingLayout);
- byte[] blob = packWidget(dpi, previewLoader, mIconCache, provider);
+ byte[] blob = packWidget(dpi, previewLoader, iconCache, provider);
keys.add(key);
writeRowToBackup(key, blob, out, data);
@@ -890,7 +882,7 @@
}
/** Deserialize an icon resource from persistence, after verifying checksum wrapper. */
- private static Resource unpackIcon(byte[] buffer, int offset, int dataSize)
+ private Resource unpackIcon(byte[] buffer, int offset, int dataSize)
throws InvalidProtocolBufferNanoException {
Resource res = new Resource();
MessageNano.mergeFrom(res, readCheckedBytes(buffer, offset, dataSize));
@@ -1088,7 +1080,7 @@
}
/** Unwrap a proto message from a CheckedMessage, verifying the checksum. */
- private static byte[] readCheckedBytes(byte[] buffer, int offset, int dataSize)
+ private byte[] readCheckedBytes(byte[] buffer, int offset, int dataSize)
throws InvalidProtocolBufferNanoException {
CheckedMessage wrapper = new CheckedMessage();
MessageNano.mergeFrom(wrapper, buffer, offset, dataSize);
@@ -1112,23 +1104,6 @@
return mWidgetMap.get(component);
}
-
- private boolean initializeIconCache() {
- if (mIconCache != null) {
- return true;
- }
-
- final LauncherAppState appState = LauncherAppState.getInstanceNoCreate();
- if (appState == null) {
- Throwable stackTrace = new Throwable();
- stackTrace.fillInStackTrace();
- Log.w(TAG, "Failed to get app state during backup/restore", stackTrace);
- return false;
- }
- mIconCache = appState.getIconCache();
- return mIconCache != null;
- }
-
private class KeyParsingException extends Throwable {
private KeyParsingException(Throwable cause) {
super(cause);
diff --git a/src/com/android/launcher3/LauncherClings.java b/src/com/android/launcher3/LauncherClings.java
index 894f64d..00711fe 100644
--- a/src/com/android/launcher3/LauncherClings.java
+++ b/src/com/android/launcher3/LauncherClings.java
@@ -41,6 +41,7 @@
private static final String FOLDER_CLING_DISMISSED_KEY = "cling_gel.folder.dismissed";
private static final boolean DISABLE_CLINGS = false;
+ private static final boolean DISABLE_CUSTOM_CLINGS = true;
private static final int SHOW_CLING_DURATION = 250;
private static final int DISMISS_CLING_DURATION = 200;
@@ -195,7 +196,8 @@
SharedPreferences sharedPrefs = mLauncher.getSharedPrefs();
return areClingsEnabled() &&
!sharedPrefs.getBoolean(FIRST_RUN_CLING_DISMISSED_KEY, false) &&
- !sharedPrefs.getBoolean(MIGRATION_CLING_DISMISSED_KEY, false);
+ !sharedPrefs.getBoolean(MIGRATION_CLING_DISMISSED_KEY, false) &&
+ LauncherAppState.getLauncherProvider().wasNewDbCreated();
}
public void removeFirstRunAndMigrationClings() {
@@ -211,6 +213,24 @@
*/
public void showFirstRunCling() {
if (!skipCustomClingIfNoAccounts()) {
+ SharedPreferences sharedPrefs = mLauncher.getSharedPrefs();
+ // If we're not using the default workspace layout, replace workspace cling
+ // with a custom workspace cling (usually specified in an overlay)
+ // For now, only do this on tablets
+ if (!DISABLE_CUSTOM_CLINGS) {
+ if (sharedPrefs.getInt(LauncherProvider.DEFAULT_WORKSPACE_RESOURCE_ID, 0) != 0 &&
+ mLauncher.getResources().getBoolean(R.bool.config_useCustomClings)) {
+ // Use a custom cling
+ View cling = mLauncher.findViewById(R.id.workspace_cling);
+ ViewGroup clingParent = (ViewGroup) cling.getParent();
+ int clingIndex = clingParent.indexOfChild(cling);
+ clingParent.removeViewAt(clingIndex);
+ View customCling = mInflater.inflate(R.layout.custom_workspace_cling,
+ clingParent, false);
+ clingParent.addView(customCling, clingIndex);
+ customCling.setId(R.id.workspace_cling);
+ }
+ }
Cling cling = (Cling) mLauncher.findViewById(R.id.first_run_cling);
if (cling != null) {
String sbHintStr = mLauncher.getFirstRunClingSearchBarHint();
@@ -272,7 +292,6 @@
removeCling(R.id.workspace_cling);
}
}
-
public Cling showFoldersCling() {
SharedPreferences sharedPrefs = mLauncher.getSharedPrefs();
// Enable the clings only if they have not been dismissed before
@@ -295,14 +314,6 @@
}
}
- public static void synchonouslyMarkFirstRunClingDismissed(Context ctx) {
- SharedPreferences prefs = ctx.getSharedPreferences(
- LauncherAppState.getSharedPreferencesKey(),Context.MODE_PRIVATE);
- SharedPreferences.Editor editor = prefs.edit();
- editor.putBoolean(LauncherClings.FIRST_RUN_CLING_DISMISSED_KEY, true);
- editor.commit();
- }
-
/** Removes the cling outright from the DragLayer */
private void removeCling(int id) {
final View cling = mLauncher.findViewById(id);
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index 007fd7a..abfca34 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -292,58 +292,17 @@
return null;
}
- public void addAppsToAllApps(final Context ctx, final ArrayList<AppInfo> allAppsApps) {
- final Callbacks callbacks = mCallbacks != null ? mCallbacks.get() : null;
-
- if (allAppsApps == null) {
- throw new RuntimeException("allAppsApps must not be null");
- }
- if (allAppsApps.isEmpty()) {
- return;
- }
-
- final ArrayList<AppInfo> restoredAppsFinal = new ArrayList<AppInfo>();
- Iterator<AppInfo> iter = allAppsApps.iterator();
- while (iter.hasNext()) {
- ItemInfo a = iter.next();
- if (LauncherModel.appWasRestored(ctx, a.getIntent())) {
- restoredAppsFinal.add((AppInfo) a);
- }
- }
-
- // Process the newly added applications and add them to the database first
- Runnable r = new Runnable() {
- public void run() {
- runOnMainThread(new Runnable() {
- public void run() {
- Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
- if (callbacks == cb && cb != null) {
- if (!restoredAppsFinal.isEmpty()) {
- for (AppInfo info : restoredAppsFinal) {
- final Intent intent = info.getIntent();
- if (intent != null) {
- mIconCache.deletePreloadedIcon(intent.getComponent());
- }
- }
- callbacks.bindAppsUpdated(restoredAppsFinal);
- }
- callbacks.bindAppsAdded(null, null, null, allAppsApps);
- }
- }
- });
- }
- };
- runOnWorkerThread(r);
+ public void addAndBindAddedApps(final Context context, final ArrayList<ItemInfo> workspaceApps,
+ final ArrayList<AppInfo> allAppsApps) {
+ Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
+ addAndBindAddedApps(context, workspaceApps, cb, allAppsApps);
}
-
- public void addAndBindAddedWorkspaceApps(final Context context,
- final ArrayList<ItemInfo> workspaceApps) {
- final Callbacks callbacks = mCallbacks != null ? mCallbacks.get() : null;
-
- if (workspaceApps == null) {
+ public void addAndBindAddedApps(final Context context, final ArrayList<ItemInfo> workspaceApps,
+ final Callbacks callbacks, final ArrayList<AppInfo> allAppsApps) {
+ if (workspaceApps == null || allAppsApps == null) {
throw new RuntimeException("workspaceApps and allAppsApps must not be null");
}
- if (workspaceApps.isEmpty()) {
+ if (workspaceApps.isEmpty() && allAppsApps.isEmpty()) {
return;
}
// Process the newly added applications and add them to the database first
@@ -351,7 +310,6 @@
public void run() {
final ArrayList<ItemInfo> addedShortcutsFinal = new ArrayList<ItemInfo>();
final ArrayList<Long> addedWorkspaceScreensFinal = new ArrayList<Long>();
- final ArrayList<AppInfo> restoredAppsFinal = new ArrayList<AppInfo>();
// Get the list of workspace screens. We need to append to this list and
// can not use sBgWorkspaceScreens because loadWorkspace() may not have been
@@ -372,11 +330,6 @@
// Short-circuit this logic if the icon exists somewhere on the workspace
if (LauncherModel.shortcutExists(context, name, launchIntent)) {
- // Only InstallShortcutReceiver sends us shortcutInfos, ignore them
- if (a instanceof AppInfo &&
- LauncherModel.appWasRestored(context, launchIntent)) {
- restoredAppsFinal.add((AppInfo) a);
- }
continue;
}
@@ -432,7 +385,7 @@
// Update the workspace screens
updateWorkspaceScreenOrder(context, workspaceScreens);
- if (!addedShortcutsFinal.isEmpty()) {
+ if (!addedShortcutsFinal.isEmpty() || !allAppsApps.isEmpty()) {
runOnMainThread(new Runnable() {
public void run() {
Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
@@ -451,10 +404,7 @@
}
}
callbacks.bindAppsAdded(addedWorkspaceScreensFinal,
- addNotAnimated, addAnimated, null);
- if (!restoredAppsFinal.isEmpty()) {
- callbacks.bindAppsUpdated(restoredAppsFinal);
- }
+ addNotAnimated, addAnimated, allAppsApps);
}
}
});
@@ -820,30 +770,6 @@
}
/**
- * Returns true if the shortcuts already exists in the database.
- * we identify a shortcut by the component name of the intent.
- */
- static boolean appWasRestored(Context context, Intent intent) {
- final ContentResolver cr = context.getContentResolver();
- final ComponentName component = intent.getComponent();
- if (component == null) {
- return false;
- }
- String componentName = component.flattenToString();
- final String where = "intent glob \"*component=" + componentName + "*\" and restored = 1";
- Cursor c = cr.query(LauncherSettings.Favorites.CONTENT_URI,
- new String[]{"intent", "restored"}, where, null, null);
- boolean result = false;
- try {
- result = c.moveToFirst();
- } finally {
- c.close();
- }
- Log.d(TAG, "shortcutWasRestored is " + result + " for " + componentName);
- return result;
- }
-
- /**
* Returns an ItemInfo array containing all the items in the LauncherModel.
* The ItemInfo.id is not set through this function.
*/
@@ -1640,7 +1566,8 @@
}
}
if (!added.isEmpty()) {
- addAndBindAddedWorkspaceApps(context, added);
+ Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
+ addAndBindAddedApps(context, added, cb, new ArrayList<AppInfo>());
}
}
@@ -1895,7 +1822,7 @@
Launcher.addDumpLog(TAG,
"constructing info for partially restored package",
true);
- info = getRestoredItemInfo(c, titleIndex, intent);
+ info = getRestoredItemInfo(c, titleIndex);
intent = getRestoredItemIntent(c, context, intent);
} else if (itemType ==
LauncherSettings.Favorites.ITEM_TYPE_APPLICATION) {
@@ -2673,7 +2600,6 @@
case OP_ADD:
for (int i=0; i<N; i++) {
if (DEBUG_LOADERS) Log.d(TAG, "mAllAppsList.addPackage " + packages[i]);
- mIconCache.remove(packages[i]);
mBgAllAppsList.addPackage(context, packages[i]);
}
break;
@@ -2721,14 +2647,14 @@
if (added != null) {
// Ensure that we add all the workspace applications to the db
- if (LauncherAppState.isDisableAllApps()) {
- final ArrayList<ItemInfo> addedInfos = new ArrayList<ItemInfo>(added);
- addAndBindAddedWorkspaceApps(context, addedInfos);
+ Callbacks cb = mCallbacks != null ? mCallbacks.get() : null;
+ if (!LauncherAppState.isDisableAllApps()) {
+ addAndBindAddedApps(context, new ArrayList<ItemInfo>(), cb, added);
} else {
- addAppsToAllApps(context, added);
+ final ArrayList<ItemInfo> addedInfos = new ArrayList<ItemInfo>(added);
+ addAndBindAddedApps(context, addedInfos, cb, added);
}
}
-
if (modified != null) {
final ArrayList<AppInfo> modifiedFinal = modified;
@@ -2867,16 +2793,16 @@
* Make an ShortcutInfo object for a restored application or shortcut item that points
* to a package that is not yet installed on the system.
*/
- public ShortcutInfo getRestoredItemInfo(Cursor cursor, int titleIndex, Intent intent) {
+ public ShortcutInfo getRestoredItemInfo(Cursor cursor, int titleIndex) {
final ShortcutInfo info = new ShortcutInfo();
+ info.usingFallbackIcon = true;
+ info.setIcon(getFallbackIcon());
if (cursor != null) {
info.title = cursor.getString(titleIndex);
} else {
info.title = "";
}
- info.setIcon(mIconCache.getIcon(intent, info.title.toString()));
info.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
- info.restoredIntent = intent;
return info;
}
@@ -2885,7 +2811,6 @@
* to the market page for the item.
*/
private Intent getRestoredItemIntent(Cursor c, Context context, Intent intent) {
- final boolean debug = false;
ComponentName componentName = intent.getComponent();
Intent marketIntent = new Intent(Intent.ACTION_VIEW);
Uri marketUri = new Uri.Builder()
@@ -2893,7 +2818,7 @@
.authority("details")
.appendQueryParameter("id", componentName.getPackageName())
.build();
- if (debug) Log.d(TAG, "manufactured intent uri: " + marketUri.toString());
+ Log.d(TAG, "manufactured intent uri: " + marketUri.toString());
marketIntent.setData(marketUri);
return marketIntent;
}
@@ -3059,10 +2984,6 @@
Intent.ACTION_MAIN.equals(intent.getAction()) && name != null) {
return true;
}
- // placeholder shortcuts get special treatment, let them through too.
- if (info.getRestoredIntent() != null) {
- return true;
- }
}
return false;
}
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index b952729..a69f423 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -71,7 +71,7 @@
private static final String DATABASE_NAME = "launcher.db";
- private static final int DATABASE_VERSION = 17;
+ private static final int DATABASE_VERSION = 16;
static final String OLD_AUTHORITY = "com.android.launcher2.settings";
static final String AUTHORITY = ProviderConfig.AUTHORITY;
@@ -769,16 +769,6 @@
}
}
- if (version < 17) {
- // We use the db version upgrade here to identify users who may not have seen
- // clings yet (because they weren't available), but for whom the clings are now
- // available (tablet users). Because one of the possible cling flows (migration)
- // is very destructive (wipes out workspaces), we want to prevent this from showing
- // until clear data. We do so by marking that the clings have been shown.
- LauncherClings.synchonouslyMarkFirstRunClingDismissed(mContext);
- version = 17;
- }
-
if (version != DATABASE_VERSION) {
Log.w(TAG, "Destroying all old data.");
db.execSQL("DROP TABLE IF EXISTS " + TABLE_FAVORITES);
diff --git a/src/com/android/launcher3/ShortcutInfo.java b/src/com/android/launcher3/ShortcutInfo.java
index 79d114c..660f32c 100644
--- a/src/com/android/launcher3/ShortcutInfo.java
+++ b/src/com/android/launcher3/ShortcutInfo.java
@@ -64,12 +64,6 @@
long firstInstallTime;
int flags = 0;
- /**
- * If this shortcut is a placeholder, then intent will be a market intent for the package, and
- * this will hold the original intent from the database. Otherwise, null.
- */
- Intent restoredIntent;
-
ShortcutInfo() {
itemType = LauncherSettings.BaseLauncherColumns.ITEM_TYPE_SHORTCUT;
}
@@ -78,21 +72,6 @@
return intent;
}
- protected Intent getRestoredIntent() {
- return restoredIntent;
- }
-
- /**
- * Overwrite placeholder data with restored data, or do nothing if this is not a placeholder.
- */
- public void restore() {
- if (restoredIntent != null) {
- intent = restoredIntent;
- restoredIntent = null;
- }
- }
-
-
ShortcutInfo(Intent intent, CharSequence title, Bitmap icon) {
this();
this.intent = intent;
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 50d29ed..751b4c6 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -2709,13 +2709,12 @@
mTargetCell);
float distance = dropTargetLayout.getDistanceFromCell(mDragViewVisualCenter[0],
mDragViewVisualCenter[1], mTargetCell);
- if (mCreateUserFolderOnDrop && willCreateUserFolder((ItemInfo) d.dragInfo,
- dropTargetLayout, mTargetCell, distance, true)) {
+ if (willCreateUserFolder((ItemInfo) d.dragInfo, dropTargetLayout,
+ mTargetCell, distance, true)) {
return true;
}
-
- if (mAddToExistingFolderOnDrop && willAddToExistingUserFolder((ItemInfo) d.dragInfo,
- dropTargetLayout, mTargetCell, distance)) {
+ if (willAddToExistingUserFolder((ItemInfo) d.dragInfo, dropTargetLayout,
+ mTargetCell, distance)) {
return true;
}
@@ -4613,15 +4612,11 @@
private void updateShortcut(HashMap<ComponentName, AppInfo> appsMap, ItemInfo info,
View child) {
ComponentName cn = info.getIntent().getComponent();
- if (info.getRestoredIntent() != null) {
- cn = info.getRestoredIntent().getComponent();
- }
if (cn != null) {
- AppInfo appInfo = appsMap.get(cn);
+ AppInfo appInfo = appsMap.get(info.getIntent().getComponent());
if ((appInfo != null) && LauncherModel.isShortcutInfoUpdateable(info)) {
ShortcutInfo shortcutInfo = (ShortcutInfo) info;
BubbleTextView shortcut = (BubbleTextView) child;
- shortcutInfo.restore();
shortcutInfo.updateIcon(mIconCache);
shortcutInfo.title = appInfo.title.toString();
shortcut.applyFromShortcutInfo(shortcutInfo, mIconCache);