preselect proper account in create contact dialog after following invite

This commit is contained in:
Daniel Gultsch 2020-01-09 17:39:55 +01:00
parent 6205574bcb
commit e57bd477a9
5 changed files with 24 additions and 21 deletions

View File

@ -435,6 +435,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
if (wasFirstAccount) { if (wasFirstAccount) {
intent.putExtra("init", true); intent.putExtra("init", true);
} }
intent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().asBareJid().toEscapedString());
} else { } else {
intent = new Intent(getApplicationContext(), PublishProfilePictureActivity.class); intent = new Intent(getApplicationContext(), PublishProfilePictureActivity.class);
intent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().asBareJid().toString()); intent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().asBareJid().toString());

View File

@ -55,6 +55,7 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC
Intent intent = new Intent(getApplicationContext(), StartConversationActivity.class); Intent intent = new Intent(getApplicationContext(), StartConversationActivity.class);
StartConversationActivity.addInviteUri(intent, getIntent()); StartConversationActivity.addInviteUri(intent, getIntent());
intent.putExtra("init", true); intent.putExtra("init", true);
intent.putExtra(EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString());
startActivity(intent); startActivity(intent);
} }
Toast.makeText(PublishProfilePictureActivity.this, Toast.makeText(PublishProfilePictureActivity.this,
@ -100,6 +101,7 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC
intent.putExtra("init", true); intent.putExtra("init", true);
} }
StartConversationActivity.addInviteUri(intent, getIntent()); StartConversationActivity.addInviteUri(intent, getIntent());
intent.putExtra(EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString());
startActivity(intent); startActivity(intent);
} }
finish(); finish();

View File

@ -499,7 +499,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
getString(R.string.add_contact), getString(R.string.add_contact),
getString(R.string.add), getString(R.string.add),
prefilledJid, prefilledJid,
null, invite == null ? null : invite.account,
invite == null || !invite.hasFingerprints(), invite == null || !invite.hasFingerprints(),
true true
); );
@ -821,7 +821,8 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
protected boolean processViewIntent(@NonNull Intent intent) { protected boolean processViewIntent(@NonNull Intent intent) {
final String inviteUri = intent.getStringExtra(EXTRA_INVITE_URI); final String inviteUri = intent.getStringExtra(EXTRA_INVITE_URI);
if (inviteUri != null) { if (inviteUri != null) {
Invite invite = new Invite(inviteUri); final Invite invite = new Invite(inviteUri);
invite.account = intent.getStringExtra(EXTRA_ACCOUNT);
if (invite.isJidValid()) { if (invite.isJidValid()) {
return invite.invite(); return invite.invite();
} }
@ -836,7 +837,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
Uri uri = intent.getData(); Uri uri = intent.getData();
if (uri != null) { if (uri != null) {
Invite invite = new Invite(intent.getData(), intent.getBooleanExtra("scanned", false)); Invite invite = new Invite(intent.getData(), intent.getBooleanExtra("scanned", false));
invite.account = intent.getStringExtra("account"); invite.account = intent.getStringExtra(EXTRA_ACCOUNT);
invite.forceDialog = intent.getBooleanExtra("force_dialog", false); invite.forceDialog = intent.getBooleanExtra("force_dialog", false);
return invite.invite(); return invite.invite();
} else { } else {
@ -857,8 +858,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
showJoinConferenceDialog(invite.getJid().asBareJid().toString()); showJoinConferenceDialog(invite.getJid().asBareJid().toString());
return false; return false;
} }
} else if (contacts.size() == 0) { //TODO or init mode } else if (contacts.size() == 0) {
//TODO if init mode; prefill dialog with account jid
showCreateContactDialog(invite.getJid().toString(), invite); showCreateContactDialog(invite.getJid().toString(), invite);
return false; return false;
} else if (contacts.size() == 1) { } else if (contacts.size() == 1) {

View File

@ -6,16 +6,16 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:paddingBottom="?attr/dialog_vertical_padding"
android:paddingLeft="?attr/dialog_horizontal_padding" android:paddingLeft="?attr/dialog_horizontal_padding"
android:paddingTop="?attr/dialog_vertical_padding"
android:paddingRight="?attr/dialog_horizontal_padding" android:paddingRight="?attr/dialog_horizontal_padding"
android:paddingTop="?attr/dialog_vertical_padding"> android:paddingBottom="?attr/dialog_vertical_padding">
<TextView <TextView
style="@style/InputLabel" style="@style/InputLabel"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/your_account"/> android:text="@string/your_account" />
<Spinner <Spinner
android:id="@+id/account" android:id="@+id/account"
@ -35,8 +35,8 @@
style="@style/Widget.Conversations.EditText" style="@style/Widget.Conversations.EditText"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:inputType="textEmailAddress" android:imeOptions="actionDone|flagNoExtractUi"
android:imeOptions="actionDone|flagNoExtractUi"/> android:inputType="textEmailAddress" />
</android.support.design.widget.TextInputLayout> </android.support.design.widget.TextInputLayout>
</LinearLayout> </LinearLayout>
</layout> </layout>

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?><!-- Copyright (C) 2006 The Android Open Source Project
<!-- Copyright (C) 2006 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -18,8 +17,9 @@
android:id="@android:id/text1" android:id="@android:id/text1"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.Conversations.Body1"
android:gravity="center_vertical" android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeightSmall"
android:paddingLeft="8dp" android:paddingLeft="8dp"
android:paddingRight="8dp" android:paddingRight="8dp"
android:minHeight="?android:attr/listPreferredItemHeightSmall" /> android:textAppearance="@style/TextAppearance.Conversations.Body1"
android:textColor="?attr/edit_text_color" />