Merge "Clean up some Action Bar style handling."
This commit is contained in:
@@ -10657,6 +10657,17 @@
|
||||
visibility="public"
|
||||
>
|
||||
</field>
|
||||
<field name="windowActionBarSize"
|
||||
type="int"
|
||||
transient="false"
|
||||
volatile="false"
|
||||
value="16843563"
|
||||
static="true"
|
||||
final="true"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
</field>
|
||||
<field name="windowActionBarStyle"
|
||||
type="int"
|
||||
transient="false"
|
||||
|
||||
@@ -110,6 +110,7 @@ public class ActionBarImpl extends ActionBar {
|
||||
com.android.internal.R.id.lower_action_context_bar);
|
||||
mAnimatorView = (ViewAnimator) decor.findViewById(
|
||||
com.android.internal.R.id.action_bar_animator);
|
||||
mActionView.setContextView(mUpperContextView);
|
||||
|
||||
if (mActionView == null || mUpperContextView == null || mAnimatorView == null) {
|
||||
throw new IllegalStateException(getClass().getSimpleName() + " can only be used " +
|
||||
|
||||
@@ -27,6 +27,7 @@ import android.view.ActionMode;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.View.MeasureSpec;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
@@ -35,9 +36,6 @@ import android.widget.TextView;
|
||||
* @hide
|
||||
*/
|
||||
public class ActionBarContextView extends ViewGroup {
|
||||
// TODO: This must be defined in the default theme
|
||||
private static final int CONTENT_HEIGHT_DIP = 50;
|
||||
|
||||
private int mItemPadding;
|
||||
private int mItemMargin;
|
||||
private int mActionSpacing;
|
||||
@@ -75,11 +73,15 @@ public class ActionBarContextView extends ViewGroup {
|
||||
com.android.internal.R.styleable.Theme_actionModeCloseDrawable);
|
||||
mItemMargin = mItemPadding / 2;
|
||||
|
||||
mContentHeight =
|
||||
(int) (CONTENT_HEIGHT_DIP * getResources().getDisplayMetrics().density + 0.5f);
|
||||
mContentHeight = a.getLayoutDimension(
|
||||
com.android.internal.R.styleable.Theme_windowActionBarSize, 0);
|
||||
a.recycle();
|
||||
}
|
||||
|
||||
public void setHeight(int height) {
|
||||
mContentHeight = height;
|
||||
}
|
||||
|
||||
public void setCustomView(View view) {
|
||||
if (mCustomView != null) {
|
||||
removeView(mCustomView);
|
||||
@@ -208,8 +210,12 @@ public class ActionBarContextView extends ViewGroup {
|
||||
final int contentWidth = MeasureSpec.getSize(widthMeasureSpec);
|
||||
final int itemMargin = mItemPadding;
|
||||
|
||||
int maxHeight = mContentHeight > 0 ?
|
||||
mContentHeight : MeasureSpec.getSize(heightMeasureSpec);
|
||||
|
||||
final int verticalPadding = getPaddingTop() + getPaddingBottom();
|
||||
int availableWidth = contentWidth - getPaddingLeft() - getPaddingRight();
|
||||
final int height = mContentHeight - getPaddingTop() - getPaddingBottom();
|
||||
final int height = maxHeight - verticalPadding;
|
||||
final int childSpecHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST);
|
||||
|
||||
if (mCloseButton != null) {
|
||||
@@ -246,7 +252,20 @@ public class ActionBarContextView extends ViewGroup {
|
||||
MeasureSpec.makeMeasureSpec(customHeight, customHeightMode));
|
||||
}
|
||||
|
||||
setMeasuredDimension(contentWidth, mContentHeight);
|
||||
if (mContentHeight <= 0) {
|
||||
int measuredHeight = 0;
|
||||
final int count = getChildCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
View v = getChildAt(i);
|
||||
int paddedViewHeight = v.getMeasuredHeight() + verticalPadding;
|
||||
if (paddedViewHeight > measuredHeight) {
|
||||
measuredHeight = paddedViewHeight;
|
||||
}
|
||||
}
|
||||
setMeasuredDimension(contentWidth, measuredHeight);
|
||||
} else {
|
||||
setMeasuredDimension(contentWidth, maxHeight);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -53,7 +53,6 @@ public class ActionBarView extends ViewGroup {
|
||||
private static final String TAG = "ActionBarView";
|
||||
|
||||
// TODO: This must be defined in the default theme
|
||||
private static final int CONTENT_HEIGHT_DIP = 50;
|
||||
private static final int CONTENT_PADDING_DIP = 3;
|
||||
private static final int CONTENT_SPACING_DIP = 6;
|
||||
private static final int CONTENT_ACTION_SPACING_DIP = 12;
|
||||
@@ -90,12 +89,17 @@ public class ActionBarView extends ViewGroup {
|
||||
private LinearLayout mTabLayout;
|
||||
private View mCustomNavView;
|
||||
|
||||
private int mTitleStyleRes;
|
||||
private int mSubtitleStyleRes;
|
||||
|
||||
private boolean mShowMenu;
|
||||
private boolean mUserTitle;
|
||||
|
||||
private MenuBuilder mOptionsMenu;
|
||||
private ActionMenuView mMenuView;
|
||||
|
||||
private ActionBarContextView mContextView;
|
||||
|
||||
private ActionMenuItem mLogoNavItem;
|
||||
|
||||
private NavigationCallback mCallback;
|
||||
@@ -151,6 +155,9 @@ public class ActionBarView extends ViewGroup {
|
||||
setBackgroundDrawable(background);
|
||||
}
|
||||
|
||||
mTitleStyleRes = a.getResourceId(R.styleable.ActionBar_titleTextStyle, 0);
|
||||
mSubtitleStyleRes = a.getResourceId(R.styleable.ActionBar_subtitleTextStyle, 0);
|
||||
|
||||
final int customNavId = a.getResourceId(R.styleable.ActionBar_customNavigationLayout, 0);
|
||||
if (customNavId != 0) {
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
@@ -159,11 +166,7 @@ public class ActionBarView extends ViewGroup {
|
||||
addView(mCustomNavView);
|
||||
}
|
||||
|
||||
final int padding = a.getDimensionPixelSize(R.styleable.ActionBar_padding,
|
||||
(int) (CONTENT_PADDING_DIP * metrics.density + 0.5f));
|
||||
setPadding(padding, padding, padding, padding);
|
||||
mContentHeight = a.getDimensionPixelSize(R.styleable.ActionBar_height,
|
||||
(int) (CONTENT_PADDING_DIP * metrics.density + 0.5f)) - padding * 2;
|
||||
mContentHeight = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
|
||||
|
||||
a.recycle();
|
||||
|
||||
@@ -473,13 +476,22 @@ public class ActionBarView extends ViewGroup {
|
||||
mTitleLayout = (LinearLayout) inflater.inflate(R.layout.action_bar_title_item, null);
|
||||
mTitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_title);
|
||||
mSubtitleView = (TextView) mTitleLayout.findViewById(R.id.action_bar_subtitle);
|
||||
|
||||
if (mTitleStyleRes != 0) {
|
||||
mTitleView.setTextAppearance(mContext, mTitleStyleRes);
|
||||
}
|
||||
if (mTitle != null) {
|
||||
mTitleView.setText(mTitle);
|
||||
}
|
||||
|
||||
if (mSubtitleStyleRes != 0) {
|
||||
mSubtitleView.setTextAppearance(mContext, mSubtitleStyleRes);
|
||||
}
|
||||
if (mSubtitle != null) {
|
||||
mSubtitleView.setText(mSubtitle);
|
||||
mSubtitleView.setVisibility(VISIBLE);
|
||||
}
|
||||
|
||||
addView(mTitleLayout);
|
||||
}
|
||||
|
||||
@@ -491,6 +503,10 @@ public class ActionBarView extends ViewGroup {
|
||||
}
|
||||
}
|
||||
|
||||
public void setContextView(ActionBarContextView view) {
|
||||
mContextView = view;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
int widthMode = MeasureSpec.getMode(widthMeasureSpec);
|
||||
@@ -506,9 +522,13 @@ public class ActionBarView extends ViewGroup {
|
||||
}
|
||||
|
||||
int contentWidth = MeasureSpec.getSize(widthMeasureSpec);
|
||||
|
||||
int maxHeight = mContentHeight > 0 ?
|
||||
mContentHeight : MeasureSpec.getSize(heightMeasureSpec);
|
||||
|
||||
final int verticalPadding = getPaddingTop() + getPaddingBottom();
|
||||
int availableWidth = contentWidth - getPaddingLeft() - getPaddingRight();
|
||||
final int height = mContentHeight - getPaddingTop() - getPaddingBottom();
|
||||
final int height = maxHeight - verticalPadding;
|
||||
final int childSpecHeight = MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST);
|
||||
|
||||
if (mLogoView != null && mLogoView.getVisibility() != GONE) {
|
||||
@@ -561,7 +581,24 @@ public class ActionBarView extends ViewGroup {
|
||||
break;
|
||||
}
|
||||
|
||||
setMeasuredDimension(contentWidth, mContentHeight);
|
||||
if (mContentHeight <= 0) {
|
||||
int measuredHeight = 0;
|
||||
final int count = getChildCount();
|
||||
for (int i = 0; i < count; i++) {
|
||||
View v = getChildAt(i);
|
||||
int paddedViewHeight = v.getMeasuredHeight() + verticalPadding;
|
||||
if (paddedViewHeight > measuredHeight) {
|
||||
measuredHeight = paddedViewHeight;
|
||||
}
|
||||
}
|
||||
setMeasuredDimension(contentWidth, measuredHeight);
|
||||
} else {
|
||||
setMeasuredDimension(contentWidth, maxHeight);
|
||||
}
|
||||
|
||||
if (mContextView != null) {
|
||||
mContextView.setHeight(getMeasuredHeight());
|
||||
}
|
||||
}
|
||||
|
||||
private int measureChildView(View child, int availableWidth, int childSpecHeight, int spacing) {
|
||||
|
||||
20
core/res/res/anim/push_down_in_no_alpha.xml
Normal file
20
core/res/res/anim/push_down_in_no_alpha.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2010 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<translate android:fromYDelta="-100%p" android:toYDelta="0"
|
||||
android:duration="@android:integer/config_longAnimTime"/>
|
||||
</set>
|
||||
20
core/res/res/anim/push_down_out_no_alpha.xml
Normal file
20
core/res/res/anim/push_down_out_no_alpha.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright (C) 2010 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<translate android:fromYDelta="0" android:toYDelta="100%p"
|
||||
android:duration="@android:integer/config_longAnimTime"/>
|
||||
</set>
|
||||
@@ -24,8 +24,8 @@ This is an optimized layout for a screen with the Action Bar enabled.
|
||||
<ViewAnimator android:id="@+id/action_bar_animator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inAnimation="@anim/push_down_in"
|
||||
android:outAnimation="@anim/push_down_out">
|
||||
android:inAnimation="@anim/push_down_in_no_alpha"
|
||||
android:outAnimation="@anim/push_down_out_no_alpha">
|
||||
<com.android.internal.widget.ActionBarView
|
||||
android:id="@+id/action_bar"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -28,8 +28,8 @@ the Action Bar enabled overlaying application content.
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="top"
|
||||
android:inAnimation="@anim/push_down_in"
|
||||
android:outAnimation="@anim/push_down_out">
|
||||
android:inAnimation="@anim/push_down_in_no_alpha"
|
||||
android:outAnimation="@anim/push_down_out_no_alpha">
|
||||
<com.android.internal.widget.ActionBarView
|
||||
android:id="@+id/action_bar"
|
||||
android:layout_width="match_parent"
|
||||
@@ -41,6 +41,7 @@ the Action Bar enabled overlaying application content.
|
||||
android:layout_height="wrap_content" />
|
||||
</ViewAnimator>
|
||||
<ImageView android:src="?android:attr/windowContentOverlay"
|
||||
android:scaleType="fitXY"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/action_bar_animator" />
|
||||
|
||||
@@ -24,8 +24,8 @@ This is an optimized layout for a screen with the Action Bar enabled.
|
||||
<ViewAnimator android:id="@+id/action_bar_animator"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inAnimation="@anim/push_down_in"
|
||||
android:outAnimation="@anim/push_down_out">
|
||||
android:inAnimation="@anim/push_down_in_no_alpha"
|
||||
android:outAnimation="@anim/push_down_out_no_alpha">
|
||||
<com.android.internal.widget.ActionBarView
|
||||
android:id="@+id/action_bar"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -28,8 +28,8 @@ the Action Bar enabled overlaying application content.
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="top"
|
||||
android:inAnimation="@anim/push_down_in"
|
||||
android:outAnimation="@anim/push_down_out">
|
||||
android:inAnimation="@anim/push_down_in_no_alpha"
|
||||
android:outAnimation="@anim/push_down_out_no_alpha">
|
||||
<com.android.internal.widget.ActionBarView
|
||||
android:id="@+id/action_bar"
|
||||
android:layout_width="match_parent"
|
||||
@@ -41,6 +41,7 @@ the Action Bar enabled overlaying application content.
|
||||
android:layout_height="wrap_content" />
|
||||
</ViewAnimator>
|
||||
<ImageView android:src="?android:attr/windowContentOverlay"
|
||||
android:scaleType="fitXY"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/action_bar_animator" />
|
||||
|
||||
@@ -256,6 +256,12 @@
|
||||
<!-- Reference to a style for the Action Bar -->
|
||||
<attr name="windowActionBarStyle" format="reference" />
|
||||
|
||||
<!-- Size of the Action Bar, including the contextual
|
||||
bar used to present Action Modes. -->
|
||||
<attr name="windowActionBarSize" format="dimension" >
|
||||
<enum name="wrap_content" value="0" />
|
||||
</attr>
|
||||
|
||||
<!-- Flag indicating whether action modes should overlay window content
|
||||
when there is not reserved space for their UI (such as an Action Bar). -->
|
||||
<attr name="windowActionModeOverlay" format="boolean" />
|
||||
@@ -1005,6 +1011,7 @@
|
||||
<attr name="windowActionBarStyle" />
|
||||
<attr name="windowActionModeOverlay" />
|
||||
<attr name="windowActionBarOverlay" />
|
||||
<attr name="windowActionBarSize" />
|
||||
</declare-styleable>
|
||||
|
||||
<!-- The set of attributes that describe a AlertDialog's theme. -->
|
||||
@@ -4003,8 +4010,6 @@
|
||||
<attr name="customNavigationLayout" format="reference" />
|
||||
<!-- Specifies a fixed height. -->
|
||||
<attr name="height" />
|
||||
<!-- Specifies padding around all sides. -->
|
||||
<attr name="padding" />
|
||||
</declare-styleable>
|
||||
|
||||
</resources>
|
||||
|
||||
@@ -1320,6 +1320,8 @@
|
||||
<public type="attr" name="fragmentOpenExitAnimation" />
|
||||
<public type="attr" name="fragmentCloseEnterAnimation" />
|
||||
<public type="attr" name="fragmentCloseExitAnimation" />
|
||||
<public type="attr" name="windowActionBarSize" />
|
||||
|
||||
<public type="anim" name="animator_fade_in" />
|
||||
<public type="anim" name="animator_fade_out" />
|
||||
|
||||
|
||||
@@ -893,8 +893,11 @@
|
||||
<item name="android:background">@android:drawable/action_bar_background</item>
|
||||
<item name="android:displayOptions">useLogo</item>
|
||||
<item name="android:divider">@android:drawable/action_bar_divider</item>
|
||||
<item name="android:height">56dip</item>
|
||||
<item name="android:padding">3dip</item>
|
||||
<item name="android:height">?android:attr/windowActionBarSize</item>
|
||||
<item name="android:paddingLeft">3dip</item>
|
||||
<item name="android:paddingTop">3dip</item>
|
||||
<item name="android:paddingRight">3dip</item>
|
||||
<item name="android:paddingBottom">3dip</item>
|
||||
</style>
|
||||
|
||||
<style name="Widget.ActionButton">
|
||||
|
||||
@@ -118,6 +118,7 @@
|
||||
<item name="windowActionBar">false</item>
|
||||
<item name="windowActionModeOverlay">false</item>
|
||||
<item name="windowActionBarStyle">@android:style/ActionBar</item>
|
||||
<item name="windowActionBarSize">50dip</item>
|
||||
|
||||
<!-- Dialog attributes -->
|
||||
<item name="alertDialogStyle">@android:style/AlertDialog</item>
|
||||
|
||||
Reference in New Issue
Block a user