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

fix(android): fix Actionbar backgroundImage doc and improve setter #14044

Merged
merged 1 commit into from
Aug 20, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.appcelerator.titanium.TiC;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.util.TiUIHelper;
import org.appcelerator.titanium.view.TiDrawableReference;

@SuppressWarnings("deprecation")
@Kroll.proxy(propertyAccessors = { TiC.PROPERTY_ON_HOME_ICON_ITEM_SELECTED, TiC.PROPERTY_CUSTOM_VIEW })
Expand Down Expand Up @@ -102,6 +103,17 @@ public void setBackgroundImage(String url)
actionBar.setDisplayShowTitleEnabled(showTitleEnabled);

actionBar.setBackgroundDrawable(backgroundImage);
} else {
// fallback check with TiDrawableReference
TiDrawableReference source = TiDrawableReference.fromUrl(this, url);
if (source.getDrawable() != null) {
actionBar.setDisplayShowTitleEnabled(!showTitleEnabled);
actionBar.setDisplayShowTitleEnabled(showTitleEnabled);
actionBar.setBackgroundDrawable(source.getDrawable());
} else {
// fail - show error
Log.e(TAG, "Image " + url + " not found");
}
}
}

Expand Down
11 changes: 10 additions & 1 deletion apidoc/Titanium/Android/ActionBar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ examples:
</Alloy>
```


`app/controllers/index.js`:
```
function doMenuClick() {}
function openSettings() {}
function doSearch() {}
$.index.open();
```

`app/styles/index.tss`:
```
"MenuItem": {
Expand Down Expand Up @@ -85,7 +94,7 @@ examples:
win.activity.onCreate = () => {
const actionBar = win.activity.actionBar;
if (actionBar) {
actionBar.backgroundImage = "/bg.png";
actionBar.backgroundImage = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory, 'bg.png').nativePath;
actionBar.title = "New Title";
actionBar.onHomeIconItemSelected = () => {
Ti.API.info("Home icon clicked!");
Expand Down
Loading