Loading src/com/android/launcher3/AppWidgetsRestoredReceiver.java +6 −7 Original line number Diff line number Diff line Loading @@ -5,13 +5,13 @@ import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProviderInfo; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.util.Log; import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.util.ContentWriter; public class AppWidgetsRestoredReceiver extends BroadcastReceiver { Loading Loading @@ -50,14 +50,13 @@ public class AppWidgetsRestoredReceiver extends BroadcastReceiver { state = LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY; } ContentValues values = new ContentValues(); values.put(LauncherSettings.Favorites.APPWIDGET_ID, newWidgetIds[i]); values.put(LauncherSettings.Favorites.RESTORED, state); String[] widgetIdParams = new String[] { Integer.toString(oldWidgetIds[i]) }; int result = new ContentWriter(context, new ContentWriter.CommitParams( "appWidgetId=? and (restored & 1) = 1", widgetIdParams)) .put(LauncherSettings.Favorites.APPWIDGET_ID, newWidgetIds[i]) .put(LauncherSettings.Favorites.RESTORED, state) .commit(); int result = cr.update(Favorites.CONTENT_URI, values, "appWidgetId=? and (restored & 1) = 1", widgetIdParams); if (result == 0) { Cursor cursor = cr.query(Favorites.CONTENT_URI, new String[] {Favorites.APPWIDGET_ID}, Loading src/com/android/launcher3/InstallShortcutReceiver.java +41 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Parcelable; import android.os.Process; import android.os.UserHandle; import android.text.TextUtils; Loading @@ -35,6 +36,7 @@ import android.util.Log; import com.android.launcher3.compat.LauncherActivityInfoCompat; import com.android.launcher3.compat.LauncherAppsCompat; import com.android.launcher3.compat.UserManagerCompat; import com.android.launcher3.graphics.LauncherIcons; import com.android.launcher3.shortcuts.DeepShortcutManager; import com.android.launcher3.shortcuts.ShortcutInfoCompat; import com.android.launcher3.shortcuts.ShortcutKey; Loading Loading @@ -454,7 +456,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver { widgetInfo.spanY = Math.min(info.spanY, idp.numRows); return widgetInfo; } else { return LauncherAppState.getInstance().getModel().infoFromShortcutIntent(mContext, data); return createShortcutInfo(data, LauncherAppState.getInstance()); } } Loading Loading @@ -598,4 +600,42 @@ public class InstallShortcutReceiver extends BroadcastReceiver { return installQueue; } } private static ShortcutInfo createShortcutInfo(Intent data, LauncherAppState app) { Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); Parcelable bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON); if (intent == null) { // If the intent is null, we can't construct a valid ShortcutInfo, so we return null Log.e(TAG, "Can't construct ShorcutInfo with null intent"); return null; } final ShortcutInfo info = new ShortcutInfo(); // Only support intents for current user for now. Intents sent from other // users wouldn't get here without intent forwarding anyway. info.user = Process.myUserHandle(); if (bitmap instanceof Bitmap) { info.iconBitmap = LauncherIcons.createIconBitmap((Bitmap) bitmap, app.getContext()); } else { Parcelable extra = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE); if (extra instanceof Intent.ShortcutIconResource) { info.iconResource = (Intent.ShortcutIconResource) extra; info.iconBitmap = LauncherIcons.createIconBitmap(info.iconResource, app.getContext()); } } if (info.iconBitmap == null) { info.iconBitmap = app.getIconCache().getDefaultIcon(info.user); } info.title = Utilities.trim(name); info.contentDescription = UserManagerCompat.getInstance(app.getContext()) .getBadgedLabelForUser(info.title, info.user); info.intent = intent; return info; } } src/com/android/launcher3/Launcher.java +3 −2 Original line number Diff line number Diff line Loading @@ -2337,13 +2337,14 @@ public class Launcher extends Activity showBrokenAppInstallDialog(packageName, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { startActivitySafely(v, LauncherModel.getMarketIntent(packageName), info); startActivitySafely( v, PackageManagerHelper.getMarketIntent(packageName), info); } }); } else { // Download has started. final String packageName = info.providerName.getPackageName(); startActivitySafely(v, LauncherModel.getMarketIntent(packageName), info); startActivitySafely(v, PackageManagerHelper.getMarketIntent(packageName), info); } } Loading src/com/android/launcher3/LauncherModel.java +85 −473 File changed.Preview size limit exceeded, changes collapsed. Show changes src/com/android/launcher3/graphics/LauncherIcons.java +0 −12 Original line number Diff line number Diff line Loading @@ -20,9 +20,7 @@ import android.content.Context; import android.content.Intent.ShortcutIconResource; import android.content.pm.PackageManager; import android.content.res.Resources; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.PaintFlagsDrawFilter; Loading Loading @@ -51,16 +49,6 @@ public class LauncherIcons { Paint.FILTER_BITMAP_FLAG)); } public static Bitmap createIconBitmap(Cursor c, int iconIndex, Context context) { byte[] data = c.getBlob(iconIndex); try { return createIconBitmap(BitmapFactory.decodeByteArray(data, 0, data.length), context); } catch (Exception e) { return null; } } /** * Returns a bitmap suitable for the all apps view. If the package or the resource do not * exist, it returns null. Loading Loading
src/com/android/launcher3/AppWidgetsRestoredReceiver.java +6 −7 Original line number Diff line number Diff line Loading @@ -5,13 +5,13 @@ import android.appwidget.AppWidgetManager; import android.appwidget.AppWidgetProviderInfo; import android.content.BroadcastReceiver; import android.content.ContentResolver; import android.content.ContentValues; import android.content.Context; import android.content.Intent; import android.database.Cursor; import android.util.Log; import com.android.launcher3.LauncherSettings.Favorites; import com.android.launcher3.util.ContentWriter; public class AppWidgetsRestoredReceiver extends BroadcastReceiver { Loading Loading @@ -50,14 +50,13 @@ public class AppWidgetsRestoredReceiver extends BroadcastReceiver { state = LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY; } ContentValues values = new ContentValues(); values.put(LauncherSettings.Favorites.APPWIDGET_ID, newWidgetIds[i]); values.put(LauncherSettings.Favorites.RESTORED, state); String[] widgetIdParams = new String[] { Integer.toString(oldWidgetIds[i]) }; int result = new ContentWriter(context, new ContentWriter.CommitParams( "appWidgetId=? and (restored & 1) = 1", widgetIdParams)) .put(LauncherSettings.Favorites.APPWIDGET_ID, newWidgetIds[i]) .put(LauncherSettings.Favorites.RESTORED, state) .commit(); int result = cr.update(Favorites.CONTENT_URI, values, "appWidgetId=? and (restored & 1) = 1", widgetIdParams); if (result == 0) { Cursor cursor = cr.query(Favorites.CONTENT_URI, new String[] {Favorites.APPWIDGET_ID}, Loading
src/com/android/launcher3/InstallShortcutReceiver.java +41 −1 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ import android.content.pm.ActivityInfo; import android.content.pm.PackageManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Parcelable; import android.os.Process; import android.os.UserHandle; import android.text.TextUtils; Loading @@ -35,6 +36,7 @@ import android.util.Log; import com.android.launcher3.compat.LauncherActivityInfoCompat; import com.android.launcher3.compat.LauncherAppsCompat; import com.android.launcher3.compat.UserManagerCompat; import com.android.launcher3.graphics.LauncherIcons; import com.android.launcher3.shortcuts.DeepShortcutManager; import com.android.launcher3.shortcuts.ShortcutInfoCompat; import com.android.launcher3.shortcuts.ShortcutKey; Loading Loading @@ -454,7 +456,7 @@ public class InstallShortcutReceiver extends BroadcastReceiver { widgetInfo.spanY = Math.min(info.spanY, idp.numRows); return widgetInfo; } else { return LauncherAppState.getInstance().getModel().infoFromShortcutIntent(mContext, data); return createShortcutInfo(data, LauncherAppState.getInstance()); } } Loading Loading @@ -598,4 +600,42 @@ public class InstallShortcutReceiver extends BroadcastReceiver { return installQueue; } } private static ShortcutInfo createShortcutInfo(Intent data, LauncherAppState app) { Intent intent = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_INTENT); String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME); Parcelable bitmap = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON); if (intent == null) { // If the intent is null, we can't construct a valid ShortcutInfo, so we return null Log.e(TAG, "Can't construct ShorcutInfo with null intent"); return null; } final ShortcutInfo info = new ShortcutInfo(); // Only support intents for current user for now. Intents sent from other // users wouldn't get here without intent forwarding anyway. info.user = Process.myUserHandle(); if (bitmap instanceof Bitmap) { info.iconBitmap = LauncherIcons.createIconBitmap((Bitmap) bitmap, app.getContext()); } else { Parcelable extra = data.getParcelableExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE); if (extra instanceof Intent.ShortcutIconResource) { info.iconResource = (Intent.ShortcutIconResource) extra; info.iconBitmap = LauncherIcons.createIconBitmap(info.iconResource, app.getContext()); } } if (info.iconBitmap == null) { info.iconBitmap = app.getIconCache().getDefaultIcon(info.user); } info.title = Utilities.trim(name); info.contentDescription = UserManagerCompat.getInstance(app.getContext()) .getBadgedLabelForUser(info.title, info.user); info.intent = intent; return info; } }
src/com/android/launcher3/Launcher.java +3 −2 Original line number Diff line number Diff line Loading @@ -2337,13 +2337,14 @@ public class Launcher extends Activity showBrokenAppInstallDialog(packageName, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { startActivitySafely(v, LauncherModel.getMarketIntent(packageName), info); startActivitySafely( v, PackageManagerHelper.getMarketIntent(packageName), info); } }); } else { // Download has started. final String packageName = info.providerName.getPackageName(); startActivitySafely(v, LauncherModel.getMarketIntent(packageName), info); startActivitySafely(v, PackageManagerHelper.getMarketIntent(packageName), info); } } Loading
src/com/android/launcher3/LauncherModel.java +85 −473 File changed.Preview size limit exceeded, changes collapsed. Show changes
src/com/android/launcher3/graphics/LauncherIcons.java +0 −12 Original line number Diff line number Diff line Loading @@ -20,9 +20,7 @@ import android.content.Context; import android.content.Intent.ShortcutIconResource; import android.content.pm.PackageManager; import android.content.res.Resources; import android.database.Cursor; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.PaintFlagsDrawFilter; Loading Loading @@ -51,16 +49,6 @@ public class LauncherIcons { Paint.FILTER_BITMAP_FLAG)); } public static Bitmap createIconBitmap(Cursor c, int iconIndex, Context context) { byte[] data = c.getBlob(iconIndex); try { return createIconBitmap(BitmapFactory.decodeByteArray(data, 0, data.length), context); } catch (Exception e) { return null; } } /** * Returns a bitmap suitable for the all apps view. If the package or the resource do not * exist, it returns null. Loading