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
Highlighted
Developer
Posts: 75
Registered: ‎02-08-2010
My Device: 9000
My Carrier: Airtel
Accepted Solution

Wallpaper for my App

[ Edited ]

Hi

I am trying to add my own Wallpaper in my App and I having some problems mentioned below

1. Image size is not fitting in the same screen. It is extending beyond one screen

    You can see the image as

    http://supportforums.blackberry.com/t5/image/gallerypage/image-id/1547i147E3E998337A940

    &

    http://supportforums.blackberry.com/t5/image/gallerypage/image-id/1545i092C85CEEE36D9D3

 

2. When I scroll down to last row of Icon (Drive Icon), and when press down key, I am going down with no field below. Can you please help how to aviod it.

     http://supportforums.blackberry.com/t5/image/gallerypage/image-id/1545i092C85CEEE36D9D3

 

3. When I moved to Top row Icon, by default it is showing Last Icon in the First Row, where as I want to remember the last highlight icon and highlight the same when moved up. Can you please let me know code for the same

    http://supportforums.blackberry.com/t5/image/gallerypage/image-id/1544i7A38465BDD6B0667

 

Note: Coding is done based on the reference found in Knowledge Base at

http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/...

 

Code is attached here for reference

 

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.FieldChangeListener;
import net.rim.device.api.ui.FocusChangeListener;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.XYEdges;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;
import net.rim.device.api.ui.decor.Border;
import net.rim.device.api.ui.decor.BorderFactory;

public class WallPaperScreen extends MainScreen {
private Bitmap _WallPaperBitmap;
private int _WallPaperWidth;
private int _WallPaperHeight;
private LabelField _ContextField;
private String _ContextSelect;

private HorizontalFieldManager _FieldManagerIcons;
private VerticalFieldManager _FieldManagerWallPaper;
private VerticalFieldManager _FieldManagerContext;
private VerticalFieldManager _FieldManagerSelect;

private myIcon _Car1Icon, _Car2Icon, _Car3Icon, _Car4Icon, _SelectIcon;

private XYEdges spacePadding = new XYEdges(10,10,10,10);
private Border spaceBorder = BorderFactory.createSimpleBorder(spacePadding,Border.STYLE_TRANSPARENT);

public WallPaperScreen() {
super();

LabelField title = new LabelField(" Select Cars to Drive ",LabelField.ELLIPSIS | LabelField.USE_ALL_WIDTH);
setTitle(title);

_ContextSelect = "Car 1";
_ContextField = new LabelField("Select Car 1");
_ContextField.setBorder(spaceBorder);

_Car1Icon = new myIcon("OnCar2.png","OffCar2.png",0);
_Car2Icon = new myIcon("OnCar3.png","OffCar3.png",0);
_Car3Icon = new myIcon("OnCar4.png","OffCar4.png",0);
_Car4Icon = new myIcon("OnCar5.png","OffCar5.png",0);
_SelectIcon = new myIcon("OnDrive.png","OffDrive.png",0);

myFocusChangeListener focusChangeListener = new myFocusChangeListener();
myFieldChangeListener fieldChangeListener = new myFieldChangeListener();

_Car1Icon.setFocusListener(focusChangeListener);
_Car1Icon.setChangeListener(fieldChangeListener);
_Car1Icon.setBorder(spaceBorder);

_Car2Icon.setFocusListener(focusChangeListener);
_Car2Icon.setChangeListener(fieldChangeListener);
_Car2Icon.setBorder(spaceBorder);

_Car3Icon.setFocusListener(focusChangeListener);
_Car3Icon.setChangeListener(fieldChangeListener);
_Car3Icon.setBorder(spaceBorder);

_Car4Icon.setFocusListener(focusChangeListener);
_Car4Icon.setChangeListener(fieldChangeListener);
_Car4Icon.setBorder(spaceBorder);

_SelectIcon.setFocusListener(focusChangeListener);
_SelectIcon.setChangeListener(fieldChangeListener);
_SelectIcon.setBorder(spaceBorder);

_WallPaperWidth = Display.getWidth();
_WallPaperHeight = Display.getHeight();

Bitmap resizeBitmap = Bitmap.getBitmapResource("WallPaper001.png");
_WallPaperBitmap = new Bitmap(_WallPaperWidth, _WallPaperHeight);
resizeBitmap.scaleInto(_WallPaperBitmap, Bitmap.FILTER_BILINEAR|Bitmap.SCALE_STRETCH);

_FieldManagerWallPaper = new VerticalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH |HorizontalFieldManager.USE_ALL_HEIGHT){
public void paint( Graphics g ) {
g.drawBitmap(0, 0, _WallPaperWidth, _WallPaperHeight, _WallPaperBitmap, 0, 0);
super.paint(g);
}
};
_FieldManagerIcons = new HorizontalFieldManager();
_FieldManagerContext = new VerticalFieldManager();
_FieldManagerSelect = new VerticalFieldManager();

_FieldManagerIcons.add(_Car1Icon);
_FieldManagerIcons.add(_Car2Icon);
_FieldManagerIcons.add(_Car3Icon);
_FieldManagerIcons.add(_Car4Icon);
_FieldManagerContext.add(_ContextField);
_FieldManagerSelect.add(_SelectIcon);

_FieldManagerWallPaper.add(_FieldManagerIcons);
_FieldManagerWallPaper.add(_FieldManagerContext);
_FieldManagerWallPaper.add(_FieldManagerSelect);

add(_FieldManagerWallPaper);
}

protected void updateChangeStatus(Field field) {
if (field == _Car1Icon) {
_ContextSelect = "Car 1";
_ContextField.setText("Select "+_ContextSelect);
}else if (field == _Car2Icon) {
_ContextSelect = "Car 2";
_ContextField.setText("Select "+_ContextSelect);
}else if (field == _Car3Icon) {
_ContextSelect = "Car 3";
_ContextField.setText("Select "+_ContextSelect);
}else if (field == _Car4Icon) {
_ContextSelect = "Car 4";
_ContextField.setText("Select "+_ContextSelect);
}else if (field == _SelectIcon) {
_ContextField.setText("Drive "+_ContextSelect);
}
}

private class myFocusChangeListener implements FocusChangeListener {
public void focusChanged(Field field, int eventType) {
if(eventType == FocusChangeListener.FOCUS_GAINED) {
updateChangeStatus(field);
}
}
}
private class myFieldChangeListener implements FieldChangeListener {
public void fieldChanged(Field field, int context) {
updateChangeStatus(field);
}
}

public boolean onClose() {
Dialog.alert("Goodbye!");
System.exit(0);
return true;
}
}

import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Graphics;

public class myIcon extends Field {

private Bitmap _currentPicture;
private Bitmap _onPicture;
private Bitmap _offPicture;
private int _prefferredHeight, _prefferredWidth;

myIcon (String onImage, String offImage, long style){

super(style);
_offPicture = Bitmap.getBitmapResource(offImage);
_onPicture = Bitmap.getBitmapResource(onImage);
_currentPicture = _offPicture;

_prefferredHeight = _offPicture.getHeight();
if(_onPicture.getHeight() > _prefferredHeight) {
_prefferredHeight = _onPicture.getHeight();
}

_prefferredWidth = _offPicture.getWidth();
if(_onPicture.getWidth() > _prefferredWidth) {
_prefferredWidth = _onPicture.getWidth();
}
}

public boolean isFocusable() {
return true;
}
public int getPreferredHeight(){
return _prefferredHeight;
}
public int getPreferredWidth(){
return _prefferredWidth;
}
protected void onFocus(int direction){
_currentPicture = _onPicture;
invalidate();
}
protected void onUnfocus(){
_currentPicture = _offPicture;
invalidate();
}
protected void layout(int width, int height) {
setExtent(Math.min( width, getPreferredWidth()), Math.min( height, getPreferredHeight()));
}
protected void paint(Graphics graphics) {
graphics.setBackgroundColor(Color.RED);
graphics.clear();
graphics.fillRect(0, 0, getWidth(), getHeight());
graphics.drawBitmap(0, 0, getWidth(), getHeight(), _currentPicture, 0, 0);
}
protected boolean navigationClick(int status, int time){
fieldChangeNotify(0);
return super.navigationClick(status, time);
}
}

Can any one help

 

 

 

Thanks
Siva
Developer
Posts: 1,055
Registered: ‎01-25-2009
My Device: BlackBerry Bold 9650/BlackBerry Torch 9800

Re: Wallpaper for my App

otoSiva, Your images may not have been approved so they are not viewable. Is there any way you could post them to a free image host (like PhotoBucket) so we can view what the problem is.

Jerome Carty - Follow jcarty on Twitter@jcarty | #webworks-dev / #BlackberryDev on irc.freenode.net | My Apps
Click "Accept as Solution" if post solved your original issue.. Give like/thumbs up if you feel post is helpful
Developer
Posts: 75
Registered: ‎02-08-2010
My Device: 9000
My Carrier: Airtel

Re: Wallpaper for my App

Hi

Can any one please help me

Thanks
Siva
Developer
Posts: 587
Registered: ‎01-19-2010
My Device: BOLD 9700 OS5.0.0.x on Rogers Canada
My Carrier: Rogers

Re: Wallpaper for my App

It's going to be awhile before anyone can view those images. Try hosting them externally. I use photobucket.com. You can then insert an image from the external site using the direct image link.

----------------------------------------------------------------------------
chown -R us ./base
~J!NX
Developer
Posts: 75
Registered: ‎02-08-2010
My Device: 9000
My Carrier: Airtel

Re: Wallpaper for my App

Images are posted onto Photobucket.com also. I gave both the links for each image

i.e. Blackberry developer form site and Photobucket.com also.

 

Can you please check it and help me

Thanks
Siva
Developer
Posts: 587
Registered: ‎01-19-2010
My Device: BOLD 9700 OS5.0.0.x on Rogers Canada
My Carrier: Rogers

Re: Wallpaper for my App

Sorry, didn't notice that. After reviewing your images, it seems that the app thinks that the screen extends below. You need to make it so that when you change vertical focus the screen doesn't move to make your selected field in the first row. This could be part of the VerticalFieldManager or your FieldChangedListener. I personally have limited experience with GUI programming, so I wasn't able to find specifically where the problem lies in your code. On a side note, I noticed that you're adding both your focusChangeListener and fieldChangeListener to each relevent field, and they do the exact same thing. You're calling updateChangeStatus twice every time the cursor moves. Just food for thought...

 

Sorry I can't be more help,

~Dom

----------------------------------------------------------------------------
chown -R us ./base
~J!NX
Developer
Posts: 75
Registered: ‎02-08-2010
My Device: 9000
My Carrier: Airtel

Re: Wallpaper for my App

Dom

I agree with  your comment on Listeners (Focus or Change).

I think focus is required in case of Touch Screen based phones, where as Change Listeners for other phones

 

All

As I mentioned in the first post, Can any one help me in providing some solutions to the problems mentioned

 

Thanks
Siva
Developer
Posts: 75
Registered: ‎02-08-2010
My Device: 9000
My Carrier: Airtel

Re: Wallpaper for my App

With following change, I am not seeing the white patch as indicated in W2.jpeg image.

But Still I see Scrollable indicated and when I press down Key, Screen is moving upwards.

 

 

Bitmap resizeBitmap = Bitmap.getBitmapResource("WallPaper001.png");
_WallPaperBitmap = new Bitmap(_WallPaperWidth, _WallPaperHeight);
resizeBitmap.scaleInto(_WallPaperBitmap, Bitmap.FILTER_BILINEAR, Bitmap.SCALE_STRETCH);
		
_FieldManagerWallPaper = new VerticalFieldManager(Field.USE_ALL_WIDTH |Field.USE_ALL_HEIGHT|Field.NON_FOCUSABLE|Manager.NO_VERTICAL_SCROLL|Manager.NO_VERTICAL_SCROLLBAR){
	public void paint( Graphics g ) {
		g.drawBitmap(0, 0, _WallPaperWidth, _WallPaperHeight, _WallPaperBitmap, 0, 0);
		super.paint(g);
	}
	public int getPreferredHeight() {
		return _WallPaperHeight;
	}
	public int getPreferredWidth() {
		return _WallPaperWidth;
	}
	protected void sublayout(int width, int height){
		super.sublayout(_WallPaperWidth, _WallPaperHeight);
		setExtent(_WallPaperWidth, _WallPaperHeight);
	}
};

 

I just want to fill up the whole screen with my image and no scrollable.

Can any one help me

 

 

Thanks
Siva
Developer
Posts: 587
Registered: ‎01-19-2010
My Device: BOLD 9700 OS5.0.0.x on Rogers Canada
My Carrier: Rogers

Re: Wallpaper for my App

This idea probably doesn't have any merit, but try changing the following:

 

 

_FieldManagerIcons = new HorizontalFieldManager();	_FieldManagerContext = new VerticalFieldManager();
_FieldManagerSelect = new VerticalFieldManager();

_FieldManagerIcons.add(_Car1Icon);
_FieldManagerIcons.add(_Car2Icon);
_FieldManagerIcons.add(_Car3Icon);
_FieldManagerIcons.add(_Car4Icon);
_FieldManagerContext.add(_ContextField);
_FieldManagerSelect.add(_SelectIcon);

_FieldManagerWallPaper.add(_FieldManagerIcons);  
_FieldManagerWallPaper.add(_FieldManagerContext);  
_FieldManagerWallPaper.add(_FieldManagerSelect);  

add(_FieldManagerWallPaper);

 

to...

 

 

_FieldManagerIcons = new HorizontalFieldManager();

_FieldManagerIcons.add(_Car1Icon);
_FieldManagerIcons.add(_Car2Icon);
_FieldManagerIcons.add(_Car3Icon);
_FieldManagerIcons.add(_Car4Icon);

_FieldManagerWallPaper.add(_FieldManagerIcons);  
_FieldManagerWallPaper.add(_ContextField);  
_FieldManagerWallPaper.add(_SelectIcon);  

add(_FieldManagerWallPaper);

 

 

The logic here is that two of your VFM's hold only a single field. Might as well eliminate the middlemen by adding the icons directly to the Background VFM. This might eliminate some conflict, and theorectically force the screen to realize that everything that needs to be displayed on the screen is already being displayed -- No need to add more vertical space.

 

Good luck,

~Dom

 

----------------------------------------------------------------------------
chown -R us ./base
~J!NX