Bug 943513 - Update visual style of action modes. r=lucasr

This commit is contained in:
Wes Johnston 2013-12-04 08:35:58 -08:00
parent 4ab42b9d9c
commit 33cb028f34
21 changed files with 86 additions and 12 deletions

View File

@ -4,12 +4,16 @@
package org.mozilla.gecko;
import org.mozilla.gecko.animation.AnimationUtils;
import org.mozilla.gecko.menu.GeckoMenu;
import org.mozilla.gecko.menu.MenuPopup;
import org.mozilla.gecko.menu.MenuPanel;
import org.mozilla.gecko.menu.MenuItemActionBar;
import org.mozilla.gecko.widget.GeckoPopupMenu;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.view.animation.ScaleAnimation;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MenuInflater;
@ -156,4 +160,18 @@ class ActionModeCompatView extends LinearLayout implements GeckoMenu.ActionItemB
mPopupMenu.dismiss();
}
public void animateIn() {
long duration = AnimationUtils.getShortDuration(getContext());
TranslateAnimation t = new TranslateAnimation(Animation.RELATIVE_TO_SELF, -0.5f, Animation.RELATIVE_TO_SELF, 0f,
Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, 0f);
t.setDuration(duration);
ScaleAnimation s = new ScaleAnimation(1f, 1f, 0f, 1f,
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
s.setDuration((long) (duration * 1.5f));
mTitleView.startAnimation(t);
mActionButtonBar.startAnimation(s);
mMenuButton.startAnimation(s);
}
}

View File

@ -2539,9 +2539,17 @@ abstract public class BrowserApp extends GeckoApp
if (mActionMode == null) {
mViewFlipper.showNext();
LayerMarginsAnimator margins = mLayerView.getLayerMarginsAnimator();
margins.setMaxMargins(0, mViewFlipper.getHeight(), 0, 0);
// If the toolbar is dynamic and not currently showing, just slide it in
if (isDynamicToolbarEnabled() && !margins.areMarginsShown()) {
margins.setMaxMargins(0, mViewFlipper.getHeight(), 0, 0);
margins.showMargins(false);
} else {
// Otherwise, we animate the actionbar itself
mActionBar.animateIn();
}
margins.setMarginsPinned(true);
margins.showMargins(false);
} else {
// Otherwise, we're already showing an action mode. Just finish it and show the new one
mActionMode.finish();

View File

@ -246,7 +246,7 @@ class TextSelection extends Layer implements GeckoEventListener {
try {
final JSONObject obj = mItems.getJSONObject(i);
final GeckoMenuItem menuitem = (GeckoMenuItem) menu.add(0, i, 0, obj.optString("label"));
menuitem.setShowAsAction(obj.optBoolean("showAsAction") ? 1 : 0);
menuitem.setShowAsAction(obj.optBoolean("showAsAction") ? 1 : 0, R.attr.menuItemActionModeStyle);
BitmapUtils.getDrawable(mStartHandle.getContext(), obj.optString("icon"), new BitmapLoader() {
public void onBitmapFound(Drawable d) {

View File

@ -0,0 +1,21 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
package org.mozilla.gecko.animation;
import android.content.Context;
public class AnimationUtils {
private static long mShortDuration;
public static long getShortDuration(Context context) {
if (mShortDuration < 0) {
mShortDuration = context.getResources().getInteger(android.R.integer.config_shortAnimTime);
}
return mShortDuration;
}
}

View File

@ -139,6 +139,14 @@ public class LayerMarginsAnimator implements TouchEventInterceptor {
mMarginsPinned = pin;
}
public boolean areMarginsShown() {
final ImmutableViewportMetrics metrics = mTarget.getViewportMetrics();
return metrics.marginLeft != 0 ||
metrics.marginRight != 0 ||
metrics.marginTop != 0 ||
metrics.marginBottom != 0;
}
/**
* This function will scroll a margin down to zero, or up to the maximum
* specified margin size and return the left-over delta.

View File

@ -290,6 +290,10 @@ public class GeckoMenuItem implements MenuItem {
@Override
public void setShowAsAction(int actionEnum) {
setShowAsAction(actionEnum, 0);
}
public void setShowAsAction(int actionEnum, int style) {
if (mShowAsActionChangedListener == null)
return;
@ -301,7 +305,12 @@ public class GeckoMenuItem implements MenuItem {
return;
// Change the type to just an icon
MenuItemActionBar actionView = new MenuItemActionBar(mMenu.getContext(), null);
MenuItemActionBar actionView;
if (style != 0) {
actionView = new MenuItemActionBar(mMenu.getContext(), null, style);
} else {
actionView = new MenuItemActionBar(mMenu.getContext());
}
actionView.initialize(this);
mActionView = actionView;

View File

@ -93,6 +93,7 @@ gbjar.sources += [
'ActionModeCompatView.java',
'ActivityHandlerHelper.java',
'AlertNotification.java',
'animation/AnimationUtils.java',
'animation/AnimatorProxy.java',
'animation/HeightChangeAnimation.java',
'animation/PropertyAnimator.java',
@ -641,6 +642,7 @@ ANDROID_RESFILES += [
'resources/drawable-mdpi/reader_cropped.png',
'resources/drawable-mdpi/reading_list.png',
'resources/drawable-mdpi/scrollbar.png',
'resources/drawable-mdpi/select_all.png',
'resources/drawable-mdpi/shadow.png',
'resources/drawable-mdpi/shield.png',
'resources/drawable-mdpi/shield_doorhanger.png',

Binary file not shown.

Before

Width:  |  Height:  |  Size: 222 B

After

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 883 B

After

Width:  |  Height:  |  Size: 757 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 210 B

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 618 B

After

Width:  |  Height:  |  Size: 573 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 242 B

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -15,7 +15,7 @@
android:layout_width="1dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:background="@android:color/darker_gray"/>
android:background="@color/text_color_secondary_inverse"/>
<LinearLayout android:id="@+id/actionbar_buttons"
android:layout_height="fill_parent"

View File

@ -76,11 +76,11 @@
<org.mozilla.gecko.toolbar.BrowserToolbar
android:id="@id/browser_toolbar"
style="@style/BrowserToolbar"
android:layout_width="fill_parent"
android:layout_height="@dimen/browser_toolbar_height"
android:clickable="true"
android:focusable="true"
style="@style/BrowserToolbar"
android:layout_width="fill_parent"
android:layout_height="@dimen/browser_toolbar_height"
android:clickable="true"
android:focusable="true"
android:background="@drawable/url_bar_bg"/>
<org.mozilla.gecko.ActionModeCompatView android:id="@+id/actionbar"

View File

@ -85,6 +85,10 @@
<item name="android:paddingRight">15dp</item>
</style>
<style name="GeckoActionBar.Button" parent="android:style/Widget.Holo.Light.ActionButton">
<item name="android:padding">12dp</item>
</style>
<style name="GeckoActionBar.Button.MenuButton" parent="android:style/Widget.Holo.Light.ActionButton.Overflow">
<item name="android:scaleType">center</item>
<item name="android:background">@android:color/transparent</item>

View File

@ -48,6 +48,7 @@
<item name="topSitesGridViewStyle">@style/Widget.TopSitesGridView</item>
<item name="topSitesThumbnailViewStyle">@style/Widget.TopSitesThumbnailView</item>
<item name="homeListViewStyle">@style/Widget.HomeListView</item>
<item name="menuItemActionModeStyle">@style/GeckoActionBar.Button</item>
</style>
</resources>

View File

@ -11,6 +11,9 @@
<!-- Style for MenuItemActionBar -->
<attr name="menuItemActionBarStyle" format="reference"/>
<!-- Style for MenuItemActionBar -->
<attr name="menuItemActionModeStyle" format="reference"/>
<!-- Style for MenuItemActionView -->
<attr name="menuItemActionViewStyle" format="reference"/>

View File

@ -556,8 +556,7 @@
</style>
<style name="GeckoActionBar.Button" parent="Widget.MenuItemActionBar">
<item name="android:background">@android:color/transparent</item>
<item name="android:gravity">center</item>
<item name="android:padding">8dp</item>
</style>
<style name="GeckoActionBar.Button.MenuButton">

View File

@ -84,6 +84,7 @@
<item name="homeListViewStyle">@style/Widget.HomeListView</item>
<item name="menuItemDefaultStyle">@style/Widget.MenuItemDefault</item>
<item name="menuItemActionBarStyle">@style/Widget.MenuItemActionBar</item>
<item name="menuItemActionModeStyle">@style/GeckoActionBar.Button</item>
</style>
<style name="Gecko.Preferences" parent="GeckoPreferencesBase"/>