Icon not showing on Notifications ( codename one ) - mobile

Icon not showing on Notifications ( codename one ). Here is the code:
LocalNotification n = new LocalNotification();
n.setId("demo-notification");
n.setAlertBody("It's time to take a break and look at me");
n.setAlertTitle("Break Time!");
// alert sound file name must begin with notification_sound
Display.getInstance().scheduleLocalNotification(
n,
System.currentTimeMillis(),
LocalNotification.REPEAT_MINUTE
);

Related

How to show the status of restaurant open or closed in react

I have a "openTime" and "closeTime" variable which stores the opening and closing time of restaurants respectively. And I want to display the status of the restaurant "open" or "closed" in react . How can I do this
You can have three date objects,
pseudocode:
D1 = new Date(); //current Time, you can manipulate this acc. to expected date format
D2 = new Date(openTime);
D3 = new Date(closeTime);
if (D1.getTime() <= D3.getTime() && D1.getTime() >= D2.getTime()) {
//change state accordingly and show open
} else {
//change state accordingly and show close
}

Swift - Update and store position of a multiple programmatically created buttons

I have a button which creates other buttons based on the class Clip seen below. Those newly created buttons are added to an array and stored in a plist.
class Clip: Encodable, Decodable {
var name: String = ""
var xCoordinate: Int = 100
var yCoordinate: Int = 300
// more parameter will be added later on e.g color, scale etc..
}
Each button can be moved around the view and the new x & y coordinates are stored in a plist.
#objc func handlePan(sender: UIPanGestureRecognizer){
let uIViewSelected = sender.view!
switch sender.state {
case .began, .changed :
moveViewWithPan(view: uIViewSelected, sender: sender)
break
case .ended:
//Finds the position when the button is no longer being dragged
let x = Int(uIViewSelected.center.x)
let y = Int(uIViewSelected.center.y)
//clipArray[0] need to be the corresponding clicked button e.g clipArray[2]
clipArray[0].xCoordinate = x
clipArray[0].yCoordinate = y
saveData()
break
default:
break
}
}
The above works only if I create one button. When more buttons are added, the above lines only change the first clip from the array. I need a way to update the value to the correct button clicked.
How can identify the array position of the click button as I am creating all them programmatically? At the moment I am placing at value 0 of the clipArray.
clipArray[0].xCoordinate = x
clipArray[0].yCoordinate = y
I am not even sure if using a plist is the best way to store the buttons in the first place.
Any help or documentation would be much appreciated.
Thanks
Following from dfd response, I added tags to each button which are created and it solved the issue for now.
let x = Int(uIViewSelected.center.x)
let y = Int(uIViewSelected.center.y)
//clipArray.append(clip)
var tagNo = uIViewSelected.tag
clipArray[tagNo].xCoordinate = x
clipArray[tagNo].yCoordinate = y

ngTagsInput- what is run when selecting one of the options displayed by autocomplete?

I am working on an AngularJS application, and have a dialog which is used to update what is displayed on one of the widgets on a particular page.
The widget is a table, and I want to allow the user to display different data types/ HTML elements in particular cells of the table.
As it currently stands, the cells will display text, a button, or a 'tag' which is a variable taken from the system, and displayed as a particular element using the ngTagsInput library. As the user types into the text input field, the autocomplete feature displays a list of 'tags' that match what has been typed so far- when the user clicks one of these tags in the list, that is when it is then displayed as a tag in the table widget (if they just type the full name of the tag without selecting it from the autocomplete list, it is just displayed as text).
I have made some changes so that when the first character that the user types is a :, the autocomplete list should show a list of the various pages of the application, for which a button linking to that page will be added to the table (i.e. typing page1 would just show the text "page1" in the table cell, but typing :, and selecting 'page1' from the autocomplete list would display a button linking to page1). This functionality currently works as expected,.
I now want to be able to add multiple buttons to a single table cell (assuming that the user inputs the tags into the text field in the dialog in the correct format). The format to do this will be the same as for one button, but with a ; separating each of the individual buttons- for example, to add buttons for page1 & page2 to the same table cell, the user should just type: :page1;page2.
The autocompleteTagsFilter() function, which is what displays the list of available tags/ pages based on what the user has typed so for (i.e. filters the list of available options as the user continues typing) is defined with:
$scope.autocompleteTagsFilter = function(query) {
if (query.startsWith(":")) {
// Split the 'query' search string on ':', to use only the string
var buttonsQuery = query.substring(1);
if (!buttonsQuery && lastTagQryKw) {
buttonsQuery = lastTagQryKw;
}
/*check whether the buttonsQuery variable contains a ';' - if it does, split it */
if(buttonsQuery.includes(';')) {
//console.log("buttonsQuery includes ; - ", buttonsQuery);
var btnsToDisplay = buttonsQuery.split(";");
console.log("btnsToDisplay: ", btnsToDisplay);
}
// Declare variables to be used in 'for' loop
var userPages = pagesPresets;
var page;
var result = [];
// 'For' loop should iterate through the list of user pages,
// and remove path, so that only the page name is shown
for (page in userPages) {
page = userPages[page];
// If the page key starts with 'buttonsQuery', and its length
// is greater than 6 (i.e. just 'pages/' shouldn't be displayed)
// add the page to the list of pages to be displayed.
if (page.key.startsWith(buttonsQuery) && page.key.length > 6) {
result.push(page.key);
//console.log("result- after result.push(page.key): ", result);
} else {
//console.log("userPages: ", userPages);
}
};
for (btn in btnsToDisplay) {
console.log("btn: ", btnsToDisplay[btn]);
result.push(btnsToDisplay[btn]);
console.log("button added to result: ", result);
if (result.length > 0) {
lastTagQryKw = query;
}
// Return the list of pages that match what the user has typed
//console.log("RESULT (when query.startsWith(':') is true) is: ", result);
return result;
// Otherwise, if the user types something that does not start with ':',
//then it should be a tag- search for tags that match this term
} else {
if (!query && lastTagQryKw) {
query = lastTagQryKw;
}
var result = Object.keys(fxTag.getTags()).filter(function(name) {
return name.indexOf(query.toLowerCase()) !== -1;
});
if (result.length > 0) {
lastTagQryKw = query;
}
console.log("RESULT (when query.startsWith(':') is false) is: ", result);
return result;
}
};
As I type, if I start typing with a :, then the browser console displays a list of pages that I could add a button for:
RESULT (when query.startsWith(':') is true) is: (4) ["pages/userpage1", "pages/pagetitle", "pages/userpage2", "pages/auth"]
If I select one of these buttons, that button is correctly added, and when I click the 'Preview' button on the dialog, the dialog closes and the page shows the table with the working button correctly added to the table cell. The console also shows the output:
tag is only one tag: {tag: "pages/auth"}
which comes from the function onAddingTagItem()
However, if I continue typing, rather than selecting one of the buttons shown by the autocomplete, and type out two buttons, i.e.
:pages/userpage1;pages/userpage2
then rather than displaying two buttons, the table cell just displays the text, i.e :pages/userpage1;pages/userpage2.
and I get the console output:
value of tags: (2) [":pages/userpage1", "pages/userpage2"]
The same onAddingTagItem() function is called in both cases, only it runs the if instead of the else when the text entered by the user contains a ;. This function is defined with:
$scope.onAddingTagItem = function(tag) {
if(tag.tag.includes(";")) {
var tags = tag.tag.split(";");
console.log("value of tags: ", tags);
angular.forEach(tags, function(tag, key) {
if(tag.startsWith(":")) {
tag = tag.split(":")[1];
}
angular.extend(tag, toTagItemObj(tag));
})
} else {
console.log("tag is only one tag: ", tag);
}
return true;
};
So, as I understand, it should be returning the tags whether there are one or several of them, because it returns true whether the if or the else is run.
Given that this function always returns true, whether it's the if or the else that has been run, why is it that a button is only displayed when I click an option from the autocomplete list, and not when typing out a button in full?
How can I ensure that the text entered will be displayed as a button when it meets the criteria (starts with a :), even if it's not selected from the autocomplete list, or enable selection of multiple items from the autocomplete list?

Toggle a key with hotkey in autohotkey

So I tried to automate running in a game, where the map is huge, and I have to run miles. I wanted to toggle on the hotkey (Ctrl+Shift+A or something else) press the running (in the game, I can run with w).
I tried code, like:
Pause On
Loop
Send w
+^a::Pause
(it can press the w, but it can't release) and like this:
+^a::
toggle := !toggle
while toggle
Send {w down}
(same problem).
It's just my problem, or these codes are wrong?
I have a (at least i think) much simpler solution :)
#NoTrayIcon
ScrollLock::
Input, Key, ,{Enter}
Send, {%Key% Down}
return
You press ScrollLock (which I doubt you use for anything else, otherwise set it to a free key), and then enter the name of button to be held down.
If you want to hold down a single character, you just write it in.
For other keys you can find the names here: http://www.autohotkey.com/docs/KeyList.htm
Mouse: LButton for left, RButton for right and MButton for middle
You end the input with the Enter key, and after that the program will hold down the entered key.
If you want to "lift up" the key, just simply press it once, and it will be held down no more. :)
ps.:I have #NoTrayIcon, because I'm running it permanently in the background, but if you wanted to be able to exit then simply add something like this:
F12::
ExitApp
return
This is my stock function. I usualy map it to ^W or Q. Pressing w or s will cancel it. Easy peasy.
HoldW(){
SendInput {w up}{w down}
Loop
{
Sleep 100
GetKeyState state, w
if state = u
return
If GetKeyState("s")
{
SendInput {w up}
return
}
}
}
+^vk41:: ; shift+ctrl+a
SetTimer, % "SomeLable", % (bToggle:=!bToggle) ? 25:"Off"
KeyWait, % "vk41"
Return
SomeLable:
SendInput, % "{vk57}" ; w
Return
A silly noob example where F10 is the toggle hotkey, and the up/down state is a variable. The variable needs to be pre-declared to give the initial value.
To be honest I expected an error message, but it seemed to run fine.
keystate=down
F10::
Send {w %keystate%}
if keystate = down
SetEnv, keystate, up
else if keystate = up
SetEnv, keystate, down
return
Toggle := 1
Q::Send, % Toggle = 1 ? ( "0", Toggle := 0 ) : ( "9", Toggle := 1 )
Change Q to your preferred hotkey, and change "0" and "9" to the keys you want to toggle through. Make sure to set your abilities or weapons to the keys you replace in "0" and "9".
So, lets say I have a primary and secondary weapon. I bind them in game to 9 and 0.
I press Q to cycle between them for fast weapon switching. Or w/e else you want.

Passing an Array with Objects to another function in GAS

Just to give you a little background on my question:
I am creating a form in Google App Script using the UI Services and I am storing specific calendar events in a dataArray. So the event object is stored in the array. I want to pass this array to the submit function but can't figure out how to go about this because :
I can't add it as a callback element (because it isn't a widget)
I can't store the event object in a widget (i.e. a listbox, etc) and then add that widget as a callback element.
Here is a brief sample of what I am trying to do:
var cal= CalendarApp.getDefaultCalendar();
var event= cal.getEvents(new Date("June 16, 2013 PST"),
new Date("July 22, 2013 PST"));
var specific = new Array;
for( var j=0; j<event.length;j++){
specific.push(event[j]);
//This stores the events in the specific variable
//I want to send this variable (w/ the data) to another function on submit
I would appreciate any suggestions you can lend me.
Thanks!
As a complement to the answer I gave in the comments : "you could also simply store the id and while you read the events again using the same start/end time you can check if an event correspond to the saved ID in a loop... if a match is found with the right ID you are sure it's the right event"
Here is a piece of code I use to modify/update/delete calendar events using their ID as reference. This code is used to delete specific events selected from the spreadsheet, the code to modify events is roughly the same, at least it uses the same ID checking.
...
var cal = CalendarApp.openByName(calName);
if (cal) {
var events = cal.getEvents(new Date(date_deb), new Date(date_fin),{max: 4000}); // stocke tt ds une variable array
var sel= sh.getRange(6,1,sh.getLastRow()-5, 10).getValues();// read data in the SS
for(e=0;e<events.length;++e){
var delFlag = false;
var ID = events[e].getId();
for(n=0;n<sel.length;++n){
if ((sel[n][8] == "x"||sel[n][8] == "X")&&sel[n][9]==ID){ // the ID here is stored in the spreadsheet in column J and I use a 'X' marker to select which event should be deleted
delFlag = true;
sh.getRange(n+6,9,1,2).setBackgroundColor('#ff5500');
SpreadsheetApp.flush();
Logger.log('FLAG '+ e);
break;
}
}
if(delFlag){
try{
var toDelete = events[e].deleteEvent();
++todel;
delFlag = false;
Logger.log('event deleted : '+sel[n][1]);
}catch(Err){Logger.log('Event from a serie already deleted from another occurence')}
}
}
}
var msg = todel + " événement(s) effacé(s) dans l'Agenda '"+calName+"'";
ss.toast("Effacement terminé", msg, 3);
...

Resources