use of net.rim.device.api.system.Clipboard 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