summaryrefslogtreecommitdiffstats
path: root/src/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/com')
-rw-r--r--src/com/android/launcher3/DeviceProfile.java3
-rw-r--r--src/com/android/launcher3/IconCache.java106
-rw-r--r--src/com/android/launcher3/Launcher.java9
-rw-r--r--src/com/android/launcher3/LauncherProvider.java5
4 files changed, 90 insertions, 33 deletions
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index b4d225e8b..73f54ab70 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -781,7 +781,8 @@ public class DeviceProfile {
lp.gravity = Gravity.BOTTOM;
lp.width = LayoutParams.MATCH_PARENT;
lp.height = hotseatBarHeightPx;
- hotseat.setPadding(2 * edgeMarginPx, 0, 2 * edgeMarginPx, 0);
+ hotseat.findViewById(R.id.layout).setPadding(2 * edgeMarginPx, 0,
+ 2 * edgeMarginPx, 0);
}
hotseat.setLayoutParams(lp);
diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java
index 9b2119e0b..f4af7f542 100644
--- a/src/com/android/launcher3/IconCache.java
+++ b/src/com/android/launcher3/IconCache.java
@@ -49,6 +49,7 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Locale;
import java.util.Map.Entry;
/**
@@ -200,7 +201,7 @@ public class IconCache {
PackageManager.GET_UNINSTALLED_PACKAGES);
long userSerial = mUserManager.getSerialNumberForUser(user);
for (LauncherActivityInfoCompat app : mLauncherApps.getActivityList(packageName, user)) {
- addIconToDB(app, info, userSerial);
+ addIconToDBAndMemCache(app, info, userSerial);
}
} catch (NameNotFoundException e) {
Log.d(TAG, "Package not found", e);
@@ -225,6 +226,7 @@ public class IconCache {
* @return The set of packages for which icons have updated.
*/
public HashSet<String> updateDBIcons(UserHandleCompat user, List<LauncherActivityInfoCompat> apps) {
+ mIconDb.updateSystemStateString(mContext);
long userSerial = mUserManager.getSerialNumberForUser(user);
PackageManager pm = mContext.getPackageManager();
HashMap<String, PackageInfo> pkgInfoMap = new HashMap<String, PackageInfo>();
@@ -239,7 +241,8 @@ public class IconCache {
Cursor c = mIconDb.getReadableDatabase().query(IconDB.TABLE_NAME,
new String[] {IconDB.COLUMN_ROWID, IconDB.COLUMN_COMPONENT,
- IconDB.COLUMN_LAST_UPDATED, IconDB.COLUMN_VERSION},
+ IconDB.COLUMN_LAST_UPDATED, IconDB.COLUMN_VERSION,
+ IconDB.COLUMN_SYSTEM_STATE},
IconDB.COLUMN_USER + " = ? ",
new String[] {Long.toString(userSerial)},
null, null, null);
@@ -248,6 +251,7 @@ public class IconCache {
final int indexLastUpdate = c.getColumnIndex(IconDB.COLUMN_LAST_UPDATED);
final int indexVersion = c.getColumnIndex(IconDB.COLUMN_VERSION);
final int rowIndex = c.getColumnIndex(IconDB.COLUMN_ROWID);
+ final int systemStateIndex = c.getColumnIndex(IconDB.COLUMN_SYSTEM_STATE);
HashSet<Integer> itemsToRemove = new HashSet<Integer>();
HashSet<String> updatedPackages = new HashSet<String>();
@@ -268,7 +272,8 @@ public class IconCache {
long updateTime = c.getLong(indexLastUpdate);
int version = c.getInt(indexVersion);
LauncherActivityInfoCompat app = componentMap.remove(component);
- if (version == info.versionCode && updateTime == info.lastUpdateTime) {
+ if (version == info.versionCode && updateTime == info.lastUpdateTime &&
+ TextUtils.equals(mIconDb.mSystemState, c.getString(systemStateIndex))) {
continue;
}
if (app == null) {
@@ -295,14 +300,25 @@ public class IconCache {
if (info == null) {
continue;
}
- addIconToDB(app, info, userSerial);
+ addIconToDBAndMemCache(app, info, userSerial);
}
return updatedPackages;
}
- private void addIconToDB(LauncherActivityInfoCompat app, PackageInfo info, long userSerial) {
+ private void addIconToDBAndMemCache(LauncherActivityInfoCompat app, PackageInfo info,
+ long userSerial) {
ContentValues values = updateCacheAndGetContentValues(app);
+ addIconToDB(values, app.getComponentName(), info, userSerial);
values.put(IconDB.COLUMN_COMPONENT, app.getComponentName().flattenToString());
+ }
+
+ /**
+ * Updates {@param values} to contain versoning information and adds it to the DB.
+ * @param values {@link ContentValues} containing icon & title
+ */
+ private void addIconToDB(ContentValues values, ComponentName key,
+ PackageInfo info, long userSerial) {
+ values.put(IconDB.COLUMN_COMPONENT, key.flattenToString());
values.put(IconDB.COLUMN_USER, userSerial);
values.put(IconDB.COLUMN_LAST_UPDATED, info.lastUpdateTime);
values.put(IconDB.COLUMN_VERSION, info.versionCode);
@@ -320,7 +336,6 @@ public class IconCache {
return mIconDb.newContentValues(entry.icon, entry.title.toString());
}
-
/**
* Empty out the cache.
*/
@@ -435,6 +450,18 @@ public class IconCache {
shortcutInfo.usingLowResIcon = entry.isLowResIcon;
}
+ /**
+ * Fill in {@param appInfo} with the icon and label for {@param packageName}
+ */
+ public synchronized void getTitleAndIconForApp(
+ String packageName, UserHandleCompat user, boolean useLowResIcon, AppInfo appInfoOut) {
+ CacheEntry entry = getEntryForPackageLocked(packageName, user, useLowResIcon);
+ appInfoOut.iconBitmap = entry.icon;
+ appInfoOut.title = entry.title;
+ appInfoOut.usingLowResIcon = entry.isLowResIcon;
+ appInfoOut.contentDescription = entry.contentDescription;
+ }
+
public synchronized Bitmap getDefaultIcon(UserHandleCompat user) {
if (!mDefaultIcons.containsKey(user)) {
mDefaultIcons.put(user, makeDefaultIcon(user));
@@ -464,8 +491,8 @@ public class IconCache {
entry.icon = Utilities.createIconBitmap(info.getBadgedIcon(mIconDpi), mContext);
} else {
if (usePackageIcon) {
- CacheEntry packageEntry = getEntryForPackage(
- componentName.getPackageName(), user);
+ CacheEntry packageEntry = getEntryForPackageLocked(
+ componentName.getPackageName(), user, false);
if (packageEntry != null) {
if (DEBUG) Log.d(TAG, "using package default icon for " +
componentName.toShortString());
@@ -498,7 +525,7 @@ public class IconCache {
Bitmap icon, CharSequence title) {
removeFromMemCacheLocked(packageName, user);
- CacheEntry entry = getEntryForPackage(packageName, user);
+ CacheEntry entry = getEntryForPackageLocked(packageName, user, false);
if (!TextUtils.isEmpty(title)) {
entry.title = title;
}
@@ -510,24 +537,41 @@ public class IconCache {
/**
* Gets an entry for the package, which can be used as a fallback entry for various components.
* This method is not thread safe, it must be called from a synchronized method.
+ *
*/
- private CacheEntry getEntryForPackage(String packageName, UserHandleCompat user) {
- ComponentName cn = new ComponentName(packageName, EMPTY_CLASS_NAME);;
+ private CacheEntry getEntryForPackageLocked(String packageName, UserHandleCompat user,
+ boolean useLowResIcon) {
+ ComponentName cn = new ComponentName(packageName, EMPTY_CLASS_NAME);
ComponentKey cacheKey = new ComponentKey(cn, user);
CacheEntry entry = mCache.get(cacheKey);
- if (entry == null) {
+ if (entry == null || (entry.isLowResIcon && !useLowResIcon)) {
entry = new CacheEntry();
- entry.title = "";
- entry.contentDescription = "";
mCache.put(cacheKey, entry);
- try {
- ApplicationInfo info = mPackageManager.getApplicationInfo(packageName, 0);
- entry.icon = Utilities.createIconBitmap(info.loadIcon(mPackageManager), mContext);
- entry.title = info.loadLabel(mPackageManager);
- entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, user);
- } catch (NameNotFoundException e) {
- if (DEBUG) Log.d(TAG, "Application not installed " + packageName);
+ // Check the DB first.
+ if (!getEntryFromDB(cn, user, entry, useLowResIcon)) {
+ try {
+ PackageInfo info = mPackageManager.getPackageInfo(packageName, 0);
+ ApplicationInfo appInfo = info.applicationInfo;
+ if (appInfo == null) {
+ throw new NameNotFoundException("ApplicationInfo is null");
+ }
+ Drawable drawable = mUserManager.getBadgedDrawableForUser(
+ appInfo.loadIcon(mPackageManager), user);
+ entry.icon = Utilities.createIconBitmap(drawable, mContext);
+ entry.title = appInfo.loadLabel(mPackageManager);
+ entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, user);
+ entry.isLowResIcon = false;
+
+ // Add the icon in the DB here, since these do not get written during
+ // package updates.
+ ContentValues values =
+ mIconDb.newContentValues(entry.icon, entry.title.toString());
+ addIconToDB(values, cn, info, mUserManager.getSerialNumberForUser(user));
+
+ } catch (NameNotFoundException e) {
+ if (DEBUG) Log.d(TAG, "Application not installed " + packageName);
+ }
}
}
return entry;
@@ -605,7 +649,7 @@ public class IconCache {
}
private static final class IconDB extends SQLiteOpenHelper {
- private final static int DB_VERSION = 2;
+ private final static int DB_VERSION = 3;
private final static String TABLE_NAME = "icons";
private final static String COLUMN_ROWID = "rowid";
@@ -616,11 +660,21 @@ public class IconCache {
private final static String COLUMN_ICON = "icon";
private final static String COLUMN_ICON_LOW_RES = "icon_low_res";
private final static String COLUMN_LABEL = "label";
+ private final static String COLUMN_SYSTEM_STATE = "system_state";
+
+ public String mSystemState;
public IconDB(Context context) {
super(context, LauncherFiles.APP_ICONS_DB, null, DB_VERSION);
+ updateSystemStateString(context);
}
+ public void updateSystemStateString(Context c) {
+ mSystemState = Locale.getDefault().toString() + ","
+ + c.getResources().getConfiguration().mcc;
+ }
+
+
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_NAME + " (" +
@@ -631,6 +685,7 @@ public class IconCache {
COLUMN_ICON + " BLOB, " +
COLUMN_ICON_LOW_RES + " BLOB, " +
COLUMN_LABEL + " TEXT, " +
+ COLUMN_SYSTEM_STATE + " TEXT, " +
"PRIMARY KEY (" + COLUMN_COMPONENT + ", " + COLUMN_USER + ") " +
");");
}
@@ -656,12 +711,13 @@ public class IconCache {
public ContentValues newContentValues(Bitmap icon, String label) {
ContentValues values = new ContentValues();
- values.put(IconDB.COLUMN_ICON, Utilities.flattenBitmap(icon));
- values.put(IconDB.COLUMN_ICON_LOW_RES, Utilities.flattenBitmap(
+ values.put(COLUMN_ICON, Utilities.flattenBitmap(icon));
+ values.put(COLUMN_ICON_LOW_RES, Utilities.flattenBitmap(
Bitmap.createScaledBitmap(icon,
icon.getWidth() / LOW_RES_SCALE_FACTOR,
icon.getHeight() / LOW_RES_SCALE_FACTOR, true)));
- values.put(IconDB.COLUMN_LABEL, label);
+ values.put(COLUMN_LABEL, label);
+ values.put(COLUMN_SYSTEM_STATE, mSystemState);
return values;
}
}
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index c040d93f2..2fa2f4ad7 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -2958,14 +2958,11 @@ public class Launcher extends Activity
sClipRevealMethod = null;
}
}
- if (opts == null) {
- opts = Utilities.isLmpOrAbove() ?
- ActivityOptions.makeCustomAnimation(this,
- R.anim.task_open_enter, R.anim.no_anim) :
- ActivityOptions.makeScaleUpAnimation(v, 0, 0,
+ if (opts == null && !Utilities.isLmpOrAbove()) {
+ opts = ActivityOptions.makeScaleUpAnimation(v, 0, 0,
v.getMeasuredWidth(), v.getMeasuredHeight());
}
- optsBundle = opts.toBundle();
+ optsBundle = opts != null ? opts.toBundle() : null;
}
if (user == null || user.equals(UserHandleCompat.myUserHandle())) {
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index a23553a04..1f59533cc 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -341,8 +341,11 @@ public class LauncherProvider extends ContentProvider {
Context ctx = getContext();
UserManager um = (UserManager) ctx.getSystemService(Context.USER_SERVICE);
Bundle bundle = um.getApplicationRestrictions(ctx.getPackageName());
- String packageName = bundle.getString(RESTRICTION_PACKAGE_NAME);
+ if (bundle == null) {
+ return null;
+ }
+ String packageName = bundle.getString(RESTRICTION_PACKAGE_NAME);
if (packageName != null) {
try {
Resources targetResources = ctx.getPackageManager()