use of net.rim.device.api.ui.MenuItem in project CodenameOne by codenameone.
the class BlackBerryCanvas method getMenu.
public Menu getMenu(int val) {
if (Display.getInstance().getCommandBehavior() == Display.COMMAND_BEHAVIOR_NATIVE) {
m = new Menu();
if (commands != null) {
for (int iter = 0; iter < commands.size(); iter++) {
final Command cmd = (Command) commands.elementAt(iter);
String txt = UIManager.getInstance().localize(cmd.getCommandName(), cmd.getCommandName());
MenuItem i = new MenuItem(txt, iter, iter) {
public void run() {
Display.getInstance().callSerially(new Runnable() {
public void run() {
impl.getCurrentForm().dispatchCommand(cmd, new ActionEvent(cmd));
}
});
}
};
m.add(i);
}
}
return m;
}
return super.getMenu(val);
}
use of net.rim.device.api.ui.MenuItem in project google-authenticator by google.
the class AuthenticatorScreen method makeMenu.
/**
* {@inheritDoc}
*/
protected void makeMenu(Menu menu, int instance) {
super.makeMenu(menu, instance);
MenuItem enterKeyItem = new MenuItem(sResources, ENTER_KEY_MENU_ITEM, 0, 0) {
public void run() {
pushScreen(new EnterKeyScreen());
}
};
MenuItem termsItem = new MenuItem(sResources, TERMS_MENU_ITEM, 0, 0) {
public void run() {
BrowserSession session = Browser.getDefaultSession();
session.displayPage(TERMS_URL);
}
};
MenuItem privacyItem = new MenuItem(sResources, PRIVACY_MENU_ITEM, 0, 0) {
public void run() {
BrowserSession session = Browser.getDefaultSession();
session.displayPage(PRIVACY_URL);
}
};
menu.add(enterKeyItem);
if (!isTimerSet()) {
MenuItem refreshItem = new MenuItem(sResources, REFRESH_MENU_ITEM, 0, 0) {
public void run() {
refreshUserList();
}
};
menu.add(refreshItem);
}
if (mUpdateAvailable) {
MenuItem updateItem = new MenuItem(sResources, UPDATE_NOW, 0, 0) {
public void run() {
BrowserSession session = Browser.getDefaultSession();
session.displayPage(Build.DOWNLOAD_URL);
mStatusText.setText("");
}
};
menu.add(updateItem);
}
menu.add(termsItem);
menu.add(privacyItem);
}
use of net.rim.device.api.ui.MenuItem in project google-authenticator by google.
the class PinListField method makeContextMenu.
/**
* {@inheritDoc}
*/
protected void makeContextMenu(ContextMenu contextMenu) {
super.makeContextMenu(contextMenu);
ListFieldCallback callback = getCallback();
final int selectedIndex = getSelectedIndex();
final PinInfo item = (PinInfo) callback.get(this, selectedIndex);
if (item.mIsHotp) {
MenuItem hotpItem = new MenuItem(sResources, COUNTER_PIN, 0, 0) {
public void run() {
AuthenticatorScreen screen = (AuthenticatorScreen) getScreen();
String user = item.mUser;
String pin = screen.computeAndDisplayPin(user, selectedIndex, true);
item.mPin = pin;
invalidate(selectedIndex);
}
};
contextMenu.addItem(hotpItem);
}
MenuItem copyItem = new MenuItem(sResources, COPY_TO_CLIPBOARD, 0, 0) {
public void run() {
Clipboard clipboard = Clipboard.getClipboard();
clipboard.put(item.mPin);
String message = sResources.getString(COPIED);
Dialog.inform(message);
}
};
MenuItem deleteItem = new MenuItem(sResources, DELETE, 0, 0) {
public void run() {
String message = (sResources.getString(DELETE_MESSAGE) + "\n" + item.mUser);
int defaultChoice = Dialog.NO;
if (Dialog.ask(Dialog.D_YES_NO, message, defaultChoice) == Dialog.YES) {
AccountDb.delete(item.mUser);
AuthenticatorScreen screen = (AuthenticatorScreen) getScreen();
screen.refreshUserList();
}
}
};
contextMenu.addItem(copyItem);
if (item.mIsHotp) {
MenuItem checkCodeItem = new MenuItem(sResources, CHECK_CODE_MENU_ITEM, 0, 0) {
public void run() {
pushScreen(new CheckCodeScreen(item.mUser));
}
};
contextMenu.addItem(checkCodeItem);
}
contextMenu.addItem(deleteItem);
}
Aggregations