Skip to content

Commit

Permalink
feat(android): statusBarColor for Window (#14089)
Browse files Browse the repository at this point in the history
Co-authored-by: Chris Barber <[email protected]>
  • Loading branch information
2 people authored and hansemannn committed Sep 16, 2024
1 parent b9932b2 commit 91499ef
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
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

0 comments on commit 91499ef

Please sign in to comment.