Avoid panel to autoHide in Firefox extension - firefox

I am actually trying to develop a Firefox extension using the high level apis, and specifically trying to avoid a panel to autohide when you pick a file or when you click outside of the panel itself.
Does somebody has an idea of how to do this?
I know that it is possible using XUL, so why is this not easy using the apis?
Thank you in advance for your answers.

This is the offical sdk method of doing it:
let myPanel = Panel({.....})
let { getActiveView }=require("sdk/view/core");
getActiveView(myPanel).setAttribute("noautohide", true);

Idea from
this
var toolbarbuttonPanel = doc.createElement('panel');
toolbarbuttonPanel.setAttribute('id', 'toolbarbutton-panel');
toolbarbuttonPanel.setAttribute('type', 'arrow');
toolbarbuttonPanel.setAttribute('noautohide', 'true'); // This is important
var toolbarbuttonLabel = doc.createElement('label');
toolbarbuttonLabel.setAttribute('value', 'toolbarbutton panel');
toolbarbuttonPanel.appendChild(toolbarbuttonLabel);
var mainPopupSet = document.querySelector('#mainPopupSet');
mainPopupSet.appendChild(toolbarbuttonPanel);
Then add this on sdk action/toggle button click:
toolbarbuttonPanel.openPopup(btn);
And Noitidart's comment

Related

Open responsive view from Firefox WebExtension

I have a legacy add-on for firefox, that opened tabs in responsive view. To achieve this, I used the functions from the responsive design module available in
try { Components.utils.import("resource://devtools/client/responsivedesign/responsivedesign.jsm", respdsgn);
} catch (e) {
try { Components.utils.import("resource:///modules/devtools/responsivedesign.jsm", respdsgn);
} catch (e) {
respdsgn = null;
}
}
From what I understand, this is no longer possible using the new web extensions api. Is there an alternative api available to turn the responsive view on for a specific tab? Or is it still possible to use the old style somehow?
Thanks for any pointers!
The old style (or a variant) cannot be used to open the responsive view. An API to open the reponsive view doesn't exist (yet) in WebExtensions and there is no feature request pending. If you want, you can create one here: http://bugzilla.mozilla.org/
(select WebExtensions - Untriaged as product)
The closest thing to achieve the same result, is implement the responsive design mode yourself. This shouldn't be hard to do, since you just have to change the width and the height of the "html" element.
Content script:
document.getElementsByTagName("html")[0].width = "250px";
Good luck!

How to Scroll In an Android Tab Using UIAutomator

i am trying to Scroll Using UIAutomator. The Scenario is I am entering the Settings menu in the tab and clicking on Apps options which gives me a list of all the apps in the tab. NOw i want to scroll the list of apps and this is where i am facing issues.It scrolls the Settings options and not the App list. I am attaching a screen shot and my piece of code.
UiScrollable scroll = new UiScrollable(
new UiSelector().scrollable(true));
scroll.setAsVerticalList();
UiObject Apps = scroll.getChildByText(new UiSelector()
.className(android.widget.TextView.class.getName()),
"Apps");
Apps.clickAndWaitForNewWindow();
UiObject Locker = scroll.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()),"Content Locker");
Locker.clickAndWaitForNewWindow();
I am new to UiAutomator too and there is not very big amount of tutorials to learn it. I used Smrti example here, but some of the things already got deprecated, so I corrected it a bit to make everything work. Here's what I got
UiDevice mDevice = UiDevice.getInstance(getInstrumentation());
mDevice.pressHome();
UiObject allAppsButton = mDevice
.findObject(new UiSelector().description("Apps"));
allAppsButton.clickAndWaitForNewWindow();
UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
appViews.scrollIntoView(new UiSelector().text("Settings"));
mDevice.findObject(new UiSelector().text("Settings")).clickAndWaitForNewWindow();
mDevice.findObject(new UiSelector().text("Apps")).click();
I didn't include the search for certain app here, I'm sure you can manage it the same way as searching for the Settings app in my code snippet.
Say I want to click on App Facebook which is a little down the Apps list under Settings.
You can use this -
getUiDevice().pressHome();
allAppsButton = new UiObject(new UiSelector().description("Apps"));
allAppsButton.click();
appViews = new UiScrollable(new UiSelector().scrollable(true));
appViews.setAsHorizontalList();
selector = new UiSelector().className(android.widget.TextView.class.getName());
appToLaunch = appViews.getChildByText(selector, "Settings");
if (appToLaunch != null)
appToLaunch.clickAndWaitForNewWindow();
new UiObject(new UiSelector().text("Apps")).click();
UiScrollable appViews1 = new UiScrollable(newUiSelector().scrollable(true));
appViews1.scrollForward();
appViews1.scrollTextIntoView("Facebook");
new UiObject(new UiSelector().text("Facebook")).click();
This should work.

alert window in my firefox addon

I'm fresh to firefox addons development, so pls excuse me if it's too dumb. I just couldnt find the answer here in the Stack.
I try to launch an alert window from my addon:
alert('This is an alert');
However, it won't recognize 'alert'. What component should I include (Require)?
Thanks!
For a modal alert, as the question asks, better to use prompt-service, not alerts-service:
var prompts = Cc["#mozilla.org/embedcomp/prompt-service;1"].getService(Ci.nsIPromptService);
prompts.alert(null, "AlertTitle", "AlertMessage");
Perhaps this could help you?
https://developer.mozilla.org/en-US/docs/XUL/School_tutorial/User_Notifications_and_Alerts?redirectlocale=en-US&redirectslug=XUL_School%2FUser_Notifications_and_Alerts
Since links occasionally die I'll save you some scrolling and post the code that might be most useful:
let alertsService =
Cc["#mozilla.org/alerts-service;1"].getService(Ci.nsIAlertsService);
let title = this._bundle.getString("xulschoolhello.greeting.title");
let message = this._bundle.getString("xulschoolhello.greeting.label");
alertsService.showAlertNotification(
"chrome://xulschoolhello/skin/hello-notification.png",
title, message, true, "", this, "XULSchool Hello Message");

Socket.io and Internet explorer

I'm having trouble with socket.io not working on internet explorer 8 and 9.
Give this error:
'this.websocket' is null or not an object
socket.io.min.js line 2
I've set the WEB_SOCKET_SWF_LOCATION this way. It is part of Jquery $(document).ready
var WEB_SOCKET_SWF_LOCATION = 'http://photosandhomes.ca/static/WebSocketMain.swf';
var page_loadSock = io.connect('/page_load');
Thank you.
PS. Here's a live example
http://photosandhomes.ca/33harbour/
The problem was that I had "var WEB_SOCKET_SWF_LOCATION" in the code.
If you're having the same problem use "WEB_SOCKET_SWF_LOCATION" without the var in the global namespace.
I personally placed WEB_SOCKET_SWF_LOCATION into the socket.io.js file.

multiple textboxes in input prompt WP7

coding4fun toolkit's input prompt has one textbox but I can't find any way to add another!
Here is the sample I found from google:
InputPrompt input = new InputPrompt();
input.Completed += new EventHandler<PopUpEventArgs<string, PopUpResult>>(input_Completed);
input.Title = "Test Title";
input.Message = "Test message !";
input.InputScope = new InputScope { Names = { new InputScopeName() { NameValue = InputScopeNameValue.EmailSmtpAddress } } };
input.Show();
Here i can add only single inputscope...but i need to add multiple text boxes here!
can anyone help me ?
Thanks in advance !
The Coding4Fun control does not support this. You'll need to create your own control for such an interface. (hint. You could extend the code of the C4F control.)
My understanding and expectation of the C4F control is that it was intended for quickly gathering an single piece of information which wouldn't warrant the need for its own page.
If you're looking to require the user to enter data into "multiple text boxes" you'll likely be able to create a better user experience (and one that is like the native apps on the phone) if you use a separate page to gather such information.

Resources