Blackberry GUI
Wednesday, May 23, 2012
Friday, March 23, 2012
Blackberry Signing Keys Installation
Blackberry Signing Keys
1. Order Blackberry signing keys from following link to get three keys
https://www.blackberry.com/SignedKeys/
2. You will get three keys in email those are
a. Client-RRT-xxxxx.csi
b. Client-RCR-xxxxx.csi
c. Client-RBB-xxxxx.csi
3. Add Those Keys In Eclipse As Follows
a.
b. Browse to those three keys & install those keys
4. Taking Backup of Those Keys
a. After installing those keys once u cant install those keys again but there is one trick to use same keys again on different pc or anywhere in eclipse
b. Just go to “ Blackberry\plugins\net.rim.ejde\vmTools” folder and copy “VmTool” folder to anywhere u ant to backup & copy same folder to other Eclipse to use
5. Signing Application with Keys
a.
b. Enter Password and Application in Signed with signing keys
1. Order Blackberry signing keys from following link to get three keys
https://www.blackberry.com/SignedKeys/
2. You will get three keys in email those are
a. Client-RRT-xxxxx.csi
b. Client-RCR-xxxxx.csi
c. Client-RBB-xxxxx.csi
3. Add Those Keys In Eclipse As Follows
a.
b. Browse to those three keys & install those keys
4. Taking Backup of Those Keys
a. After installing those keys once u cant install those keys again but there is one trick to use same keys again on different pc or anywhere in eclipse
b. Just go to “ Blackberry\plugins\net.rim.ejde\vmTools” folder and copy “VmTool” folder to anywhere u ant to backup & copy same folder to other Eclipse to use
5. Signing Application with Keys
a.
b. Enter Password and Application in Signed with signing keys
Tuesday, February 14, 2012
EditField Border
BasicEditField emailField = new BasicEditField("Email Address: ", "", 100, BasicEditField.FILTER_EMAIL)
{
private int iRectX = getFont().getAdvance(getLabel());
private int iRectWidth = Display.getWidth() - iRectX - 4;
public int getPreferredWidth() {
return Display.getWidth();
}
public int getPreferredHeight() {
return 30;
}
public void layout(int width, int height) {
super.layout(width, getPreferredHeight());
setExtent(width, getPreferredHeight());
}
public void paint(Graphics g) {
g.setColor(0x000000);
g.drawRect(iRectX, 0, iRectWidth, 16);
super.paint(g);
}
};
// ---------------------------------------------
// layout after setExtent (seems to wipe effect of setExtent)
BasicEditField emailField2 = new BasicEditField("Email Address2: ", "", 100, BasicEditField.FILTER_EMAIL)
{
private int iRectX = getFont().getAdvance(getLabel());
private int iRectWidth = Display.getWidth() - iRectX - 4;
public int getPreferredHeight() {
return 30;
}
public void layout(int width, int height) {
setExtent(width, getPreferredHeight());
super.layout(width, getPreferredHeight());
}
public void paint(Graphics g) {
g.setColor(0x000000);
g.drawRect(iRectX, 0, iRectWidth, 16);
super.paint(g);
}
};
Friday, January 20, 2012
Blackberry Custom ObjectChoiceField
package a.uilibrary;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.system.Display;
import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.DrawStyle;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.FontFamily;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.XYEdges;
import net.rim.device.api.ui.XYRect;
import net.rim.device.api.ui.component.ObjectChoiceField;
import net.rim.device.api.ui.decor.BorderFactory;
public class CustomChoiceField extends ObjectChoiceField
{
public static final int TEXT_HALINGMENT_CENTER = 1;
String[] m_Choices;
private int m_MarginLeft = 1;
private int m_PaddingTop = 1+1;
private int m_PaddingBottom = 1;
private int m_MarginTop = 1;
private int m_currentheight = 1;
private int m_ChoiceFieldWidth;
private int m_Height;
private boolean m_isFocused = false;
private Font font;
private FontFamily fontFamily[]=FontFamily.getFontFamilies();
String label1;
public CustomChoiceField(String label, String[] choices, int initialIndex, long style)
{
super(label, choices, initialIndex,Field.FOCUSABLE|DrawStyle.ELLIPSIS|Field.USE_ALL_WIDTH);
label1=label;
m_Choices = choices;
font=fontFamily[0].getFont(FontFamily.CBTF_FONT, 12).derive(Font.BOLD);
Font currFont = font;
m_Height = currFont.getHeight();
m_ChoiceFieldWidth =Display.getWidth();
m_currentheight=font.getHeight()*3;
}
public void setChoices(Object[] choices)
{
super.setChoices(choices);
m_Choices = (String[])choices;
}
public int getPreferredWidth()
{
return (Display.getWidth()-4);
}
public int getPreferredHeight()
{
return m_currentheight;
}
public boolean isFocusable()
{
return true;
}
public void getFocusRect(XYRect rect)
{
rect.set(m_MarginLeft + getFont().getAdvance(getLabel()), m_MarginTop , m_ChoiceFieldWidth, m_Height + m_PaddingBottom + m_PaddingTop+6);
}
protected void layout(int width, int height)
{
setExtent(getPreferredWidth(),getPreferredHeight());
}
protected void drawFocus(Graphics graphics, boolean on)
{
invalidate();
}
public void onFocus(int direction)
{
m_isFocused = true;
invalidate();
}
public void onUnfocus()
{
m_isFocused = false;
invalidate();
}
protected void paintBackground(Graphics g)
{
if(m_isFocused==true)
{
// 076cc7 to 7ac1ff
int[] drawColors = {
0x1a66b4 , 0x1a66b4, 0x1a66b4, 0x1a66b4, 0x1a66b4, 0x1a66b4,
0x4b80b7, 0x4b80b7, 0x4b80b7, 0x4b80b7, 0x4b80b7, 0x4b80b7 };
g=Gradient.draw(g,(m_currentheight),Display.getWidth(),drawColors);
}
else
{
int[] drawColors = {
0xf5f5f5, 0xf5f5f5, 0xf5f5f5, 0xf5f5f5, 0xf5f5f5, 0xf5f5f5,
0xbdbdbd, 0xbdbdbd, 0xbdbdbd, 0xbdbdbd, 0xbdbdbd, 0xbdbdbd };
g=Gradient.draw(g,(m_currentheight),Display.getWidth(),drawColors);
}
// super.paint(g);
}
public void paint(Graphics g)
{
String longString = (getSelectedIndex() == -1 || getSelectedIndex() >= m_Choices.length)?"":m_Choices[getSelectedIndex()];
int textY = m_MarginTop + m_PaddingTop + (m_Height -font.getHeight())/2;
if(textY < 0)
textY = m_MarginTop;
String firstLine = "";
String secondLine = "";
boolean isSecondLine = false;
int charWidth,spaceIndex=0,totalWidth=0,lastIndex = 0;
for (int i = 0; i < longString.length(); i++)
{
charWidth = Font.getDefault().getAdvance(String.valueOf(longString.charAt(i)));
if(longString.charAt(i) == ' ')
{
spaceIndex = i;
}
if((charWidth + totalWidth) > (Display.getWidth()))
{
isSecondLine=true;
firstLine = longString.substring(0, spaceIndex);
i = spaceIndex + 1;
lastIndex = i;
secondLine=longString.substring(lastIndex, longString.length());
charWidth = 0;
totalWidth = 0;
}
totalWidth += charWidth;
}
Bitmap b=Bitmap.getBitmapResource("down.png");
int x=(Display.getWidth()-b.getWidth()-(b.getWidth()/2));
int y=m_currentheight-(m_currentheight/2)-((m_currentheight/2)/2);
int temph;
if(m_isFocused==true)
{
g.setColor(Color.WHITE);
this.setFont(Font.getDefault().derive(Font.PLAIN|Font.EMBOSSED_EFFECT,Font.getDefault().getHeight()-4));
if(isSecondLine)
{
m_currentheight=font.getHeight()*6;
temph=(m_currentheight/2)/2;
g.drawText(firstLine, 4, temph,0,Display.getWidth()-10);
g.drawText(secondLine, 4, (temph+font.getHeight()+7),0,Display.getWidth()-10);
this.setBorder(BorderFactory.createBevelBorder(new XYEdges(2,2,2,2)));
}
else
{
m_currentheight=font.getHeight()*3;
temph=(m_currentheight/2)/2;
g.drawText(longString, 4, temph,0,Display.getWidth()-10);
this.setBorder(BorderFactory.createBevelBorder(new XYEdges(2,2,2,2)));
}
}
else
{
this.setFont(Font.getDefault().derive(Font.PLAIN|Font.EMBOSSED_EFFECT,Font.getDefault().getHeight()-4));
//g.drawBitmap(0, m_MarginTop-1,Display.getWidth() , image.getHeight()+2,image,0,0);
if(isSecondLine)
{
m_currentheight=font.getHeight()*6;
temph=(m_currentheight/2)/2;
g.drawText(firstLine, 4, temph,0,Display.getWidth()-10);
g.drawText(secondLine, 4, (temph+font.getHeight()+7),0,Display.getWidth()-10);
this.setBorder(BorderFactory.createBevelBorder(new XYEdges(2,2,2,2)));
}
else
{
m_currentheight=font.getHeight()*3;
temph=(m_currentheight/2)/2;
g.drawText(longString, 4, temph,0,Display.getWidth()-10);
this.setBorder(BorderFactory.createBevelBorder(new XYEdges(2,2,2,2)));
}
}
g.drawBitmap(x, y, b.getWidth(),m_currentheight+2 , b, 0, 0);
}
}
Images USed:
Gradient Class Can Be Found on the same blog as "Blackberry Gradient Fill Field Or Manager" in same "Blackberry Library, " category
Wednesday, January 18, 2012
Tooltip For Field
1. Class For Tooltip is
package a.uilibrary;
import net.rim.device.api.system.Bitmap;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.ui.XYEdges;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.PopupScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;
import net.rim.device.api.ui.decor.BorderFactory;
class MyTooltip extends PopupScreen{
int _x;
int _y;
TooltipThread _tooltipThread;
private MyTooltip(Manager manager) {
super(manager);
}
public void sublayout(int width, int height) {
super.sublayout(width,height);
setPosition(_x,_y);
System.out.println("Tooltip x: " + Integer.toString(_x) + ", y: " + Integer.toString(_y));
}
protected void applyTheme() {
// Overriden to suppress Border etc.
}
public void removeToolTip() {
if ( _tooltipThread != null ) {
_tooltipThread.dismiss();
}
}
private void display(UiApplication uiApp, int x, int y, int displayTime) {
_x = x;
_y = y;
_tooltipThread = new TooltipThread(uiApp, this, displayTime);
_tooltipThread.start();
}
public static MyTooltip addToolTip(UiApplication uiApp, String toolTipString, int x, int y, int displayTime) {
VerticalFieldManager manager = new VerticalFieldManager(Manager.FIELD_VCENTER|Manager.NON_FOCUSABLE) {
protected void paint(Graphics graphics) {
//graphics.setColor(0x00FFFFFF); // White
//graphics.fillRect(0,0,getWidth(),getHeight());
graphics.setColor(0x00000000); // Black
// graphics.drawRect(0,0,getWidth(),getHeight());
super.paint(graphics);
}
};
MyTooltip toolTip = new MyTooltip(manager);
LabelField label = new LabelField(' ' + toolTipString + ' ', LabelField.NON_FOCUSABLE);
label.setBorder(BorderFactory.createBitmapBorder(new XYEdges(5,5,5,5),Bitmap.getBitmapResource("bubble_left.png")));
label.setFont(Font.getDefault().derive(Font.PLAIN, 16));
toolTip.add(label);
toolTip.display(uiApp, x, y, displayTime);
return toolTip;
}
class TooltipThread extends Thread {
Object _notifyObject = new Object(); // Used to allow user to dismiss this Tooltip
PopupScreen _tooltip; // Screen we are going to display
UiApplication _ourApplication; // access to pushGlobalScreen and dismissStatus from our Application
int _displayTime; // in seconds
public TooltipThread(UiApplication ourApplication, PopupScreen tooltip, int displayTime) {
_tooltip = tooltip;
_ourApplication = ourApplication;
_displayTime = displayTime;
}
public void run() {
_ourApplication.pushGlobalScreen(_tooltip, 999, false);
synchronized(_notifyObject) {
try {
_notifyObject.wait(_displayTime * 1000);
} catch (Exception e) {
}
};
_ourApplication.dismissStatus(_tooltip);
}
public void dismiss() {
// notify the waiting object to stop the Thread waiting
synchronized(_notifyObject) {
_notifyObject.notify();
}
}
}
}
2 Using this class Example add this as fields onFocus & onUnfocus method
protected void onFocus(int direction)
{
invalidate();
if(this.getText().equalsIgnoreCase(promot))
{
this.setText("");
if ( _tooltip != null )
{
_tooltip.removeToolTip();
_tooltip = null;
}
contentArea = this.getContentRect();
contentBottom = contentArea.y + contentArea.height-5;
contentRight = contentArea.x + contentArea.width;
contentBottom = contentBottom - this.getManager().getVerticalScroll();
if (!(contentBottom > (getHeight() - 10)))
{
contentBottom =contentBottom - getHeight()-2;
}
_tooltip = MyTooltip.addToolTip(UiApplication.getUiApplication(), promot, 20, contentBottom,2);
flag=false;
invalidate();
}
super.onFocus(direction);
}
protected void onUnfocus()
{
// remove tooltip
if ( _tooltip != null ) {
// We have displayed a Tooltip - remove it
_tooltip.removeToolTip();
_tooltip = null;
}
invalidate();
super.onUnfocus();
}
Tuesday, January 10, 2012
Using KSOAP Blackberry
1. Download KSOAP Blackberry Source code from
Download HERE
2. Extract that zip and copy "org" folder to your current project source
3. Code For Connecting to Webservice is
2. Extract that zip and copy "org" folder to your current project source
3. Code For Connecting to Webservice is
public void obSOAP()
{
// wsdl webservice path dont add "?wsdl" it will give error
String serviceUrl = "http://ganesh.com/~ganesh/webservices/webservices.php";
String serviceNamespace = "http://ganesh.com/ganu/";
// function from webservice "getInvoiceList"
String soapAction = "http://ganesh.com/~ganesh/webservices/webservices.php/getInvoiceList";
/******************************************************************************************************************
Following are the three ways to connect webservice choose appropriate one for this we are using first one
1. For Normal connection use following line
HttpTransport ht=new HttpTransport(serviceUrl);
2. If using basic authentication use following line here Username=test & password=supp0rt
HttpTransportBasicAuth ht = new HttpTransportBasicAuth(serviceUrl,"test","supp0rt");
3. If using on wifi use following for device otherwise it will not run on device
HttpTransportBasicAuth ht = new HttpTransportBasicAuth(serviceUrl+";deviceside=true;interface=wifi","test","supp0rt");
*********************************************************************************************************************************/
HttpTransport ht=new HttpTransport(serviceUrl);
SoapObject rpc = new SoapObject(serviceNamespace,"getInvoiceList");
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);
// setup the input parameter for the webservice
// parameter to send to webservice function
rpc.addProperty("email","ganesh.pachpind@gmail.com");
rpc.addProperty("password","1234");
envelope.bodyOut = rpc;
envelope.encodingStyle = SoapSerializationEnvelope.ENC;
envelope.setOutputSoapObject(rpc);
try
{
ht.debug = true;
/******************************************************************************************************************
HERE function
ht.requestdumb & ht.responsedumb can be uset to print request and response
********************************************************************************************************************/
ht.call(soapAction, envelope);
Object response = envelope.getResponse();
// this is response from webservice
}
catch(Exception ex)
{
}
}
Using KXML For Xml Parsing
Consider Following XML
Ganesh Pachpind Om Shanti Nagar Mayur Pachpind Om Shanti Nagar
Code for Parsing :
// here XMLSTRING is the response String from webservice which is as above
//Parsing logic
byte[] xmlByteArray = XMLSTRING.getBytes();
ByteArrayInputStream xmlStream = new ByteArrayInputStream( xmlByteArray );
InputStreamReader xmlReader = new InputStreamReader( xmlStream );
// create new parser objet
KXmlParser parser = new KXmlParser();
parser.setInput(xmlReader);
parser.nextTag();
parser.require(XmlPullParser.START_TAG, null, "response");
// main tag is response
while((parser.next()==XmlPullParser.START_TAG)&&(parser.getName().equalsIgnoreCase("error")))
{
if(parser.nextText().equalsIgnoreCase(""))
{
//if error is empty then only it will check for result tag
flag=true;
while((parser.next()==XmlPullParser.START_TAG)&&(parser.getName().equalsIgnoreCase("result")))
{
//resut tag parsing now
// as their exit one more xml structure in result tag we will parse it seperate
byte[] xmlByteArray1 = (parser.nextText()).getBytes();
ByteArrayInputStream xmlStream1 = new ByteArrayInputStream( xmlByteArray1 );
InputStreamReader xmlReader1 = new InputStreamReader( xmlStream1 );
KXmlParser parser1 = new KXmlParser();
parser1.setInput(xmlReader1);
parser1.next();
//DATA tag
parser1.require(XmlPullParser.START_TAG, null, "data");
while ((parser1.nextTag () != XmlPullParser.END_TAG))
{
// this function is give bellow
readXMLData(parser1);
}
parser1.require(XmlPullParser.END_TAG, null, "data");
parser1.next();
parser1.require(XmlPullParser.END_DOCUMENT, null, null);
}// result tag parsing end
}
else
{
//if error tag is not empty do its parsing here
}
}// while error tag end
readXMLData function as follow :
// Read Inner Tags
private void readXMLData(KXmlParser parser)throws Exception
{
// TODO Auto-generated method stub.
parser.require(XmlPullParser.START_TAG, null, "data");
while (parser.nextTag() != XmlPullParser.END_TAG)
{
parser.require(XmlPullParser.START_TAG, null, null);
String name = parser.getName();
String text = parser.nextText();
if (name.equals("fname"))
System.out.println("First Name:"+name.equals("fname"));
else if (name.equals("lname"))
System.out.println("Last Name:"+name.equals("lname"));
else if (name.equals("add"))
System.out.println("Address:"+name.equals("add"));
parser.require(XmlPullParser.END_TAG, null, name);
}
parser.require(XmlPullParser.END_TAG, null, "data");
}
Subscribe to:
Posts (Atom)

