use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class ConversationFragment method onBackendConnected.
@Override
public void onBackendConnected() {
Log.d(Config.LOGTAG, "ConversationFragment.onBackendConnected()");
String uuid = pendingConversationsUuid.pop();
if (uuid != null) {
Conversation conversation = activity.xmppConnectionService.findConversationByUuid(uuid);
if (conversation == null) {
Log.d(Config.LOGTAG, "unable to restore activity");
clearPending();
return;
}
reInit(conversation);
ScrollState scrollState = pendingScrollState.pop();
if (scrollState != null) {
setScrollPosition(scrollState);
}
}
ActivityResult activityResult = postponedActivityResult.pop();
if (activityResult != null) {
handleActivityResult(activityResult);
}
clearPending();
}
use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class ConversationFragment method selectPresenceToAttachFile.
protected void selectPresenceToAttachFile(final int attachmentChoice) {
final int encryption = conversation.getNextEncryption();
final Account account = conversation.getAccount();
final PresenceSelector.OnPresenceSelected callback = () -> {
final Intent intent = new Intent();
boolean chooser = false;
String fallbackPackageId = null;
switch(attachmentChoice) {
case ATTACHMENT_CHOICE_CHOOSE_IMAGE:
intent.setAction(Intent.ACTION_GET_CONTENT);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
}
intent.setType("image/*");
chooser = true;
break;
case ATTACHMENT_CHOICE_CHOOSE_VIDEO:
chooser = true;
intent.setType("video/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setAction(Intent.ACTION_GET_CONTENT);
break;
case ATTACHMENT_CHOICE_TAKE_FROM_CAMERA:
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(getString(R.string.attach_take_from_camera));
builder.setNegativeButton(getString(R.string.action_take_photo), (dialog, which) -> {
final Uri uri = activity.xmppConnectionService.getFileBackend().getTakePhotoUri();
pendingTakePhotoUri.push(uri);
intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, attachmentChoice);
});
builder.setPositiveButton(getString(R.string.action_take_video), (dialog, which) -> {
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setAction(MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(intent, attachmentChoice);
});
builder.create().show();
break;
case ATTACHMENT_CHOICE_CHOOSE_FILE:
chooser = true;
intent.setType("*/*");
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setAction(Intent.ACTION_GET_CONTENT);
break;
case ATTACHMENT_CHOICE_RECORD_VOICE:
startActivityForResult(new Intent(getActivity(), RecordingActivity.class), attachmentChoice);
break;
case ATTACHMENT_CHOICE_LOCATION:
startActivityForResult(new Intent(getActivity(), ShareLocationActivity.class), attachmentChoice);
break;
}
if (intent.resolveActivity(getActivity().getPackageManager()) != null) {
Log.d(Config.LOGTAG, "Attachment: " + attachmentChoice);
if (chooser) {
startActivityForResult(Intent.createChooser(intent, getString(R.string.perform_action_with)), attachmentChoice);
} else {
startActivityForResult(intent, attachmentChoice);
}
} else if (fallbackPackageId != null) {
startActivity(getInstallApkIntent(fallbackPackageId));
}
};
if (account.httpUploadAvailable() || attachmentChoice == ATTACHMENT_CHOICE_LOCATION) {
if ((account.httpUploadAvailable() || attachmentChoice == ATTACHMENT_CHOICE_LOCATION) && encryption != Message.ENCRYPTION_OTR) {
conversation.setNextCounterpart(null);
callback.onPresenceSelected();
} else {
activity.selectPresence(conversation, callback);
}
}
}
use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class ConversationsOverviewFragment method onCreateView.
@Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log.d(Config.LOGTAG, "onCreateView");
this.binding = DataBindingUtil.inflate(inflater, R.layout.fragment_conversations_overview, container, false);
this.binding.fab.setOnClickListener((view) -> StartConversationActivity.launch(getActivity()));
this.conversationsAdapter = new ConversationAdapter(this.activity, this.conversations);
this.binding.list.setAdapter(this.conversationsAdapter);
this.binding.list.setOnItemClickListener((parent, view, position, id) -> {
Conversation conversation = this.conversations.get(position);
if (activity instanceof OnConversationSelected) {
((OnConversationSelected) activity).onConversationSelected(conversation);
} else {
Log.w(ConversationsOverviewFragment.class.getCanonicalName(), "Activity does not implement OnConversationSelected");
}
});
return binding.getRoot();
}
use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class ShareViaAccountActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_manage_accounts);
accountListView = findViewById(R.id.account_list);
this.mAccountAdapter = new AccountAdapter(this, accountList);
accountListView.setAdapter(this.mAccountAdapter);
accountListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View view, int position, long arg3) {
final Account account = accountList.get(position);
final String body = getIntent().getStringExtra(EXTRA_BODY);
try {
final Jid contact = Jid.fromString(getIntent().getStringExtra(EXTRA_CONTACT));
final Conversation conversation = xmppConnectionService.findOrCreateConversation(account, contact, false, false);
switchToConversation(conversation, body, false);
} catch (InvalidJidException e) {
// ignore error
}
finish();
}
});
}
use of de.pixart.messenger.entities.Conversation in project Pix-Art-Messenger by kriztan.
the class StartConversationActivity method openConversationForContact.
protected void openConversationForContact(Contact contact) {
Conversation conversation = xmppConnectionService.findOrCreateConversation(contact.getAccount(), contact.getJid(), false, true);
switchToConversation(conversation);
}
Aggregations