Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TIMOB-16888] Android: Expose ActionBar.setHomeButtonEnabled #5716

Merged
merged 2 commits into from
May 21, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class ActionBarProxy extends KrollProxy
private static final int MSG_SET_DISPLAY_SHOW_HOME = MSG_FIRST_ID + 110;
private static final int MSG_SET_DISPLAY_SHOW_TITLE = MSG_FIRST_ID + 111;
private static final String SHOW_HOME_AS_UP = "showHomeAsUp";
private static final String HOME_BUTTON_ENABLED = "homeButtonEnabled";
private static final String BACKGROUND_IMAGE = "backgroundImage";
private static final String TITLE = "title";
private static final String LOGO = "logo";
Expand Down Expand Up @@ -67,6 +68,18 @@ public void setDisplayHomeAsUp(boolean showHomeAsUp)
}
}

@Kroll.method @Kroll.setProperty
public void setHomeButtonEnabled(boolean homeButtonEnabled)
{
if(TiApplication.isUIThread()) {
handlesetHomeButtonEnabled(homeButtonEnabled);
} else {
Message message = getMainHandler().obtainMessage(MSG_SET_HOME_BUTTON_ENABLED, homeButtonEnabled);
message.getData().putBoolean(HOME_BUTTON_ENABLED, homeButtonEnabled);
message.sendToTarget();
}
}

@Kroll.method @Kroll.setProperty
public void setNavigationMode(int navigationMode)
{
Expand Down Expand Up @@ -294,6 +307,15 @@ private void handlesetDisplayHomeAsUp(boolean showHomeAsUp)
}
}

private void handlesetHomeButtonEnabled(boolean homeButtonEnabled)
{
if (actionBar != null) {
actionBar.setHomeButtonEnabled(homeButtonEnabled);
} else {
Log.w(TAG, "ActionBar is not enabled");
}
}

private void handlesetNavigationMode(int navigationMode)
{
actionBar.setNavigationMode(navigationMode);
Expand Down Expand Up @@ -366,7 +388,7 @@ public boolean handleMessage(Message msg)
handleSetIcon(msg.getData().getString(ICON));
return true;
case MSG_SET_HOME_BUTTON_ENABLED:
actionBar.setHomeButtonEnabled(true);
handlesetHomeButtonEnabled(msg.getData().getBoolean(HOME_BUTTON_ENABLED));
return true;
}
return super.handleMessage(msg);
Expand All @@ -381,7 +403,9 @@ public void onPropertyChanged(String name, Object value)
if (TiApplication.isUIThread()) {
actionBar.setHomeButtonEnabled(true);
} else {
getMainHandler().obtainMessage(MSG_SET_HOME_BUTTON_ENABLED).sendToTarget();
Message message = getMainHandler().obtainMessage(MSG_SET_HOME_BUTTON_ENABLED, true);
message.getData().putBoolean(HOME_BUTTON_ENABLED, true);
message.sendToTarget();
}
}
super.onPropertyChanged(name, value);
Expand Down
9 changes: 9 additions & 0 deletions apidoc/Titanium/Android/ActionBar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@ properties:
type: Boolean
permission: write-only

- name: homeButtonEnabled
summary: Enable or disable the "home" button in the corner of the action bar.
description: |
See also: [setHomeButtonEnabled](http://developer.android.com/reference/android/app/ActionBar.html#setHomeButtonEnabled(boolean))
in the Android Developer Reference.
type: Boolean
since: "3.3.0"
permission: write-only

- name: icon
summary: Sets the application icon displayed in the "home" area of the action bar, specified as a local file path or URL.
description: |
Expand Down