Bug 1271428 - Use CardView for main menu r=sebastian

MozReview-Commit-ID: BCZ3tmgqY0z

--HG--
extra : rebase_source : b3dc0aada8b4df5f200ee8ae74d11bc017a7fa52
This commit is contained in:
Andrzej Hunt 2016-05-09 15:18:07 -07:00
parent 1aec36f857
commit 4088c4ece0
4 changed files with 21 additions and 5 deletions

View File

@ -5,11 +5,13 @@
package org.mozilla.gecko.menu;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.R;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.support.v7.widget.CardView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -20,7 +22,7 @@ import android.widget.PopupWindow;
* A popup to show the inflated MenuPanel.
*/
public class MenuPopup extends PopupWindow {
private final FrameLayout mPanel;
private final CardView mPanel;
private final int mPopupWidth;
@ -37,9 +39,21 @@ public class MenuPopup extends PopupWindow {
ViewGroup.LayoutParams.WRAP_CONTENT);
LayoutInflater inflater = LayoutInflater.from(context);
mPanel = (FrameLayout) inflater.inflate(R.layout.menu_popup, null);
mPanel = (CardView) inflater.inflate(R.layout.menu_popup, null);
setContentView(mPanel);
// Disable corners on < lollipop:
// CardView only supports clipping content on API >= 21 (for performance reasons). Without
// content clipping the "action bar" will look ugly because it has its own background:
// by default there's a 2px white edge along the top and sides (i.e. an inset corresponding
// to the corner radius), if we disable the inset then the corners overlap.
// It's possible to implement custom clipping, however given that the support library
// chose not to support this for performance reasons, we too have chosen to just disable
// corners on < 21, see Bug 1271428.
if (AppConstants.Versions.preLollipop) {
mPanel.setRadius(0);
}
setAnimationStyle(R.style.PopupAnimation);
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 745 B

View File

@ -3,14 +3,16 @@
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/menu_panel"
android:layout_width="@dimen/menu_popup_width"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:minWidth="@dimen/menu_popup_width"
android:background="@drawable/menu_popup_bg">
app:cardBackgroundColor="@color/toolbar_grey"
app:cardUseCompatPadding="true">
<!-- MenuPanel will be added here dynamically -->
</FrameLayout>
</android.support.v7.widget.CardView>