JSON and Main.storyboard - swift 2 - ios

I want to create a website blocking app where parents can block any website they want by typing the link or any tags into UITextField. I can't work out how to have the user enter the links/tags into a UITextField ( i only know how to manually add the links/tags by accessing the .JSON file
in the code.
Any help would be appreciated,
thx,
Noja
P.S. The below code is in the .JSON file
[
{
"action": {
"type": "block"
},
"trigger": {
"url-filter": "example"
}
}
]

Related

creating annotation in mirador programmatically from javascript function

I am trying to programmatically create an annotation on a canvas in mirador by calling a javascript function outside mirador.
Basically, I have a textual representation of a scanned text that includes descriptions of certain phenomenon on the scan, such as handwritten additions. If the user clicks on that description, I want the phenomenon in question to be highlighted with a box on the specified canvas in an already opened mirador instance mymirador that has several windows showing different scans.
For this, I try to pass the annotation as JSON using the receiveAnnotation action, but the annotation is not displayed at the correct place.
Javascript (added linebreaks for convenience):
function openAnnotationInMirador() {
var item = '{"id": "url-to-canvas/annotation",
"type": "Annotation",
"motivation": "commenting",
"body": {
"type": "TextualBody",
"language": "en",
"value": "Some description"},
"target": "url-to-canvas/#xywh=100,100,200,200"}}';
mymirador.store.dispatch(Mirador.actions.receiveAnnotation('url-to-canvas/annotation', 'url-to-canvas', item));
}
Tha function is triggered by a simple html button with onclick: <button onclick="openAnnotationInMirador()">Mirador Test</button>.
I suspect the JSON to be incorrect, but I am quite at loss here. Any suggestions are very much appreciated!
The third parameter to the receiveAnnotation action creator function has to be a JavaScript object of a WebAnnotation AnnotationPage, with the actual annotation in its items array, in your case:
const annoPage = {
id: 'dummy://my.annotation/page',
type: 'AnnotationPage',
items: [
{
"id": "url-to-canvas/annotation",
"type": "Annotation",
"motivation": "commenting",
"body": {
"type": "TextualBody",
"language": "en",
"value": "Some description"},
"target": "url-to-canvas/#xywh=100,100,200,200"
}
}
]
}
When working with the Redux actions in Mirador, it's very useful to install the Redux DevTools Browser Extension with which you can inspect the actions created by Mirador itself.

How to change a Google Slides presentation theme via Slides API?

This is a duplicate of this question. However, nobody has answered it.
So, how can you change a presentation's theme via the API? Is it even possible? I'm using Java, but that shouldn't affect the API.
Thanks
You can do two things:
Import a scheme from a master when creating your presentation - as suggested in the post you are refering to
Change the exsiting theme with a presentations.batchUpdate UpdatePagePropertiesRequest or UpdateShapePropertiesRequest request:
Thereby you can specify theme colors within the update request.
Sample from the documentation:
{
"requests": [
{
"updateShapeProperties": {
"objectId": copyElementId,
"fields": "shapeBackgroundFill.solidFill.color",
"shapeProperties": {
"shapeBackgroundFill": {
"solidFill": {
"color": {
"themeColor": "LIGHT2"
}
}
}
}
}
}
]
}
References:
Pages, Page Elements, and Properties
Kind of properties
ThemeColorType
ColorScheme
PageProperties
PredefinedLayout

'requiresSelection' proprety not working for object page action extension?

For different facets in object page in List Report, when I add any custom action and add property "requiresSelection" to true, action remains disabled.
Tried adding below code in manifest.json
"Sections": {
"to_PDL::com.sap.vocabularies.UI.v1.LineItem": {
"id": "to_PDL::com.sap.vocabularies.UI.v1.LineItem",
"Actions": {
"TestAction_Deactivate": {
"id": "TestAction_Deactivate",
"text": "Deactivate",
"press": "onDeactivate",
"requiresSelection" : true
}
}
}
}
In the official SAP docu it says for property :
“Property that indicates whether the action requires a selection of items (true) or not (false). The default value is true.”
This means, that first you have to select a row in the table. Then the action becomes enabled.
Does it work for you this way?

Reading Remote JSON and Getting Image from URL

In my iOS app I am trying to read in a JSON file and populate a table with its contents. Below is a sample of the JSON file.
Presently, I am reading the JSON into a mutable array called “items” and then populating the table cells like this.
// Populate the cell
if let showName = self.items[indexPath.row]["Show"] as? NSString {
cell.textLabel!.text = showName as! String
I would like to have the image for each JSON record appear in the cell as well and that is where I am getting tripped up.
I have the URL to the image but how do I get it into the table cell?
My entire approach may be wrong so I would appreciate being pointed in the right direction.
{
"shows": [{
"Day": "Sunday",
"Time": "12am",
"Show": “Show Name Here",
"imgPath": "http://remoteserver/image.jpg"
}, {
"Day": "Sunday",
"Time": "1am",
"Show": "Show Name Here",
"imgPath": “http://remoteserver/image.jpg"
}, {
"Day": "Sunday",
"Time": "2am",
"Show": "Show Name Here",
"imgPath": http://remoteserver/image.jpg"
}
I'd recommend using a library like SDWebImage for this. That will provide you with methods for loading an image into an imageview asynchronously, and let you set a placeholder while the image is downloading.
You can set an image from a url like this (copied from SDWebImage docs):
[cell.imageView sd_setImageWithURL:[NSURL URLWithString:#"http://www.domain.com/path/to/image.jpg"]
placeholderImage:[UIImage imageNamed:#"placeholder.png"]];
More info here: https://github.com/rs/SDWebImage
Apple has a example project for this using RSS. LazyTableImages This code is not in swift but will show exactly how apple handled this.
The problem it sounds like you are having is cells are being reused and your image is not being cleared or are being added to a reused cell.

Anyway to have an onLoad function in qml when adding to NavigationPane?

I'm new to Blackberry 10 dev. So I'm wondering what's the best way to do this as I'm not getting any clear answers from the dev docs.
What I want is to start a separate view in my app from a navigation screen. The new page will then create a http request and update the UI based on the output.
The best way seems to be using the NavigationPane and add a qml view. However how do I invoke a C++ function when it's pushed onto the stack? Something similar to android onActivityCreated() in Fragments. There is the Http example docs, but the program started the http request from the constructor of the inherited QObject.
How to I have a function executed as the new qml is added to the navigation stack as
// navigationpane.qml
NavigationPane {
id: navigationPane
Page {
Container {
Label {
text: "First page"
}
}
actions: [
ActionItem {
title: "Next page"
ActionBar.placement: ActionBarPlacement.OnBar
onTriggered: {
var page = pageDefinition.createObject();
navigationPane.push(page);
}
attachedObjects: ComponentDefinition {
id: pageDefinition;
source: "secondpage.qml"
}
}
]
}
onPopTransitionEnded: { page.destroy(); }
}
I think the onCreationCompleted function may be what you're looking for.
In the Page object of your secondpage.qml file, add this:
Page {
id: secondpage
onCreationCompleted: {
// use Javascript to call the exposed C++ function
}
}
If you want something more in the spirit of "onActivityCreated()", you can use the signal transitionEnded:
NavigationPane {
onPushTransitionEnded{
top.callYourPageFunction();
}
}

Resources