channel search result long press to show join dialog
This commit is contained in:
parent
5aa83a0db4
commit
2565da03bb
5 changed files with 47 additions and 16 deletions
|
@ -2,10 +2,10 @@ package de.pixart.messenger.ui;
|
|||
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import android.text.Html;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.Menu;
|
||||
|
@ -15,6 +15,9 @@ import android.view.inputmethod.InputMethodManager;
|
|||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
@ -197,6 +200,13 @@ public class ChannelDiscoveryActivity extends XmppActivity implements MenuItem.O
|
|||
case R.id.share_with:
|
||||
StartConversationActivity.shareAsChannel(this, room.address);
|
||||
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;
|
||||
|
|
|
@ -4,15 +4,18 @@ import android.app.Activity;
|
|||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import android.os.Bundle;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import android.view.View;
|
||||
import android.widget.AutoCompleteTextView;
|
||||
import android.widget.Spinner;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
@ -74,9 +77,9 @@ public class JoinConferenceDialog extends DialogFragment implements OnBackendCon
|
|||
builder.setNegativeButton(R.string.cancel, null);
|
||||
AlertDialog dialog = builder.create();
|
||||
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) -> {
|
||||
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 dialog;
|
||||
|
@ -125,6 +128,6 @@ public class JoinConferenceDialog extends DialogFragment implements OnBackendCon
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
|
@ -48,6 +48,8 @@ import androidx.fragment.app.ListFragment;
|
|||
import androidx.viewpager.widget.PagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -820,6 +822,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
|||
if (uri != null) {
|
||||
Invite invite = new Invite(intent.getData(), intent.getBooleanExtra("scanned", false));
|
||||
invite.account = intent.getStringExtra("account");
|
||||
invite.forceDialog = intent.getBooleanExtra("force_dialog", false);
|
||||
return invite.invite();
|
||||
} else {
|
||||
return false;
|
||||
|
@ -832,7 +835,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
|||
List<Contact> contacts = xmppConnectionService.findContacts(invite.getJid(), invite.account);
|
||||
if (invite.isAction(XmppUri.ACTION_JOIN)) {
|
||||
Conversation muc = xmppConnectionService.findFirstMuc(invite.getJid());
|
||||
if (muc != null) {
|
||||
if (muc != null && !invite.forceDialog) {
|
||||
switchToConversationDoNotAppend(muc, invite.getBody());
|
||||
return true;
|
||||
} else {
|
||||
|
@ -985,7 +988,7 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
|||
}
|
||||
|
||||
@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) {
|
||||
return;
|
||||
}
|
||||
|
@ -993,17 +996,26 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
|||
if (account == null) {
|
||||
return;
|
||||
}
|
||||
final Jid conferenceJid;
|
||||
final String input = jid.getText().toString();
|
||||
Jid conferenceJid;
|
||||
try {
|
||||
conferenceJid = Jid.of(jid.getText().toString());
|
||||
conferenceJid = Jid.of(input);
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
|
||||
if (isBookmarkChecked) {
|
||||
if (account.hasBookmarkFor(conferenceJid)) {
|
||||
jid.setError(getString(R.string.bookmark_already_exists));
|
||||
layout.setError(getString(R.string.bookmark_already_exists));
|
||||
} else {
|
||||
final Bookmark bookmark = new Bookmark(account, conferenceJid.asBareJid());
|
||||
bookmark.setAutojoin(getBooleanPreference("autojoin", R.bool.autojoin));
|
||||
|
@ -1241,6 +1253,8 @@ public class StartConversationActivity extends XmppActivity implements XmppConne
|
|||
|
||||
public String account;
|
||||
|
||||
public boolean forceDialog = false;
|
||||
|
||||
public Invite(final Uri uri) {
|
||||
super(uri);
|
||||
}
|
||||
|
|
|
@ -3,4 +3,7 @@
|
|||
<item
|
||||
android:id="@+id/share_with"
|
||||
android:title="@string/share_uri_with" />
|
||||
<item
|
||||
android:id="@+id/open_join_dialog"
|
||||
android:title="@string/open_join_dialog" />
|
||||
</menu>
|
|
@ -964,4 +964,5 @@
|
|||
<string name="intro_whats_xmpp">What is XMPP / Jabber?</string>
|
||||
<string name="intro_desc_contacts_permissions">We will also ask you for granting permissions to read your address book, to read out Jabber-IDs from your contacts. We will never share, upload or copy any of your contacts.</string>
|
||||
<string name="intro_desc_account2">If you would like to create a new account, you have the choice between choosing a suggested server from the drop-down menu or use a custom one.</string>
|
||||
<string name="open_join_dialog">Join public channel…</string>
|
||||
</resources>
|
||||
|
|
Reference in a new issue