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

Java Development

Reply
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810
Accepted Solution

Draw a picture in (over) the VoiceApp screen

Hi all.

I already started/finished two threads that led me to the creation of this one.

 

This is my goal:
1) Application intercepts a callConnected() event.

2) Application displays an image of the callee (i.e.. Draws it over the VoiceApp).

3) The Phone application (VoiceApp) continues its normal operations (its menu and softkeys are active)

 

There are two approaches I researched so far:

 

A) In callConnected() use:

 

 

// fScreenWithOnlyPicture is a popup screen with a picture.

Ui.getUiEngine().pushGlobalScreen(fScreenWithOnlyPicture, 4, UiEngine.GLOBAL_SHOW_LOWER);

    

B) in callConnected() use:

  

application.invokeLater(new Runnable(){

public void run(){

Screen screenName = UiApplication.getUiApplication().getActiveScreen();

System.out.println(screenName.toString());

if (screenName.toString().indexOf("net.rim.device.apps.internal.phone.ActivePhoneScreen") != -1) // draw only in VoiceApp

{

//Perform screen changes here.

// for simplicity sake, I'll just draw a red rectangle 

Graphics g = screenName.getGraphics();

g.setColor(Color.RED);

g.fillRect(0, 96, Display.getWidth(), 92);

//Calling invalidate() on your screen forces the paint

//method to be called.

screenName.updateDisplay();

//screenName.doPaint();

//screenName.invalidate();

}

}

}, 10, true); // true -> repeat

 

Solution A) has a drawback that the  fScreenWithOnlyPicture becomes active screen and the menu (to be shown when the user clicks the MENU button) is not the VoiceApp's menu, but (of course) fScreenWithOnlyPicture's menu.

Any idea how to get around this ?

 

Solution B) has a drawback that the picture drawn is not 'attached' to the VoiceApp screen but just painted over it. So when user clicks the MENU button, the VoiceApp's menu  is shown :smileysurprised: but the VoiceApp itself (currently behind the menu) is redrawn without the picture (or in this simple test a red rectangle).

 

Does anyone have any new idea ? or maybe a comment on these two approaches ?

 

Thank you all for your help so far.

 



"Listen carefully, I shall say this only once"
Developer
Posts: 64
Registered: ‎09-02-2008
My Device: 8830, 8100

Re: Draw a picture in (over) the VoiceApp screen

You could for example import the menu items from the below screen, for solution A...
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Draw a picture in (over) the VoiceApp screen

How can I do that ?

 

After all, it's a native VoiceApp...

 

You know a way of doing this ? 



"Listen carefully, I shall say this only once"
Developer
Posts: 64
Registered: ‎09-02-2008
My Device: 8830, 8100

Re: Draw a picture in (over) the VoiceApp screen

Menu m = Ui.getUiEngine().getActiveScreen().getScreenBelow().getMenu(0); /** * You have here the menu ... Getting the menu is not a problem ... * just iterate with menu.getItem(counter) */

 

Bytheway, I want to update the current screen ...

Having the code below does not help ... Do you have an idea?


final Screen s = ui.getActiveScreen(); if(s != null){ UiApplication.getUiApplication().invokeLater(new Runnable(){ public void run(){ Graphics g = s.getGraphics(); g.setColor(0x00ffff); int w = s.getWidth(); int h = s.getHeight() >> 1; g.fillRect(0, 0, w, h); g.drawText("Someone calling", w / 2, h / 2, Graphics.TOP | Graphics.LEFT); //s.invalidate(); s.updateDisplay(); } }, 1, false); }

 

Any idea?

 

Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: Draw a picture in (over) the VoiceApp screen

Hi. 
Thanks for the menu trick info... I will try to use it :smileyhappy:

 

As for the screen ...

Well,my code worked. Try to start from there. My first guess would be that you use 'outer' Screen s from within the thread ....  Maybe someone with more 'threading' experience would know more about that.

 

Also, try to set the thread to repeat itself by setting the last parameter of the invokeLater() method to true (but increase 1 to 100 or more).

 



"Listen carefully, I shall say this only once"
New Developer
Posts: 1
Registered: ‎11-19-2008
My Device: Not Specified

Re: Draw a picture in (over) the VoiceApp screen

Hey thanks for the great info.  I was trying to do the same thing, but whenever i push a global screen it works but the active call screen goes on top of it.  Are you having this same problem?  How did you get around it?
Developer
Posts: 64
Registered: ‎09-02-2008
My Device: 8830, 8100

Re: Draw a picture in (over) the VoiceApp screen

Hi!

 

You can't push anything on top of the incoming call screen or the screen blocked screen. You will get a SecurityException when you will try to do this... But you can push a screen on top of active call screen... Of course on the emulator you will have no trouble doing so.

 

Best regards!

gunar