How to implement idle time out using java script function in sencha - sencha-touch

Can anybody tell how to implement idle timeout using java script function in sencha touch
I have tried in sencha controller
var timeoutTime =60000;
var timeoutTimer = setTimeout(function() { alert("dd"); }, timeoutTime);
**$(document).ready(function() {
    $('body').bind('mousedown keydown touchstart', function(event) {**
        clearTimeout(timeoutTimer);
        timeoutTimer = setTimeout(function() { alert("dd"); }, timeoutTime);
    });
});
I am getting error $ in undefined

Related

How should I run a background task that also updates the UI in an intellij settings plugin

I am adding some changes to an intelij plugin that integrates with vault I have settings page that implements Configurable that has a form for credentials and then a "Test Login" button. On button click I want to spawn an asynchronous background task to test the credentials and then update the UI with either success or failure.
Here is a screenshot of my settings
As far as I can tell the correct way to do this would be to use a background task but that requires a "project" which as far as I can tell you have to get from an AnAction and I don't really see how that would work in this context. Here are a few approaches I've played around with
This still blocks the UI and spits out a warning about the UI being blocked for too long
ApplicationManager.getApplication().executeOnPooledThread(() ->
ApplicationManager.getApplication().invokeLaterOnWriteThread(() -> {
// async work
// repaint
}, ModalityState.stateForComponent(myMainPanel)));
// I don't know how to get the project or if I even should here.
ProgressManager.getInstance().run(new Task.Backgroundable(project, "Login"){
public void run(#NotNull ProgressIndicator progressIndicator) {
// async work
// repaint when done
}});
All of this is happening in my AppSettingsComponent button click addActionListener. Here is my complete source code on github
I had the same problem with the project instance required. But by looking at the Task.Backgroundable constructor you can pass a #Nullable project. So I just pass null and it works well for me.
ProgressManager.getInstance().run(new Task.Backgroundable(null, "Login") {
public void run(#NotNull ProgressIndicator progressIndicator) {
// your stuff
}
});

Notification in Tizen wearable web app to display the UI of app running in background

In the tizen wearable web application that I am developing, I need my application to prompt a notification to the user every 10min to go into the same application and give some sort of input from the app UI.
I am currently using a simple status notification from notification API which gives a notification having link to the current application. When user clicks on it, the application is launched again (as it does according to description in simple status notifiation).
But I don't want the application to be restarted by clicking on the notification. Instead it should get the application running background to display on the watch UI.
Please let me know any possible solutions to achieve this.
Below is the code I am using right now.
var myappInfo = tizen.application.getAppInfo();
var notificationDict = {
content : "Please enter your response.",
iconPath : "images/icon.png",
vibration : true,
soundPath : "music/solemn.mp3",
appId : myappInfo.id
};
currentBatteryLevelNotification = new(tizen.StatusNotification("SIMPLE",
"Your input required!", notificationDict);
tizen.notification.post(currentBatteryLevelNotification);
I tried playing with your code, got some progress using:
AppContextId
var myappInfo = tizen.application.getAppContext();
//appId : myappInfo.id or muappInfo.appId
and Moving app to background:
document.addEventListener('tizenhwkey', function(e) {
if(e.keyName === "back") {
try {
tizen.application.getCurrentApplication().hide();
//instead of tizen.application.getCurrentApplication().exit();
} catch (ignore) {
}
}
});
config.xml:
<tizen:setting background-support="enable" encryption="disable" hwkey-event="enable"/>
Tip: If you don't add background-support for Web application, it just dies once you are on exit, It's not possible to get current state.
But I assume the answer is No. May be Notification API is not designed to launch running application I guess.

Sencha Touch [APPNAME].app is undefined only when testing with Jasmine

I'm trying to set up some test cases for a view using the Jasmine 2.3.4 assertion library for my Sencha Touch 2.4 app. Things seem great (I see the view rendered to a div) except the browser does not know what MyApp.app is. I have this line at my onContainerInitialize function from my view/container code:
var controller = MyApp.app.getController('loginController');
which gives this Jasmine error:
TypeError: Cannot read property 'getController' of undefined
At the time the Jasmine tests are called, from my console I do have a MyApp global object with the following structure (attached). If you expand app you will see the class name of the controller listed in an array under _controllers. The line that causes this error in my spec file is:
var myView = new MyApp.view.someViewName({ renderTo: 'test' });
I modeled my setup after a few tutorials, one of which is Sencha's https://docs.sencha.com/extjs/4.2.5/#!/guide/testing
(wish there was one for a recent version of Touch). I think my problem may be related to this note midway down that page:
Note: this Application definition is not a copy and paste of your
regular Application definition in your app.js. This version will only
include the controllers, stores, models, etc and when launch is called
it will invoke the Jasmine tests.
It may be related, but I also couldn't follow their:
ctrl = newMyApp.controller.MyController();
where I would get this error:
TypeError: app.getRouter is not a function at Ext.define.applyRoutes (http://localhost:8080/touch/sencha-t...ug.js:45800:26)
Instead, I had to add in this argument like this:
var ctrl = new Kaacoo.controller.loginController({ application : app });
Additionally, my launch file is set up like this:
Ext.require('Ext.app.Application');
Ext.Loader.setConfig({
enabled: true,
disableCaching: true
});
Ext.Loader.setPath('MyApp', '../../app');
// this file is a couple levels deep from the root of my project
Ext.application({
name : 'MyApp',
extend: 'MyApp.Application',
autoCreateViewport: true,
controllers: [
'loginController'
],
requires : [
],
launch: function() {
// Jasmine is bootstrapped with boot.js referenced in the html runner, so nothing here. My test specs are being called after this launch function is executed.
}
});
The order I have listed my resources in my html runner are: Jasmine Library with boot.js> Touch All Debug Library > Project Source Files > Spec Files > Launch file
Building and simulating the app is fine, so why can't I also have access to MyApp.app.getController('loginController') as well in my test environment?
Thanks!

Worklight 6.1: How to add EULA to hybrid app

Environment:
Worklight 6.1.0.2
dojo 1.9.4
We have created a hybrid app using Worklight 6.1 for android, iOS and windows8 platform. Now we would like to add and show End User License Agreement (EULA) window to the user, when the app first time launch. It should have Accept and Decline button. If user tap on Accept button, then he should be able to use the app.
I would like to know, how can we achieve this using Worklight 6.1.
Any help on this, will be much appreciated.
FYI there is nothing specific here to Worklight.
You could implement this in any number of ways w/out ever using any Worklight API whatsoever.
You could achieve it for example like this (untested code - you'll need to experiment):
In main.js create some global variable eulaAccepted:
var eulaAccepted;
// You will need to handle this property using HTML5 Local Storage so that it will persist for the next time the app is launched, and have the app act accordingly.
Then, in wlCommonInit():
function wlCommonInit() {
if (!eulaAccepted) {
displayEula();
} else {
displayApp();
}
}
In displayEula():
function displayEula() {
// either display a dialog using `WL.SimpleDialog`...
// Or maybe custom HTML with "accept" and "not accept" buttons
WL.SimpleDialog.show(
"Eula Agreement", "your-eula-text-here",
[{text: "Accept", handler: acceptEula },
{text: "Reject", handler: rejectEula}]
);
}
Handle the result:
function acceptEula() {
eulaAccepted = true;
... // Some code that will store the `eulaAccepted` variable using HTML5 Local Storage API
displayApp();
}
function rejectEula() {
// Display some other custom HTML instead of your app.
// Maybe also additional logic to try again to accept the Eula...
}

How to get Crash report with Sencha Touch Application

I want get the application crash report for my Sencha Touch application.Can anybody suggest me how i can achieve that..
Thanks in advance
you can use window.onerror:
window.onerror = function (message, url, lineno) {
// handle error
}