diff options
author | Richard MacGregor <rmacgregor@cyngn.com> | 2015-05-16 18:59:39 +0000 |
---|---|---|
committer | Richard MacGregor <rmacgregor@cyngn.com> | 2015-05-16 18:59:39 +0000 |
commit | 6b5530438c163ef91f0f76e4ecffae5ac20ce8a2 (patch) | |
tree | 1d78ff68fcb9c7d66f13bbf3eba31a5240644dea | |
parent | d25b46108d55a2a81aa538f777bfeb8993f8a17f (diff) | |
download | packages_apps_ThemeChooser-6b5530438c163ef91f0f76e4ecffae5ac20ce8a2.tar.gz packages_apps_ThemeChooser-6b5530438c163ef91f0f76e4ecffae5ac20ce8a2.tar.bz2 packages_apps_ThemeChooser-6b5530438c163ef91f0f76e4ecffae5ac20ce8a2.zip |
Revert "Use files instead of blobs"
This reverts commit d25b46108d55a2a81aa538f777bfeb8993f8a17f.
Change-Id: Ieec2bd3a9aa1369270e8a25eebb898eb21a25c5a
-rw-r--r-- | src/com/cyngn/theme/chooser/ComponentSelector.java | 24 | ||||
-rw-r--r-- | src/com/cyngn/theme/chooser/MyThemeFragment.java | 4 | ||||
-rw-r--r-- | src/com/cyngn/theme/chooser/ThemeFragment.java | 26 | ||||
-rw-r--r-- | src/com/cyngn/theme/util/Utils.java | 26 |
4 files changed, 27 insertions, 53 deletions
diff --git a/src/com/cyngn/theme/chooser/ComponentSelector.java b/src/com/cyngn/theme/chooser/ComponentSelector.java index d693c7e..25d25a8 100644 --- a/src/com/cyngn/theme/chooser/ComponentSelector.java +++ b/src/com/cyngn/theme/chooser/ComponentSelector.java @@ -527,16 +527,16 @@ public class ComponentSelector extends LinearLayout int pkgNameIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.PKG_NAME); ((ImageView) v.findViewById(R.id.slot1)).setImageBitmap( - Utils.loadBitmapFile(cursor, wifiIndex)); + Utils.loadBitmapBlob(cursor, wifiIndex)); ((ImageView) v.findViewById(R.id.slot2)).setImageBitmap( - Utils.loadBitmapFile(cursor, signalIndex)); + Utils.loadBitmapBlob(cursor, signalIndex)); ((ImageView) v.findViewById(R.id.slot3)).setImageBitmap( - Utils.loadBitmapFile(cursor, bluetoothIndex)); + Utils.loadBitmapBlob(cursor, bluetoothIndex)); ((ImageView) v.findViewById(R.id.slot4)).setImageBitmap( - Utils.loadBitmapFile(cursor, batteryIndex)); + Utils.loadBitmapBlob(cursor, batteryIndex)); setTitle(((TextView) v.findViewById(R.id.title)), cursor); v.findViewById(R.id.container).setBackground( - new BitmapDrawable(Utils.loadBitmapFile(cursor, backgroundIndex))); + new BitmapDrawable(Utils.loadBitmapBlob(cursor, backgroundIndex))); v.setTag(cursor.getString(pkgNameIndex)); v.setOnClickListener(mItemClickListener); return v; @@ -551,10 +551,10 @@ public class ComponentSelector extends LinearLayout int pkgNameIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.PKG_NAME); ((ImageView) v.findViewById(R.id.back)).setImageBitmap( - Utils.loadBitmapFile(cursor, backIndex)); + Utils.loadBitmapBlob(cursor, backIndex)); setTitle(((TextView) v.findViewById(R.id.title)), cursor); v.findViewById(R.id.container).setBackground( - new BitmapDrawable(Utils.loadBitmapFile(cursor, backgroundIndex))); + new BitmapDrawable(Utils.loadBitmapBlob(cursor, backgroundIndex))); v.setTag(cursor.getString(pkgNameIndex)); v.setOnClickListener(mItemClickListener); return v; @@ -586,7 +586,7 @@ public class ComponentSelector extends LinearLayout int pkgNameIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.PKG_NAME); ((ImageView) v.findViewById(R.id.icon)).setImageBitmap( - Utils.loadBitmapFile(cursor, iconIndex)); + Utils.loadBitmapBlob(cursor, iconIndex)); setTitle(((TextView) v.findViewById(R.id.title)), cursor); v.setTag(cursor.getString(pkgNameIndex)); v.setOnClickListener(mItemClickListener); @@ -601,7 +601,7 @@ public class ComponentSelector extends LinearLayout int pkgNameIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.PKG_NAME); ((ImageView) v.findViewById(R.id.icon)).setImageBitmap( - Utils.loadBitmapFile(cursor, styleIndex)); + Utils.loadBitmapBlob(cursor, styleIndex)); setTitle(((TextView) v.findViewById(R.id.title)), cursor); v.setTag(cursor.getString(pkgNameIndex)); v.setOnClickListener(mItemClickListener); @@ -626,7 +626,7 @@ public class ComponentSelector extends LinearLayout cursor.moveToPosition(position - EXTRA_WALLPAPER_COMPONENTS); int pkgNameIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.PKG_NAME); iv.setImageBitmap( - Utils.loadBitmapFile(cursor, wallpaperIndex)); + Utils.loadBitmapBlob(cursor, wallpaperIndex)); setTitle(((TextView) v.findViewById(R.id.title)), cursor); v.setTag(cursor.getString(pkgNameIndex)); } @@ -642,7 +642,7 @@ public class ComponentSelector extends LinearLayout int pkgNameIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.PKG_NAME); ((ImageView) v.findViewById(R.id.preview)).setImageBitmap( - Utils.loadBitmapFile(cursor, wallpaperIndex)); + Utils.loadBitmapBlob(cursor, wallpaperIndex)); setTitle(((TextView) v.findViewById(R.id.title)), cursor); v.setTag(cursor.getString(pkgNameIndex)); v.setOnClickListener(mItemClickListener); @@ -784,4 +784,4 @@ public class ComponentSelector extends LinearLayout public void onSelectorOpened(); public void onSelectorClosed(); } -} +}
\ No newline at end of file diff --git a/src/com/cyngn/theme/chooser/MyThemeFragment.java b/src/com/cyngn/theme/chooser/MyThemeFragment.java index c66ad53..f74d53b 100644 --- a/src/com/cyngn/theme/chooser/MyThemeFragment.java +++ b/src/com/cyngn/theme/chooser/MyThemeFragment.java @@ -423,7 +423,7 @@ public class MyThemeFragment extends ThemeFragment { Drawable wp = context == null ? null : wm.getDrawable(); if (wp == null) { - Bitmap bmp = Utils.loadBitmapFile(c, wpIdx); + Bitmap bmp = Utils.loadBitmapBlob(c, wpIdx); if (bmp != null) wp = new BitmapDrawable(res, bmp); } if (wp != null) { @@ -461,7 +461,7 @@ public class MyThemeFragment extends ThemeFragment { Drawable wp = context == null ? null : WallpaperManager.getInstance(context).getFastKeyguardDrawable(); if (wp == null) { - Bitmap bmp = Utils.loadBitmapFile(c, wpIdx); + Bitmap bmp = Utils.loadBitmapBlob(c, wpIdx); if (bmp != null) wp = new BitmapDrawable(res, bmp); } if (wp != null) { diff --git a/src/com/cyngn/theme/chooser/ThemeFragment.java b/src/com/cyngn/theme/chooser/ThemeFragment.java index 251181b..09d119b 100644 --- a/src/com/cyngn/theme/chooser/ThemeFragment.java +++ b/src/com/cyngn/theme/chooser/ThemeFragment.java @@ -1638,7 +1638,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb int pkgNameIdx = c.getColumnIndex(ThemesColumns.PKG_NAME); int wpIdx = c.getColumnIndex(PreviewColumns.KEY_WALLPAPER_PREVIEW); final Resources res = getResources(); - Bitmap bitmap = Utils.loadBitmapFile(c, wpIdx); + Bitmap bitmap = Utils.loadBitmapBlob(c, wpIdx); if (bitmap != null) { mWallpaper.setImageBitmap(bitmap); mWallpaperCard.setWallpaper(new BitmapDrawable(res, bitmap)); @@ -1671,7 +1671,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb int pkgNameIdx = c.getColumnIndex(ThemesColumns.PKG_NAME); int wpIdx = c.getColumnIndex(PreviewColumns.KEY_LOCK_WALLPAPER_PREVIEW); final Resources res = getResources(); - Bitmap bitmap = Utils.loadBitmapFile(c, wpIdx); + Bitmap bitmap = Utils.loadBitmapBlob(c, wpIdx); if (bitmap != null) { mLockScreenCard.setWallpaper(new BitmapDrawable(res, bitmap)); String pkgName = c.getString(pkgNameIdx); @@ -1701,11 +1701,11 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb int clockColorIdx = c.getColumnIndex(PreviewColumns.KEY_STATUSBAR_CLOCK_TEXT_COLOR); int pkgNameIdx = c.getColumnIndex(ThemesColumns.PKG_NAME); - Bitmap background = Utils.loadBitmapFile(c, backgroundIdx); - Bitmap bluetoothIcon = Utils.loadBitmapFile(c, bluetoothIdx); - Bitmap wifiIcon = Utils.loadBitmapFile(c, wifiIdx); - Bitmap signalIcon = Utils.loadBitmapFile(c, signalIdx); - Bitmap batteryIcon = Utils.loadBitmapFile(c, batteryIdx); + Bitmap background = Utils.loadBitmapBlob(c, backgroundIdx); + Bitmap bluetoothIcon = Utils.loadBitmapBlob(c, bluetoothIdx); + Bitmap wifiIcon = Utils.loadBitmapBlob(c, wifiIdx); + Bitmap signalIcon = Utils.loadBitmapBlob(c, signalIdx); + Bitmap batteryIcon = Utils.loadBitmapBlob(c, batteryIdx); int wifiMargin = c.getInt(wifiMarginIdx); int clockTextColor = c.getInt(clockColorIdx); @@ -1778,7 +1778,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb for(int i=0; i < iconViews.size() && i < iconIdx.length; i++) { final ImageView v = iconViews.get(i); - Bitmap bitmap = Utils.loadBitmapFile(c, iconIdx[i]); + Bitmap bitmap = Utils.loadBitmapBlob(c, iconIdx[i]); Drawable oldIcon = v.getDrawable(); Drawable newIcon; if (bitmap == null) { @@ -1826,10 +1826,10 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb } int pkgNameIdx = c.getColumnIndex(ThemesColumns.PKG_NAME); - Bitmap background = Utils.loadBitmapFile(c, backgroundIdx); - Bitmap backButton = Utils.loadBitmapFile(c, backButtonIdx); - Bitmap homeButton = Utils.loadBitmapFile(c, homeButtonIdx); - Bitmap recentButton = Utils.loadBitmapFile(c, recentButtonIdx); + Bitmap background = Utils.loadBitmapBlob(c, backgroundIdx); + Bitmap backButton = Utils.loadBitmapBlob(c, backButtonIdx); + Bitmap homeButton = Utils.loadBitmapBlob(c, homeButtonIdx); + Bitmap recentButton = Utils.loadBitmapBlob(c, recentButtonIdx); Drawable overlay = null; if (animate) { @@ -1890,7 +1890,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb int pkgNameIdx = c.getColumnIndex(ThemesColumns.PKG_NAME); int styleIdx = c.getColumnIndex(PreviewColumns.KEY_STYLE_PREVIEW); - mStylePreview.setImageBitmap(Utils.loadBitmapFile(c, styleIdx)); + mStylePreview.setImageBitmap(Utils.loadBitmapBlob(c, styleIdx)); if (pkgNameIdx > -1) { String pkgName = c.getString(pkgNameIdx); if (!mPkgName.equals(pkgName) || (mPkgName.equals(pkgName) diff --git a/src/com/cyngn/theme/util/Utils.java b/src/com/cyngn/theme/util/Utils.java index a2169e3..7b885a7 100644 --- a/src/com/cyngn/theme/util/Utils.java +++ b/src/com/cyngn/theme/util/Utils.java @@ -24,7 +24,6 @@ import android.graphics.Rect; import android.os.RemoteException; import android.provider.Settings; import android.provider.ThemesContract; -import android.text.TextUtils; import android.util.Log; import android.util.TypedValue; import android.view.IWindowManager; @@ -33,9 +32,7 @@ import android.view.WindowManager; import android.view.WindowManagerGlobal; import com.cyngn.theme.chooser.ChooserActivity; -import java.io.BufferedInputStream; import java.io.File; -import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -277,29 +274,6 @@ public class Utils { return BitmapFactory.decodeByteArray(blob, 0, blob.length); } - public static Bitmap loadBitmapFile(Cursor cursor, int columnIdx) { - if (columnIdx < 0) { - Log.w(TAG, "loadBitmapFile(): Invalid index provided, returning null"); - return null; - } - String path = cursor.getString(columnIdx); - if (TextUtils.isEmpty(path)) { - return null; - } - - Bitmap image = null; - FileInputStream inputStream; - try { - inputStream = new FileInputStream(path); - image = BitmapFactory.decodeStream(inputStream); - inputStream.close(); - } catch (Exception e) { - Log.w(TAG, "Unable to open preview " + path, e); - } - - return image; - } - public static String getBatteryKey(int type) { switch(type) { case 2: |