summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndy Mast <andy@cyngn.com>2014-07-15 10:56:03 -0700
committerAndy Mast <andy@cyngn.com>2014-07-16 00:53:51 +0000
commitc460d99e917188040e3753ed1a1e752d60cbaa29 (patch)
treebae19304d810c511cc936683462ac72ae14017a1
parent2eb74dea8d599fc2cd96e823d062fc422a58665b (diff)
downloadpackages_apps_ThemeChooser-c460d99e917188040e3753ed1a1e752d60cbaa29.tar.gz
packages_apps_ThemeChooser-c460d99e917188040e3753ed1a1e752d60cbaa29.tar.bz2
packages_apps_ThemeChooser-c460d99e917188040e3753ed1a1e752d60cbaa29.zip
Implemented bottom title card
Change-Id: Iba41091d408f8251a035b1d762c599a0fa7e025e
-rw-r--r--res/drawable-xxhdpi/bg_themepreview_shadow.9.pngbin0 -> 194 bytes
-rw-r--r--res/drawable-xxhdpi/card_themepreview_bg.9.pngbin0 -> 1269 bytes
-rw-r--r--res/drawable-xxhdpi/ic_overflow_dark.pngbin0 -> 3148 bytes
-rw-r--r--res/drawable-xxhdpi/ic_theme_apply.pngbin0 -> 4234 bytes
-rw-r--r--res/drawable-xxhdpi/ic_theme_apply2.pngbin0 -> 4690 bytes
-rw-r--r--res/layout/v2_activity_main.xml13
-rw-r--r--res/layout/v2_fragment_pager_list.xml76
-rw-r--r--res/layout/v2item_icon.xml1
-rw-r--r--res/values/dimens.xml5
-rw-r--r--res/values/strings.xml1
-rw-r--r--src/android/support/v4/view/ThemeViewPager.java37
-rw-r--r--src/org/cyanogenmod/theme/chooserv2/ChooserActivity.java36
-rw-r--r--src/org/cyanogenmod/theme/chooserv2/ComponentCardView.java9
-rw-r--r--src/org/cyanogenmod/theme/chooserv2/ThemeFragment.java155
14 files changed, 253 insertions, 80 deletions
diff --git a/res/drawable-xxhdpi/bg_themepreview_shadow.9.png b/res/drawable-xxhdpi/bg_themepreview_shadow.9.png
new file mode 100644
index 0000000..f368eb1
--- /dev/null
+++ b/res/drawable-xxhdpi/bg_themepreview_shadow.9.png
Binary files differ
diff --git a/res/drawable-xxhdpi/card_themepreview_bg.9.png b/res/drawable-xxhdpi/card_themepreview_bg.9.png
new file mode 100644
index 0000000..9dbbd30
--- /dev/null
+++ b/res/drawable-xxhdpi/card_themepreview_bg.9.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_overflow_dark.png b/res/drawable-xxhdpi/ic_overflow_dark.png
new file mode 100644
index 0000000..d76bfe1
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_overflow_dark.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_theme_apply.png b/res/drawable-xxhdpi/ic_theme_apply.png
new file mode 100644
index 0000000..d0a03fe
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_theme_apply.png
Binary files differ
diff --git a/res/drawable-xxhdpi/ic_theme_apply2.png b/res/drawable-xxhdpi/ic_theme_apply2.png
new file mode 100644
index 0000000..335c669
--- /dev/null
+++ b/res/drawable-xxhdpi/ic_theme_apply2.png
Binary files differ
diff --git a/res/layout/v2_activity_main.xml b/res/layout/v2_activity_main.xml
index 175597e..940e1b6 100644
--- a/res/layout/v2_activity_main.xml
+++ b/res/layout/v2_activity_main.xml
@@ -4,24 +4,15 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_grid">
-
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="center_vertical">
- <TextView
- android:id="@+id/theme_name"
- android:layout_width="264dp"
- android:layout_height="wrap_content"
- android:layout_marginLeft="48dp"
- android:paddingBottom="24dp"
- android:textSize="24sp"
- />
<org.cyanogenmod.theme.chooserv2.PagerContainer
android:id="@+id/pager_container"
android:layout_width="match_parent"
- android:layout_height="300dp"
+ android:layout_height="wrap_content"
android:layout_gravity="center_vertical">
<android.support.v4.view.ThemeViewPager
android:id="@+id/viewpager"
diff --git a/res/layout/v2_fragment_pager_list.xml b/res/layout/v2_fragment_pager_list.xml
index bc41379..70c1b3c 100644
--- a/res/layout/v2_fragment_pager_list.xml
+++ b/res/layout/v2_fragment_pager_list.xml
@@ -8,31 +8,71 @@
<ScrollView android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
+ android:paddingTop="@dimen/collapsed_theme_page_padding_top"
android:gravity="center"
android:layout_gravity="center_vertical"
android:divider="@null"
android:scrollbars="none"
android:fillViewport="true"
android:drawSelectorOnTop="false">
- <FrameLayout android:layout_width="match_parent"
- android:layout_height="match_parent">
- <ImageView
- android:id="@+id/wallpaper"
- android:layout_width="@dimen/theme_preview_width"
- android:layout_height="@dimen/theme_preview_height"
- android:layout_gravity="center_horizontal"
- android:scaleType="centerCrop"
- />
- <RelativeLayout
- android:id="@+id/preview_container"
+ <RelativeLayout
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+ <FrameLayout
+ android:id="@+id/shadow_frame"
android:layout_width="match_parent"
- android:layout_height="@dimen/theme_preview_height"
- android:orientation="vertical">
- <include layout="@layout/v2_status_bar_preview_item"/>
- <include layout="@layout/v2item_font"/>
- <include layout="@layout/v2item_icon"/>
- <include layout="@layout/v2_nav_bar_preview_item"/>
+ android:layout_height="wrap_content"
+ android:background="@drawable/bg_themepreview_shadow">
+ <ImageView
+ android:id="@+id/wallpaper"
+ android:layout_width="@dimen/theme_preview_width"
+ android:layout_height="@dimen/theme_preview_height"
+ android:layout_gravity="center_horizontal"
+ android:scaleType="centerCrop"
+ />
+ <RelativeLayout
+ android:id="@+id/preview_container"
+ android:layout_width="match_parent"
+ android:layout_height="@dimen/theme_preview_height">
+ <include layout="@layout/v2_status_bar_preview_item"/>
+ <include layout="@layout/v2item_font"/>
+ <include layout="@layout/v2item_icon"/>
+ <include layout="@layout/v2_nav_bar_preview_item"/>
+ </RelativeLayout>
+ </FrameLayout>
+ <RelativeLayout
+ android:id="@+id/title_card"
+ android:layout_below="@id/shadow_frame"
+ android:layout_width="@dimen/theme_preview_width"
+ android:layout_height="48dp"
+ android:layout_centerHorizontal="true"
+ android:background="@drawable/card_themepreview_bg">
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_alignParentLeft="true"
+ android:layout_marginStart="16dp"
+ android:gravity="center"
+ android:ellipsize="end"
+ android:textColor="#78000000"/>
+
+ <ImageView
+ android:id="@+id/apply"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_toLeftOf="@+id/overflow"
+ android:layout_marginRight="16dp"
+ android:src="@drawable/ic_theme_apply2"/>
+
+ <ImageView
+ android:id="@+id/overflow"
+ android:layout_width="wrap_content"
+ android:layout_height="match_parent"
+ android:layout_alignParentRight="true"
+ android:layout_marginRight="8dp"
+ android:src="@drawable/ic_overflow_dark"/>
</RelativeLayout>
- </FrameLayout>
+ </RelativeLayout>
</ScrollView>
</LinearLayout> \ No newline at end of file
diff --git a/res/layout/v2item_icon.xml b/res/layout/v2item_icon.xml
index 56537ba..10c7f46 100644
--- a/res/layout/v2item_icon.xml
+++ b/res/layout/v2item_icon.xml
@@ -5,6 +5,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
+ android:padding="0dp"
android:layout_marginTop="@dimen/collapsed_icon_card_margin_top"
android:layout_below="@+id/font_preview_container"
android:background="@drawable/theme_component_bg_transition">
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index db8fdd0..a6586ed 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -22,7 +22,7 @@
<dimen name="expanded_preview_margin">24dp</dimen>
<dimen name="navigation_button_width">80dp</dimen>
<dimen name="theme_preview_width">264dp</dimen>
- <dimen name="theme_preview_height">264dp</dimen>
+ <dimen name="theme_preview_height">300dp</dimen>
<dimen name="component_selection_cell_width">80dp</dimen>
<dimen name="component_selection_cell_height">112dp</dimen>
@@ -51,6 +51,9 @@
for the difference in width of the expanded cards-->
<dimen name="collapsed_theme_page_padding">24dp</dimen>
+ <!-- Distance from top of screen to the collapsed theme preview -->
+ <dimen name="collapsed_theme_page_padding_top">119dp</dimen>
+
<dimen name="component_divider_height">32dp</dimen>
<dimen name="component_divider_height_bootani">48dp</dimen>
<dimen name="component_divider_margin_top">32dp</dimen>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index dbcd480..29482a4 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -90,5 +90,4 @@
<string name="font_label">Fonts</string>
<string name="statusbar_label">Status</string>
<string name="navbar_label">Navigation</string>
-
</resources>
diff --git a/src/android/support/v4/view/ThemeViewPager.java b/src/android/support/v4/view/ThemeViewPager.java
index e1513e1..9a4ce9d 100644
--- a/src/android/support/v4/view/ThemeViewPager.java
+++ b/src/android/support/v4/view/ThemeViewPager.java
@@ -16,14 +16,13 @@
package android.support.v4.view;
import android.content.Context;
+import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
+import org.cyanogenmod.theme.chooser.R;
public class ThemeViewPager extends ViewPager {
private boolean mExpanded;
@@ -48,7 +47,37 @@ public class ThemeViewPager extends ViewPager {
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
- return !mExpanded;
+ boolean intercept = false;
+
+ if (!mExpanded) {
+ switch (ev.getAction()) {
+ case MotionEvent.ACTION_DOWN:
+ intercept = !isTouchingApplyButton(ev);
+ break;
+ }
+ }
+
+ return intercept;
+ }
+
+ private boolean isTouchingApplyButton(MotionEvent ev) {
+ int x = (int) ev.getRawX();
+ int y = (int) ev.getRawY();
+ View v = getViewForPosition(getCurrentItem());
+ View apply = v.findViewById(R.id.apply);
+ if (apply == null) return false;
+
+ int location[] = new int[2];
+ apply.getLocationOnScreen(location);
+ int viewX = location[0];
+ int viewY = location[1];
+
+ if((x > viewX && x < (viewX + apply.getWidth())) &&
+ ( y > viewY && y < (viewY + apply.getHeight()))){
+ return true;
+ } else {
+ return false;
+ }
}
@Override
diff --git a/src/org/cyanogenmod/theme/chooserv2/ChooserActivity.java b/src/org/cyanogenmod/theme/chooserv2/ChooserActivity.java
index 945ca36..901dbcf 100644
--- a/src/org/cyanogenmod/theme/chooserv2/ChooserActivity.java
+++ b/src/org/cyanogenmod/theme/chooserv2/ChooserActivity.java
@@ -59,10 +59,7 @@ public class ChooserActivity extends FragmentActivity
private PagerContainer mContainer;
private ThemeViewPager mPager;
- private TextView mThemeName;
- private Button mApply;
private Button mEdit;
- private ViewGroup mApplyEditBtns;
private ThemesAdapter mAdapter;
private ThemeManager mService;
private boolean mExpanded = false;
@@ -77,9 +74,6 @@ public class ChooserActivity extends FragmentActivity
mContainer = (PagerContainer) findViewById(R.id.pager_container);
mPager = (ThemeViewPager) findViewById(R.id.viewpager);
- mThemeName = (TextView) findViewById(R.id.theme_name);
- mApplyEditBtns = (ViewGroup) findViewById(R.id.apply_edit_container);
- mApply = (Button) findViewById(R.id.apply);
mEdit = (Button) findViewById(R.id.edit);
mPager.setOnClickListener(mPagerClickListener);
@@ -93,7 +87,6 @@ public class ChooserActivity extends FragmentActivity
mPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
public void onPageSelected(int position) {
- updateThemeName();
}
public void onPageScrolled(int position,
@@ -105,14 +98,6 @@ public class ChooserActivity extends FragmentActivity
}
});
- mApply.setOnClickListener(new View.OnClickListener() {
- public void onClick(View v) {
- int position = mPager.getCurrentItem();
- String pkgName = mAdapter.getItemPkgName(position);
- mService.requestThemeChange(pkgName);
- }
- });
-
mEdit.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
mExpanded = true;
@@ -267,12 +252,6 @@ public class ChooserActivity extends FragmentActivity
}
}
- private void updateThemeName() {
- int position = mPager.getCurrentItem();
- String name = mAdapter.getItemName(position);
- mThemeName.setText(name);
- }
-
private View.OnClickListener mPagerClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -317,8 +296,6 @@ public class ChooserActivity extends FragmentActivity
// old cursor once we return.)
mAdapter.swapCursor(data);
mAdapter.notifyDataSetChanged();
-
- updateThemeName();
}
@Override
@@ -383,19 +360,6 @@ public class ChooserActivity extends FragmentActivity
return mCursor == null ? 1 : mCursor.getCount() + 1;
}
- public String getItemName(int position) {
- if (position == 0) {
- return getString(R.string.my_theme);
- }
-
- mCursor.moveToPosition(position - 1);
- int pkgIdx = mCursor.getColumnIndex(ThemesColumns.PKG_NAME);
- int titleIdx = mCursor.getColumnIndex(ThemesColumns.TITLE);
- String pkgName = mCursor.getString(pkgIdx);
- return DEFAULT.equals(pkgName) ? mContext.getString(R.string.holo)
- : mCursor.getString(titleIdx);
- }
-
public String getItemPkgName(int position) {
if (position == 0) {
return ThemeFragment.CURRENTLY_APPLIED_THEME;
diff --git a/src/org/cyanogenmod/theme/chooserv2/ComponentCardView.java b/src/org/cyanogenmod/theme/chooserv2/ComponentCardView.java
index d4c4fb6..a20f032 100644
--- a/src/org/cyanogenmod/theme/chooserv2/ComponentCardView.java
+++ b/src/org/cyanogenmod/theme/chooserv2/ComponentCardView.java
@@ -5,6 +5,8 @@ import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
+import android.graphics.drawable.NinePatchDrawable;
import android.graphics.drawable.TransitionDrawable;
import android.util.AttributeSet;
import android.view.View;
@@ -56,12 +58,15 @@ public class ComponentCardView extends LinearLayout {
public void expand() {
TransitionDrawable bg = (TransitionDrawable) getBackground();
- Rect paddingRect = new Rect();
- bg.getPadding(paddingRect);
+ if (bg != null) {
+ Rect paddingRect = new Rect();
+ bg.getPadding(paddingRect);
+ }
setPadding(mExpandPadLeft, mExpandPadTop, mExpandPadRight, mExpandPadBottom);
if (mLabel != null) {
+ mLabel.setAlpha(0f);
mLabel.setVisibility(View.VISIBLE);
}
}
diff --git a/src/org/cyanogenmod/theme/chooserv2/ThemeFragment.java b/src/org/cyanogenmod/theme/chooserv2/ThemeFragment.java
index fee1dca..752bb2d 100644
--- a/src/org/cyanogenmod/theme/chooserv2/ThemeFragment.java
+++ b/src/org/cyanogenmod/theme/chooserv2/ThemeFragment.java
@@ -15,18 +15,22 @@
*/
package org.cyanogenmod.theme.chooserv2;
+import android.animation.IntEvaluator;
+import android.animation.ValueAnimator;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.ThemeConfig;
+import android.content.res.ThemeManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
+import android.graphics.drawable.NinePatchDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
@@ -42,8 +46,10 @@ import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import android.view.ViewParent;
import android.view.ViewTreeObserver;
import android.view.animation.DecelerateInterpolator;
+import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
@@ -126,6 +132,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
private TextView mClock;
// Other Misc Preview Views
+ private FrameLayout mShadowFrame;
private ImageView mWallpaper;
private ViewGroup mStatusBar;
private TextView mFontPreview;
@@ -137,6 +144,12 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
private ImageView mHomeButton;
private ImageView mRecentButton;
+ // Title Card Views
+ private ViewGroup mTitleCard;
+ private TextView mTitle;
+ private ImageView mApply;
+ private ImageView mOverflow;
+
private Handler mHandler;
private int mActiveCardId = -1;
@@ -196,11 +209,12 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
mBattery = (ImageView) v.findViewById(R.id.battery);
mClock = (TextView) v.findViewById(R.id.clock);
- // Wallpaper / Font / Icons
+ // Wallpaper / Font / Icons / etc
mWallpaper = (ImageView) v.findViewById(R.id.wallpaper);
mFontPreview = (TextView) v.findViewById(R.id.font_preview);
mFontPreview.setTypeface(mTypefaceNormal);
mIconContainer = (ViewGroup) v.findViewById(R.id.icon_container);
+ mShadowFrame = (FrameLayout) v.findViewById(R.id.shadow_frame);
// Nav Bar
mNavBar = (ViewGroup) v.findViewById(R.id.navigation_bar);
@@ -208,6 +222,22 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
mHomeButton = (ImageView) v.findViewById(R.id.home_button);
mRecentButton = (ImageView) v.findViewById(R.id.recent_button);
+ // Title Card
+ mTitleCard = (ViewGroup)v.findViewById(R.id.title_card);
+ mTitle = (TextView) v.findViewById(R.id.title);
+ mOverflow = (ImageView) v.findViewById(R.id.overflow);
+ mApply = (ImageView) v.findViewById(R.id.apply);
+ mApply.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ Context context = getActivity();
+ if (context != null) {
+ ThemeManager mService =
+ (ThemeManager) context.getSystemService(Context.THEME_SERVICE);
+ mService.requestThemeChange(mPkgName);
+ }
+ }
+ });
+
getLoaderManager().initLoader(LOADER_ID_ALL, null, this);
initCards(v);
@@ -231,6 +261,20 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
content.setPadding(0, 0, 0, 0);
ViewGroup.LayoutParams layoutParams = mPreviewContent.getLayoutParams();
layoutParams.height = ViewGroup.LayoutParams.MATCH_PARENT;
+ mPreviewContent.setLayoutParams(layoutParams);
+ mScrollView.setPadding(0,0,0,0);
+
+ // The parent of the wallpaper squishes the wp slightly because of padding from the 9 patch
+ // When the parent expands, the wallpaper returns to regular size which creates an
+ // undesireable effect.
+ Rect padding = new Rect();
+ NinePatchDrawable bg = (NinePatchDrawable) mShadowFrame.getBackground();
+ bg.getPadding(padding);
+ ViewGroup.LayoutParams wpParams = mWallpaper.getLayoutParams();
+ wpParams.width -= padding.left + padding.right;
+ mWallpaper.setLayoutParams(wpParams);
+ mIconContainer.setPadding(padding.left, padding.top, padding.right, padding.bottom);
+ mShadowFrame.setBackground(null);
// Expand the children
for (int i = 0; i < mPreviewContent.getChildCount(); i++) {
@@ -252,11 +296,16 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
// Collect the present position of all the children. The next layout/draw cycle will
// change these bounds since we just expanded them. Then we can animate from prev location
- // to the new location.
- animateChildren(true, getChildrensGlobalBounds());
+ // to the new location. Note that the order of these calls matter as they all
+ // add themselves to the root layout as overlays
+ mScrollView.requestLayout();
animateWallpaperOut();
+ animateTitleCard(true);
+ animateChildren(true, getChildrensGlobalBounds());
mSelector = ((ChooserActivity) getActivity()).getComponentSelector();
mSelector.setOnItemClickedListener(mOnComponentItemClicked);
+
+
}
// Returns the boundaries for all the children in the scrollview relative to the window
@@ -287,6 +336,36 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
int leftRightPadding = (int) r.getDimension(R.dimen.collapsed_theme_page_padding);
content.setPadding(leftRightPadding, 0, leftRightPadding, 0);
+ //Move the theme preview so that it is near the center of page per spec
+ int paddingTop = (int) r.getDimension(R.dimen.collapsed_theme_page_padding_top);
+ mScrollView.setPadding(0, paddingTop, 0, 0);
+
+ // During expand the wallpaper size decreases slightly to makeup for 9patch padding
+ // so when we collapse we should increase it again.
+ mShadowFrame.setBackgroundResource(R.drawable.bg_themepreview_shadow);
+ Rect padding = new Rect();
+ final NinePatchDrawable bg = (NinePatchDrawable) mShadowFrame.getBackground();
+ bg.getPadding(padding);
+ ViewGroup.LayoutParams wpParams = mWallpaper.getLayoutParams();
+ wpParams.width += padding.left + padding.right;
+ mWallpaper.setLayoutParams(wpParams);
+
+ // Gradually fade the drop shadow back in or else it will be out of place
+ ValueAnimator shadowAnimation = ValueAnimator.ofObject(new IntEvaluator(), 0, 255);
+ shadowAnimation.setDuration(ANIMATE_DURATION);
+ shadowAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ @Override
+ public void onAnimationUpdate(ValueAnimator animator) {
+ bg.setAlpha((Integer) animator.getAnimatedValue());
+ }
+
+ });
+ shadowAnimation.start();
+
+ //Move the title card back in
+ mTitleCard.setVisibility(View.VISIBLE);
+ mTitleCard.setTranslationY(0);
+
// Shrink the height
ViewGroup.LayoutParams layoutParams = mPreviewContent.getLayoutParams();
Resources resources = mPreviewContent.getResources();
@@ -310,9 +389,10 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
child.getLayoutParams();
child.collapse();
}
- mPreviewContent.requestLayout();
+ mScrollView.requestLayout();
animateChildren(false, getChildrensGlobalBounds());
animateWallpaperIn();
+ animateTitleCard(false);
}
// This will animate the children's vertical positions between the previous bounds and the
@@ -375,15 +455,62 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
}
}
}, ANIMATE_DURATION / 2);
+ }
+ return true;
+ }
+ });
+ }
+
+ private void animateTitleCard(final boolean expand) {
+ final ViewGroup parent = (ViewGroup) mTitleCard.getParent();
+ // Get current location of the title card
+ int[] location = new int[2];
+ mTitleCard.getLocationOnScreen(location);
+ final int prevY = location[1];
+ final ViewTreeObserver observer = mScrollContent.getViewTreeObserver();
+ observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
+ public boolean onPreDraw() {
+ observer.removeOnPreDrawListener(this);
+
+ final ViewGroup root = (ViewGroup) getActivity().getWindow()
+ .getDecorView().findViewById(android.R.id.content);
+
+ root.getOverlay().add(mTitleCard);
+ //Move title card back where it was before the relayout
+ float alpha = 1f;
+ if (expand) {
+ int[] endPos = new int[2];
+ mTitleCard.getLocationInWindow(endPos);
+ int endY = endPos[1];
+ mTitleCard.setTranslationY(prevY - endY);
+ alpha = 0;
+ } else {
}
- return false;
+
+ // Fade the title card and move it out of the way
+ mTitleCard.animate()
+ .alpha(alpha)
+ .setDuration(ANIMATE_DURATION)
+ .withEndAction(new Runnable() {
+ public void run() {
+ root.getOverlay().remove(mTitleCard);
+ parent.addView(mTitleCard);
+ if (expand) {
+ mTitleCard.setVisibility(View.GONE);
+ }
+ }
+ });
+ return true;
}
});
}
private void animateWallpaperOut() {
+ final ViewGroup root = (ViewGroup) getActivity().getWindow()
+ .getDecorView().findViewById(android.R.id.content);
+
int[] location = new int[2];
mWallpaper.getLocationOnScreen(location);
@@ -393,6 +520,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
public boolean onPreDraw() {
observer.removeOnPreDrawListener(this);
+ root.getOverlay().add(mWallpaper);
int[] location = new int[2];
mWallpaper.getLocationOnScreen(location);
@@ -400,14 +528,16 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
mWallpaper.setTranslationY(prevY - newY);
mWallpaper.animate()
- .alpha(0)
+ .alpha(0f)
.setDuration(300)
.withEndAction(new Runnable() {
public void run() {
+ root.getOverlay().remove(mWallpaper);
+ mShadowFrame.addView(mWallpaper, 0);
mWallpaper.setVisibility(View.GONE);
}
});
- return false;
+ return true;
}
});
}
@@ -553,6 +683,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
loadStatusBar(c);
loadIcons(c);
loadNavBar(c);
+ loadTitle(c);
loadFont(c);
break;
case LOADER_ID_STATUS_BAR:
@@ -576,6 +707,16 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
@Override
public void onLoaderReset(Loader<Cursor> loader) {}
+ private void loadTitle(Cursor c) {
+ if (CURRENTLY_APPLIED_THEME.equals(mPkgName)) {
+ mTitle.setText(R.string.my_theme);
+ } else {
+ int titleIdx = c.getColumnIndex(ThemesColumns.TITLE);
+ String title = c.getString(titleIdx);
+ mTitle.setText(title);
+ }
+ }
+
private void loadWallpaper(Cursor c) {
if (CURRENTLY_APPLIED_THEME.equals(mPkgName)) {
mWallpaper.setBackground(getActivity().getWallpaper());