diff options
-rw-r--r-- | res/layout/fragment_pager_list.xml | 3 | ||||
-rw-r--r-- | res/layout/live_lock_screen_card.xml | 43 | ||||
-rw-r--r-- | res/values/dimens.xml | 2 | ||||
-rw-r--r-- | res/values/integers.xml | 1 | ||||
-rw-r--r-- | res/values/strings.xml | 1 | ||||
-rw-r--r-- | src/com/cyngn/theme/chooser/ChooserActivity.java | 3 | ||||
-rw-r--r-- | src/com/cyngn/theme/chooser/ComponentSelector.java | 24 | ||||
-rw-r--r-- | src/com/cyngn/theme/chooser/ThemeFragment.java | 51 | ||||
-rw-r--r-- | src/com/cyngn/theme/util/CursorLoaderHelper.java | 23 |
9 files changed, 148 insertions, 3 deletions
diff --git a/res/layout/fragment_pager_list.xml b/res/layout/fragment_pager_list.xml index ff76c80..9a635b4 100644 --- a/res/layout/fragment_pager_list.xml +++ b/res/layout/fragment_pager_list.xml @@ -174,6 +174,9 @@ /> <Space android:layout_width="match_parent" android:layout_height="@dimen/expanded_card_margin_top" /> + <include layout="@layout/live_lock_screen_card" /> + <Space android:layout_width="match_parent" + android:layout_height="@dimen/expanded_card_margin_top" /> <include layout="@layout/style_card" /> <Space android:layout_width="match_parent" android:layout_height="@dimen/expanded_card_margin_top" /> diff --git a/res/layout/live_lock_screen_card.xml b/res/layout/live_lock_screen_card.xml new file mode 100644 index 0000000..33cd847 --- /dev/null +++ b/res/layout/live_lock_screen_card.xml @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + Copyright (C) 2014 Cyanogen, Inc. +--> +<com.cyngn.theme.chooser.ComponentCardView + xmlns:android="http://schemas.android.com/apk/res/android" + android:id="@+id/live_lock_screen_preview_container" + android:layout_width="match_parent" + android:layout_height="320dp" + android:orientation="vertical" + android:background="@drawable/card_bootanim_bg"> + <FrameLayout + android:layout_width="match_parent" + android:layout_height="match_parent"> + <!-- Need to set a valid source so this view can generate a valid bitmap + from drawing cache, otherwise it's size is 0x0 and a null bitmap is returned --> + <ImageView + android:id="@+id/live_lock_screen_preview" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/expanded_card_margin_top" + android:adjustViewBounds="true" + android:layout_gravity="center" + android:src="@drawable/card_bootanim_bg"/> + <com.cyngn.theme.widget.LatoTextView + android:id="@+id/label" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:text="@string/live_lock_screen_label" + style="@style/card_label"/> + <LinearLayout + android:id="@+id/empty" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center" + android:visibility="gone"> + <ImageView + android:layout_width="20dp" + android:layout_height="20dp" + android:src="@drawable/ic_addcomponent"/> + </LinearLayout> + </FrameLayout> +</com.cyngn.theme.chooser.ComponentCardView> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index e5b909b..8eb7bcb 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -19,6 +19,8 @@ <dimen name="component_selection_content_height">@dimen/component_selection_content_width</dimen> <dimen name="component_selection_bootani_content_width">80dp</dimen> <dimen name="component_selection_bootani_content_height">142dp</dimen> + <dimen name="component_selection_live_lock_screen_content_width">80dp</dimen> + <dimen name="component_selection_live_lock_screen_content_height">142dp</dimen> <dimen name="component_margin_top">12dp</dimen> <dimen name="card_padding_top">4dp</dimen> diff --git a/res/values/integers.xml b/res/values/integers.xml index b2d17f3..30146dd 100644 --- a/res/values/integers.xml +++ b/res/values/integers.xml @@ -5,4 +5,5 @@ <resources> <integer name="default_items_per_page">4</integer> <integer name="bootani_items_per_page">3</integer> + <integer name="live_lock_screen_items_per_page">3</integer> </resources>
\ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index 7326940..88b417e 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -31,6 +31,7 @@ <string name="navbar_label">Navigation</string> <string name="wallpaper_label">Wallpaper</string> <string name="lockscreen_label">Lockscreen wallpaper</string> + <string name="live_lock_screen_label">Live lock screen</string> <string name="style_label">Controls</string> <string name="boot_animation_label">Boot animation</string> <string name="alarm_label">Alarm</string> 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 98416f2..0f57393 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; @@ -319,6 +321,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; } @@ -349,6 +354,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); @@ -414,6 +420,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; } @@ -614,6 +623,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<Object, Void, Void> { @Override diff --git a/src/com/cyngn/theme/chooser/ThemeFragment.java b/src/com/cyngn/theme/chooser/ThemeFragment.java index 947f24c..2e8137f 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; @@ -346,6 +352,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<ImageView, MediaPlayer>(3); } @@ -475,6 +483,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); @@ -1287,6 +1298,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; } } @@ -1354,6 +1368,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); } @@ -1777,6 +1799,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( @@ -1969,6 +2018,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); } |