Skip to main content

Calendar localization and use of fire key

6 replies [Last post]
johandeschutter
Offline
Joined: 2008-07-17

Hey,

I'm using the Calendar object on an Form. The form is not scrollable anymore, so this will fit the calendar to the screen of the mobile.

I want to localize this calendar to english, french and dutch.
So i used the ResourceEdit tool to create TestCalendar.res
with a theme TestCalendar and a locazilation file DICTIONARY with the locale en, nl and fr.

The code is on the bottom of the message.

1)
The texts of the commands and the months are automatically translated.
But when i scroll throught the days of the month (using the navigation keys of my mobile) and i end up in the previous month or the next month, the abbreviation of the month is not shown (3 points are shown instead).

See http://img150.imageshack.us/img150/8202/screen1zt9.jpg

When i press the Next command (Volgende), Back command (Terug) or use the fire key (the big square button on the mobile), a dialog is shown. When i close the dialog using OK or Cancel, the calendar is shown with the abbreviation of the month instead of the 3 points.

See http://img229.imageshack.us/img229/492/screen2ro9.jpg

I think there is something wrong with the repainting, refreshing of the calendar, when you switch months. How do I solve this?

How can I localise the name of the weekdays? I added Calendar.Su and Calendar.Sun to the locazilation file DICTIONARY, but it does not work.

2)
I want to the user to be able to navigate to a date (using the navigation keys), then select the date by pressing the fire key (biq square button) and then another frame is shown.

So i need a kind of a firekey-eventlistener.

I tried using the fireClicked and isSelectableInteraction-methods of both the Calendar and the Frame. But that did not work.

So i used the setDefaultCommand method of the frame.
Is this the correct solution?
What is the usage of the fireClicked and isSelectableInteraction-methods?
How do i use these methods?

3)
What is the use of the setStyle -method of the Calendar object? Because there is already a setMonthViewStyle - method. And I also cannot choose a Calendar in the theme editor of ResourceEdit.
Which part of the Calendar is affected by the setStyle method?

Thank you and kind regards,

Johan
----

protected void startApp() throws MIDletStateChangeException {
if (mainForm == null) {

//init the LWUIT Display
Display.init(this);

// Setting theme
Resources r = null;
try {
r = Resources.open("/TestCalendar.res");
UIManager.getInstance().setThemeProps(r.getTheme("TestCalendar"));
} catch (java.io.IOException e) {

}

Hashtable h = null;
if (r!= null) {
h = r.getL10N("DICTIONARY", "nl");
if (h != null)
UIManager.getInstance().setResourceBundle(h);
}

c = new Calendar();

mainForm = new Form();
mainForm.setLayout(new BorderLayout());
mainForm.setScrollable(false);
mainForm.addComponent(BorderLayout.CENTER, c);
mainForm.setCommandListener(this);

// Go to next frame (Volgende)
Command nextCommand = new Command("NEXT", NEXT_COMMAND);
mainForm.addCommand(nextCommand);

// Go to previous frame (Terug)
Command backCommand = new Command("BACK", BACK_COMMAND);
mainForm.addCommand(backCommand);

// Select date on calendar and go to the next frame
Command fireCommand = new Command("FIRE", FIRE_COMMAND);
mainForm.setDefaultCommand(fireCommand);

mainForm.show();
}
}

public void actionPerformed(ActionEvent ae) {

String CommandString = "";

switch (ae.getCommand().getId()) {
case BACK_COMMAND: // Go to the previous frame (Terug)
CommandString = "BACK";
break;
case FIRE_COMMAND: // Select date on calendar and go to the next frame
CommandString = "FIRE";
break;
case NEXT_COMMAND: // Go to the next frame (Volgende)
CommandString = "NEXT";
break;
}
Dialog.show("title", CommandString, "OK", "CANCEL");
}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
johandeschutter
Offline
Joined: 2008-07-17

Is it possible to detect if a device has a fire key (real hardware button)?
Is it possible to detect if a device has a back key (real hardware button)?

Kind regards,

Johan

Shai Almog

Hi,
> Is it possible to detect if a device has a fire key (real hardware
> button)?

All devices have some form of fire key, I'm assuming you mean 3rd
softbutton (as in the new Nokia's & Sony Ericsson's). If you find a
way to do this please let me know.

> Is it possible to detect if a device has a back key (real hardware
> button)?

We do that by detecting the specific device but we can't be sure.
E.g. Sony Ericsson removed their hardware button in new JP9 devices...

In LWUIT if you use the setBackCommand method it will work with
common back keys (not all) but will do nothing for other devices. The
same applies for the clear key.

Thanks.

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

johandeschutter
Offline
Joined: 2008-07-17

Thank you chen for the answers.

Display.setThirdSoftButton(true); is not possible, i had to use Display.getInstance().setThirdSoftButton(true);

So the fire button/key is the 3rd soft button. The 1st soft button is on the left, the 2nd soft button is on the right and the 3rd soft button is in the center of the menubar?

And the defaultcommand of a form is triggered/invoked when the fire button is clicked?

Kind regards and many thanks to you and your coworkers for creating LWUIT.

Johan

johandeschutter
Offline
Joined: 2008-07-17

Chen,

thanks for the answers.
But i have still some questions

1) What is the usage of the fireClicked and isSelectableInteraction-methods?
How do i use these methods?

Is it possible to check for the event created by the firekey, if i create an object that extends the Calendar-object and i override the fireClicked and isSelectableInteraction-methods?

2)The style of the Monthview is available in the resource-edit, but the style of the Calendar is not available in the resource-edit? Is this a bug? Can i type Calendar (instead of Montview) in the combobox of the resourcedit?

3) Maybe you can add an event that is created/triggerd when you switch months. The handler for this event has a cancel argument to prevent the switch of the month.
Or some property on the object to prevent switching months.

Kind regards,

Johan

chen

Hi,

lwuit-users@mobileandembedded.org wrote:
> Chen,
>
> thanks for the answers.
> But i have still some questions
>
> 1) What is the usage of the fireClicked and isSelectableInteraction-methods?
> How do i use these methods?
>
This methods are relevant for an application that is interested in a 3
soft buttons look, to set 'on' the 3rd soft button you can use the jad
file property 'isThirdSoftButtonSupported=true'or do it manually by
using Display.setThirdSoftButton method, then if your component return
true from isSelectableInteraction you will get a callback to fireClicked
method
> Is it possible to check for the event created by the firekey, if i create an object that extends the Calendar-object and i override the fireClicked and isSelectableInteraction-methods?
>
> 2)The style of the Monthview is available in the resource-edit, but the style of the Calendar is not available in the resource-edit? Is this a bug?
yes
> Can i type Calendar (instead of Montview) in the combobox of the resourcedit?
>
No, currently the Calendar is a simple Container, and it will get the
styling of a Container, if you will type Calendar in the resource editor
it won't help you much, unless you will retrieve the style yourself from
the theme.

Style style = UIManager.getInstance().getComponentStyle("Calendar");
calendar.setStyle(style);
> 3) Maybe you can add an event that is created/triggerd when you switch months. The handler for this event has a cancel argument to prevent the switch of the month.
> Or some property on the object to prevent switching months.
>
We need to rethink this Component, I accept any thoughts.

Regards,
Chen

> Kind regards,
>
> Johan
> [Message sent by forum member 'johandeschutter' (johandeschutter)]
>
> http://forums.java.net/jive/thread.jspa?messageID=288142
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net

chen

Hi Johan,
Thanks for the feedback

lwuit-users@mobileandembedded.org wrote:
> Hey,
>
> I'm using the Calendar object on an Form. The form is not scrollable anymore, so this will fit the calendar to the screen of the mobile.
>
> I want to localize this calendar to english, french and dutch.
> So i used the ResourceEdit tool to create TestCalendar.res
> with a theme TestCalendar and a locazilation file DICTIONARY with the locale en, nl and fr.
>
> The code is on the bottom of the message.
>
> 1)
> The texts of the commands and the months are automatically translated.
> But when i scroll throught the days of the month (using the navigation keys of my mobile) and i end up in the previous month or the next month, the abbreviation of the month is not shown (3 points are shown instead).
>
> See http://img150.imageshack.us/img150/8202/screen1zt9.jpg
>
> When i press the Next command (Volgende), Back command (Terug) or use the fire key (the big square button on the mobile), a dialog is shown. When i close the dialog using OK or Cancel, the calendar is shown with the abbreviation of the month instead of the 3 points.
>
> See http://img229.imageshack.us/img229/492/screen2ro9.jpg
>
> I think there is something wrong with the repainting, refreshing of the calendar, when you switch months. How do I solve this?
>
It is a bug, we will have a look, however i'm not sure we will make it
for next drop, due to the long list we have.
> How can I localise the name of the weekdays? I added Calendar.Su and Calendar.Sun to the locazilation file DICTIONARY, but it does not work.
>
Currently you can't do that.
> 2)
> I want to the user to be able to navigate to a date (using the navigation keys), then select the date by pressing the fire key (biq square button) and then another frame is shown.
>
> So i need a kind of a firekey-eventlistener.
>
> I tried using the fireClicked and isSelectableInteraction-methods of both the Calendar and the Frame. But that did not work.
>
> So i used the setDefaultCommand method of the frame.
> Is this the correct solution?
> What is the usage of the fireClicked and isSelectableInteraction-methods?
> How do i use these methods?
>
Thanks, this is a valuable feedback I will add an action listener to the
Calendar, what you have done is a work around that would work just fine.
> 3)
> What is the use of the setStyle -method of the Calendar object? Because there is already a setMonthViewStyle - method. And I also cannot choose a Calendar in the theme editor of ResourceEdit.
> Which part of the Calendar is affected by the setStyle method?
>
> Thank you and kind regards,
>
> Johan
>
The Calendar contains the month and the year at the top and the
setMonthViewStyle modifies the days table.

Anyway, it seems like we need to do some more work on this widget so to
make it more usable.

Thanks,
Chen

> ----
>
> protected void startApp() throws MIDletStateChangeException {
> if (mainForm == null) {
>
> //init the LWUIT Display
> Display.init(this);
>
> // Setting theme
> Resources r = null;
> try {
> r = Resources.open("/TestCalendar.res");
> UIManager.getInstance().setThemeProps(r.getTheme("TestCalendar"));
> } catch (java.io.IOException e) {
>
> }
>
> Hashtable h = null;
> if (r!= null) {
> h = r.getL10N("DICTIONARY", "nl");
> if (h != null)
> UIManager.getInstance().setResourceBundle(h);
> }
>
> c = new Calendar();
>
> mainForm = new Form();
> mainForm.setLayout(new BorderLayout());
> mainForm.setScrollable(false);
> mainForm.addComponent(BorderLayout.CENTER, c);
> mainForm.setCommandListener(this);
>
> // Go to next frame (Volgende)
> Command nextCommand = new Command("NEXT", NEXT_COMMAND);
> mainForm.addCommand(nextCommand);
>
> // Go to previous frame (Terug)
> Command backCommand = new Command("BACK", BACK_COMMAND);
> mainForm.addCommand(backCommand);
>
> // Select date on calendar and go to the next frame
> Command fireCommand = new Command("FIRE", FIRE_COMMAND);
> mainForm.setDefaultCommand(fireCommand);
>
> mainForm.show();
> }
> }
>
> public void actionPerformed(ActionEvent ae) {
>
> String CommandString = "";
>
> switch (ae.getCommand().getId()) {
> case BACK_COMMAND: // Go to the previous frame (Terug)
> CommandString = "BACK";
> break;
> case FIRE_COMMAND: // Select date on calendar and go to the next frame
> CommandString = "FIRE";
> break;
> case NEXT_COMMAND: // Go to the next frame (Volgende)
> CommandString = "NEXT";
> break;
> }
> Dialog.show("title", CommandString, "OK", "CANCEL");
> }
> [Message sent by forum member 'johandeschutter' (johandeschutter)]
>
> http://forums.java.net/jive/thread.jspa?messageID=287910
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
> For additional commands, e-mail: users-help@lwuit.dev.java.net
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@lwuit.dev.java.net
For additional commands, e-mail: users-help@lwuit.dev.java.net