use of com.codename1.ui.Display in project CodenameOne by codenameone.
the class AndroidContactsManager method getAllContacts.
public Contact[] getAllContacts(Context activity, boolean withNumbers, boolean includesFullName, boolean includesPicture, boolean includesNumbers, boolean includesEmail, boolean includeAddress) {
HashMap<String, Contact> contacts = new HashMap<String, Contact>();
ArrayList sortedContacts = new ArrayList();
String selection = null;
if (withNumbers) {
selection = ContactsContract.Contacts.HAS_PHONE_NUMBER + "=1";
}
String[] projection = new String[] { ContactsContract.Contacts._ID, ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts.PHOTO_ID, ContactsContract.Contacts.HAS_PHONE_NUMBER };
ContentResolver contentResolver = activity.getContentResolver();
Cursor cursor = contentResolver.query(ContactsContract.Contacts.CONTENT_URI, projection, selection, null, "upper(" + ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME + ") ASC");
while (cursor.moveToNext()) {
String contactId = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
Contact contact = new Contact();
contact.setId(contactId);
contact.setEmails(new Hashtable());
// the contacts hash is for faster lookups and the sortedContacts will keep the order sorted
Contact old = contacts.put(contactId, contact);
sortedContacts.add(contact);
String name = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
contact.setDisplayName(name);
if (includesPicture) {
String photoID = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts.PHOTO_ID));
if (photoID != null) {
InputStream input = loadContactPhoto(contentResolver, Long.parseLong(contactId), Long.parseLong(photoID));
if (input != null) {
try {
contact.setPhoto(Image.createImage(input));
} catch (IOException ex) {
Logger.getLogger(AndroidContactsManager.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
}
cursor.close();
if (includesNumbers) {
projection = new String[] { ContactsContract.CommonDataKinds.Phone.CONTACT_ID, ContactsContract.CommonDataKinds.Phone.TYPE, ContactsContract.CommonDataKinds.Phone.NUMBER, ContactsContract.CommonDataKinds.Phone.IS_PRIMARY };
Cursor pCur = contentResolver.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, projection, null, null, null);
while (pCur.moveToNext()) {
String id = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.CONTACT_ID));
Contact contact = contacts.get(id);
if (contact == null) {
continue;
}
Hashtable phones = contact.getPhoneNumbers();
if (phones == null) {
phones = new Hashtable();
contact.setPhoneNumbers(phones);
}
String type = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));
String phone = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
boolean isPrimary = pCur.getInt(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.IS_PRIMARY)) != 0;
if (String.valueOf(ContactsContract.CommonDataKinds.Phone.TYPE_HOME).equals(type)) {
type = "home";
} else if (String.valueOf(ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE).equals(type)) {
type = "mobile";
} else if (String.valueOf(ContactsContract.CommonDataKinds.Phone.TYPE_WORK).equals(type)) {
type = "work";
} else if (String.valueOf(ContactsContract.CommonDataKinds.Phone.TYPE_FAX_HOME).equals(type)) {
type = "fax";
} else {
type = "other";
}
if (isPrimary) {
contact.setPrimaryPhoneNumber(phone);
}
phones.put(type, phone);
}
pCur.close();
}
if (includesEmail) {
projection = new String[] { ContactsContract.CommonDataKinds.Email.CONTACT_ID, ContactsContract.CommonDataKinds.Email.DATA, ContactsContract.CommonDataKinds.Email.TYPE, ContactsContract.CommonDataKinds.Email.IS_PRIMARY };
Cursor emailCur = contentResolver.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, projection, null, null, null);
while (emailCur.moveToNext()) {
String id = emailCur.getString(emailCur.getColumnIndex(ContactsContract.CommonDataKinds.Email.CONTACT_ID));
Contact contact = contacts.get(id);
if (contact == null) {
continue;
}
Hashtable emails = contact.getEmails();
if (emails == null) {
emails = new Hashtable();
contact.setEmails(emails);
}
// This would allow you get several email addresses
// if the email addresses were stored in an array
String email = emailCur.getString(emailCur.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
String type = emailCur.getString(emailCur.getColumnIndex(ContactsContract.CommonDataKinds.Email.TYPE));
boolean isPrimary = emailCur.getInt(emailCur.getColumnIndex(ContactsContract.CommonDataKinds.Email.IS_PRIMARY)) != 0;
if (String.valueOf(ContactsContract.CommonDataKinds.Email.TYPE_HOME).equals(type)) {
type = "home";
} else if (String.valueOf(ContactsContract.CommonDataKinds.Email.TYPE_MOBILE).equals(type)) {
type = "mobile";
} else if (String.valueOf(ContactsContract.CommonDataKinds.Email.TYPE_WORK).equals(type)) {
type = "work";
} else {
type = "other";
}
if (isPrimary) {
contact.setPrimaryEmail(email);
}
emails.put(type, email);
}
emailCur.close();
}
if (includesFullName) {
String birthWhere = ContactsContract.Data.MIMETYPE + "= ? AND " + ContactsContract.CommonDataKinds.Event.TYPE + "=" + ContactsContract.CommonDataKinds.Event.TYPE_BIRTHDAY;
String[] birthWhereParams = new String[] { ContactsContract.CommonDataKinds.Event.CONTENT_ITEM_TYPE };
Cursor birthCur = contentResolver.query(ContactsContract.Data.CONTENT_URI, null, birthWhere, birthWhereParams, null);
while (birthCur.moveToNext()) {
String id = birthCur.getString(birthCur.getColumnIndex(ContactsContract.CommonDataKinds.Event.CONTACT_ID));
Contact contact = contacts.get(id);
if (contact == null) {
continue;
}
String birth = birthCur.getString(birthCur.getColumnIndex(ContactsContract.CommonDataKinds.Event.START_DATE));
Date bd = null;
try {
bd = new SimpleDateFormat("yyyy-MM-dd").parse(birth);
contact.setBirthday(bd.getTime());
} catch (ParseException ex) {
}
}
birthCur.close();
String nameWhere = ContactsContract.Data.MIMETYPE + " = ?";
String[] nameWhereParams = new String[] { ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE };
projection = new String[] { ContactsContract.CommonDataKinds.StructuredName.CONTACT_ID, ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME, ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME, ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME };
Cursor nameCursor = contentResolver.query(ContactsContract.Data.CONTENT_URI, projection, nameWhere, nameWhereParams, ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME);
while (nameCursor.moveToNext()) {
String id = nameCursor.getString(nameCursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.CONTACT_ID));
Contact contact = contacts.get(id);
if (contact == null) {
continue;
}
String given = nameCursor.getString(nameCursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME));
String family = nameCursor.getString(nameCursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME));
String display = nameCursor.getString(nameCursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME));
if (given != null)
contact.setFirstName(given);
if (family != null)
contact.setFamilyName(family);
if (display != null)
contact.setDisplayName(display);
}
nameCursor.close();
String noteWhere = ContactsContract.Data.MIMETYPE + " = ?";
String[] noteWhereParams = new String[] { ContactsContract.CommonDataKinds.Note.CONTENT_ITEM_TYPE };
projection = new String[] { ContactsContract.CommonDataKinds.Note.CONTACT_ID, ContactsContract.CommonDataKinds.Note.NOTE };
Cursor noteCur = contentResolver.query(ContactsContract.Data.CONTENT_URI, projection, noteWhere, noteWhereParams, null);
while (noteCur.moveToNext()) {
String id = noteCur.getString(noteCur.getColumnIndex(ContactsContract.CommonDataKinds.Note.CONTACT_ID));
Contact contact = contacts.get(id);
if (contact == null) {
continue;
}
String note = noteCur.getString(noteCur.getColumnIndex(ContactsContract.CommonDataKinds.Note.NOTE));
contact.setNote(note);
}
noteCur.close();
}
if (includeAddress) {
String addrWhere = ContactsContract.Data.MIMETYPE + " = ?";
String[] addrWhereParams = new String[] { ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE };
projection = new String[] { ContactsContract.CommonDataKinds.StructuredPostal.CONTACT_ID, ContactsContract.CommonDataKinds.StructuredPostal.POBOX, ContactsContract.CommonDataKinds.StructuredPostal.STREET, ContactsContract.CommonDataKinds.StructuredPostal.CITY, ContactsContract.CommonDataKinds.StructuredPostal.REGION, ContactsContract.CommonDataKinds.StructuredPostal.POSTCODE, ContactsContract.CommonDataKinds.StructuredPostal.COUNTRY, ContactsContract.CommonDataKinds.StructuredPostal.TYPE };
Cursor addrCur = contentResolver.query(ContactsContract.Data.CONTENT_URI, projection, addrWhere, addrWhereParams, null);
while (addrCur.moveToNext()) {
String id = addrCur.getString(addrCur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.CONTACT_ID));
Contact contact = contacts.get(id);
if (contact == null) {
continue;
}
Hashtable addresses = contact.getAddresses();
if (addresses == null) {
addresses = new Hashtable();
contact.setAddresses(addresses);
}
Address address = new Address();
// String poBox = addrCur.getString(
// addrCur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.POBOX));
String street = addrCur.getString(addrCur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.STREET));
String city = addrCur.getString(addrCur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.CITY));
String state = addrCur.getString(addrCur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.REGION));
String postalCode = addrCur.getString(addrCur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.POSTCODE));
String country = addrCur.getString(addrCur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.COUNTRY));
String type = addrCur.getString(addrCur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.TYPE));
address.setCountry(country);
address.setLocality(city);
address.setPostalCode(postalCode);
address.setRegion(state);
address.setStreetAddress(street);
if (String.valueOf(ContactsContract.CommonDataKinds.StructuredPostal.TYPE_HOME).equals(type)) {
type = "home";
} else if (String.valueOf(ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK).equals(type)) {
type = "work";
} else {
type = "other";
}
addresses.put(type, address);
contact.setAddresses(addresses);
}
addrCur.close();
}
Contact[] contactsArray = new Contact[sortedContacts.size()];
sortedContacts.toArray(contactsArray);
return contactsArray;
}
use of com.codename1.ui.Display in project CodenameOne by codenameone.
the class AndroidContactsManager method getContact.
public Contact getContact(Context activity, String id, boolean includesFullName, boolean includesPicture, boolean includesNumbers, boolean includesEmail, boolean includeAddress) {
Contact retVal = new Contact();
retVal.setId(id);
ContentResolver cr = activity.getContentResolver();
String[] projection = new String[] { ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts.PHOTO_ID, ContactsContract.Contacts.HAS_PHONE_NUMBER };
Cursor result = cr.query(ContactsContract.Contacts.CONTENT_URI, projection, ContactsContract.Contacts._ID + " = ?", new String[] { id }, null);
if (result.moveToFirst()) {
String name = result.getString(result.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME));
retVal.setDisplayName(name);
if (includesPicture) {
String photoID = result.getString(result.getColumnIndex(ContactsContract.Contacts.PHOTO_ID));
if (photoID != null) {
InputStream input = loadContactPhoto(cr, Long.parseLong(id), Long.parseLong(photoID));
if (input != null) {
try {
retVal.setPhoto(Image.createImage(input));
} catch (IOException ex) {
Logger.getLogger(AndroidContactsManager.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
}
if (includesNumbers) {
Hashtable phones = new Hashtable();
if (Integer.parseInt(result.getString(result.getColumnIndex(ContactsContract.Contacts.HAS_PHONE_NUMBER))) > 0) {
// String[] whereParameters = new String[]{id, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE};
projection = new String[] { ContactsContract.CommonDataKinds.Phone.TYPE, ContactsContract.CommonDataKinds.Phone.NUMBER, ContactsContract.CommonDataKinds.Phone.IS_PRIMARY };
Cursor pCur = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, projection, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[] { id }, null);
while (pCur.moveToNext()) {
String type = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.TYPE));
String phone = pCur.getString(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER));
boolean isPrimary = pCur.getInt(pCur.getColumnIndex(ContactsContract.CommonDataKinds.Phone.IS_PRIMARY)) != 0;
if (String.valueOf(ContactsContract.CommonDataKinds.Phone.TYPE_HOME).equals(type)) {
type = "home";
} else if (String.valueOf(ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE).equals(type)) {
type = "mobile";
} else if (String.valueOf(ContactsContract.CommonDataKinds.Phone.TYPE_WORK).equals(type)) {
type = "work";
} else if (String.valueOf(ContactsContract.CommonDataKinds.Phone.TYPE_FAX_HOME).equals(type)) {
type = "fax";
} else {
type = "other";
}
if (isPrimary) {
retVal.setPrimaryPhoneNumber(phone);
}
phones.put(type, phone);
}
retVal.setPhoneNumbers(phones);
pCur.close();
}
}
if (includesEmail) {
Hashtable emails = new Hashtable();
projection = new String[] { ContactsContract.CommonDataKinds.Email.DATA, ContactsContract.CommonDataKinds.Email.TYPE, ContactsContract.CommonDataKinds.Email.IS_PRIMARY };
Cursor emailCur = cr.query(ContactsContract.CommonDataKinds.Email.CONTENT_URI, projection, ContactsContract.CommonDataKinds.Email.CONTACT_ID + " = ?", new String[] { id }, null);
while (emailCur.moveToNext()) {
// This would allow you get several email addresses
// if the email addresses were stored in an array
String email = emailCur.getString(emailCur.getColumnIndex(ContactsContract.CommonDataKinds.Email.DATA));
String type = emailCur.getString(emailCur.getColumnIndex(ContactsContract.CommonDataKinds.Email.TYPE));
boolean isPrimary = emailCur.getInt(emailCur.getColumnIndex(ContactsContract.CommonDataKinds.Email.IS_PRIMARY)) != 0;
if (String.valueOf(ContactsContract.CommonDataKinds.Email.TYPE_HOME).equals(type)) {
type = "home";
} else if (String.valueOf(ContactsContract.CommonDataKinds.Email.TYPE_MOBILE).equals(type)) {
type = "mobile";
} else if (String.valueOf(ContactsContract.CommonDataKinds.Email.TYPE_WORK).equals(type)) {
type = "work";
} else {
type = "other";
}
if (isPrimary) {
retVal.setPrimaryEmail(email);
}
emails.put(type, email);
}
retVal.setEmails(emails);
emailCur.close();
}
if (includesFullName) {
String birthWhere = ContactsContract.Data.CONTACT_ID + " = ? AND " + ContactsContract.Data.MIMETYPE + "= ? AND " + ContactsContract.CommonDataKinds.Event.TYPE + "=" + ContactsContract.CommonDataKinds.Event.TYPE_BIRTHDAY;
String[] birthWhereParams = new String[] { id, ContactsContract.CommonDataKinds.Event.CONTENT_ITEM_TYPE };
Cursor birthCur = cr.query(ContactsContract.Data.CONTENT_URI, null, birthWhere, birthWhereParams, null);
if (birthCur.moveToFirst()) {
String birth = birthCur.getString(birthCur.getColumnIndex(ContactsContract.CommonDataKinds.Event.START_DATE));
Date bd = null;
try {
bd = new SimpleDateFormat("yyyy-MM-dd").parse(birth);
retVal.setBirthday(bd.getTime());
} catch (ParseException ex) {
}
}
birthCur.close();
String nameWhere = ContactsContract.Data.CONTACT_ID + " = ? AND " + ContactsContract.Data.MIMETYPE + " = ?";
String[] nameWhereParams = new String[] { id, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE };
projection = new String[] { ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME, ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME, ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME };
Cursor nameCursor = cr.query(ContactsContract.Data.CONTENT_URI, projection, nameWhere, nameWhereParams, ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME);
while (nameCursor.moveToNext()) {
String given = nameCursor.getString(nameCursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME));
String family = nameCursor.getString(nameCursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME));
String display = nameCursor.getString(nameCursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME));
retVal.setFirstName(given);
retVal.setFamilyName(family);
retVal.setDisplayName(display);
}
nameCursor.close();
String noteWhere = ContactsContract.Data.CONTACT_ID + " = ? AND " + ContactsContract.Data.MIMETYPE + " = ?";
String[] noteWhereParams = new String[] { id, ContactsContract.CommonDataKinds.Note.CONTENT_ITEM_TYPE };
projection = new String[] { ContactsContract.CommonDataKinds.Note.NOTE };
Cursor noteCur = cr.query(ContactsContract.Data.CONTENT_URI, projection, noteWhere, noteWhereParams, null);
if (noteCur.moveToFirst()) {
String note = noteCur.getString(noteCur.getColumnIndex(ContactsContract.CommonDataKinds.Note.NOTE));
retVal.setNote(note);
}
noteCur.close();
}
if (includeAddress) {
Hashtable addresses = new Hashtable();
String addrWhere = ContactsContract.Data.CONTACT_ID + " = ? AND " + ContactsContract.Data.MIMETYPE + " = ?";
String[] addrWhereParams = new String[] { id, ContactsContract.CommonDataKinds.StructuredPostal.CONTENT_ITEM_TYPE };
projection = new String[] { ContactsContract.CommonDataKinds.StructuredPostal.POBOX, ContactsContract.CommonDataKinds.StructuredPostal.STREET, ContactsContract.CommonDataKinds.StructuredPostal.CITY, ContactsContract.CommonDataKinds.StructuredPostal.REGION, ContactsContract.CommonDataKinds.StructuredPostal.POSTCODE, ContactsContract.CommonDataKinds.StructuredPostal.COUNTRY, ContactsContract.CommonDataKinds.StructuredPostal.TYPE };
Cursor addrCur = cr.query(ContactsContract.Data.CONTENT_URI, projection, addrWhere, addrWhereParams, null);
while (addrCur.moveToNext()) {
Address address = new Address();
String poBox = addrCur.getString(addrCur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.POBOX));
String street = addrCur.getString(addrCur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.STREET));
String city = addrCur.getString(addrCur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.CITY));
String state = addrCur.getString(addrCur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.REGION));
String postalCode = addrCur.getString(addrCur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.POSTCODE));
String country = addrCur.getString(addrCur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.COUNTRY));
String type = addrCur.getString(addrCur.getColumnIndex(ContactsContract.CommonDataKinds.StructuredPostal.TYPE));
address.setCountry(country);
address.setLocality(city);
address.setPostalCode(postalCode);
address.setRegion(state);
address.setStreetAddress(street);
if (String.valueOf(ContactsContract.CommonDataKinds.StructuredPostal.TYPE_HOME).equals(type)) {
type = "home";
} else if (String.valueOf(ContactsContract.CommonDataKinds.StructuredPostal.TYPE_WORK).equals(type)) {
type = "work";
} else {
type = "other";
}
addresses.put(type, address);
}
retVal.setAddresses(addresses);
addrCur.close();
}
result.close();
return retVal;
}
use of com.codename1.ui.Display in project CodenameOne by codenameone.
the class LocalNotificationPublisher method onReceive.
public void onReceive(Context context, Intent intent) {
// Fire the notification to the display
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Bundle extras = intent.getExtras();
PendingIntent content = extras.getParcelable(NOTIFICATION_INTENT);
Bundle b = extras.getParcelable(NOTIFICATION);
LocalNotification notif = AndroidImplementation.createNotificationFromBundle(b);
if (AndroidImplementation.BACKGROUND_FETCH_NOTIFICATION_ID.equals(notif.getId())) {
PendingIntent backgroundFetchIntent = extras.getParcelable(BACKGROUND_FETCH_INTENT);
if (backgroundFetchIntent != null) {
try {
backgroundFetchIntent.send();
} catch (Exception ex) {
Log.e("Codename One", "Failed to send BackgroundFetchHandler intent", ex);
}
} else {
Log.d("Codename One", "BackgroundFetch intent was null");
}
} else {
Notification notification = createAndroidNotification(context, notif, content);
notification.when = System.currentTimeMillis();
try {
int notifId = Integer.parseInt(notif.getId());
notificationManager.notify("CN1", notifId, notification);
} catch (Exception e) {
// that was a mistake, the first param is the tag not the id
notificationManager.notify(notif.getId(), 0, notification);
}
}
}
use of com.codename1.ui.Display in project CodenameOne by codenameone.
the class Component method paintInternal.
final void paintInternal(Graphics g, boolean paintIntersects) {
Display d = Display.getInstance();
CodenameOneImplementation impl = d.getImplementation();
if (!isVisible()) {
return;
}
if (paintLockImage != null) {
if (paintLockImage instanceof Image) {
Image i = (Image) paintLockImage;
g.drawImage(i, getX(), getY());
} else {
Image i = (Image) d.extractHardRef(paintLockImage);
if (i == null) {
i = Image.createImage(getWidth(), getHeight());
int x = getX();
int y = getY();
setX(0);
setY(0);
paintInternalImpl(i.getGraphics(), paintIntersects);
setX(x);
setY(y);
paintLockImage = d.createSoftWeakRef(i);
}
g.drawImage(i, getX(), getY());
}
return;
}
impl.beforeComponentPaint(this, g);
paintInternalImpl(g, paintIntersects);
impl.afterComponentPaint(this, g);
}
use of com.codename1.ui.Display in project codenameone-google-maps by codenameone.
the class MapInfoPanel method show.
public void show() {
if (getParent() != null) {
return;
}
Display disp = Display.getInstance();
if (disp.isTablet()) {
if (disp.isPortrait()) {
markers.setLayout(new BoxLayout(BoxLayout.X_AXIS));
for (Component marker : markers) {
if (marker instanceof Button) {
Button btnMarker = (Button) marker;
btnMarker.setTextPosition(Label.BOTTOM);
}
}
InteractionDialog dlg = new InteractionDialog("Map Info");
dlg.setLayout(new BorderLayout());
dlg.add(BorderLayout.CENTER, this);
int dh = disp.getDisplayHeight();
int dw = disp.getDisplayWidth();
dlg.show(3 * dh / 4, 0, 0, 0);
updateMapPosition();
} else {
markers.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
for (Component marker : markers) {
if (marker instanceof Button) {
Button btnMarker = (Button) marker;
btnMarker.setTextPosition(Label.RIGHT);
}
}
InteractionDialog dlg = new InteractionDialog("Map Info");
dlg.setLayout(new BorderLayout());
dlg.add(BorderLayout.CENTER, this);
int dh = disp.getDisplayHeight();
int dw = disp.getDisplayWidth();
// makeTransparent(dlg);
dlg.getAllStyles().setBorder(Border.createEmpty());
dlg.getAllStyles().setBgColor(0x0);
dlg.getAllStyles().setBgTransparency(128);
List<Component> dialogTitle = findByUIID("DialogTitle", dlg);
for (Component c : dialogTitle) {
c.getAllStyles().setFgColor(0xffffff);
}
List<Component> tabsContainer = findByUIID("TabsContainer", dlg);
for (Component c : tabsContainer) {
c.getAllStyles().setBgColor(0xEAEAEA);
// c.getAllStyles().setBackgroundType(Style.BACKGROUND_NONE);
c.getAllStyles().setBgTransparency(255);
}
;
dlg.show(0, 0, 0, dw * 3 / 4);
updateMapPosition();
System.out.println("Making transparent");
// makeTransparent(dlg);
}
} else {
if (disp.isPortrait()) {
markers.setLayout(new BoxLayout(BoxLayout.X_AXIS));
for (Component marker : markers) {
if (marker instanceof Button) {
Button btnMarker = (Button) marker;
btnMarker.setTextPosition(Label.BOTTOM);
}
}
InteractionDialog dlg = new InteractionDialog("Map Info");
dlg.setLayout(new BorderLayout());
dlg.add(BorderLayout.CENTER, this);
int dh = disp.getDisplayHeight();
int dw = disp.getDisplayWidth();
dlg.show(dh / 2, 0, 0, 0);
updateMapPosition();
} else {
markers.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
for (Component marker : markers) {
if (marker instanceof Button) {
Button btnMarker = (Button) marker;
btnMarker.setTextPosition(Label.RIGHT);
}
}
InteractionDialog dlg = new InteractionDialog("Map Info");
dlg.setLayout(new BorderLayout());
dlg.add(BorderLayout.CENTER, this);
int dh = disp.getDisplayHeight();
int dw = disp.getDisplayWidth();
dlg.show(0, dw / 2, 0, 0);
updateMapPosition();
}
}
}
Aggregations