summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2016-10-07 14:06:28 +0200
committerDanny Baumann <dannybaumann@web.de>2016-10-07 14:06:28 +0200
commit2282e80cd40ccd7255d82470f39043d0de1c46d1 (patch)
tree89612397e1a8baea808f53fdeb008d95bd8b5d2d
parentc84f5b63e94d8abbd8d61427bccb389be1a404cb (diff)
downloadandroid_packages_apps_Snap-2282e80cd40ccd7255d82470f39043d0de1c46d1.tar.gz
android_packages_apps_Snap-2282e80cd40ccd7255d82470f39043d0de1c46d1.tar.bz2
android_packages_apps_Snap-2282e80cd40ccd7255d82470f39043d0de1c46d1.zip
Furtherly improve list menu handling.
Improve layout of top-level menu items, and avoid second level menu items being obscured by the navigation bar. Change-Id: Ic3ee983e33613f7337839d11cae9520b86636b7d
-rw-r--r--res/layout/list_menu_item.xml50
-rw-r--r--src/com/android/camera/PhotoUI.java4
-rw-r--r--src/com/android/camera/VideoUI.java4
-rw-r--r--src/com/android/camera/ui/ListMenu.java21
-rw-r--r--src/com/android/camera/ui/ListMenuItem.java4
-rw-r--r--src/com/android/camera/ui/ListSubMenu.java31
-rw-r--r--src/com/android/camera/ui/RotateLayout.java12
7 files changed, 87 insertions, 39 deletions
diff --git a/res/layout/list_menu_item.xml b/res/layout/list_menu_item.xml
index 025bb607d..36e41d2a5 100644
--- a/res/layout/list_menu_item.xml
+++ b/res/layout/list_menu_item.xml
@@ -28,37 +28,41 @@
-->
<com.android.camera.ui.ListMenuItem xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
- android:layout_height="wrap_content"
+ android:layout_height="@dimen/setting_row_height"
android:background="@drawable/setting_list_item_bg"
- android:padding="5dip" >
+ android:orientation="horizontal"
+ android:gravity="center_vertical"
+ android:paddingLeft="8dip"
+ android:paddingRight="8dip" >
<ImageView
android:id="@+id/list_image"
android:layout_width="@dimen/setting_item_icon_width"
android:layout_height="@dimen/setting_item_icon_width"
- android:layout_alignParentLeft="true"
- android:layout_centerVertical="true"
- android:layout_marginRight="20dp"
- android:gravity="center" />
+ android:layout_marginRight="16dp" />
- <TextView
- android:id="@+id/title"
- android:layout_width="wrap_content"
+ <LinearLayout
+ android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:layout_toRightOf="@+id/list_image"
- android:textColor="@android:color/white"
- android:textStyle="bold" />
+ android:orientation="vertical">
- <TextView
- android:id="@+id/current_setting"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/title"
- android:layout_marginTop="1dip"
- android:layout_toRightOf="@+id/list_image"
- android:text="@string/crop_save"
- android:textColor="@color/white"
- android:textSize="10dip"
- android:textStyle="bold" />
+ <TextView
+ android:id="@+id/title"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:textColor="@android:color/white"
+ android:textStyle="bold" />
+
+ <TextView
+ android:id="@+id/current_setting"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_marginTop="1dip"
+ android:text="@string/crop_save"
+ android:textColor="@color/white"
+ android:textSize="10dip"
+ android:textStyle="bold" />
+
+ </LinearLayout>
</com.android.camera.ui.ListMenuItem>
diff --git a/src/com/android/camera/PhotoUI.java b/src/com/android/camera/PhotoUI.java
index bacffe6fe..f00b63eb2 100644
--- a/src/com/android/camera/PhotoUI.java
+++ b/src/com/android/camera/PhotoUI.java
@@ -776,12 +776,14 @@ public class PhotoUI implements PieListener,
Gravity.START | Gravity.TOP));
mRootView.addView(mMenuLayout);
}
- mMenuLayout.addView(popup);
+ mMenuLayout.addView(popup, new RotateLayout.LayoutParams(
+ LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
mMenuLayout.setOrientation(mOrientation, true);
}
if (level == 2) {
if (mSubMenuLayout == null) {
mSubMenuLayout = new RotateLayout(mActivity, null);
+ mSubMenuLayout.setRootView(mRootView);
mRootView.addView(mSubMenuLayout);
}
diff --git a/src/com/android/camera/VideoUI.java b/src/com/android/camera/VideoUI.java
index b983cd1fb..a5ec680dd 100644
--- a/src/com/android/camera/VideoUI.java
+++ b/src/com/android/camera/VideoUI.java
@@ -760,12 +760,14 @@ public class VideoUI implements PieRenderer.PieListener,
Gravity.START | Gravity.TOP));
mRootView.addView(mMenuLayout);
}
- mMenuLayout.addView(popup);
+ mMenuLayout.addView(popup, new RotateLayout.LayoutParams(
+ LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
mMenuLayout.setOrientation(mOrientation, true);
}
if (level == 2) {
if (mSubMenuLayout == null) {
mSubMenuLayout = new RotateLayout(mActivity, null);
+ mSubMenuLayout.setRootView(mRootView);
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(
CameraActivity.SETTING_LIST_WIDTH_2, LayoutParams.WRAP_CONTENT);
mSubMenuLayout.setLayoutParams(params);
diff --git a/src/com/android/camera/ui/ListMenu.java b/src/com/android/camera/ui/ListMenu.java
index bb21f7e0a..f56200a55 100644
--- a/src/com/android/camera/ui/ListMenu.java
+++ b/src/com/android/camera/ui/ListMenu.java
@@ -75,18 +75,13 @@ public class ListMenu extends ListView
mOffString = context.getString(R.string.setting_off);
}
- private int getSettingLayoutId(ListPreference pref) {
- return R.layout.list_menu_item;
- }
-
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ListPreference pref = mListItem.get(position);
- int viewLayoutId = getSettingLayoutId(pref);
ListMenuItem view = (ListMenuItem) convertView;
view = (ListMenuItem)
- mInflater.inflate(viewLayoutId, parent, false);
+ mInflater.inflate(R.layout.list_menu_item, parent, false);
view.initialize(pref); // no init for restore one
view.setSettingChangedListener(ListMenu.this);
@@ -112,7 +107,7 @@ public class ListMenu extends ListView
}
@Override
- public void onApplyWindowInsets(Rect insets) {
+ public void onApplyWindowInsets(Rect insets, int rootWidth, int rootHeight) {
if (mHeader == null) {
mHeader = new Space(getContext());
addHeaderView(mHeader);
@@ -122,8 +117,10 @@ public class ListMenu extends ListView
setFooterDividersEnabled(false);
}
- adjustViewHeight(mHeader, insets.top);
- adjustViewHeight(mFooter, insets.bottom);
+ boolean largerThanRoot =
+ getPreCalculatedHeight() - insets.top - insets.bottom > rootHeight;
+ adjustViewHeight(mHeader, largerThanRoot ? insets.top : 0);
+ adjustViewHeight(mFooter, largerThanRoot ? insets.bottom : 0);
}
private void adjustViewHeight(View view, int height) {
@@ -241,6 +238,12 @@ public class ListMenu extends ListView
}
+ private int getPreCalculatedHeight() {
+ int count = getAdapter().getCount();
+ return count * (int) getContext().getResources().getDimension(R.dimen.setting_row_height)
+ + (count - 1) * getDividerHeight();
+ }
+
public void reloadPreference() {
int count = getChildCount();
for (int i = 0; i < count; i++) {
diff --git a/src/com/android/camera/ui/ListMenuItem.java b/src/com/android/camera/ui/ListMenuItem.java
index f3c7f017e..4774b8319 100644
--- a/src/com/android/camera/ui/ListMenuItem.java
+++ b/src/com/android/camera/ui/ListMenuItem.java
@@ -22,7 +22,7 @@ import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.accessibility.AccessibilityEvent;
-import android.widget.RelativeLayout;
+import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.ImageView;
@@ -40,7 +40,7 @@ import org.codeaurora.snapcam.R;
* Other setting popup window includes several InLineSettingItem items with
* different types if possible.
*/
-public class ListMenuItem extends RelativeLayout {
+public class ListMenuItem extends LinearLayout {
private static final String TAG = "ListMenuItem";
private Listener mListener;
protected ListPreference mPreference;
diff --git a/src/com/android/camera/ui/ListSubMenu.java b/src/com/android/camera/ui/ListSubMenu.java
index 3501af3bc..87c99c0fe 100644
--- a/src/com/android/camera/ui/ListSubMenu.java
+++ b/src/com/android/camera/ui/ListSubMenu.java
@@ -29,11 +29,13 @@ import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;
+import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.SimpleAdapter;
+import android.widget.Space;
import com.android.camera.IconListPreference;
import com.android.camera.ListPreference;
@@ -45,10 +47,11 @@ import org.codeaurora.snapcam.R;
// the entries will contain both text and icons. Otherwise, entries will be
// shown in text.
public class ListSubMenu extends ListView implements
- AdapterView.OnItemClickListener {
+ RotateLayout.Child, AdapterView.OnItemClickListener {
private static final String TAG = "ListPrefSettingPopup";
private ListPreference mPreference;
private Listener mListener;
+ private View mHeader, mFooter;
private int mY;
static public interface Listener {
@@ -145,6 +148,32 @@ public class ListSubMenu extends ListView implements
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
}
+ @Override
+ public void onApplyWindowInsets(Rect insets, int rootWidth, int rootHeight) {
+ if (mHeader == null) {
+ mHeader = new Space(getContext());
+ addHeaderView(mHeader);
+ setHeaderDividersEnabled(false);
+ mFooter = new Space(getContext());
+ addFooterView(mFooter);
+ setFooterDividersEnabled(false);
+ }
+
+ boolean largerThanRoot =
+ getPreCalculatedHeight() - insets.top - insets.bottom > rootHeight;
+ adjustViewHeight(mHeader, largerThanRoot ? insets.top : 0);
+ adjustViewHeight(mFooter, largerThanRoot ? insets.bottom : 0);
+ }
+
+ private void adjustViewHeight(View view, int height) {
+ ViewGroup.LayoutParams lp = view.getLayoutParams();
+ if (lp == null) {
+ lp = generateDefaultLayoutParams();
+ }
+ lp.height = height;
+ view.setLayoutParams(lp);
+ }
+
public int getPreCalculatedHeight() {
int count = getAdapter().getCount();
return count * (int) getContext().getResources().getDimension(R.dimen.setting_row_height)
diff --git a/src/com/android/camera/ui/RotateLayout.java b/src/com/android/camera/ui/RotateLayout.java
index 61bcf2282..1ebdf719d 100644
--- a/src/com/android/camera/ui/RotateLayout.java
+++ b/src/com/android/camera/ui/RotateLayout.java
@@ -36,7 +36,7 @@ public class RotateLayout extends ViewGroup implements Rotatable {
private CameraRootView mRootView;
public interface Child {
- void onApplyWindowInsets(Rect insets);
+ void onApplyWindowInsets(Rect insets, int rootWidth, int rootHeight);
}
public RotateLayout(Context context, AttributeSet attrs) {
@@ -66,11 +66,18 @@ public class RotateLayout extends ViewGroup implements Rotatable {
}
}
+ @Override
public void addView(View child) {
super.addView(child);
setupChild(child);
}
+ @Override
+ public void addView(View child, LayoutParams params) {
+ super.addView(child, params);
+ setupChild(child);
+ }
+
public void removeView(View v) {
super.removeView(v);
mOrientation = 0;
@@ -165,7 +172,8 @@ public class RotateLayout extends ViewGroup implements Rotatable {
private void applyInsetsToChild() {
if (mRootView != null && mChild instanceof Child) {
Rect insets = mRootView.getInsetsForOrientation(mOrientation);
- ((Child) mChild).onApplyWindowInsets(insets);
+ final Child child = (Child) mChild;
+ child.onApplyWindowInsets(insets, mRootView.getWidth(), mRootView.getHeight());
}
}