Bug 1275880 - Correct action mode styling. r=liuche

MozReview-Commit-ID: H7up9G5vlcg

--HG--
extra : rebase_source : 6c881551c530b0ce90801bf272b8a3ab0f8b35f2
This commit is contained in:
Michael Comella 2016-05-27 12:49:55 -07:00
Родитель c903ed153c
Коммит 8b44ee5388
5 изменённых файлов: 42 добавлений и 9 удалений

Просмотреть файл

@ -4,6 +4,9 @@
package org.mozilla.gecko;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import org.mozilla.gecko.animation.AnimationUtils;
import org.mozilla.gecko.menu.GeckoMenu;
import org.mozilla.gecko.widget.GeckoPopupMenu;
@ -36,22 +39,20 @@ class ActionModeCompatView extends LinearLayout implements GeckoMenu.ActionItemB
private int mActionButtonsWidth;
public ActionModeCompatView(Context context) {
super(context);
init(context);
}
private Paint mBottomDividerPaint;
private int mBottomDividerOffset;
public ActionModeCompatView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
init(context, attrs, 0);
}
public ActionModeCompatView(Context context, AttributeSet attrs, int style) {
super(context, attrs, style);
init(context);
init(context, attrs, style);
}
public void init(Context context) {
public void init(final Context context, final AttributeSet attrs, final int defStyle) {
LayoutInflater.from(context).inflate(R.layout.actionbar, this);
mTitleView = (Button) findViewById(R.id.actionmode_title);
@ -67,6 +68,15 @@ class ActionModeCompatView extends LinearLayout implements GeckoMenu.ActionItemB
openMenu();
}
});
// The built-in action bar uses colorAccent for the divider so we duplicate that here.
final TypedArray arr = context.obtainStyledAttributes(attrs, new int[] { R.attr.colorAccent }, defStyle, 0);
final int bottomDividerColor = arr.getColor(0, 0);
arr.recycle();
mBottomDividerPaint = new Paint();
mBottomDividerPaint.setColor(bottomDividerColor);
mBottomDividerOffset = getResources().getDimensionPixelSize(R.dimen.action_bar_divider_height);
}
public void initForMode(final ActionModeCompat mode) {
@ -178,4 +188,15 @@ class ActionModeCompatView extends LinearLayout implements GeckoMenu.ActionItemB
mMenuButton.startAnimation(s);
}
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
// Draw the divider at the bottom of the screen. We could do this with a layer-list
// but then we'd have overdraw (http://stackoverflow.com/a/13509472).
final int bottom = getHeight();
final int top = bottom - mBottomDividerOffset;
canvas.drawRect(0, top, getWidth(), bottom, mBottomDividerPaint);
}
}

Просмотреть файл

@ -146,7 +146,7 @@
<org.mozilla.gecko.ActionModeCompatView android:id="@+id/actionbar"
android:layout_height="match_parent"
android:layout_width="match_parent"
style="@style/GeckoActionBar"/>
style="@style/GeckoActionBar.ActionMode"/>
</ViewFlipper>

Просмотреть файл

@ -138,4 +138,6 @@
<color name="private_active_text">#FFFFFF</color>
<color name="action_bar_bg_color">@color/toolbar_grey</color>
</resources>

Просмотреть файл

@ -207,6 +207,10 @@
<dimen name="find_in_page_control_margin_top">2dip</dimen>
<dimen name="progress_bar_scroll_offset">1.5dp</dimen>
<!-- Matches the built-in divider height. fwiw, in the framework
I suspect this is a drawable rather than a dimen. -->
<dimen name="action_bar_divider_height">2dp</dimen>
<!-- http://blog.danlew.net/2015/01/06/handling-android-resources-with-non-standard-formats/ -->
<item name="match_parent" type="dimen">-1</item>
<item name="wrap_content" type="dimen">-2</item>

Просмотреть файл

@ -662,11 +662,17 @@
<item name="android:textStyle">bold</item>
</style>
<!-- Ideally, we use the same style for the action bar & action mode, but unfortunately
some attrs that share a purpose have different names so instead we inherit. -->
<style name="GeckoActionBar" parent="ThemeOverlay.AppCompat.ActionBar">
<item name="android:colorBackground">@color/toolbar_grey</item>
<item name="android:colorBackground">@color/action_bar_bg_color</item>
<item name="colorAccent">@color/fennec_ui_orange</item>
<item name="colorControlNormal">@color/toolbar_icon_grey</item>
</style>
<style name="GeckoActionBar.ActionMode">
<item name="android:background">@color/action_bar_bg_color</item>
<!-- Note: the bottom divider is drawn in code. -->
</style>
<style name="PreferencesActionBar" parent="Widget.AppCompat.ActionBar.Solid">
<item name="displayOptions">showHome|homeAsUp|showTitle</item>