summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorClark Scheff <clark@cyngn.com>2014-08-11 15:19:36 +0000
committerGerrit Code Review <gerrit@cyngn.com>2014-08-11 15:19:36 +0000
commit4eb3a378d072d51ec5275452a735bb9715236112 (patch)
tree172e4aa8ef65341318d9021680acb9b34d372c3a /src
parent6707d3a63e1abb20059a0a351158f2eb34dd00e7 (diff)
parent5f903c2159a8a3fce0ef71c76ca201c3d54ffc12 (diff)
downloadpackages_apps_ThemeChooser-4eb3a378d072d51ec5275452a735bb9715236112.zip
packages_apps_ThemeChooser-4eb3a378d072d51ec5275452a735bb9715236112.tar.gz
packages_apps_ThemeChooser-4eb3a378d072d51ec5275452a735bb9715236112.tar.bz2
Merge "Add tags to theme cards" into cm-11.0
Diffstat (limited to 'src')
-rw-r--r--src/com/cyngn/theme/chooser/ChooserActivity.java2
-rw-r--r--src/com/cyngn/theme/chooser/MyThemeFragment.java12
-rw-r--r--src/com/cyngn/theme/chooser/ThemeFragment.java39
-rw-r--r--src/com/cyngn/theme/widget/ThemeTagLayout.java105
4 files changed, 147 insertions, 11 deletions
diff --git a/src/com/cyngn/theme/chooser/ChooserActivity.java b/src/com/cyngn/theme/chooser/ChooserActivity.java
index 23c3af5..7fc2c21 100644
--- a/src/com/cyngn/theme/chooser/ChooserActivity.java
+++ b/src/com/cyngn/theme/chooser/ChooserActivity.java
@@ -265,7 +265,7 @@ public class ChooserActivity extends FragmentActivity
mAppliedBaseTheme = f.getThemePackageName();
SharedPreferences prefs = getPreferences(MODE_PRIVATE);
prefs.edit().putString(APPLIED_BASE_THEME, mAppliedBaseTheme).commit();
- getSupportLoaderManager().restartLoader(LOADER_ID_INSTALLED_THEMES, null,
+ getSupportLoaderManager().restartLoader(LOADER_ID_APPLIED, null,
ChooserActivity.this);
}
mPager.setEnabled(true);
diff --git a/src/com/cyngn/theme/chooser/MyThemeFragment.java b/src/com/cyngn/theme/chooser/MyThemeFragment.java
index 2a26339..322f3e3 100644
--- a/src/com/cyngn/theme/chooser/MyThemeFragment.java
+++ b/src/com/cyngn/theme/chooser/MyThemeFragment.java
@@ -5,6 +5,7 @@ package com.cyngn.theme.chooser;
import android.app.WallpaperManager;
import android.content.Context;
+import android.content.pm.ThemeUtils;
import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Typeface;
@@ -30,6 +31,7 @@ import com.cyngn.theme.util.TypefaceHelperCache;
import com.cyngn.theme.util.Utils;
import java.io.IOException;
+import java.util.Map;
public class MyThemeFragment extends ThemeFragment {
private static final String TAG = MyThemeFragment.class.getSimpleName();
@@ -62,6 +64,16 @@ public class MyThemeFragment extends ThemeFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = super.onCreateView(inflater, container, savedInstanceState);
+ mThemeTagLayout.setAppliedTagEnabled(true);
+ if (mBaseThemePkgName.equals(ThemeUtils.getDefaultThemePackageName(getActivity()))) {
+ mThemeTagLayout.setDefaultTagEnabled(true);
+ }
+ for (String pkgName : mCurrentTheme.values()) {
+ if (!pkgName.equals(mBaseThemePkgName)) {
+ mThemeTagLayout.setCustomizedTagEnabled(true);
+ break;
+ }
+ }
return v;
}
diff --git a/src/com/cyngn/theme/chooser/ThemeFragment.java b/src/com/cyngn/theme/chooser/ThemeFragment.java
index 36826a6..88b381d 100644
--- a/src/com/cyngn/theme/chooser/ThemeFragment.java
+++ b/src/com/cyngn/theme/chooser/ThemeFragment.java
@@ -76,6 +76,7 @@ import com.cyngn.theme.util.TypefaceHelperCache;
import com.cyngn.theme.util.Utils;
import com.cyngn.theme.widget.BootAniImageView;
import com.cyngn.theme.widget.LockableScrollView;
+import com.cyngn.theme.widget.ThemeTagLayout;
import java.io.File;
import java.io.IOException;
@@ -233,6 +234,8 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
protected View mApplyButton;
protected View mCancelButton;
+ protected ThemeTagLayout mThemeTagLayout;
+
static ThemeFragment newInstance(String pkgName) {
ThemeFragment f = new ThemeFragment();
Bundle args = new Bundle();
@@ -369,7 +372,6 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
// Additional cards which should hang out offscreen until expanded
mAdditionalCards = (LinearLayout) v.findViewById(R.id.additional_cards);
-
mWallpaperCard = (WallpaperCardView) v.findViewById(R.id.wallpaper_card);
mLockScreenCard = (WallpaperCardView) v.findViewById(R.id.lockscreen_card);
int translationY = getDistanceToMoveBelowScreen(mAdditionalCards);
@@ -381,6 +383,12 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
mCancelButton = mApplyThemeLayout.findViewById(R.id.apply_cancel);
mCancelButton.setOnClickListener(mApplyCancelClickListener);
+ mThemeTagLayout = (ThemeTagLayout) v.findViewById(R.id.tag_layout);
+
+ if (mPkgName.equals(ThemeUtils.getDefaultThemePackageName(getActivity()))) {
+ mThemeTagLayout.setDefaultTagEnabled(true);
+ }
+
getLoaderManager().initLoader(LOADER_ID_ALL, null, this);
setupCardClickListeners(v);
@@ -488,6 +496,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
mSelector = ((ChooserActivity) getActivity()).getComponentSelector();
mSelector.setOnItemClickedListener(mOnComponentItemClicked);
if (mBootAnimation != null) mBootAnimation.start();
+ hideThemeTagLayout();
}
@@ -520,6 +529,10 @@ 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);
+ if (applyTheme && componentsChanged()) {
+ mThemeTagLayout.setCustomizedTagEnabled(true);
+ }
+
//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);
@@ -594,6 +607,7 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
animateTitleCard(false, applyTheme);
if (mBootAnimation != null) mBootAnimation.stop();
stopMediaPlayers();
+ showThemeTagLayout();
}
// This will animate the children's vertical positions between the previous bounds and the
@@ -1604,10 +1618,6 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
final Context context = getActivity();
if (context != null) {
if (mSelectedComponentsMap != null && mSelectedComponentsMap.size() > 0) {
- if (!CURRENTLY_APPLIED_THEME.equals(mPkgName)) {
- ThemeUtils.completeComponentMap(getActivity(),
- mSelectedComponentsMap);
- }
// Post this on mHandler so the client is added and removed from the same
// thread
mHandler.post(new Runnable() {
@@ -1615,8 +1625,6 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
public void run() {
ThemeManager tm = getThemeManager();
if (tm != null) {
- // if this is not the "my theme" card, add missing components
- // from defaults
tm.addClient(ThemeFragment.this);
tm.requestThemeChange(mSelectedComponentsMap);
}
@@ -1742,7 +1750,8 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
anim.alpha(0f).start();
anim.setListener(new Animator.AnimatorListener() {
@Override
- public void onAnimationStart(Animator animation) {}
+ public void onAnimationStart(Animator animation) {
+ }
@Override
public void onAnimationEnd(Animator animation) {
@@ -1751,13 +1760,23 @@ public class ThemeFragment extends Fragment implements LoaderManager.LoaderCallb
}
@Override
- public void onAnimationCancel(Animator animation) {}
+ public void onAnimationCancel(Animator animation) {
+ }
@Override
- public void onAnimationRepeat(Animator animation) {}
+ public void onAnimationRepeat(Animator animation) {
+ }
});
}
+ public void showThemeTagLayout() {
+ mThemeTagLayout.animate().alpha(1f).setStartDelay(ANIMATE_DURATION).start();
+ }
+
+ public void hideThemeTagLayout() {
+ mThemeTagLayout.setAlpha(0f);
+ }
+
public void fadeInCards() {
for (int i = 0; i < mCardIdsToComponentTypes.size(); i++) {
final int key = mCardIdsToComponentTypes.keyAt(i);
diff --git a/src/com/cyngn/theme/widget/ThemeTagLayout.java b/src/com/cyngn/theme/widget/ThemeTagLayout.java
new file mode 100644
index 0000000..6835006
--- /dev/null
+++ b/src/com/cyngn/theme/widget/ThemeTagLayout.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2014 The Cyanogen, Inc
+ */
+package com.cyngn.theme.widget;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+import com.cyngn.theme.chooser.R;
+
+public class ThemeTagLayout extends LinearLayout {
+ private ImageView mAppliedTag;
+ private ImageView mCustomizedTag;
+ private ImageView mUpdatedTag;
+ private TextView mDefaultTag;
+
+ public ThemeTagLayout(Context context) {
+ this(context, null);
+ }
+
+ public ThemeTagLayout(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public ThemeTagLayout(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ protected void onFinishInflate() {
+ super.onFinishInflate();
+ LayoutInflater inflater =
+ (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+ mAppliedTag = (ImageView) inflater.inflate(R.layout.tag_applied, this, false);
+ mCustomizedTag = (ImageView) inflater.inflate(R.layout.tag_customized, this, false);
+ mUpdatedTag = (ImageView) inflater.inflate(R.layout.tag_updated, this, false);
+ mDefaultTag = (TextView) inflater.inflate(R.layout.tag_default, this, false);
+ }
+
+ public void setAppliedTagEnabled(boolean enabled) {
+ if (enabled) {
+ if (findViewById(R.id.tag_applied) != null) return;
+ addView(mAppliedTag, 0);
+ } else {
+ if (findViewById(R.id.tag_applied) == null) return;
+ removeView(mAppliedTag);
+ }
+ }
+
+ public void setCustomizedTagEnabled(boolean enabled) {
+ if (enabled) {
+ if (findViewById(R.id.tag_customized) != null) return;
+ final int childCount = getChildCount();
+ if (childCount > 1) {
+ for (int i = 0; i < childCount; i++) {
+ final View child = getChildAt(i);
+ if (child != mAppliedTag) {
+ addView(mCustomizedTag, i);
+ break;
+ }
+ }
+ } else {
+ addView(mCustomizedTag);
+ }
+ } else {
+ if (findViewById(R.id.tag_customized) == null) return;
+ removeView(mCustomizedTag);
+ }
+ }
+
+ public void setUpdatedTagEnabled(boolean enabled) {
+ if (enabled) {
+ if (findViewById(R.id.tag_updated) != null) return;
+ final int childCount = getChildCount();
+ if (childCount > 2) {
+ for (int i = 0; i < childCount; i++) {
+ final View child = getChildAt(i);
+ if (child != mAppliedTag && child != mCustomizedTag) {
+ addView(mUpdatedTag, i);
+ break;
+ }
+ }
+ } else {
+ addView(mUpdatedTag);
+ }
+ } else {
+ if (findViewById(R.id.tag_updated) == null) return;
+ removeView(mUpdatedTag);
+ }
+ }
+
+ public void setDefaultTagEnabled(boolean enabled) {
+ if (enabled) {
+ if (findViewById(R.id.tag_default) != null) return;
+ addView(mDefaultTag);
+ } else {
+ if (findViewById(R.id.tag_default) == null) return;
+ removeView(mDefaultTag);
+ }
+ }
+}