diff options
Diffstat (limited to 'src/com/android/camera/ui/ListSubMenu.java')
-rw-r--r-- | src/com/android/camera/ui/ListSubMenu.java | 31 |
1 files changed, 30 insertions, 1 deletions
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) |