transport invitee from welcome activity to start conversations activity
This commit is contained in:
parent
c58fcb1dc6
commit
21615477ed
|
@ -312,7 +312,9 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
&& mAccount.isOptionSet(Account.OPTION_REGISTER)
|
&& mAccount.isOptionSet(Account.OPTION_REGISTER)
|
||||||
&& xmppConnectionService.getAccounts().size() == 1) {
|
&& xmppConnectionService.getAccounts().size() == 1) {
|
||||||
xmppConnectionService.deleteAccount(mAccount);
|
xmppConnectionService.deleteAccount(mAccount);
|
||||||
startActivity(new Intent(EditAccountActivity.this, WelcomeActivity.class));
|
Intent intent = new Intent(EditAccountActivity.this, WelcomeActivity.class);
|
||||||
|
WelcomeActivity.addInvitee(intent, getIntent());
|
||||||
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,10 +369,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
};
|
};
|
||||||
|
|
||||||
protected void finishInitialSetup(final Avatar avatar) {
|
protected void finishInitialSetup(final Avatar avatar) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(() -> {
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
hideKeyboard();
|
hideKeyboard();
|
||||||
final Intent intent;
|
final Intent intent;
|
||||||
final XmppConnection connection = mAccount.getXmppConnection();
|
final XmppConnection connection = mAccount.getXmppConnection();
|
||||||
|
@ -388,9 +387,9 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
|
||||||
if (wasFirstAccount) {
|
if (wasFirstAccount) {
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
}
|
}
|
||||||
|
WelcomeActivity.addInvitee(intent, getIntent());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
finish();
|
finish();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,13 +54,11 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher {
|
||||||
}
|
}
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.magic_create);
|
setContentView(R.layout.magic_create);
|
||||||
mFullJidDisplay = (TextView) findViewById(R.id.full_jid);
|
mFullJidDisplay = findViewById(R.id.full_jid);
|
||||||
mUsername = (EditText) findViewById(R.id.username);
|
mUsername = findViewById(R.id.username);
|
||||||
mRandom = new SecureRandom();
|
mRandom = new SecureRandom();
|
||||||
Button next = (Button) findViewById(R.id.create_account);
|
Button next = findViewById(R.id.create_account);
|
||||||
next.setOnClickListener(new View.OnClickListener() {
|
next.setOnClickListener(v -> {
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
String username = mUsername.getText().toString();
|
String username = mUsername.getText().toString();
|
||||||
if (username.contains("@") || username.length() < 3) {
|
if (username.contains("@") || username.length() < 3) {
|
||||||
mUsername.setError(getString(R.string.invalid_username));
|
mUsername.setError(getString(R.string.invalid_username));
|
||||||
|
@ -82,20 +80,20 @@ public class MagicCreateActivity extends XmppActivity implements TextWatcher {
|
||||||
intent.putExtra("init", true);
|
intent.putExtra("init", true);
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
Toast.makeText(MagicCreateActivity.this, R.string.secure_password_generated, Toast.LENGTH_SHORT).show();
|
Toast.makeText(MagicCreateActivity.this, R.string.secure_password_generated, Toast.LENGTH_SHORT).show();
|
||||||
|
WelcomeActivity.addInvitee(intent, getIntent());
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
} catch (InvalidJidException e) {
|
} catch (InvalidJidException e) {
|
||||||
mUsername.setError(getString(R.string.invalid_username));
|
mUsername.setError(getString(R.string.invalid_username));
|
||||||
mUsername.requestFocus();
|
mUsername.requestFocus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
});
|
||||||
mUsername.addTextChangedListener(this);
|
mUsername.addTextChangedListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String createPassword() {
|
private String createPassword() {
|
||||||
StringBuilder builder = new StringBuilder(PW_LENGTH);
|
StringBuilder builder = new StringBuilder(PW_LENGTH);
|
||||||
for(int i = 0; i < PW_LENGTH; ++i) {
|
for (int i = 0; i < PW_LENGTH; ++i) {
|
||||||
builder.append(CHARS.charAt(mRandom.nextInt(CHARS.length() - 1)));
|
builder.append(CHARS.charAt(mRandom.nextInt(CHARS.length() - 1)));
|
||||||
}
|
}
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
|
|
|
@ -61,8 +61,8 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC
|
||||||
public void success(Avatar object) {
|
public void success(Avatar object) {
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
if (mInitialAccountSetup) {
|
if (mInitialAccountSetup) {
|
||||||
Intent intent = new Intent(getApplicationContext(),
|
Intent intent = new Intent(getApplicationContext(), StartConversationActivity.class);
|
||||||
StartConversationActivity.class);
|
WelcomeActivity.addInvitee(intent, getIntent());
|
||||||
intent.putExtra("init", true);
|
intent.putExtra("init", true);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
}
|
||||||
|
@ -108,9 +108,9 @@ public class PublishProfilePictureActivity extends XmppActivity implements XmppC
|
||||||
});
|
});
|
||||||
this.cancelButton.setOnClickListener(v -> {
|
this.cancelButton.setOnClickListener(v -> {
|
||||||
if (mInitialAccountSetup) {
|
if (mInitialAccountSetup) {
|
||||||
Intent intent = new Intent(getApplicationContext(),
|
Intent intent = new Intent(getApplicationContext(), StartConversationActivity.class);
|
||||||
StartConversationActivity.class);
|
|
||||||
if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() == 1) {
|
if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() == 1) {
|
||||||
|
WelcomeActivity.addInvitee(intent, getIntent());
|
||||||
intent.putExtra("init", true);
|
intent.putExtra("init", true);
|
||||||
}
|
}
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
|
|
@ -268,8 +268,11 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
if (this.mTheme != theme) {
|
if (this.mTheme != theme) {
|
||||||
recreate();
|
recreate();
|
||||||
} else {
|
} else {
|
||||||
|
Intent i = getIntent();
|
||||||
|
if (i == null || !i.hasExtra(WelcomeActivity.EXTRA_INVITEE)) {
|
||||||
askForContactsPermissions();
|
askForContactsPermissions();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
mConferenceAdapter.refreshSettings();
|
mConferenceAdapter.refreshSettings();
|
||||||
mContactsAdapter.refreshSettings();
|
mContactsAdapter.refreshSettings();
|
||||||
}
|
}
|
||||||
|
@ -786,7 +789,17 @@ public class StartConversationActivity extends XmppActivity implements OnRosterU
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean handleIntent(Intent intent) {
|
protected boolean handleIntent(Intent intent) {
|
||||||
if (intent == null || intent.getAction() == null) {
|
if (intent == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final String invitee = intent.getStringExtra(WelcomeActivity.EXTRA_INVITEE);
|
||||||
|
if (invitee != null) {
|
||||||
|
Invite invite = new Invite("xmpp:" + invitee);
|
||||||
|
if (invite.isJidValid()) {
|
||||||
|
return invite.invite();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (intent.getAction() == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (intent.getAction()) {
|
switch (intent.getAction()) {
|
||||||
|
|
|
@ -35,6 +35,7 @@ public class UriHandlerActivity extends Activity {
|
||||||
|
|
||||||
if (accounts.size() == 0) {
|
if (accounts.size() == 0) {
|
||||||
intent = new Intent(getApplicationContext(), WelcomeActivity.class);
|
intent = new Intent(getApplicationContext(), WelcomeActivity.class);
|
||||||
|
WelcomeActivity.addInvitee(intent, xmppUri);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,16 +4,18 @@ import android.app.ActionBar;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
|
import eu.siacs.conversations.utils.XmppUri;
|
||||||
|
|
||||||
public class WelcomeActivity extends XmppActivity {
|
public class WelcomeActivity extends XmppActivity {
|
||||||
|
|
||||||
|
public static final String EXTRA_INVITEE = "eu.siacs.conversations.invitee";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void refreshUiReal() {
|
protected void refreshUiReal() {
|
||||||
|
|
||||||
|
@ -45,31 +47,43 @@ public class WelcomeActivity extends XmppActivity {
|
||||||
ab.setDisplayShowHomeEnabled(false);
|
ab.setDisplayShowHomeEnabled(false);
|
||||||
ab.setDisplayHomeAsUpEnabled(false);
|
ab.setDisplayHomeAsUpEnabled(false);
|
||||||
}
|
}
|
||||||
final Button createAccount = (Button) findViewById(R.id.create_account);
|
final Button createAccount = findViewById(R.id.create_account);
|
||||||
createAccount.setOnClickListener(new View.OnClickListener() {
|
createAccount.setOnClickListener(v -> {
|
||||||
@Override
|
final Intent intent = new Intent(WelcomeActivity.this, MagicCreateActivity.class);
|
||||||
public void onClick(View v) {
|
|
||||||
Intent intent = new Intent(WelcomeActivity.this, MagicCreateActivity.class);
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||||
|
addInvitee(intent);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
final Button useOwnProvider = (Button) findViewById(R.id.use_own_provider);
|
final Button useOwnProvider = findViewById(R.id.use_own_provider);
|
||||||
useOwnProvider.setOnClickListener(new View.OnClickListener() {
|
useOwnProvider.setOnClickListener(v -> {
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
List<Account> accounts = xmppConnectionService.getAccounts();
|
List<Account> accounts = xmppConnectionService.getAccounts();
|
||||||
Intent intent = new Intent(WelcomeActivity.this, EditAccountActivity.class);
|
Intent intent = new Intent(WelcomeActivity.this, EditAccountActivity.class);
|
||||||
if (accounts.size() == 1) {
|
if (accounts.size() == 1) {
|
||||||
intent.putExtra("jid",accounts.get(0).getJid().toBareJid().toString());
|
intent.putExtra("jid", accounts.get(0).getJid().toBareJid().toString());
|
||||||
intent.putExtra("init",true);
|
intent.putExtra("init", true);
|
||||||
} else if (accounts.size() >= 1) {
|
} else if (accounts.size() >= 1) {
|
||||||
intent = new Intent(WelcomeActivity.this, ManageAccountActivity.class);
|
intent = new Intent(WelcomeActivity.this, ManageAccountActivity.class);
|
||||||
}
|
}
|
||||||
|
addInvitee(intent);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addInvitee(Intent intent) {
|
||||||
|
addInvitee(intent, getIntent());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addInvitee(Intent intent, XmppUri uri) {
|
||||||
|
if (uri.isJidValid()) {
|
||||||
|
intent.putExtra(EXTRA_INVITEE, uri.getJid().toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addInvitee(Intent to, Intent from) {
|
||||||
|
if (from != null && from.hasExtra(EXTRA_INVITEE)) {
|
||||||
|
to.putExtra(EXTRA_INVITEE, from.getStringExtra(EXTRA_INVITEE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue