Nativescript using android - nativescript

I am new to NativeScript.
I am trying to figure out how to use the Bluetooth Native Api (Classic not LE).
I have a hard time finding out how I can interact with the bluetooth api.
The first wall I hit is using android in my typescript code.
For exemple in a component if i do :
ngOnInit(): void {
console.info(android.os.Build.VERSION.SDK_INT)
}
I get the error:
JS: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'os' of undefined
Any suggestions ?

To have access (and intelliSense which is even better) via TypeScript to the native APIs you need the generated declarations files. Fortunately, you do not have to provide these files as they are already avaiable via the tns-platform-declarations plugin
To install the declarations do the fiollwing in your Angular project
npm i tns-platform-declarations --save-dev
And then create references.d.ts file with the following content:
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />
Finally, modify the content of your tsconfig.json file to include the following:
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"experimentalDecorators": true,
"lib": [
"es6",
"dom"
]
}
}
If for some reason you do not need IntelliSense you can skip all this and simply give a type to android in the beginning of your *.ts file
declare var android: any;
However, I would strongly recommend the first approach as it will give you really nice IntelliSense for the really enormous native APIs

Related

Add FontSize,FontColor,FontFamily Plugin to Ckeditor5 ClassicEditor in Asp.Net MVC

has anyone worked with ckeditor5? Unfortunately, I have difficulty reading and understanding the document.
I have a ckeditor.js file with settings and basic tools included
"undo", "redo", "bold", "italic", "alignment", "Underline", "link", "heading", "bulletedList", "numberedList", "blockQuote", "mediaBrowser", "insertTable "
Now I want to add "fontColor", "fontFamily" and "fontSize". But I do not know how I can add this plugin or any other plugin at all. Of course, I could not find the underline that was not in the initial list, but I had a problem with these plugins because it called so many nested functions in the online builder version that I download, I could not get it?
If I want to use a separate config file in the new version, what is the procedure?
Thank you for your help.

Typescript and Web Console in Firefox

I wrote a web page using Angular 2 and Typescript. When I opened Firefox Web Console, and I tried to find the .ts file in order to debug it, all I found is the Javascript file that was 'transpiled' from the original .ts file.
In Chrome, it's possible to see the Typescript file in the Developer Tools and debug it. Is it also possible in FF ?
Yes. You need to create the .map files when transpiling from TypeScript to Javascript.
Just include the property "sourceMap": true in the compilerOptions in your tsconfig.json and you're done!

Adding PCL project to VSIX not working

I´m trying to create a multi-project-solution-template with VSIX for my Xamarin solutions but I just can´t get the template to work when I add a PCL to it.
I´m using this Git project (see How to create a multi project template) as a boiler plate and I can easily add ordinary projects (e.g class libraries) to it and get them to work just fine.
I´m guessing it is not working because I probably need to add some Dependencies in the vsixmanifest file to e.g ASP.NET Core 1.0 or more of the stuff the PCL is referring to.
But I have not been able to find out what to add to get it to work.. and of course this could be something totally different...
I just tried to change the PCL to the new .net Standard by using this guide ".NET Standard Library with Xamarin Forms" and it works like a charm. But with Xamarin.Forms 2.3.1.114 I needed to go for netstandard 1.4.
So my project.json file looks like this
{
"supports": {},
"dependencies": {
"Xamarin.Forms": "2.3.1.114",
"NETStandard.Library": "1.6.0",
"Microsoft.NETCore.Portable.Compatibility": "1.0.1"
},
"frameworks": {
"netstandard1.4": {
"imports": [
"portable-net45+win8+wpa81+wp8"
]
}
}
}
This ".NET Standard with Xamarin Forms Gotchas" might also help you as it did me.

How to install Sass in brackets text editor

Duplicate Question?
Yes it is. But a little bit different from this
Overview:
I am also a new user of the brackets text editor. I know the difference between Scss & Sass. But the reason why I am using brackets text editor is for just Sass not Scss.
I saw some tutorials of Jason Sanjose for integrating Sass in brackets text editor. But I think. I am not doing it right. Below is my steps. What I am doing.
Install Sass for bracket using Extension Manager.
Install bower and bourbon
Create folder on root named: "SASS" and inside this folder create app.sass file.
Create folder on root named: "CSS"
Create a config file named: ".brackets.json" and put below code inside it:
{
"sass.enabled": false,
"path": {
"SASS/app.scss": {
"sass.enabled": true,
"sass.options": {
"outputDir": "../CSS/",
"includePaths": [],
"sourceComments": true,
"outputStyle": "nested"
}
}
}
}
and here is the snapshot also
Question:
When I write below code in app.sass file it is not converting it to css file or creating any css file in output directory.
body
background-color: black
Now my question is: Please explain me how I convert sass file in css or tell me what I am doing wrong in ".brackets.json" file or in my "app.sass" file.
After a lot searching on web. I found a useful article and my answer. Which I am sharing with you guys.
Brackets-SASS Plugin setup
Step By Step Tutorial Without migrating on other apps.
You don't need to install Sass in you text editor mate,only thing you need to install on your computer is Prepros,that software support sass/scss coffeescript typescript FTP upload and much more
I personally recommend installing Koala.app - it's fully automated and refreshes on save.
Text editors can come pre-packaged or with an addon that highlights SASS and SCSS, but all (which I know of) cannot compile it.

How to view css stylesheet injected by a Google Chrome extension using dev tools?

I'm injecting a css file from my chrome extension using the manifest.json (full source):
"content_scripts": [
{
"matches": [
"http://*/*"
],
"css":["src/inject/gfi_extension.css"],
"js": [/*...*/]
}
]
In Chrome Dev Tools, if I inspect an element which is affected by the injected css, the rules are visible, but in the upper right where the source filename would normally be, it just says "injected stylesheet." I'd like to view ALL of the rules being injected, even those that affect elements which do not currently exist in the DOM.
I would have expected the .css to appear in "sources" under "content scripts" with the .js files, but they aren't there.
Is there a way to view the .css file through dev tools? If not, please explain why there isn't.
Edit: I've just found that this question also appears as a "sub-question" of this one, however no one over there has attempted to answer it, even though there is an accepted answer.
Looks like there's no way to do this if you inject the CSS via content_scripts. I filed a bug here: https://crbug.com/800070
When the extension is in your control, Paul Irish suggests using this code pattern in order to make your styles inspectable: https://github.com/lateral/chrome-extension-blogpost/compare/master...paulirish:master
For other people's extensions, as far as I can tell there's no way to view the source code of the injected stylesheets in DevTools, if you go the content_scripts route.
Go to Sources and then Content Scripts. You have to go to the extension name and then you'll see the injected files.
Use the Chrome App and Extensions Developer Tool on an extension which injects CSS, such as Bootstrap Grid Overlay:
the injected URL can be used on the console tab on the app to get the runtime URL using the getURL method:
chrome.runtime.getURL("src/grid.css")
and produce the source:
References
Content Scripts - Google Chrome
chrome.runtime - Google Chrome

Resources