Skip to content

Commit

Permalink
remove duplicated flattenBitmap method
Browse files Browse the repository at this point in the history
Signed-off-by: Saul Henriquez <[email protected]>
  • Loading branch information
saulhdev committed Sep 20, 2020
1 parent 902ac35 commit 0011547
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 22 deletions.
21 changes: 0 additions & 21 deletions src/com/android/launcher3/Utilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@
import com.saggitt.omega.iconpack.IconPackManager;
import com.saggitt.omega.util.Config;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
Expand Down Expand Up @@ -857,25 +855,6 @@ public static <T> T notNullOrDefault(T value, T defValue) {

private static List<Runnable> onStart = new ArrayList<>();

/**
* Compresses the bitmap to a byte array for serialization.
*/
public static byte[] flattenBitmap(Bitmap bitmap) {
// Try go guesstimate how much space the icon will take when serialized
// to avoid unnecessary allocations/copies during the write.
int size = bitmap.getWidth() * bitmap.getHeight() * 4;
ByteArrayOutputStream out = new ByteArrayOutputStream(size);
try {
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
out.flush();
out.close();
return out.toByteArray();
} catch (IOException e) {
Log.w(TAG, "Could not write bitmap");
return null;
}
}

/**
* ATTENTION: Only ever call this from within LawnchairLauncher.kt
*/
Expand Down
3 changes: 2 additions & 1 deletion src/com/android/launcher3/model/ModelWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import com.android.launcher3.Utilities;
import com.android.launcher3.WorkspaceItemInfo;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.icons.GraphicsUtils;
import com.android.launcher3.logging.FileLog;
import com.android.launcher3.model.BgDataModel.Callbacks;
import com.android.launcher3.util.ContentWriter;
Expand Down Expand Up @@ -223,7 +224,7 @@ public static void modifyItemInDatabase(Context context, final ItemInfo item, St
writer.put(Favorites.TITLE_ALIAS, alias);
writer.put(Favorites.SWIPE_UP_ACTION, swipeUpAction);
if (updateIcon) {
writer.put(Favorites.CUSTOM_ICON, icon != null ? Utilities.flattenBitmap(icon) : null);
writer.put(Favorites.CUSTOM_ICON, icon != null ? GraphicsUtils.flattenBitmap(icon) : null);
writer.put(Favorites.CUSTOM_ICON_ENTRY, iconEntry != null ? iconEntry.toString() : null);
}
return writer;
Expand Down

0 comments on commit 0011547

Please sign in to comment.