From 590804752bc280f2905b3bf86b49e467fd0fd610 Mon Sep 17 00:00:00 2001 From: d34d Date: Fri, 9 Oct 2015 15:58:51 -0700 Subject: Add live lock screen support for dogefood The final UX will combine both static lock screen wallpapers and the new live lock screen with a banner indicating which are "live" Change-Id: I26fc793930316296178437d1d98e6e645e17b7e5 --- src/com/cyngn/theme/chooser/ChooserActivity.java | 3 +- src/com/cyngn/theme/chooser/ComponentSelector.java | 24 ++++++++++ src/com/cyngn/theme/chooser/ThemeFragment.java | 51 ++++++++++++++++++++++ src/com/cyngn/theme/util/CursorLoaderHelper.java | 23 +++++++++- 4 files changed, 98 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/com/cyngn/theme/chooser/ChooserActivity.java b/src/com/cyngn/theme/chooser/ChooserActivity.java index c851abe..b395ecc 100644 --- a/src/com/cyngn/theme/chooser/ChooserActivity.java +++ b/src/com/cyngn/theme/chooser/ChooserActivity.java @@ -65,6 +65,7 @@ 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_LIVE_LOCK_SCREEN; import static android.provider.ThemesContract.ThemesColumns.MODIFIES_NOTIFICATIONS; import static android.provider.ThemesContract.ThemesColumns.MODIFIES_RINGTONES; @@ -506,7 +507,7 @@ public class ChooserActivity extends FragmentActivity final Resources res = getResources(); int itemsPerPage = res.getInteger(R.integer.default_items_per_page); int height = res.getDimensionPixelSize(R.dimen.component_selection_cell_height); - if (MODIFIES_BOOT_ANIM.equals(component)) { + if (MODIFIES_BOOT_ANIM.equals(component) || MODIFIES_LIVE_LOCK_SCREEN.equals(component)) { itemsPerPage = res.getInteger(R.integer.bootani_items_per_page); height = res.getDimensionPixelSize( R.dimen.component_selection_cell_height_boot_anim); diff --git a/src/com/cyngn/theme/chooser/ComponentSelector.java b/src/com/cyngn/theme/chooser/ComponentSelector.java index 1898a94..9f63344 100644 --- a/src/com/cyngn/theme/chooser/ComponentSelector.java +++ b/src/com/cyngn/theme/chooser/ComponentSelector.java @@ -50,6 +50,7 @@ import com.cyngn.theme.util.Utils; 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; +import static android.provider.ThemesContract.ThemesColumns.MODIFIES_LIVE_LOCK_SCREEN; import static android.provider.ThemesContract.ThemesColumns.MODIFIES_LOCKSCREEN; import static android.provider.ThemesContract.ThemesColumns.MODIFIES_NOTIFICATIONS; import static android.provider.ThemesContract.ThemesColumns.MODIFIES_OVERLAYS; @@ -59,6 +60,7 @@ import static android.provider.ThemesContract.ThemesColumns.MODIFIES_NAVIGATION_ import static android.provider.ThemesContract.ThemesColumns.MODIFIES_ICONS; import static android.provider.ThemesContract.ThemesColumns.MODIFIES_FONTS; +import static com.cyngn.theme.util.CursorLoaderHelper.LOADER_ID_LIVE_LOCK_SCREEN; import static com.cyngn.theme.util.CursorLoaderHelper.LOADER_ID_STATUS_BAR; import static com.cyngn.theme.util.CursorLoaderHelper.LOADER_ID_FONT; import static com.cyngn.theme.util.CursorLoaderHelper.LOADER_ID_ICONS; @@ -318,6 +320,9 @@ public class ComponentSelector extends LinearLayout if (MODIFIES_LOCKSCREEN.equals(component)) { return LOADER_ID_LOCKSCREEN; } + if (MODIFIES_LIVE_LOCK_SCREEN.equals(component)) { + return LOADER_ID_LIVE_LOCK_SCREEN; + } return -1; } @@ -348,6 +353,7 @@ public class ComponentSelector extends LinearLayout mContent.setShowDividers(LinearLayout.SHOW_DIVIDER_NONE); break; case LOADER_ID_BOOT_ANIMATION: + case LOADER_ID_LIVE_LOCK_SCREEN: dividerPadding = res.getDimensionPixelSize( R.dimen.component_divider_padding_top_bootani); dividerHeight = res.getDimensionPixelSize(R.dimen.component_divider_height_bootani); @@ -413,6 +419,9 @@ public class ComponentSelector extends LinearLayout return newWallpapersView(cursor, container, position, cursor.getColumnIndex(PreviewColumns.LOCK_WALLPAPER_THUMBNAIL)); } + if (MODIFIES_LIVE_LOCK_SCREEN.equals(mComponentType)) { + return newLiveLockScreenView(cursor, container, position); + } return null; } @@ -613,6 +622,21 @@ public class ComponentSelector extends LinearLayout return container; } + private View newLiveLockScreenView(Cursor cursor, ViewGroup parent, int position) { + cursor.moveToPosition(position); + View v = mInflater.inflate(R.layout.bootani_component_selection_item, parent, + false); + int wallpaperIndex = cursor.getColumnIndex(PreviewColumns.LIVE_LOCK_SCREEN_THUMBNAIL); + int pkgNameIndex = cursor.getColumnIndex(ThemesContract.ThemesColumns.PKG_NAME); + + ((ImageView) v.findViewById(R.id.preview)).setImageBitmap( + Utils.loadBitmapBlob(cursor, wallpaperIndex)); + setTitle(((TextView) v.findViewById(R.id.title)), cursor); + v.setTag(R.id.tag_key_package_name, cursor.getString(pkgNameIndex)); + v.setOnClickListener(mItemClickListener); + return v; + } + private class LoadItemsTask extends AsyncTask { @Override diff --git a/src/com/cyngn/theme/chooser/ThemeFragment.java b/src/com/cyngn/theme/chooser/ThemeFragment.java index 30090b9..f4cec1a 100644 --- a/src/com/cyngn/theme/chooser/ThemeFragment.java +++ b/src/com/cyngn/theme/chooser/ThemeFragment.java @@ -102,6 +102,7 @@ import java.util.zip.ZipFile; 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; +import static android.provider.ThemesContract.ThemesColumns.MODIFIES_LIVE_LOCK_SCREEN; import static android.provider.ThemesContract.ThemesColumns.MODIFIES_LOCKSCREEN; import static android.provider.ThemesContract.ThemesColumns.MODIFIES_NOTIFICATIONS; import static android.provider.ThemesContract.ThemesColumns.MODIFIES_OVERLAYS; @@ -126,6 +127,7 @@ import static com.cyngn.theme.util.CursorLoaderHelper.LOADER_ID_BOOT_ANIMATION; import static com.cyngn.theme.util.CursorLoaderHelper.LOADER_ID_RINGTONE; import static com.cyngn.theme.util.CursorLoaderHelper.LOADER_ID_NOTIFICATION; import static com.cyngn.theme.util.CursorLoaderHelper.LOADER_ID_ALARM; +import static com.cyngn.theme.util.CursorLoaderHelper.LOADER_ID_LIVE_LOCK_SCREEN; import static android.content.pm.ThemeUtils.SYSTEM_TARGET_API; @@ -215,6 +217,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb protected ComponentCardView mFontCard; protected ComponentCardView mIconCard; protected ComponentCardView mBootAnimationCard; + protected ComponentCardView mLiveLockScreenCard; protected BootAniImageView mBootAnimation; // Nav Bar Views @@ -243,6 +246,9 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb // Style views protected ImageView mStylePreview; + // Live lock screen view + protected ImageView mLiveLockScreenView; + // Sound cards protected ComponentCardView mRingtoneCard; protected ImageView mRingtonePlayPause; @@ -345,6 +351,8 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb mCardIdsToComponentTypes.put(R.id.ringtone_preview_container, MODIFIES_RINGTONES); mCardIdsToComponentTypes.put(R.id.notification_preview_container, MODIFIES_NOTIFICATIONS); mCardIdsToComponentTypes.put(R.id.alarm_preview_container, MODIFIES_ALARMS); + mCardIdsToComponentTypes.put(R.id.live_lock_screen_preview_container, + MODIFIES_LIVE_LOCK_SCREEN); mMediaPlayers = new HashMap(3); } @@ -474,6 +482,9 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb mWallpaperCard = (WallpaperCardView) v.findViewById(R.id.wallpaper_card); mLockScreenCard = (WallpaperCardView) v.findViewById(R.id.lockscreen_card); + mLiveLockScreenCard = + (ComponentCardView) v.findViewById(R.id.live_lock_screen_preview_container); + mLiveLockScreenView = (ImageView) v.findViewById(R.id.live_lock_screen_preview); int translationY = getDistanceToMoveBelowScreen(mAdditionalCards); mAdditionalCards.setTranslationY(translationY); @@ -1286,6 +1297,9 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb case LOADER_ID_ALARM: loadAudible(RingtoneManager.TYPE_ALARM, c, animate); break; + case LOADER_ID_LIVE_LOCK_SCREEN: + loadLiveLockScreen(c, animate); + break; } } @@ -1353,6 +1367,14 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb setAddComponentTitle(mAlarmCard, getAudibleLabel(RingtoneManager.TYPE_ALARM)); } + } else if (MODIFIES_LIVE_LOCK_SCREEN.equals(component)) { + if (hasContent) { + loadLiveLockScreen(c, false); + } else { + mLiveLockScreenCard.setEmptyViewEnabled(true); + setAddComponentTitle(mLiveLockScreenCard, + getString(R.string.live_lock_screen_label)); + } } else { throw new IllegalArgumentException("Don't know how to load: " + component); } @@ -1776,6 +1798,33 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb thread.start(); } + protected void loadLiveLockScreen(Cursor c, boolean animate) { + Drawable overlay = null; + if (animate) { + overlay = getOverlayDrawable(mLiveLockScreenView, false); + } + if (mLiveLockScreenCard.isShowingEmptyView()) { + mLiveLockScreenCard.setEmptyViewEnabled(false); + } + + int pkgNameIdx = c.getColumnIndex(ThemesColumns.PKG_NAME); + int styleIdx = c.getColumnIndex(PreviewColumns.LIVE_LOCK_SCREEN_PREVIEW); + mLiveLockScreenView.setImageBitmap(Utils.loadBitmapBlob(c, styleIdx)); + if (pkgNameIdx > -1) { + String pkgName = c.getString(pkgNameIdx); + if (!mPkgName.equals(pkgName) || (mPkgName.equals(pkgName) + && mBaseThemeSupportedComponents.contains(MODIFIES_LIVE_LOCK_SCREEN))) { + mSelectedComponentsMap.put(MODIFIES_LIVE_LOCK_SCREEN, pkgName); + setCardTitle(mLiveLockScreenCard, pkgName, + getString(R.string.live_lock_screen_label)); + } + } + if (animate) { + animateContentChange(R.id.live_lock_screen_preview_container, mLiveLockScreenView, + overlay); + } + } + protected Drawable getOverlayDrawable(View v, boolean requiresTransparency) { if (!v.isDrawingCacheEnabled()) v.setDrawingCacheEnabled(true); Bitmap cache = v.getDrawingCache(true).copy( @@ -1968,6 +2017,8 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb loaderId = LOADER_ID_NOTIFICATION; } else if (MODIFIES_ALARMS.equals(component)) { loaderId = LOADER_ID_ALARM; + } else if (MODIFIES_LIVE_LOCK_SCREEN.equals(component)) { + loaderId = LOADER_ID_LIVE_LOCK_SCREEN; } else { return; } diff --git a/src/com/cyngn/theme/util/CursorLoaderHelper.java b/src/com/cyngn/theme/util/CursorLoaderHelper.java index e4f2ebe..fdbb64f 100644 --- a/src/com/cyngn/theme/util/CursorLoaderHelper.java +++ b/src/com/cyngn/theme/util/CursorLoaderHelper.java @@ -18,6 +18,7 @@ import cyanogenmod.app.ThemeVersion; 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; +import static android.provider.ThemesContract.ThemesColumns.MODIFIES_LIVE_LOCK_SCREEN; import static android.provider.ThemesContract.ThemesColumns.MODIFIES_LOCKSCREEN; import static android.provider.ThemesContract.ThemesColumns.MODIFIES_NOTIFICATIONS; import static android.provider.ThemesContract.ThemesColumns.MODIFIES_OVERLAYS; @@ -42,6 +43,7 @@ public class CursorLoaderHelper { public static final int LOADER_ID_RINGTONE = 9; public static final int LOADER_ID_NOTIFICATION = 10; public static final int LOADER_ID_ALARM = 11; + public static final int LOADER_ID_LIVE_LOCK_SCREEN = 12; public static final int LOADER_ID_INSTALLED_THEMES = 1000; public static final int LOADER_ID_APPLIED = 1001; @@ -184,6 +186,14 @@ public class CursorLoaderHelper { }; } break; + case LOADER_ID_LIVE_LOCK_SCREEN: + selection = MODIFIES_LIVE_LOCK_SCREEN + "=?"; + projection = new String[] { + PreviewColumns.LIVE_LOCK_SCREEN_THUMBNAIL, + ThemesColumns.TITLE, + ThemesColumns.PKG_NAME + }; + break; default: return null; } @@ -215,7 +225,8 @@ public class CursorLoaderHelper { PreviewColumns.ICON_PREVIEW_3, PreviewColumns.LOCK_WALLPAPER_PREVIEW, PreviewColumns.STYLE_PREVIEW, - PreviewColumns.NAVBAR_BACKGROUND + PreviewColumns.NAVBAR_BACKGROUND, + PreviewColumns.LIVE_LOCK_SCREEN_PREVIEW }; uri = PreviewColumns.APPLIED_URI; return new CursorLoader(context, uri, projection, null, null, null); @@ -274,7 +285,8 @@ public class CursorLoaderHelper { PreviewColumns.ICON_PREVIEW_2, PreviewColumns.ICON_PREVIEW_3, PreviewColumns.LOCK_WALLPAPER_PREVIEW, - PreviewColumns.STYLE_PREVIEW + PreviewColumns.STYLE_PREVIEW, + PreviewColumns.LIVE_LOCK_SCREEN_PREVIEW }; break; case LOADER_ID_STATUS_BAR: @@ -366,6 +378,13 @@ public class CursorLoaderHelper { ThemesColumns.TITLE }; break; + case LOADER_ID_LIVE_LOCK_SCREEN: + projection = new String[] { + ThemesColumns.PKG_NAME, + ThemesColumns.TITLE, + PreviewColumns.LIVE_LOCK_SCREEN_PREVIEW + }; + break; } return new CursorLoader(context, uri, projection, selection, selectionArgs, null); } -- cgit v1.2.3