How to make an HTML page to be shown when Pepper boots - nao-robot

I have a behavior which purpose is to show an HTML page (hosted on the robot). I want that behavior to be loaded on boot and that HTML page to be shown on the Pepper's tablet when Pepper is booted.
I have added it to the robot default behaviors but that doesn't do the trick. It shows me that this behavior is running, that it is in the default behaviors but the HTML page is not shown. Just to make it clear when this behavior is not running and I trigger it, it works as it is intended - I mean the problem is not in the HTML code.

It might be that your behavior is started before the AutonomousLife service or before ALTabletService is ready. This is possible with default behaviors. In your code you need to wait for those 2 to be ready otherwise:
if ALTabletService is not ready, your code will just do nothing
if ALAutonomousLife starts after your app, it will reset the tablet so your page will be hidden.
The best solution is probably to not add it as a default behavior, but edit the app properties and set this behavior as a "solitary" activity, and use a "launch trigger condition" that is always true, like "1".
In that case, as soon as Pepper doesn't have any interactive behavior to start, it will run yours (so it will display the webpage). Also with this solution you ensure that all other services are ready before your behavior is started.
More info in the documentation about how to create solitary activites and launch trigger conditions.

Related

How to fix "Does not provide fallback content when JavaScript is not available" in audit in PWA?

I have made a angular application and I want to test it in audit but in PWA under audit, i got error in PWA optimized section like
Does not provide fallback content when JavaScript is not available
I have even written <noscript>Please enable javascript</noscript> in index.html file. I have not got this error when i ran audit in localhost by starting http-server but the same thing i am checking on server then it gives red mark in PWA optimized section? How to solve this ?
This is the error:
Usually, Adding the <noscript> block on your page would take care of this... I had gone around this myself on my website
Referring to Google's site (which i visited today after your question, we see the description:
Given these considerations, this Lighthouse audit performs a simple
check to ensure that your page isn't blank when JavaScript is
disabled. How strictly your app adheres to progressive enhancement is
a topic of debate, but there's widespread agreement that all pages
should display at least some information when JavaScript is disabled,
even if the content is just an alert to the user that JavaScript is
required to use the page.
For pages that absolutely must rely on JavaScript, one approach is to
use a element to alert the user that JavaScript is required
for the page. This is better than a blank page, because the blank page
leaves users uncertain about whether there's a problem with the page,
their browsers, or their computers.
I suspect that when you disable javascript via chrome, you might end up with just the text "Please enable javascript"; Try also placing
an image, a backup navigation (which runs in case of no JS only)
a backup footer (which runs in case of no JS only)

How to get the current state of the tablet

Is there a way to get the current state of the tablet - if it is in sleep mode, in screen saver mode or if a picture is loaded - to get the name of the loaded picture for example. I didn't find anything in ALTabletService API, but judging on ALTabletService::resetTablet() - Reset the tablet as if no one used it before, i.e. clean the stack of activities, the web browser content, and the web browser cache. there is a stack of tablet activities and perhaps there is what I am looking for.
I don't think you can actually do that. You have to assume it's doing the right thing. If you need to check if your webview is loaded properly, why not raising an Event every 15s from the javascript and subscribe to it from Python? then as soon as Python does not receive this event for 15s, it can reload the page !

Conditionally enable contextMenus based on Tab URL

contextMenus has a enabled property which can be set to true or false.
contextMenus.update() can be used to update the properties.
I would like to enable or disable a contextmenu (one of a few contextmenus) based on conditions.
contextMenus.onClicked.addListener() is fired after the contextmenu is shown so there is no point to use update to change the enabled property (based on tab URL).
Is there a way to change the enabled property before it is shown? (like popupshowing event was in Firefox)
Update:
Note: At this point I am looking for any method of controlling the contextmenu (based on Tab URL) BEFORE it is displayed. The case listed here is just one
example of a situation where such method would be needed.
I am looking for a direct method and not a hack by listening to all mouse events. Furthermore, using a series of asynchronous functions will have unpredictable results.
The actual contexts in this case is tab (which is only supported by Firefox 53.*+).
I am not aware of any mouse event listener for it for this purpose.
Injecting scripts into the context is the heart of the problem.
Firefox (& Chrome) by design prevent script injection into certain locations eg: addons.mozilla.org, about:* or Chrome Web Store; etc.
The problem is more pronounced on Firefox due to unavailability of a number of APIs.
(You can read my comments: WebExtension content script not working on mozilla.org sites)
At the moment, I am forced to run a series of functions to check if the page is blocked or not, after action has been initiated from the contextmenu.
I was looking for a way to disable some of the extensions contextmenu items based on the URL of the tab. In other words, disable few of the extension's contextmenu items on addons.mozilla.org
There are some tab listeners but they don't seem to suit the purpose ie (tabs.onCreated: Fired when a tab is created. Note that the tab's URL may not be set at the time this event fired.)
PS. While I am working on a Firefox extension, since Firefox & Chrome share the similar API and the enable property is used by both, the question has been tagged with both browsers. I have re-ordered the tags to list Firefox as its primary target.
PS2. Stack Overflow puts it under Chrome Extension regardless, so I have removed the Chrome reference tag.
PS3. Voting to close a question prematurely and without knowing all the facts is rather counterproductive.

How to load data at launching Chrome App?

What's the best practice of loading data at launching Chrome App?
The landing page of my Chrome App is dependent on some configuration data, which I've stored in the chrome local storage. However, reading chrome local storage is an asynchronous process. Hence, after the App has launched, there is a period of time when the landing page doesn't show correctly.
To avoid this blank time (due to the asynchronous process of reading local storage), I'm thinking about reading data at background JS. However, I haven't googled out what's the best practice to do it.
Anybody has any comments? Thanks.
just listen to the onLaunched event
chrome.app.runtime.onLaunched.addListener(function() {
// load your data
});
Here's one piece of helpful suggestion I've got from the Google Group. Share here so that someone with the same problem might refer to it:
You can read from chrome.storage in the background page and open the window when the data is ready. However, the user experience might be even worse, because instead of the incorrect landing page, you have no user feedback at all.
The usual (and easy to implement) solution is to show your landing page with some visual feedback during data loading, like a spinning wheel with a "Loading" label. If you UI really requires the data to show up, you can add this visual indicator as an opaque div on top of the whole window.
Some people use splash screens, but I don't think it adds to the user experience.

Windows Phone show ConnectionSettingsTask and back

I am working on a windows phone app right now.
In the app, I am handling an exception in page 1, that when there is no wifi connection, it will pop a XNA messagebox, user can choose to open the WIFI settings page. I have the following code:
ConnectionSettingsTask connectionSettingsTask = new ConnectionSettingsTask();
connectionSettingsTask.ConnectionSettingsType = ConnectionSettingsType.WiFi;
connectionSettingsTask.Show();
But the problem with this is, when user hit back key in the wifi settings page, they will be navigate back to page 1, which has a loading problem and can not display the proper content. In this case, I would like user to directly go to another page, call it page 2.
Is that possible? Thank you
++++++++++++++Update
Is there are way to customize the back key functionality when showing the XNA messagebox?
I don't know about XNA coding much, but I do know that if you return from wifi connection page to your app, the OnNavigatedTo function is invoked. Try setting out your flow of code according to the application flow. If there is some code you have executed at the constructor, shift it to OnNavigatedTo and vice-verse, which may solve your problem. Also if you want to shift to another page, do it in the same function (OnNavigatedTo) itself. Hope it helps.
Maybe you can change the navigation behavior: http://blogs.msdn.com/b/ptorr/archive/2010/08/28/redirecting-an-initial-navigation.aspx
However it is recommended to merge the two pages together (hide loading bar and show main page) as you will have less problems...
why not handle this code in the IsNetworkAvailable check? that way you'l avoid the exception altogether

Resources