Skip to content

Commit

Permalink
Merge branch 'main' into android-background-improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanWalker committed Jan 19, 2024
2 parents 9f34d01 + c15820b commit 9524783
Show file tree
Hide file tree
Showing 28 changed files with 350 additions and 65 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/apps_automated.yml
Expand Up @@ -21,12 +21,12 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20.10.0

- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '11'
java-version: '17'

- name: Install Python
uses: actions/setup-python@v4
Expand All @@ -49,6 +49,8 @@ jobs:

- name: Create Emulator
uses: rigor789/action-create-emulator@main
with:
package: system-images;android-34;default;x86_64

- name: Test (Android)
run: node tools/scripts/run-automated.js android
Expand Down
24 changes: 24 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,27 @@
## [8.6.2](https://github.com/NativeScript/NativeScript/compare/8.6.1-core...8.6.2) (2023-12-22)


### Bug Fixes

* **android:** proper change of input interaction mode programmatically ([#10434](https://github.com/NativeScript/NativeScript/issues/10434)) ([07d2129](https://github.com/NativeScript/NativeScript/commit/07d2129f9c9b387c238c9a7c2da29b5690bac986))
* **android:** use nativeTextViewProtected in TextField ([#10450](https://github.com/NativeScript/NativeScript/issues/10450)) ([c5561d6](https://github.com/NativeScript/NativeScript/commit/c5561d60df0fb093c88a30e072ffdc10f31015b8))
* **core:** inheritable property changes backstack propagation ([#10438](https://github.com/NativeScript/NativeScript/issues/10438)) ([48b1856](https://github.com/NativeScript/NativeScript/commit/48b1856d6cb024ee2a42082e6cf0b8923b0cd8f4))
* **core:** safe important check ([#10455](https://github.com/NativeScript/NativeScript/issues/10455)) ([172d346](https://github.com/NativeScript/NativeScript/commit/172d3463a30cf1ee3727aaa42d6a33505332c6bf))
* **css:** box-shadow none handling ([#10445](https://github.com/NativeScript/NativeScript/issues/10445)) ([6744009](https://github.com/NativeScript/NativeScript/commit/67440095f4fafd68da528e9a88e6a42a86136d9c))
* **ios:** font variation settings not applied to labels ([#10429](https://github.com/NativeScript/NativeScript/issues/10429)) ([2cf166d](https://github.com/NativeScript/NativeScript/commit/2cf166da5974083d1f1431624a4ff06ad648913b))
* **ios:** non-uniform border angle ([#10437](https://github.com/NativeScript/NativeScript/issues/10437)) ([aba3093](https://github.com/NativeScript/NativeScript/commit/aba3093e69004e44aa4afa1f245e7cfa3f6e7b97))
* **ios:** ScrollView with listeners removed scroll delegate ([#10432](https://github.com/NativeScript/NativeScript/issues/10432)) ([9fae9c4](https://github.com/NativeScript/NativeScript/commit/9fae9c428185ed2f99b3710e3fe16cf060bc072b))
* **ios:** shadow does not consider z-index ([#10433](https://github.com/NativeScript/NativeScript/issues/10433)) ([5a4bb7c](https://github.com/NativeScript/NativeScript/commit/5a4bb7c38cc694a312135e44022d5a4c8dc79d1c))
* **time-picker:** properly handle 0 on hour and minutes with valueChanged ([#10460](https://github.com/NativeScript/NativeScript/issues/10460)) ([4762699](https://github.com/NativeScript/NativeScript/commit/4762699fa19fb81a766310724ad2cf0741b105c3))


### Features

* **core:** initRootView event ([#10442](https://github.com/NativeScript/NativeScript/issues/10442)) ([82e9c67](https://github.com/NativeScript/NativeScript/commit/82e9c67d3398c376be1641c5f23bf82a492a48c3))
* **core:** new `defaultVisualState` property option to override 'normal' default visualState ([#10440](https://github.com/NativeScript/NativeScript/issues/10440)) ([31ed40c](https://github.com/NativeScript/NativeScript/commit/31ed40c17ab6ff026dde65c786a3c8ad8e625b3b))



## [8.6.1](https://github.com/NativeScript/NativeScript/compare/5.0.18-webpack...8.6.1) (2023-11-02)


Expand Down
16 changes: 8 additions & 8 deletions README.md
Expand Up @@ -13,7 +13,7 @@

</p>

[NativeScript](http://www.nativescript.org) empowers you to access native APIs from JavaScript directly. Currently iOS and Android runtimes are provided for rich mobile development across a variety of diverse use cases.
[NativeScript](http://www.nativescript.org) empowers you to access native APIs from JavaScript directly. Currently iOS, Android, and visionOS runtimes are provided for rich mobile development across a variety of diverse use cases.


[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FNativeScript%2FNativeScript.svg?type=large)](https://app.fossa.com/projects/git%2Bgithub.com%2FNativeScript%2FNativeScript?ref=badge_large)
Expand All @@ -40,7 +40,7 @@ We love you and your pull requests 🤗. Please follow our [contributing guide](
## @nativescript/*

- [@nativescript/core](https://github.com/NativeScript/NativeScript/tree/main/packages/core)
Core iOS/Android for NativeScript.
Singular primitives offering an easy-to-use API surface for diverse iOS/Android APIs implemented with NativeScript.
- [@nativescript/types](https://www.npmjs.com/package/@nativescript/types)
Types for both iOS/Android below wrapped up as a convenience. *Most commonly used.*
- [@nativescript/types-ios](https://github.com/NativeScript/NativeScript/tree/main/packages/types-ios)
Expand Down Expand Up @@ -73,14 +73,14 @@ We love you and your pull requests 🤗. Please follow our [contributing guide](

Outside the source centralized in this repo, NativeScript consists of a few other source repos. Here are the major ones:

- [iOS Runtime](https://github.com/NativeScript/ns-v8ios-runtime)
NativeScript iOS Runtime: Empowers JavaScript code to be executed on iOS devices written in a mix of C++, Objective-C, and Swift.
- [iOS and visionOS Runtime](https://github.com/NativeScript/ns-v8ios-runtime)
Empowers JavaScript code to be executed on iOS and visionOS devices written in a mix of C++, Objective-C, and Swift.
- [Android Runtime](https://github.com/NativeScript/android-runtime)
NativeScript Android Runtim: Empowers JavaScript code to be executed on Android devices written in a mix of C++, Java and Kotlin.
Empowers JavaScript code to be executed on Android devices written in a mix of C++, Java and Kotlin.
- [CLI](//github.com/NativeScript/nativescript-cli)
NativeScript command-line interface empowering you to create, build, and run apps using NativeScript.
Command-line interface empowering you to create, build, and run apps using NativeScript.
- [Docs](//github.com/NativeScript/docs-new)
NativeScript documentation available at <http://docs.nativescript.org/> written in Markdown.
Documentation available at <http://docs.nativescript.org/> written in Markdown.
- [Plugins](https://github.com/NativeScript/plugins)
A [plugin workspace](https://docs.nativescript.org/plugins/plugin-workspace-guide.html) with several useful plugins.
- [Firebase](https://github.com/NativeScript/firebase)
Expand All @@ -92,4 +92,4 @@ Outside the source centralized in this repo, NativeScript consists of a few othe
- [Artwork](https://github.com/NativeScript/artwork)
Want to use our logo or colors? Feel free to use any of our ready-to-use media material.

<h3 align="center">Made with ❤️</h3>
<h3 align="center">Made with ❤️</h3>
@@ -1,4 +1,9 @@
import * as segmentedBarModule from '@nativescript/core/ui/segmented-bar';
import { Color } from '@nativescript/core';

export function getNativeTabWidget(bar: segmentedBarModule.SegmentedBar): android.widget.TabWidget {
return (<android.widget.TabHost>bar.android).getTabWidget();
}

export function getNativeItemsCount(bar: segmentedBarModule.SegmentedBar): number {
return (<android.widget.TabHost>bar.android).getTabWidget().getTabCount();
Expand All @@ -25,3 +30,54 @@ export function checkNativeItemsTextColor(bar: segmentedBarModule.SegmentedBar):
export function setNativeSelectedIndex(bar: segmentedBarModule.SegmentedBar, index: number): void {
(<android.widget.TabHost>bar.android).setCurrentTab(index);
}

export var checkBackgroundColorUpdatedAfterItemSelected = function (bar: segmentedBarModule.SegmentedBar): boolean {
let isValid = 0;
bar.selectedIndex = 0;
bar.selectedTextColor = new Color('green');
bar.selectedBackgroundColor = new Color('red');

const tabWidget = getNativeTabWidget(bar);
if (tabWidget) {
for (let i = 0; i < tabWidget.getTabCount(); i++) {
const view = tabWidget.getChildTabViewAt(i);
const item = bar.items[i];
const textView = item?.nativeViewProtected;

const newDrawable = tryCloneDrawable(view.getBackground(), view.getResources());
newDrawable.setColorFilter(new android.graphics.Paint(bar.selectedBackgroundColor.android).getColorFilter());

if (bar.selectedIndex == i) {
if (view.getBackground() !== newDrawable) {
console.log('>>>>>>>>>>>>>>>>>>>>>> newDrawable', view.getBackground());
console.log('>>>>>>>>>>>>>>>>>>>>>> bar.selectedBackgroundColor.android', newDrawable);
console.log('>>>>>>>>>>>>>>>>>>>>>> selectedBackgroundColor', newDrawable.getColorFilter(), view.getBackground().getColorFilter());
console.log('>>>>>>>>>>>>>>>>>>>>>> selectedBackgroundColor', newDrawable.hashCode(), view.hashCode());

isValid++;
break;
} else if (textView.getCurrentTextColor() !== bar.selectedTextColor) {
console.log('>>>>>>>>>>>>>>>>>>>>>>');
console.log('>>>>>>>>>>>>>>>>>>>>>>');
console.log('>>>>>>>>>>>>>>>>>>>>>> selectedTextColor');

isValid++;
break;
}
}
}
}

function tryCloneDrawable(value: android.graphics.drawable.Drawable, resources: android.content.res.Resources): android.graphics.drawable.Drawable {
if (value) {
const constantState = value.getConstantState();
if (constantState) {
return constantState.newDrawable(resources);
}
}

return value;
}

return isValid === 0;
};
Expand Up @@ -5,3 +5,5 @@ export declare function getNativeItemsCount(bar: segmentedBarModule.SegmentedBar
export declare function setNativeSelectedIndex(bar: segmentedBarModule.SegmentedBar, index: number): void;

export declare function checkNativeItemsTextColor(bar: segmentedBarModule.SegmentedBar): boolean;

export declare function checkBackgroundColorUpdatedAfterItemSelected(bar: segmentedBarModule.SegmentedBar): boolean;
18 changes: 18 additions & 0 deletions apps/automated/src/ui/segmented-bar/segmented-bar-tests.ts
Expand Up @@ -276,3 +276,21 @@ export function test_SettingNumberAsTitleFromXML_DoesNotThrow() {
TKUnit.assertEqual(item.title, '1');
});
}

/*export function testBackgroundColorUpdatedAfterItemSelected() {
let segmentedBar = new segmentedBarModule.SegmentedBar();
let item1 = new segmentedBarModule.SegmentedBarItem();
(<any>item1).title = 1;
let item2 = new segmentedBarModule.SegmentedBarItem();
(<any>item2).title = 2;
let item3 = new segmentedBarModule.SegmentedBarItem();
(<any>item3).title = 3;
let item4 = new segmentedBarModule.SegmentedBarItem();
(<any>item4).title = 4;
segmentedBar.items = [item1, item2, item3, item4];
buildUIAndRunTest(segmentedBar, function (views: Array<View>) {
TKUnit.assertTrue(segmentedBarTestsNative.checkBackgroundColorUpdatedAfterItemSelected(segmentedBar));
});
}*/
14 changes: 14 additions & 0 deletions apps/automated/src/ui/time-picker/time-picker-tests.ts
Expand Up @@ -197,13 +197,27 @@ export class TimePickerTest extends testModule.UITest<timePickerModule.TimePicke
TKUnit.assertEqual(actualValue, expectedValue);
}

public testHourZeroFromLocalToNative() {
let expectedValue = 0;
this.testView.hour = expectedValue;
let actualValue = timePickerTestsNative.getNativeHour(this.testView);
TKUnit.assertEqual(actualValue, expectedValue);
}

public testMinuteFromLocalToNative() {
let expectedValue = 59;
this.testView.minute = expectedValue;
let actualValue = timePickerTestsNative.getNativeMinute(this.testView);
TKUnit.assertEqual(actualValue, expectedValue);
}

public testMinuteZeroFromLocalToNative() {
let expectedValue = 0;
this.testView.minute = expectedValue;
let actualValue = timePickerTestsNative.getNativeMinute(this.testView);
TKUnit.assertEqual(actualValue, expectedValue);
}

public testHourFromNativeToLocal() {
let expectedValue = 14;
timePickerTestsNative.setNativeHour(this.testView, expectedValue);
Expand Down
2 changes: 2 additions & 0 deletions apps/toolbox/src/pages/datepicker.ts
Expand Up @@ -10,6 +10,8 @@ export function navigatingTo(args: EventData) {
export class SampleData extends Observable {
minDate = new Date();
maxDate = new Date(2030, 7, 1);
hour = 8;
minute = 0;
displayDate = {
day: new Date().getDate(),
month: new Date().getMonth(),
Expand Down
4 changes: 4 additions & 0 deletions apps/toolbox/src/pages/datepicker.xml
Expand Up @@ -16,5 +16,9 @@ year="{{displayDate?.year}}"
<Switch checked="true" col="0" checkedChange="{{checkedChange}}" />
<Label text="Show Time" col="1" class="m-l-10" />
</GridLayout>
<GridLayout rows="auto,auto" columns="">
<Label text="Time Picker standalone:" row="0" col="0" class="m-t-10" />
<TimePicker row="1" hour="{{hour}}" minute="{{minute}}"></TimePicker>
</GridLayout>
</StackLayout>
</Page>
15 changes: 14 additions & 1 deletion apps/ui/src/segmented-bar/all-page.xml
Expand Up @@ -7,7 +7,20 @@
<SegmentedBarItem title="Item 3" />
</SegmentedBar.items>
</SegmentedBar>
<SegmentedBar selectedIndex="2" style="margin: 5; color: blue; background-color: yellow; font-weight: bold; font-size: 20; font-style: italic; font-family: monospace; height: 72; border-width: 2; border-radius: 7; border-color:green; selected-background-color: red;">
<SegmentedBar selectedIndex="2" style="margin: 5; color: blue; background-color: yellow; font-weight: bold; font-size: 20; font-style: italic; font-family: monospace; height: 72; border-width: 2; border-radius: 7; border-color:green; selected-background-color: red;selected-text-color: green">
<SegmentedBar.items>
<SegmentedBarItem title="Item 1" />
<SegmentedBarItem title="Item 2" />
<SegmentedBarItem title="Item 3" />
</SegmentedBar.items>
</SegmentedBar>
<SegmentedBar selectedIndex="2"
selectedTextColor="#00ffd9"
color="red"
android:backgroundColor="#A8A8A8"
selectedBackgroundColor="blue"
android:borderRadius="6"
>
<SegmentedBar.items>
<SegmentedBarItem title="Item 1" />
<SegmentedBarItem title="Item 2" />
Expand Down
20 changes: 10 additions & 10 deletions packages/core/file-system/file-system-access.android.ts
Expand Up @@ -279,7 +279,7 @@ export class FileSystemAccess implements IFileSystemAccess {
resolve(result);
},
onError: (err) => {
reject(new Error(err));
reject(err);
},
}),
getApplicationContext()
Expand All @@ -302,7 +302,7 @@ export class FileSystemAccess implements IFileSystemAccess {
resolve((ArrayBuffer as any).from(result));
},
onError: (err) => {
reject(new Error(err));
reject(err);
},
}),
null
Expand Down Expand Up @@ -340,7 +340,7 @@ export class FileSystemAccess implements IFileSystemAccess {
resolve(result);
},
onError: (err) => {
reject(new Error(err));
reject(err);
},
}),
null
Expand Down Expand Up @@ -388,7 +388,7 @@ export class FileSystemAccess implements IFileSystemAccess {
resolve();
},
onError: (err) => {
reject(new Error(err));
reject(err);
},
}),
null
Expand Down Expand Up @@ -426,7 +426,7 @@ export class FileSystemAccess implements IFileSystemAccess {
resolve();
},
onError: (err) => {
reject(new Error(err));
reject(err);
},
}),
null
Expand Down Expand Up @@ -463,7 +463,7 @@ export class FileSystemAccess implements IFileSystemAccess {
resolve();
},
onError: (err) => {
reject(new Error(err));
reject(err);
},
}),
null
Expand Down Expand Up @@ -501,7 +501,7 @@ export class FileSystemAccess implements IFileSystemAccess {
resolve();
},
onError: (err) => {
reject(new Error(err));
reject(err);
},
}),
null
Expand Down Expand Up @@ -547,7 +547,7 @@ export class FileSystemAccess implements IFileSystemAccess {
resolve(result);
},
onError: (err) => {
reject(new Error(err));
reject(err);
},
}),
null
Expand Down Expand Up @@ -632,7 +632,7 @@ export class FileSystemAccess implements IFileSystemAccess {
resolve();
},
onError: (err) => {
reject(new Error(err));
reject(err);
},
}),
null
Expand Down Expand Up @@ -682,7 +682,7 @@ export class FileSystemAccess implements IFileSystemAccess {
resolve();
},
onError: (err) => {
reject(new Error(err));
reject(err);
},
}),
null
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
@@ -1,6 +1,6 @@
{
"name": "@nativescript/core",
"version": "8.6.2",
"version": "8.6.3",
"description": "A JavaScript library providing an easy to use api for interacting with iOS and Android platform APIs.",
"main": "index",
"types": "index.d.ts",
Expand Down
10 changes: 5 additions & 5 deletions packages/core/profiling/index.ts
Expand Up @@ -177,10 +177,10 @@ export function disable() {
}

function profileFunction<F extends Function>(fn: F, customName?: string): F {
return profileFunctionFactory(fn, customName || fn.name);
return profileFunctionFactory<F>(fn, customName || fn.name);
}

const profileMethodUnnamed = (target, key, descriptor) => {
const profileMethodUnnamed = (target: Object, key: symbol | string, descriptor) => {
// save a reference to the original method this way we keep the values currently in the
// descriptor and don't overwrite what another decorator might have done to the descriptor.
if (descriptor === undefined) {
Expand All @@ -193,7 +193,7 @@ const profileMethodUnnamed = (target, key, descriptor) => {
className = target.constructor.name + '.';
}

const name = className + key;
const name = className + key?.toString();

//editing the descriptor/value parameter
descriptor.value = profileFunctionFactory(originalMethod, name, MemberType.Instance);
Expand All @@ -202,7 +202,7 @@ const profileMethodUnnamed = (target, key, descriptor) => {
return descriptor;
};

const profileStaticMethodUnnamed = (ctor, key, descriptor) => {
const profileStaticMethodUnnamed = <F extends Function>(ctor: F, key: symbol | string, descriptor) => {
// save a reference to the original method this way we keep the values currently in the
// descriptor and don't overwrite what another decorator might have done to the descriptor.
if (descriptor === undefined) {
Expand All @@ -214,7 +214,7 @@ const profileStaticMethodUnnamed = (ctor, key, descriptor) => {
if (ctor && ctor.name) {
className = ctor.name + '.';
}
const name = className + key;
const name = className + key?.toString();

//editing the descriptor/value parameter
descriptor.value = profileFunctionFactory(originalMethod, name, MemberType.Static);
Expand Down

0 comments on commit 9524783

Please sign in to comment.