Nativescript - referencing Android api methods - nativescript

I'm getting an syntax/undefined error in VSCode (under Android) for Manifest.
android.Manifest.permission.READ_EXTERNAL_STORAGE
Exact message is "Property 'Manifest' does not exist on type 'typeof android'.".
I don't have 'android' defined - but so doesn't the following sample
sample file
My references.d.ts file looks like
/// <reference path="./node_modules/tns-core-modules/tns-core-modules.es2016.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />

#dashman you can provide string instead of the actual enumerations to use nativescript-permissions plugin.
permissions.requestPermission([
"android.permission.INTERNET",
"android.permission.READ_EXTERNAL_STORAGE",
"android.permission.WRITE_EXTERNAL_STORAGE",
"android.permission.SET_WALLPAPER",
"android.permission.ACCESS_NETWORK_STATE"
], "I need these permissions")
.then(function (res) {
console.log("Permissions granted!");
})
.catch(function () {
console.log("No permissions - plan B time!");
});
Note that I am passing an array of strings.

Related

I need to remove the two fields as mentioned in the screenshot from Magento 2

As you can see in the screenshot, we have skin type and product brand with an asterik.
I have created a new attribute and I don't want these two field to be included in it. So how can I remove the field manually from the Magento dashboard or I can make it not mandatory to add.
Currently I have dragged skin type from Stores->Product Attributes->Groups to unassigned attributes.
You can try below steps to hide product fields
Step 1:
create catalog_product_edit.xml under
app/code/Vendor/Module/view/adminhtml/layout
File: catalog_product_edit.xml
<referenceContainer name="content">
<block class="Magento\Framework\View\Element\Template" name="myattribHide" before="before.body.end" template="Vendor_Module::product/edit/fieldhide.phtml" />
</referenceContainer>
Step 2: Create file fieldhide.phtml under
app/code/Vendor/Module/view/adminhtml/templates/product/edit
File : fieldhide.phtml
<script>
require([
'jquery',
'uiRegistry'
], function($,uiRegistry){
uiRegistry.get("product_form.product_form.content.container_yourcustomfield.yourcustomfield", function (element) {
element.hide();
});
})
</script>
Note: Please replace "yourcustomfield" with your attribute code
Step 3: Please remove static files and refresh cache

Unable to find locators for App Login - Xamarin.UI Automation test

As our app login page is upgraded from ADAL library to MSAL library. We are unable to find the locators(Automation IDs) for sign in option via Automation.
we tried
App.EnterText(“UserID”);
App.PressEnter();
App.EnterText(“Password”);
App.PressEnter();
but the value is not entering in user name field and got below Exception Exception: System.Exception: No keyboard is visible for text entry.
at Xamarin.UITest.iOS.iOSApp+<>c__DisplayClass19_0.b__0 () [0x0002b] in <5c98084b260c4b7c9bafd9f653301be5>:0
Any suggestions to identify the user name field.
You need to add Xamarin.UITest to the Xamarin.Forms solution first.
And Set the AutomationIdfor the Entry.
xaml:
<Entry AutomationId="UserID" />
<Entry AutomationId="Password" />
UITest:
[Test]
public void test3()
{
app.EnterText("UserID","5");//UserID is 5
app.PressEnter();
app.EnterText("Password","123456");//password is 123456
app.PressEnter();
}

How to add a fragment to a page's content in SAPUI5

I would like to add a dynamically created fragment to a page's content inside the view's controller.
I currently have the following code:
if(this.tableFragment) {
this.tableFragment.destroy(true);
}
this.tableFragment = sap.ui.xmlfragment("com.example.app.view.fragments.FragmentName");
this.getView().byId("pageID").addDependent(this.tableFragment);
and would like to insert it into a page:
<Page id="pageID" title="Page Title" class="sapUiStdPage">
<content>
</content>
</Page>
but I get an error that contains the following:
is not valid for aggregation "dependents" of Element
I also get the error:
this.tableFragment.destroy is not a function

Redux DevTools could not render

I am using redux-devtools with redux-devtools-dock-monitor and redux-devtools-log-monitor.
I followed documentation. However, in the console I receive this error:
index.js:1452 Redux DevTools could not render.
You must pass the Redux store to <DevTools> either as a "store" prop
or by wrapping it in a <Provider store={store}>.
Here is my Root component:
const Root = () => {
return (
<Provider store={store}>
<div>
<h1>Hello !!!</h1>
<DevTools/>
</div>
</Provider>
);
};
export default Root;
Additionally, I am getting this warning too:
redux-devtools#3.4.2" has incorrect peer dependency "react-redux#^4.0.0 || ^5.0.0".
I have used redux-devtools-log-monitor and redux-devtools-dock-monitor as monitors
I've tried the suggestion and now it gives another error (I'm using the DockMonitor). Ie this is my setup.
<DockMonitor toggleVisibilityKey='ctrl-h'
changePositionKey='ctrl-q'
changeMonitorKey='ctrl-m' >
<LogMonitor />
</DockMonitor>
<Provider store={store}>
<App />
<DevTools store={store} />
</Provider>
Produces the following error:
Uncaught Error: Passing redux store in props has been removed and does not do anything. To use a custom Redux store for specific components, create a custom React context with React.createContext(), and pass the context object to React-Redux's Provider and specific components like: . You may also pass a {context : MyContext} option to connect
In react-redux#6, the store is not passed via legacy React context and you should specify it explecitely via props like so:
<DevTools store={store}/>
Update 1: It was working for me because I had react-redux#6 in main project, but react-redux#5 for redux-devtools dependency. So if someone needs a quick workaround (you shouldn't include DevTools component in production anyway) till it will be supported, just do: cd ./node_modules/redux-devtools && npm i react-redux#5.
Update 2: redux-devtools#3.5.0 was just published, which adds support for react-redux#6.

magento2: loading an uicomponent with Ajax

I've been struggling with that for days...
For an admin extension, I'm trying to load an uiComponent with Ajax to be displayed in a tab. The uiComponent is correctly loaded but seems not to be fully processed by client-side knockout logic.
namespace Man4x\MondialRelay2\Block\Adminhtml\Shipping;
class Tabs
extends \Magento\Backend\Block\Widget\Tabs {
protected function _construct()
{
parent::_construct();
$this->setId('mondialrelay2_shipping_tabs');
$this->setDestElementId('container');
$this->setTitle(__('MondialRelay'));
}
protected function _beforeToHtml()
{
$this->addTab(
'mass_shipping',
[
'label' => __('Mass Shipping'),
'title' => __('Mass Shipping'),
'url' => $this->getUrl('*/*/massshipping', ['_current' => true]),
'class' => 'ajax'
]
);
return parent::_beforeToHtml();
}
}
Here is the simple controller layout:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<container name="root" label="Root">
<uiComponent name="mondialrelay2_massshipping_grid"/>
</container>
Note: this custom uiComponent is perfectly functional when loaded in a standard (i.e. non-AJAX) way
When tracking out AJAX response, I can see the correct HTML code for the uiComponent is loaded (included the Magento specific "x-magento-init" tag). It's then processed by the jquery-ui callback:
this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
// support: jQuery <1.8
// jQuery <1.8 returns false if the request is canceled in beforeSend,
// but as of 1.8, $.ajax() always returns a jqXHR object.
if ( this.xhr && this.xhr.statusText !== "canceled" ) {
tab.addClass( "ui-tabs-loading" );
panel.attr( "aria-busy", "true" );
this.xhr
.success(function( response ) {
// support: jQuery <1.8
// http://bugs.jquery.com/ticket/11778
setTimeout(function() {
panel.html( response );
that._trigger( "load", event, eventData );
}, 1 );
})
...for loaded HTML code to be inserted in the container tag.
Then, a bunch of callbacks and hooks are processed in the js modules jungle. A "contentUpdated" event is finally triggered, causing the:
/**
* Init components inside of dynamically updated elements
*/
$('body').on('contentUpdated', function () {
if (mage) {
mage.apply();
}
});
return $.mage;
}));
mage/apply/main.js and mage/apply/scripts.js are then correctly called (as tracked down in the browser console) but... nothing happens. My loaded
<script type="x-magento-init">
disappeared but my component JS logic doesn't process at all.
Any enlightenment would be highly appreciated.
PS: after deeper investigation, it seems that component JS files of the uiComponent are actually loaded, but not their templates !
I encountered the same problem you did in a similar scenario. It seems like the bindings are not applied as they should, or at least not when they should, in this scenario. To fix it without altering the template i resorted to some additional xml, in your case this could be:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<container name="root" label="Root" htmlTag="div" htmlId="mondialrelay2">
<uiComponent name="mondialrelay2_massshipping_grid"/>
<block class="Magento\Framework\View\Element\Text" name="ajax_ui_component_fix">
<action method="setText">
<argument name="text" xsi:type="string"><![CDATA[<script>
require(['jquery'], function ($) {
$('#mondialrelay2').applyBindings();
});
</script>]]></argument>
</action>
</block>
</container>

Resources