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

Android: improve BottomNavigation (experimental feature) #14126

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
cee32ae
xml test
m1ga Sep 27, 2024
4d7916b
badge
m1ga Sep 29, 2024
a89b6cd
use old tabgroup layout
m1ga Oct 2, 2024
4978b22
theme
m1ga Oct 2, 2024
9f3b4c2
more features
m1ga Oct 2, 2024
aa21b57
Merge branch 'master' into bottomNavigationXML
m1ga Oct 5, 2024
c1294ec
more colors
m1ga Oct 5, 2024
0851417
touchfeedback
m1ga Oct 9, 2024
dd1615d
res icons
m1ga Oct 15, 2024
62a6168
add addTab()
m1ga Oct 17, 2024
ff6d9d5
Merge branch 'master' into bottomNavigationXML
m1ga Oct 17, 2024
a657695
Merge branch 'master' into bottomNavigationXML
m1ga Oct 17, 2024
20cda85
remove redundant code, floating bar
m1ga Oct 17, 2024
48c31b0
icon font support
m1ga Oct 19, 2024
a057fb5
tintColor support for icons
m1ga Oct 19, 2024
6536b01
Merge branch 'master' into bottomNavigationXML
m1ga Oct 19, 2024
6e0ddfc
optimize selected state
m1ga Oct 20, 2024
85fc7a6
color updates
m1ga Oct 20, 2024
706cf01
add flags
m1ga Oct 20, 2024
cb1da13
status bar
m1ga Oct 21, 2024
23b1f88
Merge branch 'master' into bottomNavigationXML
m1ga Dec 14, 2024
a1930c2
chore: apidoc
m1ga Dec 14, 2024
42ff775
update property
m1ga Dec 15, 2024
fa95329
Merge branch 'master' into bottomNavigationXML
m1ga Dec 21, 2024
92c117a
Merge branch 'master' into bottomNavigationXML
m1ga Jan 2, 2025
3a52011
events
m1ga Jan 2, 2025
dbceb8e
test, bugfix for empty title
m1ga Jan 2, 2025
dec1971
add enabled property
m1ga Jan 15, 2025
a6f57f9
docs
m1ga Jan 15, 2025
ac5a629
Merge branch 'master' into bottomNavigationXML
m1ga Jan 15, 2025
60c5047
fix WindowProxy
m1ga Jan 15, 2025
4df0d81
fix WindowProxy
m1ga Jan 15, 2025
ba637af
fix linting
m1ga Jan 15, 2025
ad2748e
add back windowFlags for light status bar
m1ga Jan 15, 2025
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 @@ -363,6 +363,9 @@ public class AndroidModule extends KrollModule
@Kroll.constant
public static final int FLAG_UPDATE_CURRENT = PendingIntent.FLAG_UPDATE_CURRENT;

@Kroll.constant
public static final int STATUS_BAR_LIGHT = 8192;

@Kroll.constant
public static final int RESULT_OK = Activity.RESULT_OK;
@Kroll.constant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@
*/
package ti.modules.titanium.ui;

import static ti.modules.titanium.android.AndroidModule.STATUS_BAR_LIGHT;

import android.app.Activity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.appcompat.app.ActionBar;
Expand All @@ -29,6 +33,7 @@
import org.appcelerator.titanium.TiRootActivity;
import org.appcelerator.titanium.proxy.ActivityProxy;
import org.appcelerator.titanium.proxy.TiWindowProxy;
import org.appcelerator.titanium.util.TiColorHelper;
import org.appcelerator.titanium.util.TiConvert;
import org.appcelerator.titanium.util.TiRHelper;
import org.appcelerator.titanium.util.TiUIHelper;
Expand Down Expand Up @@ -426,6 +431,22 @@ public void windowCreated(TiBaseActivity activity, Bundle savedInstanceState)

// Need to handle the cached activity proxy properties in the JS side.
callPropertySync(PROPERTY_POST_TAB_GROUP_CREATED, null);

if (getActivity() != null) {
if (hasPropertyAndNotNull(TiC.PROPERTY_FLAGS)) {
if (TiConvert.toInt(getProperty(TiC.PROPERTY_FLAGS)) == STATUS_BAR_LIGHT
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
getActivity().getWindow().getDecorView()
.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
}
if (hasPropertyAndNotNull(TiC.PROPERTY_STATUS_BAR_COLOR)) {
int colorInt = TiColorHelper.parseColor(
TiConvert.toString(getProperty(TiC.PROPERTY_STATUS_BAR_COLOR)),
TiApplication.getAppRootOrCurrentActivity());
getActivity().getWindow().setStatusBarColor(colorInt);
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@

package ti.modules.titanium.ui;

import static ti.modules.titanium.android.AndroidModule.STATUS_BAR_LIGHT;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.text.Spannable;
Expand Down Expand Up @@ -328,6 +331,13 @@ public void windowCreated(TiBaseActivity activity, Bundle savedInstanceState)
win.setStatusBarColor(colorInt);
}

if (hasProperty(TiC.PROPERTY_WINDOW_FLAGS)) {
if ((TiConvert.toInt(getProperty(TiC.PROPERTY_WINDOW_FLAGS)) & STATUS_BAR_LIGHT) != 0
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
win.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
}
}

// Handle titleAttributes property.
if (hasProperty(TiC.PROPERTY_TITLE_ATTRIBUTES)) {
KrollDict innerAttributes = getProperties().getKrollDict(TiC.PROPERTY_TITLE_ATTRIBUTES);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ public void addTabItemInController(TiViewProxy tabProxy)
if (tabProxy.hasPropertyAndNotNull(TiC.PROPERTY_ICON)) {
menuItem.setIcon(setIcon(tabProxy.getProperty(TiC.PROPERTY_ICON), tabProxy.getProperty("iconFamily")));
}

mMenuItemsArray.add(menuItem);
int index = this.mMenuItemsArray.size() - 1;
updateDrawablesAfterNewItem(index);
Expand Down Expand Up @@ -251,8 +252,13 @@ private void updateDrawablesAfterNewItem(int index)
updateTabIcon(index);
updateBadge(index);
updateBadgeColor(index);
updateTabTitleColor(index);
updateTabBackgroundDrawable(index);

for (int i = 0; i < this.bottomNavigation.getMenu().size(); i++) {
// Set the title text color.
updateTabTitleColor(i);
// Set the background drawable.
updateTabBackgroundDrawable(i);
}
}

@Override
Expand Down Expand Up @@ -314,6 +320,14 @@ public void updateTabBackgroundDrawable(int index)
Drawable drawable = new RippleDrawable(ColorStateList.valueOf(Color.TRANSPARENT), null, null);
this.bottomNavigation.getChildAt(0).setBackground(drawable);
}

if (tabProxy.hasPropertyAndNotNull(TiC.PROPERTY_BACKGROUND_COLOR)) {
BottomNavigationMenuView bottomMenuView =
((BottomNavigationMenuView) this.bottomNavigation.getChildAt(0));
bottomMenuView.getChildAt(index).setBackgroundColor(TiConvert.toColor(
tabProxy.getProperty(TiC.PROPERTY_BACKGROUND_COLOR), TiApplication.getAppRootOrCurrentActivity()
));
}
} catch (Exception e) {
Log.w(TAG, WARNING_LAYOUT_MESSAGE);
}
Expand Down
6 changes: 6 additions & 0 deletions apidoc/Titanium/UI/Android/Android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,12 @@ properties:
type: Number
permission: read-only

- name: STATUS_BAR_LIGHT
summary: Sets the color of the statusbar to light mode. Needs Android API level 23.
type: Number
permission: read-only
since: "12.6.0"

- name: SWITCH_STYLE_CHECKBOX
summary: Display a checkbox.
description: Use with the <Titanium.UI.Switch.style> property.
Expand Down
15 changes: 15 additions & 0 deletions apidoc/Titanium/UI/TabGroup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,12 @@ properties:
since: "8.0.0"
platforms: [android]

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

- name: style
summary: Property defining which style for the TabGroup to be used.
description: |
Expand Down Expand Up @@ -520,6 +526,15 @@ properties:
default: true
platforms: [iphone, ipad, macos]

- name: flags
summary: Additional flags to set on the TabGroup.
description: |
Use <Titanium.UI.Android.STATUS_BAR_LIGHT> to set the statusbar text color to light mode.
platforms: [android]
type: Number
since: "12.6.0"
availability: creation

- name: activeTintColor
summary: The activeTintColor to apply to tabs.
description: |
Expand Down
2 changes: 2 additions & 0 deletions apidoc/Titanium/UI/Window.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1532,6 +1532,8 @@ properties:

Setting <Titanium.UI.Window.fullscreen> to `true` automatically sets the [WindowManager.LayoutParams.FLAG_FULLSCREEN](https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_FULLSCREEN)
flag. Setting <Titanium.UI.Window.flagSecure> to true automatically sets the [WindowManager.LayoutParams.FLAG_SECURE](https://developer.android.com/reference/android/view/WindowManager.LayoutParams.html#FLAG_SECURE) flag.

Use <Titanium.UI.Android.STATUS_BAR_LIGHT> to set the statusbar text color to light mode.
platforms: [android]
type: Number
since: "3.3.0"
Expand Down
Loading