Merge "Bug 2841148 - Add accessors for action bar context mode state."
This commit is contained in:
@@ -19890,6 +19890,17 @@
|
||||
visibility="public"
|
||||
>
|
||||
</method>
|
||||
<method name="getCustomView"
|
||||
return="android.view.View"
|
||||
abstract="true"
|
||||
native="false"
|
||||
synchronized="false"
|
||||
static="false"
|
||||
final="false"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
</method>
|
||||
<method name="getMenu"
|
||||
return="android.view.Menu"
|
||||
abstract="true"
|
||||
@@ -19901,6 +19912,28 @@
|
||||
visibility="public"
|
||||
>
|
||||
</method>
|
||||
<method name="getSubtitle"
|
||||
return="java.lang.CharSequence"
|
||||
abstract="true"
|
||||
native="false"
|
||||
synchronized="false"
|
||||
static="false"
|
||||
final="false"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
</method>
|
||||
<method name="getTitle"
|
||||
return="java.lang.CharSequence"
|
||||
abstract="true"
|
||||
native="false"
|
||||
synchronized="false"
|
||||
static="false"
|
||||
final="false"
|
||||
deprecated="not deprecated"
|
||||
visibility="public"
|
||||
>
|
||||
</method>
|
||||
<method name="invalidate"
|
||||
return="void"
|
||||
abstract="true"
|
||||
|
||||
@@ -368,6 +368,24 @@ public abstract class ActionBar {
|
||||
* @return The context mode's menu.
|
||||
*/
|
||||
public abstract Menu getMenu();
|
||||
|
||||
/**
|
||||
* Returns the current title of this context mode.
|
||||
* @return Title text
|
||||
*/
|
||||
public abstract CharSequence getTitle();
|
||||
|
||||
/**
|
||||
* Returns the current subtitle of this context mode.
|
||||
* @return Subtitle text
|
||||
*/
|
||||
public abstract CharSequence getSubtitle();
|
||||
|
||||
/**
|
||||
* Returns the current custom view for this context mode.
|
||||
* @return The current custom view
|
||||
*/
|
||||
public abstract View getCustomView();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -34,6 +34,7 @@ import android.widget.LinearLayout;
|
||||
import android.widget.SpinnerAdapter;
|
||||
import android.widget.ViewAnimator;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
@@ -338,6 +339,7 @@ public class ActionBarImpl extends ActionBar {
|
||||
public class ContextMode extends ActionBar.ContextMode {
|
||||
private ContextModeCallback mCallback;
|
||||
private ActionMenu mMenu;
|
||||
private WeakReference<View> mCustomView;
|
||||
|
||||
public ContextMode(ContextModeCallback callback) {
|
||||
mCallback = callback;
|
||||
@@ -375,6 +377,7 @@ public class ActionBarImpl extends ActionBar {
|
||||
@Override
|
||||
public void setCustomView(View view) {
|
||||
mUpperContextView.setCustomView(view);
|
||||
mCustomView = new WeakReference<View>(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -386,7 +389,22 @@ public class ActionBarImpl extends ActionBar {
|
||||
public void setTitle(CharSequence title) {
|
||||
mUpperContextView.setTitle(title);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getTitle() {
|
||||
return mUpperContextView.getTitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getSubtitle() {
|
||||
return mUpperContextView.getSubtitle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getCustomView() {
|
||||
return mCustomView != null ? mCustomView.get() : null;
|
||||
}
|
||||
|
||||
public void dispatchOnContextItemClicked(MenuItem item) {
|
||||
ActionMenuItem actionItem = (ActionMenuItem) item;
|
||||
if (!actionItem.invoke()) {
|
||||
|
||||
@@ -105,6 +105,14 @@ public class ActionBarContextView extends ViewGroup {
|
||||
initTitle();
|
||||
}
|
||||
|
||||
public CharSequence getTitle() {
|
||||
return mTitle;
|
||||
}
|
||||
|
||||
public CharSequence getSubtitle() {
|
||||
return mSubtitle;
|
||||
}
|
||||
|
||||
private void initTitle() {
|
||||
if (mTitleLayout == null) {
|
||||
LayoutInflater inflater = LayoutInflater.from(getContext());
|
||||
|
||||
Reference in New Issue
Block a user