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

feat(android): statusBarColor for Window #14089

Merged
merged 5 commits into from
Sep 13, 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 @@ -69,8 +69,10 @@
TiC.PROPERTY_MODAL,
TiC.PROPERTY_WINDOW_PIXEL_FORMAT,
TiC.PROPERTY_FLAG_SECURE,
TiC.PROPERTY_BAR_COLOR
TiC.PROPERTY_BAR_COLOR,
TiC.PROPERTY_STATUS_BAR_COLOR
})

public class WindowProxy extends TiWindowProxy implements TiActivityWindow
{
private static final String TAG = "WindowProxy";
Expand Down Expand Up @@ -320,6 +322,12 @@ public void windowCreated(TiBaseActivity activity, Bundle savedInstanceState)
}
}

if (hasProperty(TiC.PROPERTY_STATUS_BAR_COLOR)) {
int colorInt = TiColorHelper.parseColor(
TiConvert.toString(getProperty(TiC.PROPERTY_STATUS_BAR_COLOR)), activity);
win.setStatusBarColor(colorInt);
}

// Handle titleAttributes property.
if (hasProperty(TiC.PROPERTY_TITLE_ATTRIBUTES)) {
KrollDict innerAttributes = getProperties().getKrollDict(TiC.PROPERTY_TITLE_ATTRIBUTES);
Expand Down Expand Up @@ -446,6 +454,14 @@ public void onPropertyChanged(String name, Object value)
}
}

if (name.equals(TiC.PROPERTY_STATUS_BAR_COLOR)) {
if (windowActivity != null && windowActivity.get() != null) {
AppCompatActivity activity = windowActivity.get();
int colorInt = TiColorHelper.parseColor(TiConvert.toString(value), activity);
activity.getWindow().setStatusBarColor(colorInt);
}
}

if (name.equals(TiC.PROPERTY_TITLE_ATTRIBUTES)) {
if (windowActivity != null && windowActivity.get() != null) {
// Get a reference to the ActionBar.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ public class TiC
public static final String PROPERTY_TOUCH_FEEDBACK_COLOR = "touchFeedbackColor";
public static final String PROPERTY_TRANSITION_NAME = "transitionName";
public static final String PROPERTY_BAR_COLOR = "barColor";
public static final String PROPERTY_STATUS_BAR_COLOR = "statusBarColor";
public static final String PROPERTY_BASE_URL = "baseUrl";
public static final String PROPERTY_BASE_URL_WEBVIEW = "baseURL";
public static final String PROPERTY_BIG_TEXT = "bigText";
Expand Down
6 changes: 6 additions & 0 deletions apidoc/Titanium/UI/Window.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,12 @@ properties:
platforms: [iphone, ipad, macos]
since: {iphone: "3.1.3", ipad: "3.1.3", macos: "9.2.0"}

- name: statusBarColor
summary: The color of the status bar (top bar) for this window.
type: [Number]
platforms: [android]
since: {android: "12.5.0"}

- name: sustainedPerformanceMode
summary: Maintain a sustainable level of performance.
description: |
Expand Down
Loading