show own account if multi account is enabled

This commit is contained in:
Christian Schneppe 2018-03-20 22:04:46 +01:00
parent 76e10f17a6
commit f249b9bf33
7 changed files with 39 additions and 17 deletions

View file

@ -86,7 +86,7 @@ public class BlocklistActivity extends AbstractSearchableListItemActivity implem
EnterJidDialog dialog = new EnterJidDialog(
this, mKnownHosts, null,
getString(R.string.block_jabber_id), getString(R.string.block),
null, account.getJid().toBareJid().toString(), true
null, account.getJid().toBareJid().toString(), true, xmppConnectionService.multipleAccounts()
);
dialog.setOnEnterJidDialogPositiveListener(new EnterJidDialog.OnEnterJidDialogPositiveListener() {

View file

@ -207,7 +207,7 @@ public class ChooseContactActivity extends AbstractSearchableListItemActivity {
EnterJidDialog dialog = new EnterJidDialog(
this, mKnownHosts, mActivatedAccounts,
getString(R.string.enter_contact), getString(R.string.select),
null, getIntent().getStringExtra(EXTRA_ACCOUNT), true
null, getIntent().getStringExtra(EXTRA_ACCOUNT), true, xmppConnectionService.multipleAccounts()
);
dialog.setOnEnterJidDialogPositiveListener(new EnterJidDialog.OnEnterJidDialogPositiveListener() {

View file

@ -617,6 +617,11 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers
}
ConferenceName.setText(mConversation.getName());
mAccountJid.setText(getString(R.string.using_account, account));
if (xmppConnectionService.multipleAccounts()) {
mAccountJid.setVisibility(View.VISIBLE);
} else {
mAccountJid.setVisibility(View.GONE);
}
mYourPhoto.setImageBitmap(avatarService().get(mConversation.getAccount(), getPixel(48)));
setTitle(mConversation.getName());
mFullJid.setText(mConversation.getJid().toBareJid().toString());

View file

@ -530,6 +530,12 @@ public class ContactDetailsActivity extends OmemoActivity implements OnAccountUp
binding.detailsContactBadge.setImageBitmap(avatarService().get(contact, getPixel(Config.AVATAR_SIZE)));
binding.detailsContactBadge.setOnClickListener(this.onBadgeClick);
if (xmppConnectionService.multipleAccounts()) {
binding.detailsAccount.setVisibility(View.VISIBLE);
} else {
binding.detailsAccount.setVisibility(View.GONE);
}
binding.detailsContactKeys.removeAllViews();
boolean hasKeys = false;
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

View file

@ -1,8 +1,8 @@
package de.pixart.messenger.ui;
import android.support.v7.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ArrayAdapter;
@ -42,13 +42,14 @@ public class EnterJidDialog {
public EnterJidDialog(
final Context context, List<String> knownHosts, final List<String> activatedAccounts,
final String title, final String positiveButton,
final String prefilledJid, final String account, boolean allowEditJid
final String prefilledJid, final String account, boolean allowEditJid, boolean multipleAccounts
) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title);
View dialogView = LayoutInflater.from(context).inflate(R.layout.enter_jid_dialog, null);
final View dialogView = LayoutInflater.from(context).inflate(R.layout.enter_jid_dialog, null);
final TextView jabberIdDesc = dialogView.findViewById(R.id.jabber_id);
jabberIdDesc.setText(R.string.account_settings_jabber_id);
final TextView yourAccount = dialogView.findViewById(R.id.your_account);
final Spinner spinner = dialogView.findViewById(R.id.account);
final AutoCompleteTextView jid = dialogView.findViewById(R.id.jid);
jid.setAdapter(new KnownHostsAdapter(context, R.layout.simple_list_item, knownHosts));
@ -64,6 +65,14 @@ public class EnterJidDialog {
jid.setHint(R.string.account_settings_example_jabber_id);
if (multipleAccounts) {
yourAccount.setVisibility(View.VISIBLE);
spinner.setVisibility(View.VISIBLE);
} else {
yourAccount.setVisibility(View.GONE);
spinner.setVisibility(View.GONE);
}
if (account == null) {
StartConversationActivity.populateAccountSpinner(context, activatedAccounts, spinner);
} else {
@ -130,4 +139,6 @@ public class EnterJidDialog {
this.dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(this.dialogOnClick);
return this.dialog;
}
}

View file

@ -433,7 +433,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
EnterJidDialog dialog = new EnterJidDialog(
this, mKnownHosts, mActivatedAccounts,
getString(R.string.create_contact), getString(R.string.create),
prefilledJid, null, invite == null || !invite.hasFingerprints()
prefilledJid, null, invite == null || !invite.hasFingerprints(), xmppConnectionService.multipleAccounts()
);
dialog.setOnEnterJidDialogPositiveListener((accountJid, contactJid) -> {

View file

@ -105,6 +105,16 @@
android:textIsSelectable="true"
android:visibility="gone"
android:textAppearance="@style/TextAppearance.AppCompat.Title" />
<TextView
android:id="@+id/details_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="32dp"
android:text="@string/using_account"
android:visibility="gone"
android:textAppearance="@style/TextAppearance.AppCompat.Caption" />
</LinearLayout>
</android.support.v7.widget.CardView>
@ -248,16 +258,6 @@
android:textAppearance="@style/TextAppearance.AppCompat.Body1" />
</TableRow>
</TableLayout>
<TextView
android:id="@+id/details_account"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="32dp"
android:text="@string/using_account"
android:visibility="gone"
android:textAppearance="@style/TextAppearance.AppCompat.Caption" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>