use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class AvatarService method get.
public Bitmap get(Message message, int size, boolean cachedOnly) {
final Conversation conversation = message.getConversation();
if (message.getType() == Message.TYPE_STATUS && message.getCounterparts() != null && message.getCounterparts().size() > 1) {
return get(message.getCounterparts(), size, cachedOnly);
} else if (message.getStatus() == Message.STATUS_RECEIVED) {
Contact c = message.getContact();
if (c != null && (c.getProfilePhoto() != null || c.getAvatar() != null)) {
return get(c, size, cachedOnly);
} else if (message.getConversation().getMode() == Conversation.MODE_MULTI) {
final Jid trueCounterpart = message.getTrueCounterpart();
MucOptions.User user;
if (trueCounterpart != null) {
user = conversation.getMucOptions().findUserByRealJid(trueCounterpart);
} else {
user = conversation.getMucOptions().findUserByFullJid(message.getCounterpart());
}
if (user != null) {
return getImpl(user, size, cachedOnly);
}
} else if (c != null) {
return get(c, size, cachedOnly);
}
Jid tcp = message.getTrueCounterpart();
String seed = tcp != null ? tcp.toBareJid().toString() : null;
return get(UIHelper.getMessageDisplayName(message), seed, size, cachedOnly);
} else {
return get(conversation.getAccount(), size, cachedOnly);
}
}
use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class AvatarService method get.
private Bitmap get(MucOptions mucOptions, int size, boolean cachedOnly) {
final String KEY = key(mucOptions, size);
Bitmap bitmap = this.mXmppConnectionService.getBitmapCache().get(KEY);
if (bitmap != null || cachedOnly) {
return bitmap;
}
final List<MucOptions.User> users = mucOptions.getUsersRelevantForNameAndAvatar();
if (users.size() == 0) {
Conversation c = mucOptions.getConversation();
bitmap = getImpl(c.getName(), c.getJid().toBareJid().toString(), size);
} else {
bitmap = getImpl(users, size);
}
this.mXmppConnectionService.getBitmapCache().put(KEY, bitmap);
return bitmap;
}
use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class AvatarService method key.
private String key(List<MucOptions.User> users, int size) {
final Conversation conversation = users.get(0).getConversation();
StringBuilder builder = new StringBuilder("TILE_");
builder.append(conversation.getUuid());
for (MucOptions.User user : users) {
builder.append("\0");
builder.append(user.getRealJid() == null ? "" : user.getRealJid().toBareJid().toPreppedString());
builder.append("\0");
builder.append(user.getFullJid() == null ? "" : user.getFullJid().toPreppedString());
}
final String key = builder.toString();
synchronized (this.conversationDependentKeys) {
Set<String> keys;
if (this.conversationDependentKeys.containsKey(conversation.getUuid())) {
keys = this.conversationDependentKeys.get(conversation.getUuid());
} else {
keys = new HashSet<>();
this.conversationDependentKeys.put(conversation.getUuid(), keys);
}
keys.add(key);
}
return key;
}
use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class ContactChooserTargetService method onGetChooserTargets.
@Override
public List<ChooserTarget> onGetChooserTargets(ComponentName targetActivityName, IntentFilter matchedFilter) {
Intent intent = new Intent(this, XmppConnectionService.class);
intent.setAction("contact_chooser");
startService(intent);
bindService(intent, this, Context.BIND_AUTO_CREATE);
ArrayList<ChooserTarget> chooserTargets = new ArrayList<>();
try {
waitForService();
final ArrayList<Conversation> conversations = new ArrayList<>();
if (!mXmppConnectionService.areMessagesInitialized()) {
return chooserTargets;
}
mXmppConnectionService.populateWithOrderedConversations(conversations, false);
final ComponentName componentName = new ComponentName(this, ShareWithActivity.class);
final int pixel = (int) (48 * getResources().getDisplayMetrics().density);
for (int i = 0; i < Math.min(conversations.size(), MAX_TARGETS); ++i) {
final Conversation conversation = conversations.get(i);
final String name = conversation.getName();
final Icon icon = Icon.createWithBitmap(mXmppConnectionService.getAvatarService().get(conversation, pixel));
final float score = 1 - (1.0f / MAX_TARGETS) * i;
final Bundle extras = new Bundle();
extras.putString("uuid", conversation.getUuid());
chooserTargets.add(new ChooserTarget(name, icon, score, componentName, extras));
}
} catch (InterruptedException e) {
}
unbindService(this);
return chooserTargets;
}
use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class ExportLogsService method export.
private void export() {
wakeLock.acquire();
List<Conversation> conversations = mDatabaseBackend.getConversations(Conversation.STATUS_AVAILABLE);
conversations.addAll(mDatabaseBackend.getConversations(Conversation.STATUS_ARCHIVED));
NotificationManager mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(getBaseContext());
mBuilder.setContentTitle(getString(R.string.app_name)).setContentText(getString(R.string.notification_export_logs_title)).setSmallIcon(R.drawable.ic_import_export_white_24dp).setProgress(0, 0, true);
startForeground(NOTIFICATION_ID, mBuilder.build());
mNotifyManager.notify(NOTIFICATION_ID, mBuilder.build());
if (ReadableLogsEnabled) {
for (Conversation conversation : conversations) {
writeToFile(conversation);
}
}
if (mAccounts.size() == 1) {
try {
ExportDatabase();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Aggregations