Skip to content

Commit b2b4ac8

Browse files
authored
feat(android): navBarColor for Window (#14243)
* feat(android): navBarColor for Window
1 parent c026d19 commit b2b4ac8

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

android/modules/ui/src/java/ti/modules/titanium/ui/WindowProxy.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@
7474
TiC.PROPERTY_FLAG_SECURE,
7575
TiC.PROPERTY_BAR_COLOR,
7676
TiC.PROPERTY_STATUS_BAR_COLOR,
77-
TiC.PROPERTY_UI_FLAGS
77+
TiC.PROPERTY_UI_FLAGS,
78+
TiC.PROPERTY_NAV_BAR_COLOR
7879
})
7980

8081
public class WindowProxy extends TiWindowProxy implements TiActivityWindow
@@ -332,6 +333,12 @@ public void windowCreated(TiBaseActivity activity, Bundle savedInstanceState)
332333
win.setStatusBarColor(colorInt);
333334
}
334335

336+
if (hasProperty(TiC.PROPERTY_NAV_BAR_COLOR)) {
337+
int colorInt = TiColorHelper.parseColor(
338+
TiConvert.toString(getProperty(TiC.PROPERTY_NAV_BAR_COLOR)), activity);
339+
win.setNavigationBarColor(colorInt);
340+
}
341+
335342
if (hasProperty(TiC.PROPERTY_UI_FLAGS)) {
336343
win.getDecorView().setSystemUiVisibility(TiConvert.toInt(getProperty(TiC.PROPERTY_UI_FLAGS)));
337344
}
@@ -477,6 +484,14 @@ public void onPropertyChanged(String name, Object value)
477484
}
478485
}
479486

487+
if (name.equals(TiC.PROPERTY_NAV_BAR_COLOR)) {
488+
if (windowActivity != null && windowActivity.get() != null) {
489+
AppCompatActivity activity = windowActivity.get();
490+
int colorInt = TiColorHelper.parseColor(TiConvert.toString(value), activity);
491+
activity.getWindow().setNavigationBarColor(colorInt);
492+
}
493+
}
494+
480495
if (name.equals(TiC.PROPERTY_UI_FLAGS)) {
481496
if (windowActivity != null && windowActivity.get() != null) {
482497
AppCompatActivity activity = windowActivity.get();

android/titanium/src/java/org/appcelerator/titanium/TiC.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ public class TiC
598598
public static final String PROPERTY_MULTIPLY = "multiply";
599599
public static final String PROPERTY_NAME = "name";
600600
public static final String PROPERTY_NATIVE_SPINNER = "nativeSpinner";
601+
public static final String PROPERTY_NAV_BAR_COLOR = "navBarColor";
601602
public static final String PROPERTY_NAVIGATION_ICON = "navigationIcon";
602603
public static final String PROPERTY_NAVIGATION_ICON_COLOR = "navigationIconColor";
603604
public static final String PROPERTY_NICKNAME = "nickname";

apidoc/Titanium/UI/Window.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,12 @@ properties:
13741374
platforms: [android]
13751375
since: {android: "12.5.0"}
13761376

1377+
- name: navBarColor
1378+
summary: The color of the navigation bar (bottom bar) for this window.
1379+
type: [Number]
1380+
platforms: [android]
1381+
since: {android: "13.1.0"}
1382+
13771383
- name: sustainedPerformanceMode
13781384
summary: Maintain a sustainable level of performance.
13791385
description: |

0 commit comments

Comments
 (0)