summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/layout/per_app_theme_list.xml7
-rw-r--r--res/values/attrs.xml5
-rw-r--r--res/values/dimens.xml3
-rw-r--r--src/com/cyngn/theme/perapptheming/PerAppThemeListLayout.java2
-rw-r--r--src/com/cyngn/theme/perapptheming/PerAppThemeListView.java54
-rw-r--r--src/com/cyngn/theme/perapptheming/PerAppThemingWindow.java23
6 files changed, 83 insertions, 11 deletions
diff --git a/res/layout/per_app_theme_list.xml b/res/layout/per_app_theme_list.xml
index b3c06f3..1d4e437 100644
--- a/res/layout/per_app_theme_list.xml
+++ b/res/layout/per_app_theme_list.xml
@@ -1,14 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<com.cyngn.theme.perapptheming.PerAppThemeListLayout
xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
- <ListView
+ <com.cyngn.theme.perapptheming.PerAppThemeListView
android:id="@+id/theme_list"
android:layout_width="@dimen/theme_list_width"
- android:layout_height="@dimen/theme_list_height"
+ android:layout_height="wrap_content"
android:layout_gravity="center_vertical|left"
+ android:minHeight="@dimen/theme_list_min_height"
+ app:maxHeight="@dimen/theme_list_max_height"
android:divider="@android:color/transparent"
android:padding="4dp"
android:elevation="10dp"
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index ca011a9..d78f25e 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -13,4 +13,9 @@
<attr name="labelText" format="string" />
</declare-styleable>
+ <!-- Attributes for PerAppThemeListView -->
+ <declare-styleable name="PerAppThemeListView">
+ <attr name="maxHeight" format="dimension" />
+ </declare-styleable>
+
</resources> \ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 7abdd11..8c9ee88 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -75,7 +75,8 @@
<dimen name="floating_window_delete_box_width">360dp</dimen>
<!-- Theme list -->
<dimen name="theme_list_width">204dp</dimen>
- <dimen name="theme_list_height">360dp</dimen>
+ <dimen name="theme_list_min_height">160dp</dimen>
+ <dimen name="theme_list_max_height">360dp</dimen>
<dimen name="theme_list_side_margin">16dp</dimen>
<!-- floating window dimens -->
<dimen name="floating_window_margin_vertical">5dp</dimen>
diff --git a/src/com/cyngn/theme/perapptheming/PerAppThemeListLayout.java b/src/com/cyngn/theme/perapptheming/PerAppThemeListLayout.java
index e27adad..a1a753d 100644
--- a/src/com/cyngn/theme/perapptheming/PerAppThemeListLayout.java
+++ b/src/com/cyngn/theme/perapptheming/PerAppThemeListLayout.java
@@ -46,7 +46,7 @@ public class PerAppThemeListLayout extends FrameLayout {
super(context, attrs, defStyleAttr);
final Resources res = getResources();
float width = res.getDimension(R.dimen.theme_list_width);
- float height = res.getDimension(R.dimen.theme_list_height);
+ float height = res.getDimension(R.dimen.theme_list_max_height);
mMaxRadius = (float) Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2));
mRevealPath = new Path();
diff --git a/src/com/cyngn/theme/perapptheming/PerAppThemeListView.java b/src/com/cyngn/theme/perapptheming/PerAppThemeListView.java
new file mode 100644
index 0000000..646cb49
--- /dev/null
+++ b/src/com/cyngn/theme/perapptheming/PerAppThemeListView.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2015 Cyanogen, Inc.
+ */
+package com.cyngn.theme.perapptheming;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.util.AttributeSet;
+import android.widget.ListView;
+import com.cyngn.theme.chooser.R;
+
+public class PerAppThemeListView extends ListView {
+ private int mMinHeight;
+ private int mMaxHeight;
+
+ public PerAppThemeListView(Context context) {
+ this(context, null);
+ }
+
+ public PerAppThemeListView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public PerAppThemeListView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ TypedArray a = context.obtainStyledAttributes(attrs, com.android.internal.R.styleable.View);
+ mMinHeight = a.getDimensionPixelSize(com.android.internal.R.styleable.View_minHeight, 0);
+ a.recycle();
+
+ a = context.obtainStyledAttributes(attrs, R.styleable.PerAppThemeListView);
+ mMaxHeight = a.getDimensionPixelSize(R.styleable.PerAppThemeListView_maxHeight, 0);
+ a.recycle();
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ // let the super do the heavy lifting and then we'll cap the values to any max and/or min
+ // values that were defined in the layout
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+ int measuredWidth = getMeasuredWidth();
+ int measuredHeight = getMeasuredHeight();
+ int newHeight = measuredHeight;
+ if (mMaxHeight > 0) {
+ newHeight = Math.min(measuredHeight, mMaxHeight);
+ }
+ if (mMinHeight > 0) {
+ newHeight = Math.max(newHeight, mMinHeight);
+ }
+ if (newHeight != measuredHeight) {
+ setMeasuredDimension(measuredWidth, newHeight);
+ }
+ }
+}
diff --git a/src/com/cyngn/theme/perapptheming/PerAppThemingWindow.java b/src/com/cyngn/theme/perapptheming/PerAppThemingWindow.java
index 0edf074..0c17ebc 100644
--- a/src/com/cyngn/theme/perapptheming/PerAppThemingWindow.java
+++ b/src/com/cyngn/theme/perapptheming/PerAppThemingWindow.java
@@ -630,7 +630,8 @@ public class PerAppThemingWindow extends Service implements OnTouchListener,
});
animator.addListener(new Animator.AnimatorListener() {
@Override
- public void onAnimationStart(Animator animation) {}
+ public void onAnimationStart(Animator animation) {
+ }
@Override
public void onAnimationEnd(Animator animation) {
@@ -638,10 +639,12 @@ public class PerAppThemingWindow extends Service implements OnTouchListener,
}
@Override
- public void onAnimationCancel(Animator animation) {}
+ public void onAnimationCancel(Animator animation) {
+ }
@Override
- public void onAnimationRepeat(Animator animation) {}
+ public void onAnimationRepeat(Animator animation) {
+ }
});
animator.start();
mThemeApplyingView.animate()
@@ -653,7 +656,15 @@ public class PerAppThemingWindow extends Service implements OnTouchListener,
int thirdHeight = getScreenHeight() / 3;
// use the center of the fab to decide where to place the list
int fabLocationY = mParams.y + mDraggableIconImage.getHeight() / 2;
- int listHeight = getResources().getDimensionPixelSize(R.dimen.theme_list_height);
+ int listHeight = mThemeList.getMeasuredHeight();
+ if (listHeight <= 0) {
+ // not measured yet so let's force that
+ int width = getResources().getDimensionPixelSize(R.dimen.theme_list_width);
+ int height = getResources().getDimensionPixelSize(R.dimen.theme_list_max_height);
+ mThemeList.measure(View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.AT_MOST),
+ View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.AT_MOST));
+ listHeight = mThemeList.getMeasuredHeight();
+ }
// If we're in the top 1/3 of the screen position the top of the list with the top
// of the fab. Second 3rd will position the list so that it is vertically centered
@@ -664,13 +675,11 @@ public class PerAppThemingWindow extends Service implements OnTouchListener,
} else if (fabLocationY < thirdHeight * 2) {
mListParams.topMargin = fabLocationY - listHeight / 2;
} else {
- mListParams.topMargin = mParams.y + mDraggableIconImage.getHeight() -
- getResources().getDimensionPixelSize(R.dimen.theme_list_height);
+ mListParams.topMargin = mParams.y + mDraggableIconImage.getHeight() - listHeight;
}
mListParams.gravity = Gravity.TOP |
(listSide == LIST_ON_LEFT_SIDE ? Gravity.LEFT : Gravity.RIGHT);
mThemeList.setLayoutParams(mListParams);
- mThemeList.requestLayout();
}
private AdapterView.OnItemClickListener mThemeClickedListener =