use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class DatabaseBackend method getConversations.
public CopyOnWriteArrayList<Conversation> getConversations(int status) {
CopyOnWriteArrayList<Conversation> list = new CopyOnWriteArrayList<>();
SQLiteDatabase db = this.getReadableDatabase();
String[] selectionArgs = { Integer.toString(status) };
Cursor cursor = db.rawQuery("select * from " + Conversation.TABLENAME + " where " + Conversation.STATUS + " = ? order by " + Conversation.CREATED + " desc", selectionArgs);
while (cursor.moveToNext()) {
list.add(Conversation.fromCursor(cursor));
}
cursor.close();
return list;
}
use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class ConferenceDetailsActivity method startConversation.
protected void startConversation(User user) {
if (user.getRealJid() != null) {
Conversation conversation = xmppConnectionService.findOrCreateConversation(this.mConversation.getAccount(), user.getRealJid().toBareJid(), false, true);
switchToConversation(conversation);
}
}
use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class ConversationActivity method invalidateActionBarTitle.
private void invalidateActionBarTitle() {
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
if (mainFragment != null && mainFragment instanceof ConversationFragment) {
final Conversation conversation = ((ConversationFragment) mainFragment).getConversation();
if (conversation != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
View view = getLayoutInflater().inflate(R.layout.ab_title, null);
getSupportActionBar().setCustomView(view);
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayShowCustomEnabled(true);
TextView abtitle = findViewById(android.R.id.text1);
TextView absubtitle = findViewById(android.R.id.text2);
abtitle.setText(conversation.getName());
abtitle.setOnClickListener(view1 -> {
if (conversation.getMode() == Conversation.MODE_SINGLE) {
switchToContactDetails(conversation.getContact());
} else if (conversation.getMode() == Conversation.MODE_MULTI) {
Intent intent = new Intent(ConversationActivity.this, ConferenceDetailsActivity.class);
intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC);
intent.putExtra("uuid", conversation.getUuid());
startActivity(intent);
}
});
abtitle.setSelected(true);
if (conversation.getMode() == Conversation.MODE_SINGLE && !conversation.withSelf()) {
ChatState state = conversation.getIncomingChatState();
if (conversation.getContact().getShownStatus() == Presence.Status.OFFLINE) {
absubtitle.setText(getString(R.string.account_status_offline));
absubtitle.setSelected(true);
absubtitle.setOnClickListener(view12 -> {
if (conversation.getMode() == Conversation.MODE_SINGLE) {
switchToContactDetails(conversation.getContact());
} else if (conversation.getMode() == Conversation.MODE_MULTI) {
Intent intent = new Intent(ConversationActivity.this, ConferenceDetailsActivity.class);
intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC);
intent.putExtra("uuid", conversation.getUuid());
startActivity(intent);
}
});
} else {
if (state == ChatState.COMPOSING) {
absubtitle.setText(getString(R.string.is_typing));
absubtitle.setTypeface(null, Typeface.BOLD_ITALIC);
absubtitle.setSelected(true);
absubtitle.setOnClickListener(view13 -> {
if (conversation.getMode() == Conversation.MODE_SINGLE) {
switchToContactDetails(conversation.getContact());
} else if (conversation.getMode() == Conversation.MODE_MULTI) {
Intent intent = new Intent(ConversationActivity.this, ConferenceDetailsActivity.class);
intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC);
intent.putExtra("uuid", conversation.getUuid());
startActivity(intent);
}
});
} else {
if (showLastSeen && conversation.getContact().getLastseen() > 0) {
absubtitle.setText(UIHelper.lastseen(getApplicationContext(), conversation.getContact().isActive(), conversation.getContact().getLastseen()));
} else {
absubtitle.setText(getString(R.string.account_status_online));
}
absubtitle.setSelected(true);
absubtitle.setOnClickListener(view14 -> {
if (conversation.getMode() == Conversation.MODE_SINGLE) {
switchToContactDetails(conversation.getContact());
} else if (conversation.getMode() == Conversation.MODE_MULTI) {
Intent intent = new Intent(ConversationActivity.this, ConferenceDetailsActivity.class);
intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC);
intent.putExtra("uuid", conversation.getUuid());
startActivity(intent);
}
});
}
}
} else {
if (conversation.getParticipants() != null) {
ChatState state = ChatState.COMPOSING;
List<MucOptions.User> userWithChatStates = conversation.getMucOptions().getUsersWithChatState(state, 5);
if (userWithChatStates.size() == 0) {
state = ChatState.PAUSED;
userWithChatStates = conversation.getMucOptions().getUsersWithChatState(state, 5);
}
List<MucOptions.User> users = conversation.getMucOptions().getUsers(true);
if (state == ChatState.COMPOSING) {
if (userWithChatStates.size() > 0) {
if (userWithChatStates.size() == 1) {
MucOptions.User user = userWithChatStates.get(0);
absubtitle.setText(getString(R.string.contact_is_typing, UIHelper.getDisplayName(user)));
} else {
StringBuilder builder = new StringBuilder();
for (MucOptions.User user : userWithChatStates) {
if (builder.length() != 0) {
builder.append(", ");
}
builder.append(UIHelper.getDisplayName(user));
}
absubtitle.setText(getString(R.string.contacts_are_typing, builder.toString()));
}
}
} else {
if (users.size() == 1) {
absubtitle.setText(getString(R.string.one_participant));
} else {
absubtitle.setText(getString(R.string.more_participants, users.size()));
}
}
absubtitle.setSelected(true);
absubtitle.setOnClickListener(view15 -> {
if (conversation.getMode() == Conversation.MODE_SINGLE) {
switchToContactDetails(conversation.getContact());
} else if (conversation.getMode() == Conversation.MODE_MULTI) {
Intent intent = new Intent(ConversationActivity.this, ConferenceDetailsActivity.class);
intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC);
intent.putExtra("uuid", conversation.getUuid());
startActivity(intent);
}
});
} else {
absubtitle.setText(R.string.no_participants);
abtitle.setSelected(true);
absubtitle.setOnClickListener(view16 -> {
if (conversation.getMode() == Conversation.MODE_SINGLE) {
switchToContactDetails(conversation.getContact());
} else if (conversation.getMode() == Conversation.MODE_MULTI) {
Intent intent = new Intent(ConversationActivity.this, ConferenceDetailsActivity.class);
intent.setAction(ConferenceDetailsActivity.ACTION_VIEW_MUC);
intent.putExtra("uuid", conversation.getUuid());
startActivity(intent);
}
});
}
}
return;
}
}
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setDisplayShowCustomEnabled(false);
actionBar.setTitle(R.string.app_name);
actionBar.setSubtitle(null);
actionBar.setDisplayHomeAsUpEnabled(false);
}
}
use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class ConversationActivity method onBackendConnected.
@Override
void onBackendConnected() {
if (performRedirectIfNecessary(true)) {
return;
}
xmppConnectionService.getNotificationService().setIsInForeground(true);
final Intent FirstStartIntent = getIntent();
final Bundle extras = FirstStartIntent.getExtras();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (extras != null && extras.containsKey(PREF_FIRST_START)) {
FirstStartTime = extras.getLong(PREF_FIRST_START);
Log.d(Config.LOGTAG, "Get first start time from StartUI: " + FirstStartTime);
}
} else {
FirstStartTime = System.currentTimeMillis();
Log.d(Config.LOGTAG, "Device is running Android < SDK 23, no restart required: " + FirstStartTime);
}
Intent intent = pendingViewIntent.pop();
if (intent != null) {
if (processViewIntent(intent)) {
if (binding.secondaryFragment != null) {
notifyFragmentOfBackendConnected(R.id.main_fragment);
}
invalidateActionBarTitle();
return;
}
}
if (FirstStartTime == 0) {
Log.d(Config.LOGTAG, "First start time: " + FirstStartTime + ", restarting App");
// write first start timestamp to file
FirstStartTime = System.currentTimeMillis();
SharedPreferences FirstStart = getApplicationContext().getSharedPreferences(PREF_FIRST_START, Context.MODE_PRIVATE);
SharedPreferences.Editor editor = FirstStart.edit();
editor.putLong(PREF_FIRST_START, FirstStartTime);
editor.commit();
// restart
Intent restartintent = getBaseContext().getPackageManager().getLaunchIntentForPackage(getBaseContext().getPackageName());
restartintent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
restartintent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(restartintent);
System.exit(0);
}
if (xmppConnectionService.getAccounts().size() != 0) {
if (xmppConnectionService.hasInternetConnection()) {
if (xmppConnectionService.isWIFI() || (xmppConnectionService.isMobile() && !xmppConnectionService.isMobileRoaming())) {
if (!xmppConnectionService.installedFromFDroid()) {
AppUpdate(xmppConnectionService.installedFromPlayStore());
}
}
}
}
for (@IdRes int id : FRAGMENT_ID_NOTIFICATION_ORDER) {
notifyFragmentOfBackendConnected(id);
}
ActivityResult activityResult = postponedActivityResult.pop();
if (activityResult != null) {
handleActivityResult(activityResult);
}
invalidateActionBarTitle();
if (binding.secondaryFragment != null && ConversationFragment.getConversation(this) == null) {
Conversation conversation = ConversationsOverviewFragment.getSuggestion(this);
if (conversation != null) {
openConversation(conversation, null);
}
}
showDialogsIfMainIsOverview();
}
use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class ConversationActivity method onConversationArchived.
@Override
public void onConversationArchived(Conversation conversation) {
if (performRedirectIfNecessary(conversation, false)) {
return;
}
Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
if (mainFragment != null && mainFragment instanceof ConversationFragment) {
getFragmentManager().popBackStack();
return;
}
Fragment secondaryFragment = getFragmentManager().findFragmentById(R.id.secondary_fragment);
if (secondaryFragment != null && secondaryFragment instanceof ConversationFragment) {
if (((ConversationFragment) secondaryFragment).getConversation() == conversation) {
Conversation suggestion = ConversationsOverviewFragment.getSuggestion(this, conversation);
if (suggestion != null) {
openConversation(suggestion, null);
}
}
}
}
Aggregations