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
Contributor
Posts: 22
Registered: ‎11-04-2010
My Device: 9900
My Carrier: Rogers

Re: Help Desk Application - Pop Up Help

Do I have to create a new file to change the screen color and insert the image or does this all fit within the existing code you sent to me?

My Home on the Web: http://www.closetgeek.ca
Developer
Posts: 19,631
Registered: ‎07-14-2008
My Device: Not Specified

Re: Help Desk Application - Pop Up Help

You will need a new file which will provide the image for the background.  The background color you can do withint the source already given.

 

I'll see what I can knock together over the weekend, busy atm.

Contributor
Posts: 22
Registered: ‎11-04-2010
My Device: 9900
My Carrier: Rogers

Re: Help Desk Application - Pop Up Help

Really appreciate all of your help - you are a testament to what a great community forum member is all about! Hopefully someway I can repay you :smileyhappy:.

 

I'm trying to make the screen look like this:

 

-----IMAGE-----

Space

-----Email-----

Space

-----Call-----

 

With a black background and possibly change some colors around on the buttons..

My Home on the Web: http://www.closetgeek.ca
Developer
Posts: 19,631
Registered: ‎07-14-2008
My Device: Not Specified

Re: Help Desk Application - Pop Up Help

Sorry I have a few design quesitos.

 

How big is the image?  Are you using it as a 'Banner' for the top?  What do you want to happen if all three can't fit on the one screen (small device like 9300).  What about if you have a tall device, like 9860?

Contributor
Posts: 22
Registered: ‎11-04-2010
My Device: 9900
My Carrier: Rogers

Re: Help Desk Application - Pop Up Help

No problem at all. I have the image created as 200 x 96 right now. It's just a company logo. Is it possible to have it not show up if all 3 can't fit? I think blank space below on a taller device is fine..
My Home on the Web: http://www.closetgeek.ca
Contributor
Posts: 22
Registered: ‎11-04-2010
My Device: 9900
My Carrier: Rogers

Re: Help Desk Application - Pop Up Help

happy tuesday! I spent some time on the application over the weekend and got nowhere. Just wondering if you had a chance to look at it?

My Home on the Web: http://www.closetgeek.ca
Developer
Posts: 19,631
Registered: ‎07-14-2008
My Device: Not Specified

Re: Help Desk Application - Pop Up Help

[ Edited ]

Updated Constructor:

 

    public ChooseScreen() {
        super(MainScreen.NO_HORIZONTAL_SCROLL | MainScreen.NO_VERTICAL_SCROLL | MainScreen.USE_ALL_HEIGHT | MainScreen.USE_ALL_HEIGHT);

        Bitmap companyLogo = Bitmap.getBitmapResource("Company.png");
        BitmapField companyLogoField = new BitmapField(companyLogo, BitmapField.FIELD_HCENTER);
        this.add(companyLogoField);

        Background blackBackground = BackgroundFactory.createSolidBackground(Color.BLACK);
        this.getMainManager().setBackground(blackBackground);

        // Figure out spacing
        // We are just approximating here as we really need to do this in layout, but that is quite complicated
        int heightToPlayWith = Display.getHeight() - companyLogo.getHeight();
        int spaceToFiestButton = heightToPlayWith / 5;
        _callButton.setMargin(spaceToFiestButton, 0, 0, 0);
        int spaceToFSecondButton = spaceToFiestButton / 2;
        _emailButton.setMargin(spaceToFSecondButton, 0, 0, 0);
       
        this.add(_callButton);
        _callButton.setChangeListener(this);
        this.add(_emailButton);
        _emailButton.setChangeListener(this);
    }

 

Attached you will find the Bitmap I tested with.  You have to add this to your project.  if the application starts failing with a NullPointterException here:

int heightToPlayWith = Display.getHeight() - companyLogo.getHeight();

Then this statement:

Bitmap companyLogo = Bitmap.getBitmapResource("Company.png");

has not managed to find the png file in your project.

 

You have to add two imports to your file:

import net.rim.device.api.system.*;
import net.rim.device.api.ui.decor.*;

 

Hope this fits the bill.


 


 

 

Contributor
Posts: 22
Registered: ‎11-04-2010
My Device: 9900
My Carrier: Rogers

Re: Help Desk Application - Pop Up Help

Thanks - buttons are centered, but the background and image did not show up.

 

Original code (with API's added) - where should I be adding the new code? What should be removed?

 

package com.rim.samples.helpdeskdialer;

import net.rim.blackberry.api.invoke.Invoke;
import net.rim.blackberry.api.invoke.PhoneArguments;
import net.rim.blackberry.api.invoke.MessageArguments;
import net.rim.device.api.ui.UiApplication;
import net.rim.blackberry.api.mail.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.ui.*;
import net.rim.device.api.system.*;
import net.rim.device.api.ui.decor.*;


public class MyHelpDeskApp extends UiApplication {


    public static void main(String[] args){
        MyHelpDeskApp app = new MyHelpDeskApp();
        app.enterEventDispatcher();
    }
   
    public MyHelpDeskApp(){
        pushScreen(new ChooseScreen());
    }
   
}
class ChooseScreen extends MainScreen
                   implements FieldChangeListener {

    // The number we want our application to call followed by the extension
    private final String _numberToCall = "1-506-456-6711";

    // The address we want our application to use
    private final String _emailAddress = "helpdesk@cookeaqua.com";
    // The subject we want our application to use
    private final String _emailSubject = "HelpDesk email initiated from BlackBerry";

    private ButtonField _callButton = new ButtonField("Call Help Desk", ButtonField.FIELD_HCENTER) ;
    private ButtonField _emailButton = new ButtonField("Email Help Desk", ButtonField.FIELD_HCENTER);

    public ChooseScreen() {
        this.add(_callButton);
        _callButton.setChangeListener(this);
        this.add(_emailButton);
        _emailButton.setChangeListener(this);
    }
 
    public void fieldChanged(Field f, int context) {
        if ( f == _callButton ) {
            //Generate the arguments to make the call
            PhoneArguments phoneArguments = new PhoneArguments(PhoneArguments.ARG_CALL, _numberToCall);
            //Invoke the phone to initiate the call
            Invoke.invokeApplication(Invoke.APP_TYPE_PHONE, phoneArguments);
            //Close our application
            System.exit(0);
        } else {
            try {
                Message m = new Message();
                m.setSubject(_emailSubject);
                Address toAdd = new Address(_emailAddress, "Support");
                Address toAdds[] = new Address[1];
                toAdds[0] = toAdd;
                m.addRecipients(Message.RecipientType.TO,toAdds);
                MessageArguments m1 = new MessageArguments(m);
                Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES,m1);
                System.exit(0);
            } catch (Throwable t) {
                t.printStackTrace();
                System.out.println("Exception generating email: " + t.toString());
            }
        }
    }
}

My Home on the Web: http://www.closetgeek.ca
Developer
Posts: 19,631
Registered: ‎07-14-2008
My Device: Not Specified

Re: Help Desk Application - Pop Up Help

Your current constructor, which is:

 

   public ChooseScreen() {
        this.add(_callButton);
        _callButton.setChangeListener(this);
        this.add(_emailButton);
        _emailButton.setChangeListener(this);
    }

 

is replaced by the constructor I supplied. 

Contributor
Posts: 22
Registered: ‎11-04-2010
My Device: 9900
My Carrier: Rogers

Re: Help Desk Application - Pop Up Help

Still can't seem to get it going properly. Hate to be a burden on your time, but would you mind if I send you the full project file for review?
My Home on the Web: http://www.closetgeek.ca