BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 03-22-2010, 05:05 AM   #1 (permalink)
New Member
 
Join Date: May 2009
Model: 8100
PIN: N/A
Carrier: airtel
Posts: 14
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Switch application icon issue

Please Login to Remove!

Hi

I am using the following code for implementing Switch application. but the icons coming are not the Home screen icons. How i can include the Home screen icons to the switch application ribbon ???


class SwitchApplicationMenuItem extends MenuItem
{
ApplicationManager _appm;
PopupScreen _pop;
LabelField _appname;
static boolean _colorSupported = Graphics.isColor();

public SwitchApplicationMenuItem()
{
super("Switch Application", 268501007, 268501007); // 268501007 comes right before the Close (0x10010010) Menu
}

private final class ApplicationIconField extends BitmapField
{
private Bitmap _icon;
private String _name;
private int _pcid;
ApplicationIconField(ApplicationDescriptor appdescriptor)
{
super(appdescriptor.getIcon(), Field.FOCUSABLE);
_icon = appdescriptor.getIcon();
if (_icon == null) // Just for safety
_icon = Bitmap.getPredefinedBitmap(Bitmap.QUESTION);
_name = appdescriptor.getName();
if (_name.length() >= 2 && _name.charAt(1) == 0x0332) // remove underscores
{
StringBuffer temp = new StringBuffer(_name);
temp.deleteCharAt(1);
_name = temp.toString();
}
_pcid = _appm.getProcessId(appdescriptor);
setSpace(10, 3);
}

protected void paint(Graphics graphics)
{
int x, y, width, height, iconWidth, iconHeight, xOffset, yOffset;
width = getContentWidth();
height = getContentHeight();
iconWidth = _icon.getWidth();
iconHeight = _icon.getHeight();
if (iconWidth <= width)
{
x = (width - iconWidth) / 2;
xOffset = 0;
}
else
{
x = 0;
xOffset = (iconWidth - width) / 2;
iconWidth = width;
}

if (iconHeight <= height)
{
y = (height - iconHeight) / 2;
yOffset = 0;
}
else
{
y = 0;
yOffset = (iconHeight - height) / 2;
iconHeight = height;
}
if (_colorSupported && this.isFocus())
{
int circleSize = Math.min(iconHeight, iconWidth);
int maxSize = Math.min(height, width);
if (circleSize < maxSize)
circleSize = Math.min(maxSize, circleSize + ((maxSize - circleSize) / 2));
else
circleSize = maxSize;
graphics.setColor(Color.YELLOW);
graphics.fillRoundRect((width - circleSize) / 2, (height - circleSize) / 2, circleSize, circleSize, circleSize, circleSize); // circle
}
if (_colorSupported && _icon.getBitsPerPixel() == 1) // add some color to Mono images
{
graphics.setColor(Color.DARKBLUE);
graphics.rop(Graphics.ROP_SRCMONOEXPAND_ALPHA, x, y, iconWidth, iconHeight, _icon, xOffset, yOffset);
}
else
{
graphics.drawBitmap(x, y, iconWidth, iconHeight, _icon, xOffset, yOffset);
}
}

protected void drawFocus(Graphics graphics, boolean on)
{
if (!_colorSupported)
super.drawFocus(graphics, on);
// else - Do nothing. We handle it already in Paint
}

protected boolean trackwheelClick(int status, int time)
{
HandleSelect();
return true;
}

protected boolean keyChar(char key, int status, int time)
{
if (key == '\n')
{
HandleSelect();
return true;
}
return super.keyChar(key, status, time);
}

public void HandleSelect()
{
_pop.close();
_appm.requestForeground(_pcid);
}
protected void onFocus(int direction)
{
super.onFocus(direction);
_appname.setText(_name);
}
public int getPreferredHeight()
{
return 48;
}
public int getPreferredWidth()
{
return 48;
}
}

public void run()
{
try
{
_appm = ApplicationManager.getApplicationManager();
ApplicationDescriptor [] appdes = _appm.getVisibleApplications();
int tot_app = appdes.length;
VerticalFieldManager vfm = new VerticalFieldManager();
HorizontalFieldManager hfm = new HorizontalFieldManager(Manager.HORIZONTAL_SCROLL);
ApplicationIconField focusField = null;
for (int i = 0; i < tot_app; i++)
{
ApplicationIconField iconField = new ApplicationIconField(appdes[i]);
hfm.add(iconField);
if (i <= 1) // We want the second one, if it exists
focusField = iconField;
}
vfm.add(hfm);
_appname = new LabelField(" ",Field.NON_FOCUSABLE);
vfm.add(_appname);

_pop = new PopupScreen(vfm, PopupScreen.DEFAULT_CLOSE);
UiApplication.getUiApplication().pushScreen(_pop);
focusField.setFocus();

}
catch (Exception e)
{
System.out.println("Error from Switch Application:" + e);
}

}

}
Offline  
Old 03-22-2010, 08:31 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

You cannot. The RIM application icons are protected.

I assume you are implementing this on pre-4.7 OS level? I ask because this function is built-in to JDE 4.7 and above.
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.