refactor StartConversationsActivity
This commit is contained in:
parent
cc6a001ac2
commit
0be41e0aab
|
@ -100,15 +100,10 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onMenuItemActionExpand(MenuItem item) {
|
public boolean onMenuItemActionExpand(MenuItem item) {
|
||||||
mSearchEditText.post(new Runnable() {
|
mSearchEditText.post(() -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
mSearchEditText.requestFocus();
|
mSearchEditText.requestFocus();
|
||||||
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
imm.showSoftInput(mSearchEditText,
|
imm.showSoftInput(mSearchEditText, InputMethodManager.SHOW_IMPLICIT);
|
||||||
InputMethodManager.SHOW_IMPLICIT);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -204,23 +199,15 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
private UiCallback<Conversation> mAdhocConferenceCallback = new UiCallback<Conversation>() {
|
private UiCallback<Conversation> mAdhocConferenceCallback = new UiCallback<Conversation>() {
|
||||||
@Override
|
@Override
|
||||||
public void success(final Conversation conversation) {
|
public void success(final Conversation conversation) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(() -> {
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
hideToast();
|
hideToast();
|
||||||
switchToConversation(conversation);
|
switchToConversation(conversation);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void error(final int errorCode, Conversation object) {
|
public void error(final int errorCode, Conversation object) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(() -> replaceToast(getString(errorCode)));
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
replaceToast(getString(errorCode));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -422,9 +409,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
prefilledJid, null, invite == null || !invite.hasFingerprints()
|
prefilledJid, null, invite == null || !invite.hasFingerprints()
|
||||||
);
|
);
|
||||||
|
|
||||||
dialog.setOnEnterJidDialogPositiveListener(new EnterJidDialog.OnEnterJidDialogPositiveListener() {
|
dialog.setOnEnterJidDialogPositiveListener((accountJid, contactJid) -> {
|
||||||
@Override
|
|
||||||
public boolean onEnterJidDialogPositive(Jid accountJid, Jid contactJid) throws EnterJidDialog.JidError {
|
|
||||||
if (!xmppConnectionServiceBound) {
|
if (!xmppConnectionServiceBound) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -445,7 +430,6 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
switchToConversation(contact, invite == null ? null : invite.getBody());
|
switchToConversation(contact, invite == null ? null : invite.getBody());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
mCurrentDialog = dialog.show();
|
mCurrentDialog = dialog.show();
|
||||||
|
@ -589,7 +573,7 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
} else {
|
} else {
|
||||||
ArrayAdapter<String> adapter = new ArrayAdapter<>(context,
|
ArrayAdapter<String> adapter = new ArrayAdapter<>(context,
|
||||||
R.layout.simple_list_item,
|
R.layout.simple_list_item,
|
||||||
Arrays.asList(new String[]{context.getString(R.string.no_accounts)}));
|
Arrays.asList(context.getString(R.string.no_accounts)));
|
||||||
adapter.setDropDownViewResource(R.layout.simple_list_item);
|
adapter.setDropDownViewResource(R.layout.simple_list_item);
|
||||||
spinner.setAdapter(adapter);
|
spinner.setAdapter(adapter);
|
||||||
spinner.setEnabled(false);
|
spinner.setEnabled(false);
|
||||||
|
@ -877,29 +861,16 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
}
|
}
|
||||||
warning.setText(spannable);
|
warning.setText(spannable);
|
||||||
builder.setView(view);
|
builder.setView(view);
|
||||||
builder.setPositiveButton(R.string.confirm, new OnClickListener() {
|
builder.setPositiveButton(R.string.confirm, (dialog, which) -> {
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
if (isTrustedSource.isChecked() && invite.hasFingerprints()) {
|
if (isTrustedSource.isChecked() && invite.hasFingerprints()) {
|
||||||
xmppConnectionService.verifyFingerprints(contact, invite.getFingerprints());
|
xmppConnectionService.verifyFingerprints(contact, invite.getFingerprints());
|
||||||
}
|
}
|
||||||
switchToConversation(contact, invite.getBody());
|
switchToConversation(contact, invite.getBody());
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(R.string.cancel, new OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
|
||||||
StartConversationActivity.this.finish();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
builder.setNegativeButton(R.string.cancel, (dialog, which) -> StartConversationActivity.this.finish());
|
||||||
AlertDialog dialog = builder.create();
|
AlertDialog dialog = builder.create();
|
||||||
dialog.setCanceledOnTouchOutside(false);
|
dialog.setCanceledOnTouchOutside(false);
|
||||||
dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
|
dialog.setOnCancelListener(dialog1 -> StartConversationActivity.this.finish());
|
||||||
@Override
|
|
||||||
public void onCancel(DialogInterface dialog) {
|
|
||||||
StartConversationActivity.this.finish();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue