use of de.pixart.messenger.entities.Account in project Pix-Art-Messenger by kriztan.
the class MessageGenerator method generateChatState.
public MessagePacket generateChatState(Conversation conversation) {
final Account account = conversation.getAccount();
MessagePacket packet = new MessagePacket();
packet.setType(conversation.getMode() == Conversation.MODE_MULTI ? MessagePacket.TYPE_GROUPCHAT : MessagePacket.TYPE_CHAT);
packet.setTo(conversation.getJid().toBareJid());
packet.setFrom(account.getJid());
packet.addChild(ChatState.toElement(conversation.getOutgoingChatState()));
packet.addChild("no-store", "urn:xmpp:hints");
// wrong! don't copy this. Its *store*
packet.addChild("no-storage", "urn:xmpp:hints");
return packet;
}
use of de.pixart.messenger.entities.Account 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.Account in project Pix-Art-Messenger by kriztan.
the class WelcomeActivity method onCreate.
@Override
protected void onCreate(final Bundle savedInstanceState) {
if (getResources().getBoolean(R.bool.portrait_only)) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome);
final ActionBar ab = getSupportActionBar();
if (ab != null) {
ab.setDisplayShowHomeEnabled(false);
ab.setDisplayHomeAsUpEnabled(false);
}
// check if there is a backed up database --
if (hasStoragePermission(REQUEST_READ_EXTERNAL_STORAGE)) {
BackupAvailable();
}
final Button ImportDatabase = findViewById(R.id.import_database);
final TextView ImportText = findViewById(R.id.import_text);
if (BackupAvailable()) {
ImportDatabase.setVisibility(View.VISIBLE);
ImportText.setVisibility(View.VISIBLE);
}
ImportDatabase.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
enterPasswordDialog();
}
});
final Button createAccount = findViewById(R.id.create_account);
createAccount.setOnClickListener(v -> {
final Intent intent = new Intent(WelcomeActivity.this, MagicCreateActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
addInviteUri(intent);
startActivity(intent);
});
final Button useOwnProvider = findViewById(R.id.use_existing_account);
useOwnProvider.setOnClickListener(v -> {
List<Account> accounts = xmppConnectionService.getAccounts();
Intent intent = new Intent(WelcomeActivity.this, EditAccountActivity.class);
if (accounts.size() == 1) {
intent.putExtra("jid", accounts.get(0).getJid().toBareJid().toString());
intent.putExtra("init", true);
} else if (accounts.size() >= 1) {
intent = new Intent(WelcomeActivity.this, ManageAccountActivity.class);
}
addInviteUri(intent);
startActivity(intent);
});
}
use of de.pixart.messenger.entities.Account in project Pix-Art-Messenger by kriztan.
the class AccountAdapter method getView.
@Override
public View getView(int position, View view, ViewGroup parent) {
final Account account = getItem(position);
if (view == null) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
view = inflater.inflate(R.layout.account_row, parent, false);
}
TextView jid = view.findViewById(R.id.account_jid);
if (Config.DOMAIN_LOCK != null) {
jid.setText(account.getJid().getLocalpart());
} else {
jid.setText(account.getJid().toBareJid().toString());
}
TextView statusView = view.findViewById(R.id.account_status);
ImageView imageView = view.findViewById(R.id.account_image);
loadAvatar(account, imageView);
statusView.setText(getContext().getString(account.getStatus().getReadableId()));
switch(account.getStatus()) {
case ONLINE:
statusView.setTextColor(activity.getOnlineColor());
break;
case DISABLED:
case CONNECTING:
statusView.setTextColor(Color.get(activity, android.R.attr.textColorSecondary));
break;
default:
statusView.setTextColor(activity.getWarningTextColor());
break;
}
return view;
}
use of de.pixart.messenger.entities.Account 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();
}
});
}
Aggregations