diff options
author | Andy Mast <andy@cyngn.com> | 2014-07-21 09:53:51 -0700 |
---|---|---|
committer | Andy Mast <andy@cyngn.com> | 2014-07-23 21:49:20 +0000 |
commit | 1a1a2332d39d056d2d863deea9738cd09c80e003 (patch) | |
tree | 94fab182dac34605d99a5b43d654f27cb4294e77 /src/org/cyanogenmod/theme/chooserv2/ThemeFragment.java | |
parent | 0e554fb2ec729ecce9df46c2cfcfc4878a3ffac2 (diff) | |
download | packages_apps_ThemeChooser-1a1a2332d39d056d2d863deea9738cd09c80e003.zip packages_apps_ThemeChooser-1a1a2332d39d056d2d863deea9738cd09c80e003.tar.gz packages_apps_ThemeChooser-1a1a2332d39d056d2d863deea9738cd09c80e003.tar.bz2 |
Update UI from new redlines & assets
Change-Id: Ifc40edd9ee2a5bb5478af63d56991303be146e8e
Diffstat (limited to 'src/org/cyanogenmod/theme/chooserv2/ThemeFragment.java')
-rw-r--r-- | src/org/cyanogenmod/theme/chooserv2/ThemeFragment.java | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/src/org/cyanogenmod/theme/chooserv2/ThemeFragment.java b/src/org/cyanogenmod/theme/chooserv2/ThemeFragment.java index 30a5b80..cac2ff5 100644 --- a/src/org/cyanogenmod/theme/chooserv2/ThemeFragment.java +++ b/src/org/cyanogenmod/theme/chooserv2/ThemeFragment.java @@ -324,11 +324,9 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb 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); + mShadowFrame.setPadding(0, 0, 0, 0); mAdditionalCards.setPadding(padding.left, padding.top, padding.right, padding.bottom); // Off screen cards will become visible and then be animated in @@ -360,19 +358,19 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb mScrollView.requestLayout(); animateWallpaperOut(); animateTitleCard(true, false); - animateChildren(true, getChildrensGlobalBounds()); - animateExtras(true, getChildrensGlobalBounds()); + animateChildren(true, getChildrensGlobalBounds(mPreviewContent)); + animateExtras(true, getChildrensGlobalBounds(mAdditionalCards)); mSelector = ((ChooserActivity) getActivity()).getComponentSelector(); mSelector.setOnItemClickedListener(mOnComponentItemClicked); } - // Returns the boundaries for all the children in the scrollview relative to the window - private List<Rect> getChildrensGlobalBounds() { + // Returns the boundaries for all the children of parent relative to the app window + private List<Rect> getChildrensGlobalBounds(ViewGroup parent) { List<Rect> bounds = new ArrayList<Rect>(); - for (int i = 0; i < mPreviewContent.getChildCount(); i++) { - final View v = mPreviewContent.getChildAt(i); + for (int i = 0; i < parent.getChildCount(); i++) { + final View v = parent.getChildAt(i); int[] pos = new int[2]; v.getLocationInWindow(pos); Rect boundary = new Rect(pos[0], pos[1], pos[0] + v.getWidth(), pos[1]+v.getHeight()); @@ -406,9 +404,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb 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); + mShadowFrame.setPadding(padding.left, padding.top, padding.right, padding.bottom); // Gradually fade the drop shadow back in or else it will be out of place ValueAnimator shadowAnimation = ValueAnimator.ofObject(new IntEvaluator(), 0, 255); @@ -444,6 +440,10 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb int top = (int) child.getResources() .getDimension(R.dimen.collapsed_icon_card_margin_top); lparams.setMargins(0, top, 0, 0); + } else if (child.getId() == R.id.font_preview_container) { + int top = (int) child.getResources() + .getDimension(R.dimen.collapsed_font_card_margin_top); + lparams.setMargins(0, top, 0, 0); } child.getLayoutParams(); @@ -451,8 +451,8 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb } mScrollView.requestLayout(); - animateChildren(false, getChildrensGlobalBounds()); - animateExtras(false, getChildrensGlobalBounds()); + animateChildren(false, getChildrensGlobalBounds(mPreviewContent)); + animateExtras(false, getChildrensGlobalBounds(mAdditionalCards)); animateWallpaperIn(); animateTitleCard(false, applyTheme); } @@ -493,7 +493,8 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb endHeight = v.getHeight(); } - v.setTranslationY((prevY - endY) + (prevHeight - endHeight) / 2); + int paddingTop = v.getPaddingTop(); + v.setTranslationY((prevY - endY - paddingTop) + (prevHeight - endHeight) / 2); root.getOverlay().add(v); // Expanding has a delay while the wallpaper begins to fade out @@ -678,6 +679,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb } }); return true; + } }); } @@ -954,9 +956,17 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb // Set the icons. If the provider does not have an icon preview then // fall back to the default icon set IconPreviewHelper helper = new IconPreviewHelper(getActivity(), ""); - ViewGroup container = (ViewGroup) mIconContainer.findViewById(R.id.icon_preview_container); - for(int i=0; i < container.getChildCount() && i < iconIdx.length; i++) { - final ImageView v = (ImageView) ((ViewGroup)mIconContainer.getChildAt(1)).getChildAt(i); + int numOfChildren = ((ViewGroup)mIconContainer.getChildAt(1)).getChildCount(); + + List<ImageView> iconViews = new ArrayList<ImageView>(numOfChildren); + for(int i=0; i < numOfChildren; i++) { + final View view = (View) ((ViewGroup)mIconContainer.getChildAt(1)).getChildAt(i); + if (!(view instanceof ImageView)) continue; + iconViews.add((ImageView) view); + } + + for(int i=0; i < iconViews.size() && i < iconIdx.length; i++) { + final ImageView v = iconViews.get(i); Bitmap bitmap = Utils.loadBitmapBlob(c, iconIdx[i]); Drawable oldIcon = v.getDrawable(); Drawable newIcon; |