From e57bd477a9fd4665d3a648877685e6f535da6db4 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Thu, 9 Jan 2020 17:39:55 +0100 Subject: [PATCH] preselect proper account in create contact dialog after following invite --- .../conversations/ui/EditAccountActivity.java | 1 + .../ui/PublishProfilePictureActivity.java | 2 ++ .../ui/StartConversationActivity.java | 10 +++++----- src/main/res/layout/enter_jid_dialog.xml | 12 +++++------ src/main/res/layout/simple_list_item.xml | 20 +++++++++---------- 5 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java index 7a102bc98..9edd0293d 100644 --- a/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/EditAccountActivity.java @@ -435,6 +435,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat if (wasFirstAccount) { intent.putExtra("init", true); } + intent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().asBareJid().toEscapedString()); } else { intent = new Intent(getApplicationContext(), PublishProfilePictureActivity.class); intent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().asBareJid().toString()); diff --git a/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java b/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java index 022daa56a..8f91ffdc1 100644 --- a/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/PublishProfilePictureActivity.java @@ -55,6 +55,7 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC Intent intent = new Intent(getApplicationContext(), StartConversationActivity.class); StartConversationActivity.addInviteUri(intent, getIntent()); intent.putExtra("init", true); + intent.putExtra(EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString()); startActivity(intent); } Toast.makeText(PublishProfilePictureActivity.this, @@ -100,6 +101,7 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC intent.putExtra("init", true); } StartConversationActivity.addInviteUri(intent, getIntent()); + intent.putExtra(EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString()); startActivity(intent); } finish(); diff --git a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java index b57943fbc..4e6b8fe51 100644 --- a/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/StartConversationActivity.java @@ -499,7 +499,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne getString(R.string.add_contact), getString(R.string.add), prefilledJid, - null, + invite == null ? null : invite.account, invite == null || !invite.hasFingerprints(), true ); @@ -821,7 +821,8 @@ public class StartConversationActivity extends XmppActivity implements XmppConne protected boolean processViewIntent(@NonNull Intent intent) { final String inviteUri = intent.getStringExtra(EXTRA_INVITE_URI); if (inviteUri != null) { - Invite invite = new Invite(inviteUri); + final Invite invite = new Invite(inviteUri); + invite.account = intent.getStringExtra(EXTRA_ACCOUNT); if (invite.isJidValid()) { return invite.invite(); } @@ -836,7 +837,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne Uri uri = intent.getData(); if (uri != null) { 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); return invite.invite(); } else { @@ -857,8 +858,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne showJoinConferenceDialog(invite.getJid().asBareJid().toString()); return false; } - } else if (contacts.size() == 0) { //TODO or init mode - //TODO if init mode; prefill dialog with account jid + } else if (contacts.size() == 0) { showCreateContactDialog(invite.getJid().toString(), invite); return false; } else if (contacts.size() == 1) { diff --git a/src/main/res/layout/enter_jid_dialog.xml b/src/main/res/layout/enter_jid_dialog.xml index 1c20ef722..b7b7a310f 100644 --- a/src/main/res/layout/enter_jid_dialog.xml +++ b/src/main/res/layout/enter_jid_dialog.xml @@ -1,21 +1,21 @@ + xmlns:app="http://schemas.android.com/apk/res-auto"> + android:paddingBottom="?attr/dialog_vertical_padding"> + android:text="@string/your_account" /> + android:imeOptions="actionDone|flagNoExtractUi" + android:inputType="textEmailAddress" /> diff --git a/src/main/res/layout/simple_list_item.xml b/src/main/res/layout/simple_list_item.xml index 388505d20..2944632e8 100644 --- a/src/main/res/layout/simple_list_item.xml +++ b/src/main/res/layout/simple_list_item.xml @@ -1,5 +1,4 @@ - - + android:id="@android:id/text1" + android:layout_width="match_parent" + android:layout_height="wrap_content" + android:gravity="center_vertical" + android:minHeight="?android:attr/listPreferredItemHeightSmall" + android:paddingLeft="8dp" + android:paddingRight="8dp" + android:textAppearance="@style/TextAppearance.Conversations.Body1" + android:textColor="?attr/edit_text_color" />