Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Contributor
Posts: 20
Registered: ‎12-22-2012
My Device: PlayBook
My Carrier: Verizon

Updating Active Frames with Webworks?

[ Edited ]

Is it possible to dynamically change an app's Active Frame (on a Z10) while the app is minimized?

 

I've used the demos to experiment with changing the label and with updating the Frame with a picture file. Both of those work fine for me.

 

But what I want to do is have my app periodically redraw it's screen (to show battery percentage for example) while minimized, then show that screen as the new Active Frame. But it seems no matter what I do, the frame continues to show the preview when the app was first minimized. I can see the transition flashing, but the image is just "updated" with the original preview instead of the current screen.

 

I'd assumed that simply calling blackberry.ui.cover.updateCover(); while the app is minimized would update the Active Frame with a new preview of the app's current screen?

 

I've tried things like

 

function updateFrame() {

     blackberry.ui.cover.updateCover();

}

 

and

 

function updateFrame() {

     blackberry.ui.cover.resetCover();

     blackberry.ui.cover.updateCover();

}

 

and

 

function updateFrame() {

     blackberry.ui.cover.resetCover();

     var coverOptions = {"x": 1, "y": 1, "width": 768, "height": 1024};
     blackberry.ui.cover.setContent(blackberry.ui.TYPE_SNAPSHOT, coverOptions);

     blackberry.ui.cover.updateCover();

}

Developer
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C
My Carrier: 3, Orange, Vodafone

Re: Updating Active Frames with Webworks?

Sounds a bit like Cascases - answer anyway

 

Both yes and no

 

Try trappng the onPause event

 

A simple alert works here - you won't see it

 

When your app backgrounds it (basically) stops so you never see the alert

 

If you background the app ad then open it again - we get the alert (took me a LONG time to work that one out as dox are bad)

 

 




Click the like button if you find my posts useful!
Highlighted
Retired
Posts: 203
Registered: ‎12-18-2012
My Device: Z10, Q10, Q5, Z30, Z3
My Carrier: Bell

Re: Updating Active Frames with Webworks?

Hi,

 

You'll need run_when_backgrounded permit in your config.xml in order to update the cover while the app is minimized.

Bryan Higgins
BlackBerry WebWorks
@bryanhiggins
Contributor
Posts: 20
Registered: ‎12-22-2012
My Device: PlayBook
My Carrier: Verizon

Re: Updating Active Frames with Webworks?

Yup, I snuck the run_when_backgrounded in there. Which allows me to periodically update the minimized frame with a picture file or change the label, but it won't seem to update the frame with a new preview of actual app screen when minimized.

 

It's been suggested that the DOM or whatever doesn't repaint when minimized, so maybe it's not going to happen?

 

One solution offered was to draw my screen as a canvas, save it as a .png file, and update the Active Frame with that picture file. That should work in theory, I just haven't figured out how to save a canvas yet Smiley Happy

BlackBerry Development Advisor
Posts: 42
Registered: ‎01-11-2013
My Device: BlackBerry Z10
My Carrier: Rogers

Re: Updating Active Frames with Webworks?

BBKate - have a look at The Marco's Last Weather App, he open sourced it and it has rendering to canvas + saving to update active frame. He doesn't do it once minimized, but you already have that part figured out Smiley Happy

 

He renders the page to canvas in this file (https://github.com/TheMarco/The-Last-Weather-App/blob/master/js/tlwa.js#L257-L270) the code should be highlighted, Lines 257 - 270. It requires this file (https://github.com/TheMarco/The-Last-Weather-App/blob/master/js/html2canvas.js). This calls saveCanvas (https://github.com/TheMarco/The-Last-Weather-App/blob/master/js/savecanvas.js) which saves the Canvas to the local file system. 

 

R

--
System Software Developer II - Enterprise R&D

@roryboy

1.Please resolve your thread by clicking the "Accept as Solution" button below the post which solved your problem!
2. If any post helps you please click the like/thumbs up button below the post(s)
Developer
Posts: 1,229
Registered: ‎03-20-2011
My Device: Playbook, Z10 LE, Dev Alpha B, 2x Dev Alpha C
My Carrier: 3, Orange, Vodafone

Re: Updating Active Frames with Webworks?

I can assure you that the repaint dont track activity (I'm pretty dissapointed by this)

 

If you wanna see a fail condition try going to a buy page on BBW, pause it and pay attention




Click the like button if you find my posts useful!
Developer
Posts: 124
Registered: ‎11-05-2011
My Device: Z10, Bold 9900
My Carrier: Smartone

Re: Updating Active Frames with Webworks?


rcraigbarnes wrote:

BBKate - have a look at The Marco's Last Weather App, he open sourced it and it has rendering to canvas + saving to update active frame. He doesn't do it once minimized, but you already have that part figured out Smiley Happy

 

He renders the page to canvas in this file (https://github.com/TheMarco/The-Last-Weather-App/blob/master/js/tlwa.js#L257-L270) the code should be highlighted, Lines 257 - 270. It requires this file (https://github.com/TheMarco/The-Last-Weather-App/blob/master/js/html2canvas.js). This calls saveCanvas (https://github.com/TheMarco/The-Last-Weather-App/blob/master/js/savecanvas.js) which saves the Canvas to the local file system. 

 

R


I was hoping that blackberry.ui.cover.setContent() would support setting a canvas to it in addition to just TYPE_IMAGE and TYPE_SNAPSHOT. Could we also know the resolutions of the window cover so we don't need to worry about any undesirable scaling?

Thank you.

Developer
Posts: 178
Registered: ‎03-10-2011
My Device: Not Specified

Re: Updating Active Frames with Webworks?

active frame size is mentioned in BB10 UI guidelines: http://developer.blackberry.com/design/bb10/active_frames.html

 

Webworks should allow updating Active Frames content and layout directly, rather than just image and 3 lines labels. I am currrently filling/drawing content to canvas, converting canvas to png and then update image, that brings a lot of additional (and unnecessary) works.

 

 

Contributor
Posts: 30
Registered: ‎02-05-2013
My Device: 9860
My Carrier: Vodafone

Re: Updating Active Frames with Webworks?

Hi,

I am facing an issue in displaying the active frame in a setTimeout.

I want to show an array of images imgPath[] in the window cover as a slideshow but no success.

 

Please let me know if I am doing anything wrong. Thanks in advance.

 

var k = 0;
if(!bb.device.isRipple) {
    blackberry.event.addEventListener("entercover", function() {                                        

        // reset the cover settings upon maximizing the app
        setTimeout(function() {                 
            blackberry.ui.cover.resetCover();

            //Set the cover content
            blackberry.ui.cover.setContent(blackberry.ui.cover.TYPE_IMAGE, {
                path: imgPath[k]
            });

            blackberry.ui.cover.labels = [{
                label: "News",
                size: 10,
                wrap: true
            }];

            blackberry.ui.cover.setTransition(blackberry.ui.cover.TRANSITION_FADE);                     

            //Listen to window minimize event and update the cover
            blackberry.ui.cover.updateCover();

            k++;                    
        },1000);                    
    });                                                             
}
Contributor
Posts: 30
Registered: ‎02-05-2013
My Device: 9860
My Carrier: Vodafone

Re: Updating Active Frames with Webworks?

Hi,

 

Found out the silly mistake I was doing. The simple mistake was setTimeout instead of setInterval... My bad...

 

Also the correct rim perssion is "run_when_backgrounded" but not "run_in_background".

 

Thanks.