Toolbar issue with android 4.4.2 and above

99 views
Skip to first unread message

Chibuike Mba

unread,
May 25, 2015, 6:50:36 AM5/25/15
to codenameone...@googlegroups.com
Hi,
Toolbar on my app built with the latest Codename One is making my app unresponsive on Android 4.4.2 and 5.0 once any command on the toolbar is tapped.

When I launch the app it opens but once I tap on any command like sidemenu icon or overflow menu icon on the Toolbar my app freezes.

It works well on Android 4.2 and below.

Please how can I fixed this or is it a bug?

Thanks in advance.

Chen Fishbein

unread,
May 25, 2015, 10:21:53 AM5/25/15
to codenameone...@googlegroups.com, chib...@gmail.com
Hi,
We had a regression in that area a couple of days ago, but as far as I'm aware of it's being fixed and working, did you build the app today?
if yes, please provide us a testcase and submit an issue.
 
 

Chibuike Mba

unread,
May 27, 2015, 6:55:28 AM5/27/15
to codenameone...@googlegroups.com, chib...@gmail.com
Hi Chen,

my project is GUI project and it added the Toolbar to the Form on beforeShow like this:
protected void beforeAboutForm(Form f) {
       
super.beforeAboutForm(f);
         
       
Toolbar toolBar = new Toolbar();
        f
.setToolBar(toolBar);
        toolBar
.setUIID("TitleContainer");
        toolBar
.setTitle("About");
       
       
Command cmdBack = new Command("") {
           
public void actionPerformed(ActionEvent evt) {
                goToPrevForm
();
           
}
       
};
        cmdBack
.setIcon(this.getResource().getImage("ic_back.png"));
        toolBar
.addCommandToLeftBar(cmdBack);
       
       
Command cmdHelp = new Command("Help") {
           
public void actionPerformed(ActionEvent evt) {
                faqs
();
           
}
       
};
       
//cmdHelp.setIcon(this.getResource().getImage("ic_back.png"));
        toolBar
.addCommandToRightBar(cmdHelp);
       
        f
.revalidate();
   
}

I did a build after your comment and issue was the same.

Chen Fishbein

unread,
May 27, 2015, 10:44:23 AM5/27/15
to codenameone...@googlegroups.com, chib...@gmail.com
I don't understand how you have side menu with that code, you just added a couple of commands to the toolbar, the side menu doesn't have any commands.
Is it possible you are using the android native menu?

Chibuike Mba

unread,
May 27, 2015, 11:33:08 AM5/27/15
to codenameone...@googlegroups.com, chib...@gmail.com
That was just one of my Forms with few commands, I posted that code because it have the same issue.

This is my MainScreen Form Toolbar
   protected void beforeOziomaForm(Form f) {
       
super.beforeOziomaForm(f);
       
       
ActionListener aListener = new ActionListener(){
           
public void actionPerformed(ActionEvent ae)
           
{
               
Display.getInstance().exitApplication();
           
}
       
};
        f
.addKeyListener(BACK_COMMAND_ID, aListener);
       
       
Container con = findConPane(f);
       
Button btnVersion = findBtnNewVersion(con);
       
       
if(!versionOutOfDate)
       
{
            con
.removeComponent(btnVersion);
       
}

        homeForm
= f;
   
       
        addHomeToolbar
();
       
//toolBar.getMenuBar().getMenuStyle().setBgColor(255);

        f
.revalidate();
       
   
}



public void addHomeToolbar()
   
{
       
Form f = homeForm;
       
final Toolbar toolBar = new Toolbar();
        f
.setToolBar(toolBar);
        toolBar
.setUIID("TitleContainer");
       
if(this.authenticated)
            toolBar
.addComponentToSideMenu(this.getUserInfoContainer());
       
Command cmdUser = new Command("  My Account") {
           
public void actionPerformed(ActionEvent evt) {
               
if(isLogin())
                    showForm
("UserAccountForm", null);
           
}
       
};
        cmdUser
.setIcon(this.getResource().getImage("ic_user.png"));
        cmdUser
.setRolloverIcon(this.getResource().getImage("ic_user_select.png"));
       
//cmdUser.setPressedIcon(this.getResource().getImage("ic_user_select.png"));
        toolBar
.addCommandToSideMenu(cmdUser);
       
       
/*Command cmdContest = new Command("  Ozi Contest") {
            public void actionPerformed(ActionEvent evt) {
               
            }
        };
        cmdContest.setIcon(this.getResource().getImage("ic_magic.png"));
        cmdContest.setRolloverIcon(this.getResource().getImage("ic_magic_select.png"));
        toolBar.addCommandToSideMenu(cmdContest);*/

       
       
Command cmdNotify = new Command("  Notifications") {
           
public void actionPerformed(ActionEvent evt) {
                 
if(isLogin())
                    showForm
("NotificationForm", null);
           
}
       
};
        cmdNotify
.setIcon(this.getResource().getImage("ic_notifications.png"));
        cmdNotify
.setRolloverIcon(this.getResource().getImage("ic_notifications_select.png"));
        toolBar
.addCommandToSideMenu(cmdNotify);
       
       
Command cmdVoucherLocator = new Command("  Voucher Locator") {
           
public void actionPerformed(ActionEvent evt) {
                showForm
("VoucherLocatorForm", null);
           
}
       
};
        cmdVoucherLocator
.setIcon(this.getResource().getImage("ic_tack.png"));
        cmdVoucherLocator
.setRolloverIcon(this.getResource().getImage("ic_tack_select.png"));
        toolBar
.addCommandToSideMenu(cmdVoucherLocator);
       
       
Command cmdSupport = new Command("  Ozi Support") {
           
public void actionPerformed(ActionEvent evt) {
                showForm
("OziSupportForm", null);
           
}
       
};
        cmdSupport
.setIcon(this.getResource().getImage("ic_headset.png"));
        cmdSupport
.setRolloverIcon(this.getResource().getImage("ic_headset_select.png"));
        toolBar
.addCommandToSideMenu(cmdSupport);
       
       
Command cmdSettings = new Command("  Settings") {
           
public void actionPerformed(ActionEvent evt) {
               
if(isLogin())
                    showForm
("SettingsForm", null);
           
}
       
};
        cmdSettings
.setIcon(this.getResource().getImage("ic_settings.png"));
        cmdSettings
.setRolloverIcon(this.getResource().getImage("ic_settings_select.png"));
        toolBar
.addCommandToSideMenu(cmdSettings);
       
       
Command cmdAbout = new Command("  About") {
           
public void actionPerformed(ActionEvent evt) {
                showForm
("AboutForm", null);    
           
}

       
};
        cmdAbout
.setIcon(this.getResource().getImage("ic_shining.png"));
        cmdAbout
.setRolloverIcon(this.getResource().getImage("ic_shining_select.png"));
        toolBar
.addCommandToSideMenu(cmdAbout);
       
       
String loginState = this.isAuthenticated() ? "  Sign Out":"  Sign In";
       
Command signInOut = new Command(loginState) {
           
public void actionPerformed(ActionEvent evt) {
               
if(isLogin())
                    logout
();
               
if(getCommandName().trim().equals("Sign Out"))
               
{
                    setCommandName
("  Sign In");
                    setIcon
(getResource().getImage("ic_locked.png"));
                    setRolloverIcon
(getResource().getImage("ic_locked_select.png"));
               
}
           
}
       
};
       
if(this.isAuthenticated())
       
{
            signInOut
.setIcon(this.getResource().getImage("ic_unlocked.png"));
            signInOut
.setRolloverIcon(this.getResource().getImage("ic_unlocked_select.png"));
       
}
       
else
       
{
            signInOut
.setIcon(this.getResource().getImage("ic_locked.png"));
            signInOut
.setRolloverIcon(this.getResource().getImage("ic_locked_select.png"));
       
}
        toolBar
.addCommandToSideMenu(signInOut);
       
       
Container conTitleArea = new Container();
        conTitleArea
.setLayout(new BorderLayout());
       
ShareButton btnShare = new ShareButton();
        btnShare
.setIcon(this.getResource().getImage("ic_share.png"));
        btnShare
.setTextToShare("Ozioma brings flexibility to you and wants to be your messaging companion on any platform "
               
+ "- Web, Mobile, PC, Mac, API, Wordpress, Facebook, Excel etc. For bulk sms, sms template,"
               
+ "birthday messenger, free sms, sms campaign, ad campaign, sms forwarding, scheduling with recurrences, contact grouping, etc."
               
+ " Think convenience while messaging, think Ozioma. "
               
+ "\nDownload link: http://ozioma.net");
        btnShare
.setUIID("BorderCenterCustomButton");
        conTitleArea
.addComponent(BorderLayout.EAST, btnShare);
        toolBar
.setTitleComponent(conTitleArea);
       
       
Label lblTitle = new Label("Ozioma");
        lblTitle
.setUIID("Title");
        conTitleArea
.addComponent(BorderLayout.CENTER, lblTitle);
       
       
Command cmdFacebook = new Command("Like on Facebook ") {
           
public void actionPerformed(ActionEvent evt) {
               
           
}
       
};
       
//cmdFacebook.setIcon(this.getResource().getImage("ic_favorite.png"));
        toolBar
.addCommandToOverflowMenu(cmdFacebook);
        toolBar
.addCommandToOverflowMenu(new Command("Recommend") {
           
public void actionPerformed(ActionEvent evt) {
               
if(isLogin())
                    showForm
("RecommendForm", null);
           
}

       
});
        toolBar
.addCommandToOverflowMenu(new Command("Help/FAQs") {

           
public void actionPerformed(ActionEvent evt) {
                faqs
();
           
}


       
});
        toolBar
.addCommandToOverflowMenu(new Command("Exit") {
           
public void actionPerformed(ActionEvent evt) {
               
Display.getInstance().exitApplication();
           
}

       
});
        toolBar
.getMenuBar().addFocusListener(new FocusListener(){

           
public void focusGained(Component cmp) {
               
System.out.println("The side menu has gained focus");
           
}

           
public void focusLost(Component cmp) {
               
System.out.println("The side menu has losed focus");
           
}
       
       
});
   
}

Note the issue is only on Android version 4.4.2 and above (5.0), other versions I tested are OK.

Chibuike Mba

unread,
May 27, 2015, 11:57:55 AM5/27/15
to codenameone...@googlegroups.com
Emulator screenshots of the app.
...
CodenameOne Screenshot 10.png
Emulator screenshot.PNG

Chen Fishbein

unread,
May 27, 2015, 3:58:35 PM5/27/15
to codenameone...@googlegroups.com, chib...@gmail.com
Hi,
I tried to reproduce this without luck, if you can isolate this to a test case I'll have a look.

Chibuike Mba

unread,
May 29, 2015, 9:25:56 AM5/29/15
to codenameone...@googlegroups.com, chib...@gmail.com
Hi Chen,

I've resolved the issue.

The cause was the image I used as background for MenuButton and TitleCommand UIIDs for selected and pressed states, it was a 1 x 1 pixel image and I set the background type as IMAGE_TILE_BOTH.

I now changed the image with color equivalent and it worked.

Thanks for your responses.

Shai Almog

unread,
May 29, 2015, 12:00:34 PM5/29/15
to codenameone...@googlegroups.com, chib...@gmail.com

Chibuike Mba

unread,
May 29, 2015, 2:34:43 PM5/29/15
to codenameone...@googlegroups.com, chib...@gmail.com
Okay Shai,

I will see how I can improve my app performance with the guides on the video link you provided.

Thanks.
Reply all
Reply to author
Forward
0 new messages