diff options
author | Clark Scheff <clark@cyngn.com> | 2014-08-28 09:44:28 -0700 |
---|---|---|
committer | Clark Scheff <clark@cyngn.com> | 2014-08-28 09:44:28 -0700 |
commit | c359371d576f1e8119c1bd3c14234ff7b2766170 (patch) | |
tree | d48df0bd261505366fe162b50dea145a11f4ca56 | |
parent | c0d722b992aa20235434a48d9efec44d6aff4dbd (diff) | |
download | packages_apps_ThemeChooser-c359371d576f1e8119c1bd3c14234ff7b2766170.zip packages_apps_ThemeChooser-c359371d576f1e8119c1bd3c14234ff7b2766170.tar.gz packages_apps_ThemeChooser-c359371d576f1e8119c1bd3c14234ff7b2766170.tar.bz2 |
Dismiss apply theme overlay when clicked outside of content.
Change-Id: I745d94c5e3cd24deeff5a3c4e3c295dda679af33
-rw-r--r-- | src/android/support/v4/view/ThemeViewPager.java | 10 | ||||
-rw-r--r-- | src/com/cyngn/theme/chooser/ChooserActivity.java | 6 | ||||
-rw-r--r-- | src/com/cyngn/theme/chooser/MyThemeFragment.java | 5 | ||||
-rw-r--r-- | src/com/cyngn/theme/chooser/ThemeFragment.java | 28 |
4 files changed, 36 insertions, 13 deletions
diff --git a/src/android/support/v4/view/ThemeViewPager.java b/src/android/support/v4/view/ThemeViewPager.java index 235129b..b43eaa2 100644 --- a/src/android/support/v4/view/ThemeViewPager.java +++ b/src/android/support/v4/view/ThemeViewPager.java @@ -20,6 +20,7 @@ public class ThemeViewPager extends ViewPager { private float mLastX; private float mLastY; private boolean mScrollingEnabled = true; + private boolean mClickedContent = false; public ThemeViewPager(Context context, AttributeSet attrs) { super(context, attrs); @@ -38,6 +39,10 @@ public class ThemeViewPager extends ViewPager { mIsAnimating = isAnimating; } + public boolean isClickedOnContent() { + return mClickedContent; + } + @Override public boolean onInterceptTouchEvent(MotionEvent ev) { boolean intercept = false; @@ -97,7 +102,10 @@ public class ThemeViewPager extends ViewPager { mIsDragging = false; break; case MotionEvent.ACTION_UP: - if (!mIsDragging && isTouching(R.id.clickable_view, ev)) { + if (!mIsDragging) { + mClickedContent = isTouching(R.id.clickable_view, ev); + // only play the click sound when we click on the content :) + setSoundEffectsEnabled(mClickedContent); performClick(); } mIsDragging = false; diff --git a/src/com/cyngn/theme/chooser/ChooserActivity.java b/src/com/cyngn/theme/chooser/ChooserActivity.java index de75e8c..1e3c503 100644 --- a/src/com/cyngn/theme/chooser/ChooserActivity.java +++ b/src/com/cyngn/theme/chooser/ChooserActivity.java @@ -514,11 +514,7 @@ public class ChooserActivity extends FragmentActivity public void onClick(View v) { ThemeFragment f = getCurrentFragment(); if (f != null) { - if (f instanceof MyThemeFragment) { - expand(); - } else { - f.showApplyThemeLayout(); - } + f.performClick(mPager.isClickedOnContent()); } } }; diff --git a/src/com/cyngn/theme/chooser/MyThemeFragment.java b/src/com/cyngn/theme/chooser/MyThemeFragment.java index d3e868c..801a15f 100644 --- a/src/com/cyngn/theme/chooser/MyThemeFragment.java +++ b/src/com/cyngn/theme/chooser/MyThemeFragment.java @@ -144,6 +144,11 @@ public class MyThemeFragment extends ThemeFragment { } } + @Override + public void performClick(boolean clickedOnContent) { + getChooserActivity().expand(); + } + private void resetTheme() { mSelectedComponentsMap.clear(); Bundle args = new Bundle(); diff --git a/src/com/cyngn/theme/chooser/ThemeFragment.java b/src/com/cyngn/theme/chooser/ThemeFragment.java index 1b30119..76dc8a1 100644 --- a/src/com/cyngn/theme/chooser/ThemeFragment.java +++ b/src/com/cyngn/theme/chooser/ThemeFragment.java @@ -374,7 +374,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb mCustomize.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (!isShowingApplyThemeLayout()) { - ((ChooserActivity) getActivity()).expand(); + getChooserActivity().expand(); } } }); @@ -448,7 +448,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb if (isSuccess) { mProgress.setProgress(100); animateProgressOut(); - ((ChooserActivity) getActivity()).themeChangeEnded(); + getChooserActivity().themeChangeEnded(); } } @@ -468,6 +468,10 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb } } + protected ChooserActivity getChooserActivity() { + return (ChooserActivity) getActivity(); + } + private void adjustScrollViewPaddingTop() { Resources res = getResources(); int extraPadding = @@ -559,7 +563,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb animateTitleCard(true, false); animateChildren(true, getChildrensGlobalBounds(mPreviewContent)); animateExtras(true); - mSelector = ((ChooserActivity) getActivity()).getComponentSelector(); + mSelector = getChooserActivity().getComponentSelector(); mSelector.setOnItemClickedListener(mOnComponentItemClicked); if (mBootAnimation != null) mBootAnimation.start(); hideThemeTagLayout(); @@ -580,6 +584,16 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb return bounds; } + public void performClick(boolean clickedOnContent) { + if (clickedOnContent) { + showApplyThemeLayout(); + } else { + if (isShowingApplyThemeLayout()) { + hideApplyThemeLayout(); + } + } + } + public void fadeOutCards(Runnable endAction) { for (int i = 0; i < mPreviewContent.getChildCount(); i++) { ComponentCardView v = (ComponentCardView) mPreviewContent.getChildAt(i); @@ -1709,7 +1723,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb } mActiveCardId = v.getId(); String component = mCardIdsToComponentTypes.get(mActiveCardId); - ((ChooserActivity) getActivity()).showComponentSelector(component, v); + getChooserActivity().showComponentSelector(component, v); fadeOutNonSelectedCards(mActiveCardId); stopMediaPlayers(); } @@ -1814,7 +1828,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb protected void applyTheme() { if (mSelectedComponentsMap == null || mSelectedComponentsMap.size() <= 0) return; - ((ChooserActivity) getActivity()).themeChangeStarted(); + getChooserActivity().themeChangeStarted(); animateProgressIn(mApplyThemeRunnable); } @@ -1907,7 +1921,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb public void showApplyThemeLayout() { if (mApplyThemeLayout.getVisibility() == View.VISIBLE) return; - ((ChooserActivity) getActivity()).lockPager(); + getChooserActivity().lockPager(); ViewPropertyAnimator anim = mApplyThemeLayout.animate(); mApplyThemeLayout.setVisibility(View.VISIBLE); mApplyThemeLayout.setAlpha(0f); @@ -1925,7 +1939,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb * @param applyThemeWhenFinished If true, the current theme will be applied. */ private void hideApplyThemeLayout(final boolean applyThemeWhenFinished) { - ((ChooserActivity) getActivity()).unlockPager(); + getChooserActivity().unlockPager(); ViewPropertyAnimator anim = mApplyThemeLayout.animate(); mApplyThemeLayout.setVisibility(View.VISIBLE); anim.setDuration(ANIMATE_APPLY_LAYOUT_DURATION); |