From 4991e6dc993559f1b5be2d3c58813462248ec2c3 Mon Sep 17 00:00:00 2001 From: Yurii Cherniavskyi Date: Wed, 25 Sep 2019 13:23:33 +0300 Subject: [PATCH] fix(android/action-bar): process Icon Fonts in NavigationButton the same way as in ActionItem (#7842) * fix(android/action-bar): process Icon Fonts in NavigationButton the same way as in ActionItem * Add NavigationButton with font icons to corresponding page in ui tests app --- .../app/action-bar/font-icons-page.xml | 1 + .../ui/action-bar/action-bar.android.ts | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/e2e/ui-tests-app/app/action-bar/font-icons-page.xml b/e2e/ui-tests-app/app/action-bar/font-icons-page.xml index 8ffe23323..0bfedfb15 100644 --- a/e2e/ui-tests-app/app/action-bar/font-icons-page.xml +++ b/e2e/ui-tests-app/app/action-bar/font-icons-page.xml @@ -1,6 +1,7 @@ + diff --git a/tns-core-modules/ui/action-bar/action-bar.android.ts b/tns-core-modules/ui/action-bar/action-bar.android.ts index 0b1b82b10..fc6a3fc50 100644 --- a/tns-core-modules/ui/action-bar/action-bar.android.ts +++ b/tns-core-modules/ui/action-bar/action-bar.android.ts @@ -227,9 +227,21 @@ export class ActionBar extends ActionBarBase { } } else if (navButton.icon) { - let drawableOrId = getDrawableOrResourceId(navButton.icon, appResources); - if (drawableOrId) { - this.nativeViewProtected.setNavigationIcon(drawableOrId); + if (isFontIconURI(navButton.icon)) { + const fontIconCode = navButton.icon.split("//")[1]; + const font = navButton.style.fontInternal; + const color = navButton.style.color; + const is = fromFontIconCode(fontIconCode, font, color); + + if (is && is.android) { + const drawable = new android.graphics.drawable.BitmapDrawable(appResources, is.android); + this.nativeViewProtected.setNavigationIcon(drawable); + } + } else { + let drawableOrId = getDrawableOrResourceId(navButton.icon, appResources); + if (drawableOrId) { + this.nativeViewProtected.setNavigationIcon(drawableOrId); + } } }