Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7c8d19d5 authored by Adam Powell's avatar Adam Powell Committed by Android (Google) Code Review
Browse files

Merge "Fix bug 5087752 - Maintain correct contrast against action bars in inverse-bar themes"

parents a7ffaee2 88ab6978
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -198,6 +198,7 @@ package android {
    field public static final int actionBarTabBarStyle = 16843508; // 0x10102f4
    field public static final int actionBarTabStyle = 16843507; // 0x10102f3
    field public static final int actionBarTabTextStyle = 16843509; // 0x10102f5
    field public static final int actionBarWidgetTheme = 16843683; // 0x10103a3
    field public static final int actionButtonStyle = 16843480; // 0x10102d8
    field public static final int actionDropDownStyle = 16843479; // 0x10102d7
    field public static final int actionLayout = 16843515; // 0x10102fb
@@ -2243,6 +2244,7 @@ package android.app {
    method public abstract java.lang.CharSequence getSubtitle();
    method public abstract android.app.ActionBar.Tab getTabAt(int);
    method public abstract int getTabCount();
    method public android.content.Context getThemedContext();
    method public abstract java.lang.CharSequence getTitle();
    method public abstract void hide();
    method public abstract boolean isShowing();
@@ -2263,7 +2265,7 @@ package android.app {
    method public abstract void setDisplayShowHomeEnabled(boolean);
    method public abstract void setDisplayShowTitleEnabled(boolean);
    method public abstract void setDisplayUseLogoEnabled(boolean);
    method public abstract void setHomeButtonEnabled(boolean);
    method public void setHomeButtonEnabled(boolean);
    method public abstract void setIcon(int);
    method public abstract void setIcon(android.graphics.drawable.Drawable);
    method public abstract void setListNavigationCallbacks(android.widget.SpinnerAdapter, android.app.ActionBar.OnNavigationListener);
+12 −1
Original line number Diff line number Diff line
@@ -627,7 +627,18 @@ public abstract class ActionBar {
     *
     * @param enabled true to enable the home button, false to disable the home button.
     */
    public abstract void setHomeButtonEnabled(boolean enabled);
    public void setHomeButtonEnabled(boolean enabled) { }

    /**
     * Returns a {@link Context} with an appropriate theme for creating views that
     * will appear in the action bar. If you are inflating or instantiating custom views
     * that will appear in an action bar, you should use the Context returned by this method.
     * (This includes adapters used for list navigation mode.)
     * This will ensure that views contrast properly against the action bar.
     *
     * @return A themed Context for creating views
     */
    public Context getThemedContext() { return null; }

    /**
     * Listener interface for ActionBar navigation events.
+13 −1
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.content.res.Resources.Theme;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -54,6 +55,7 @@ import android.util.AttributeSet;
import android.util.EventLog;
import android.util.Log;
import android.util.SparseArray;
import android.util.TypedValue;
import android.view.ActionMode;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
@@ -672,6 +674,7 @@ public class Activity extends ContextThemeWrapper
    /*package*/ int mConfigChangeFlags;
    /*package*/ Configuration mCurrentConfig;
    private SearchManager mSearchManager;
    private MenuInflater mMenuInflater;

    static final class NonConfigurationInstances {
        Object activity;
@@ -3083,7 +3086,16 @@ public class Activity extends ContextThemeWrapper
     * Returns a {@link MenuInflater} with this context.
     */
    public MenuInflater getMenuInflater() {
        return new MenuInflater(this);
        // Make sure that action views can get an appropriate theme.
        if (mMenuInflater == null) {
            initActionBar();
            if (mActionBar != null) {
                mMenuInflater = new MenuInflater(mActionBar.getThemedContext());
            } else {
                mMenuInflater = new MenuInflater(this);
            }
        }
        return mMenuInflater;
    }

    @Override
+21 −0
Original line number Diff line number Diff line
@@ -35,10 +35,13 @@ import android.app.Dialog;
import android.app.FragmentTransaction;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Handler;
import android.util.TypedValue;
import android.view.ActionMode;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
@@ -61,6 +64,7 @@ public class ActionBarImpl extends ActionBar {
    private static final String TAG = "ActionBarImpl";

    private Context mContext;
    private Context mThemedContext;
    private Activity mActivity;
    private Dialog mDialog;

@@ -605,6 +609,23 @@ public class ActionBarImpl extends ActionBar {
        }
    }

    public Context getThemedContext() {
        if (mThemedContext == null) {
            TypedValue outValue = new TypedValue();
            Resources.Theme currentTheme = mContext.getTheme();
            currentTheme.resolveAttribute(com.android.internal.R.attr.actionBarWidgetTheme,
                    outValue, true);
            final int targetThemeRes = outValue.resourceId;
            
            if (targetThemeRes != 0 && mContext.getThemeResId() != targetThemeRes) {
                mThemedContext = new ContextThemeWrapper(mContext, targetThemeRes);
            } else {
                mThemedContext = mContext;
            }
        }
        return mThemedContext;
    }
    
    /**
     * @hide 
     */
+8 −0
Original line number Diff line number Diff line
@@ -616,6 +616,14 @@
             buttons. actionBarStyle is still used for the primary
             bar. -->
        <attr name="actionBarSplitStyle" format="reference" />
        <!-- Reference to a theme that should be used to inflate widgets
             and layouts destined for the action bar. Most of the time
             this will be a reference to the current theme, but when
             the action bar has a significantly different contrast
             profile than the rest of the activity the difference
             can become important. If this is set to @null the current
             theme will be used.-->
        <attr name="actionBarWidgetTheme" format="reference" />
        <!-- Size of the Action Bar, including the contextual
             bar used to present Action Modes. -->
        <attr name="actionBarSize" format="dimension" >
Loading