Skip to content

Commit

Permalink
Merge pull request #5515 from pec1985/timob-15580-3_2_X
Browse files Browse the repository at this point in the history
[TIMOB-15580] (3_2_X)Back port - add setSubTitle property and method
  • Loading branch information
srahim committed Mar 24, 2014
2 parents 8b43cff + 44cf38d commit 34192a2
Showing 1 changed file with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ public class ActionBarProxy extends KrollProxy
private static final int MSG_SET_ICON = MSG_FIRST_ID + 106;
private static final int MSG_SET_HOME_BUTTON_ENABLED = MSG_FIRST_ID + 107;
private static final int MSG_SET_NAVIGATION_MODE = MSG_FIRST_ID + 108;

private static final int MSG_SET_SUBTITLE = MSG_FIRST_ID + 109;
private static final String SHOW_HOME_AS_UP = "showHomeAsUp";
private static final String BACKGROUND_IMAGE = "backgroundImage";
private static final String TITLE = "title";
private static final String LOGO = "logo";
private static final String ICON = "icon";
private static final String NAVIGATION_MODE = "navigationMode";

private static final String TAG = "ActionBarProxy";

private ActionBar actionBar;
Expand Down Expand Up @@ -101,6 +100,28 @@ public void setTitle(String title)
}
}

@Kroll.method @Kroll.setProperty
public void setSubtitle(String subTitle)
{
if (TiApplication.isUIThread()) {
handleSetSubTitle(subTitle);
} else {
Message message = getMainHandler().obtainMessage(MSG_SET_SUBTITLE, subTitle);
message.getData().putString(TiC.PROPERTY_SUBTITLE, subTitle);
message.sendToTarget();
}
}

@Kroll.method @Kroll.getProperty
public String getSubtitle()
{
if (actionBar == null) {
return null;
}
return (String) actionBar.getSubtitle();
}


@Kroll.method @Kroll.getProperty
public String getTitle()
{
Expand All @@ -109,6 +130,7 @@ public String getTitle()
}
return (String) actionBar.getTitle();
}


@Kroll.method @Kroll.getProperty
public int getNavigationMode()
Expand Down Expand Up @@ -190,6 +212,16 @@ private void handleSetTitle(String title)
}
}

private void handleSetSubTitle(String subTitle)
{
if (actionBar != null) {
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setSubtitle(subTitle);
} else {
Log.w(TAG, "ActionBar is not enabled");
}
}

private void handleShow()
{
if (actionBar != null) {
Expand Down Expand Up @@ -271,6 +303,10 @@ public boolean handleMessage(Message msg)
case MSG_SET_TITLE:
handleSetTitle(msg.getData().getString(TITLE));
return true;
case MSG_SET_SUBTITLE:
handleSetSubTitle(msg.getData().getString(TiC.PROPERTY_SUBTITLE));
return true;

case MSG_SHOW:
handleShow();
return true;
Expand Down

0 comments on commit 34192a2

Please sign in to comment.