From f893331cb986ed915d5f4facc299e12ccb446a9d Mon Sep 17 00:00:00 2001 From: Luis Vidal Date: Tue, 12 Jan 2016 10:20:08 -0800 Subject: Fix to display Live Lock Screen preview If current theme has a LLS, we need to get the path from the provider and manually load the bitmap (WallpaperManager will return a Drawable only for lock wallpaper) This patch also prevents two titles from being highlighted in the lock screen selector when a package contains a static wallaper AND a live lock screen Change-Id: I6e8312e7a6e15dfff930de23c3a24afa74df43d1 TICKET: CHOOSER-106 --- src/com/cyngn/theme/chooser/ChooserActivity.java | 4 +++ src/com/cyngn/theme/chooser/ComponentSelector.java | 40 +++++++++++++++++++--- src/com/cyngn/theme/chooser/MyThemeFragment.java | 17 +++++---- src/com/cyngn/theme/chooser/ThemeFragment.java | 12 +++++-- 4 files changed, 60 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/com/cyngn/theme/chooser/ChooserActivity.java b/src/com/cyngn/theme/chooser/ChooserActivity.java index 78a583f..b80e6c7 100644 --- a/src/com/cyngn/theme/chooser/ChooserActivity.java +++ b/src/com/cyngn/theme/chooser/ChooserActivity.java @@ -896,6 +896,10 @@ public class ChooserActivity extends FragmentActivity return CursorLoaderHelper.chooserActivityCursorLoader(this, id, mAppliedBaseTheme); } + public Map getSelectedComponentsMap() { + return getCurrentFragment().getSelectedComponentsMap(); + } + public class ThemesAdapter extends NewFragmentStatePagerAdapter { private ArrayList mInstalledThemes; private String mAppliedThemeTitle; diff --git a/src/com/cyngn/theme/chooser/ComponentSelector.java b/src/com/cyngn/theme/chooser/ComponentSelector.java index f3f4af2..8b69b0a 100644 --- a/src/com/cyngn/theme/chooser/ComponentSelector.java +++ b/src/com/cyngn/theme/chooser/ComponentSelector.java @@ -48,6 +48,8 @@ import com.cyngn.theme.util.ThemedTypefaceHelper; import com.cyngn.theme.util.TypefaceHelperCache; import com.cyngn.theme.util.Utils; +import java.util.Map; + import static android.provider.ThemesContract.ThemesColumns.MODIFIES_ALARMS; import static android.provider.ThemesContract.ThemesColumns.MODIFIES_BOOT_ANIM; import static android.provider.ThemesContract.ThemesColumns.MODIFIES_LAUNCHER; @@ -230,6 +232,12 @@ public class ComponentSelector extends LinearLayout } else if (mComponentType != null) { int count = mContent.getChildCount(); final Resources res = getResources(); + boolean highlightTitle; + Map selectedComponents = null; + if (mComponentType.equals(MODIFIES_LOCKSCREEN)) { + selectedComponents = ((ChooserActivity)mContext) + .getSelectedComponentsMap(); + } for (int i = 0; i < count; i++) { final View child = mContent.getChildAt(i); final TextView tv = (TextView) child.findViewById(R.id.title); @@ -241,7 +249,18 @@ public class ComponentSelector extends LinearLayout if (cmpntId == null) { cmpntId = DEFAULT_COMPONENT_ID; } - if (pkgName.equals(selectedPkgName) && cmpntId == selectedComponentId) { + Boolean isLLS = (Boolean) viewWithTag.getTag(R.id.tag_key_live_lock_screen); + highlightTitle = false; + if (selectedComponents != null && isLLS != null) { + if ((TextUtils.equals(selectedComponents.get(MODIFIES_LOCKSCREEN), pkgName) + && !isLLS) || (TextUtils.equals(selectedComponents.get( + MODIFIES_LIVE_LOCK_SCREEN), pkgName) && isLLS)) { + highlightTitle = true; + } + } else if (pkgName.equals(selectedPkgName) && cmpntId == selectedComponentId) { + highlightTitle = true; + } + if (highlightTitle) { tv.setTextColor(res.getColor(R.color.component_selection_current_text_color)); } else { tv.setTextColor(res.getColor(android.R.color.white)); @@ -782,9 +801,22 @@ public class ComponentSelector extends LinearLayout } else { titleView.setText(cursor.getString(cursor.getColumnIndex(ThemesColumns.TITLE))); } - if (pkgName.equals(mSelectedComponentPkgName) && cmpntId == mSelectedComponentId) { - titleView.setTextColor(getResources().getColor( - R.color.component_selection_current_text_color)); + boolean highlightTitle = false; + if (mComponentType.equals(MODIFIES_LOCKSCREEN)) { + Map selectedComponents = ((ChooserActivity)mContext) + .getSelectedComponentsMap(); + int isLLS = cursor.getInt(cursor.getColumnIndex(MODIFIES_LIVE_LOCK_SCREEN)); + if ((TextUtils.equals(selectedComponents.get(MODIFIES_LOCKSCREEN), pkgName) + && isLLS == 0) || (TextUtils.equals( + selectedComponents.get(MODIFIES_LIVE_LOCK_SCREEN), pkgName) && isLLS == 1)) { + highlightTitle = true; + } + } else if (pkgName.equals(mSelectedComponentPkgName) && cmpntId == mSelectedComponentId) { + highlightTitle = true; + } + if (highlightTitle) { + titleView.setTextColor(getResources().getColor( + R.color.component_selection_current_text_color)); } } diff --git a/src/com/cyngn/theme/chooser/MyThemeFragment.java b/src/com/cyngn/theme/chooser/MyThemeFragment.java index c8a941b..2b76d5b 100644 --- a/src/com/cyngn/theme/chooser/MyThemeFragment.java +++ b/src/com/cyngn/theme/chooser/MyThemeFragment.java @@ -466,14 +466,19 @@ public class MyThemeFragment extends ThemeFragment { overlay = getOverlayDrawable(mLockScreenCard, true); } - int wpIdx = c.getColumnIndex(PreviewColumns.LOCK_WALLPAPER_PREVIEW); - final Resources res = getResources(); - final Context context = getActivity(); - Drawable wp = context == null ? null : - WallpaperManager.getInstance(context).getFastKeyguardDrawable(); - if (wp == null) { + //If the current theme includes a lock wallpaper, the WallpaperMgr will + //return a valid Drawable we can display in the card. However, if the user + //picked a LLS, we need to get the path from the provider and manually load the bitmap + int wpIdx = c.getColumnIndex(PreviewColumns.LIVE_LOCK_SCREEN_PREVIEW); + Drawable wp = null; + if (wpIdx >= 0) { + final Resources res = getResources(); Bitmap bmp = Utils.loadBitmapBlob(c, wpIdx); if (bmp != null) wp = new BitmapDrawable(res, bmp); + } else { + final Context context = getActivity(); + wp = context == null ? null : + WallpaperManager.getInstance(context).getFastKeyguardDrawable(); } if (wp != null) { mLockScreenCard.setWallpaper(wp); diff --git a/src/com/cyngn/theme/chooser/ThemeFragment.java b/src/com/cyngn/theme/chooser/ThemeFragment.java index e6fcd9e..3cc229d 100644 --- a/src/com/cyngn/theme/chooser/ThemeFragment.java +++ b/src/com/cyngn/theme/chooser/ThemeFragment.java @@ -1972,9 +1972,11 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb long selectedComponentId = (ThemesColumns.MODIFIES_LAUNCHER.equals(component)) ? mSelectedWallpaperComponentId : DEFAULT_COMPONENT_ID; String pkgName = mSelectedComponentsMap.get(component); - if (component.equals(MODIFIES_LOCKSCREEN) - && mSelectedComponentsMap.containsKey(MODIFIES_LIVE_LOCK_SCREEN)) { - pkgName = mSelectedComponentsMap.get(MODIFIES_LIVE_LOCK_SCREEN); + if (component.equals(MODIFIES_LOCKSCREEN) && TextUtils.isEmpty(pkgName)) { + String liveLockScreenPkg = mSelectedComponentsMap.get(MODIFIES_LIVE_LOCK_SCREEN); + if (liveLockScreenPkg != null) { + pkgName = liveLockScreenPkg; + } } getChooserActivity().showComponentSelector(component, pkgName, selectedComponentId, v); fadeOutNonSelectedCards(mActiveCardId); @@ -2673,6 +2675,10 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb scrollAnimator.start(); } + public Map getSelectedComponentsMap() { + return mSelectedComponentsMap; + } + /** * Slides the scrollview content down and removes a space view at the bottom * of mAdditionalCards. -- cgit v1.1