channel search result long press to show join dialog
This commit is contained in:
parent
92e27a3649
commit
6c5b71440f
|
@ -2,8 +2,10 @@ package eu.siacs.conversations.ui;
|
||||||
|
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.databinding.DataBindingUtil;
|
import android.databinding.DataBindingUtil;
|
||||||
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
|
@ -203,6 +205,13 @@ public class ChannelDiscoveryActivity extends XmppActivity implements MenuItem.O
|
||||||
case R.id.share_with:
|
case R.id.share_with:
|
||||||
StartConversationActivity.shareAsChannel(this, room.address);
|
StartConversationActivity.shareAsChannel(this, room.address);
|
||||||
return true;
|
return true;
|
||||||
|
case R.id.open_join_dialog:
|
||||||
|
final Intent intent = new Intent(this, StartConversationActivity.class);
|
||||||
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
|
intent.putExtra("force_dialog", true);
|
||||||
|
intent.setData(Uri.parse(String.format("xmpp:%s?join", room.address)));
|
||||||
|
startActivity(intent);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -4,6 +4,7 @@ import android.app.Activity;
|
||||||
import android.app.Dialog;
|
import android.app.Dialog;
|
||||||
import android.databinding.DataBindingUtil;
|
import android.databinding.DataBindingUtil;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.design.widget.TextInputLayout;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
|
@ -65,9 +66,9 @@ public class JoinConferenceDialog extends DialogFragment implements OnBackendCon
|
||||||
builder.setNegativeButton(R.string.cancel, null);
|
builder.setNegativeButton(R.string.cancel, null);
|
||||||
AlertDialog dialog = builder.create();
|
AlertDialog dialog = builder.create();
|
||||||
dialog.show();
|
dialog.show();
|
||||||
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(view -> mListener.onJoinDialogPositiveClick(dialog, binding.account, binding.jid, binding.bookmark.isChecked()));
|
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(view -> mListener.onJoinDialogPositiveClick(dialog, binding.account, binding.accountJidLayout, binding.jid, binding.bookmark.isChecked()));
|
||||||
binding.jid.setOnEditorActionListener((v, actionId, event) -> {
|
binding.jid.setOnEditorActionListener((v, actionId, event) -> {
|
||||||
mListener.onJoinDialogPositiveClick(dialog, binding.account, binding.jid, binding.bookmark.isChecked());
|
mListener.onJoinDialogPositiveClick(dialog, binding.account, binding.accountJidLayout, binding.jid, binding.bookmark.isChecked());
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
return dialog;
|
return dialog;
|
||||||
|
@ -116,6 +117,6 @@ public class JoinConferenceDialog extends DialogFragment implements OnBackendCon
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface JoinConferenceDialogListener {
|
public interface JoinConferenceDialogListener {
|
||||||
void onJoinDialogPositiveClick(Dialog dialog, Spinner spinner, AutoCompleteTextView jid, boolean isBookmarkChecked);
|
void onJoinDialogPositiveClick(Dialog dialog, Spinner spinner, TextInputLayout jidLayout, AutoCompleteTextView jid, boolean isBookmarkChecked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
import android.support.design.widget.TextInputLayout;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v4.app.FragmentManager;
|
import android.support.v4.app.FragmentManager;
|
||||||
import android.support.v4.app.FragmentTransaction;
|
import android.support.v4.app.FragmentTransaction;
|
||||||
|
@ -837,6 +838,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
||||||
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("account");
|
||||||
|
invite.forceDialog = intent.getBooleanExtra("force_dialog", false);
|
||||||
return invite.invite();
|
return invite.invite();
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -849,7 +851,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
||||||
List<Contact> contacts = xmppConnectionService.findContacts(invite.getJid(), invite.account);
|
List<Contact> contacts = xmppConnectionService.findContacts(invite.getJid(), invite.account);
|
||||||
if (invite.isAction(XmppUri.ACTION_JOIN)) {
|
if (invite.isAction(XmppUri.ACTION_JOIN)) {
|
||||||
Conversation muc = xmppConnectionService.findFirstMuc(invite.getJid());
|
Conversation muc = xmppConnectionService.findFirstMuc(invite.getJid());
|
||||||
if (muc != null) {
|
if (muc != null && !invite.forceDialog) {
|
||||||
switchToConversationDoNotAppend(muc, invite.getBody());
|
switchToConversationDoNotAppend(muc, invite.getBody());
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1004,7 +1006,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onJoinDialogPositiveClick(Dialog dialog, Spinner spinner, AutoCompleteTextView jid, boolean isBookmarkChecked) {
|
public void onJoinDialogPositiveClick(Dialog dialog, Spinner spinner, TextInputLayout layout, AutoCompleteTextView jid, boolean isBookmarkChecked) {
|
||||||
if (!xmppConnectionServiceBound) {
|
if (!xmppConnectionServiceBound) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1012,17 +1014,26 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
||||||
if (account == null) {
|
if (account == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Jid conferenceJid;
|
final String input = jid.getText().toString();
|
||||||
|
Jid conferenceJid;
|
||||||
try {
|
try {
|
||||||
conferenceJid = Jid.of(jid.getText().toString());
|
conferenceJid = Jid.of(input);
|
||||||
} catch (final IllegalArgumentException e) {
|
} catch (final IllegalArgumentException e) {
|
||||||
jid.setError(getString(R.string.invalid_jid));
|
final XmppUri xmppUri = new XmppUri(input);
|
||||||
|
if (xmppUri.isJidValid() && xmppUri.isAction(XmppUri.ACTION_JOIN)) {
|
||||||
|
final Editable editable = jid.getEditableText();
|
||||||
|
editable.clear();
|
||||||
|
editable.append(xmppUri.getJid().toEscapedString());
|
||||||
|
conferenceJid = xmppUri.getJid();
|
||||||
|
} else {
|
||||||
|
layout.setError(getString(R.string.invalid_jid));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (isBookmarkChecked) {
|
if (isBookmarkChecked) {
|
||||||
if (account.hasBookmarkFor(conferenceJid)) {
|
if (account.hasBookmarkFor(conferenceJid)) {
|
||||||
jid.setError(getString(R.string.bookmark_already_exists));
|
layout.setError(getString(R.string.bookmark_already_exists));
|
||||||
} else {
|
} else {
|
||||||
final Bookmark bookmark = new Bookmark(account, conferenceJid.asBareJid());
|
final Bookmark bookmark = new Bookmark(account, conferenceJid.asBareJid());
|
||||||
bookmark.setAutojoin(getBooleanPreference("autojoin", R.bool.autojoin));
|
bookmark.setAutojoin(getBooleanPreference("autojoin", R.bool.autojoin));
|
||||||
|
@ -1278,6 +1289,8 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
||||||
|
|
||||||
public String account;
|
public String account;
|
||||||
|
|
||||||
|
public boolean forceDialog = false;
|
||||||
|
|
||||||
public Invite(final Uri uri) {
|
public Invite(final Uri uri) {
|
||||||
super(uri);
|
super(uri);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,4 +3,7 @@
|
||||||
<item
|
<item
|
||||||
android:id="@+id/share_with"
|
android:id="@+id/share_with"
|
||||||
android:title="@string/share_uri_with" />
|
android:title="@string/share_uri_with" />
|
||||||
|
<item
|
||||||
|
android:id="@+id/open_join_dialog"
|
||||||
|
android:title="@string/open_join_dialog"/>
|
||||||
</menu>
|
</menu>
|
|
@ -876,4 +876,5 @@
|
||||||
<string name="account_already_setup">This account has already been setup</string>
|
<string name="account_already_setup">This account has already been setup</string>
|
||||||
<string name="please_enter_password">Please enter the password for this account</string>
|
<string name="please_enter_password">Please enter the password for this account</string>
|
||||||
<string name="unable_to_perform_this_action">Unable to perform this action</string>
|
<string name="unable_to_perform_this_action">Unable to perform this action</string>
|
||||||
|
<string name="open_join_dialog">Join public channel…</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in New Issue