2016-04-19 16:03:24 +00:00
|
|
|
package eu.siacs.conversations.ui;
|
|
|
|
|
|
|
|
import android.content.Intent;
|
2016-08-26 14:05:38 +00:00
|
|
|
import android.content.pm.ActivityInfo;
|
2016-04-19 16:03:24 +00:00
|
|
|
import android.os.Bundle;
|
2018-02-16 11:30:46 +00:00
|
|
|
import android.support.v7.app.ActionBar;
|
|
|
|
import android.support.v7.app.AppCompatActivity;
|
2016-04-19 16:03:24 +00:00
|
|
|
import android.widget.Button;
|
|
|
|
|
2016-11-17 10:40:29 +00:00
|
|
|
import java.util.List;
|
|
|
|
|
2016-04-19 16:03:24 +00:00
|
|
|
import eu.siacs.conversations.R;
|
2016-11-17 10:40:29 +00:00
|
|
|
import eu.siacs.conversations.entities.Account;
|
2017-12-16 19:38:14 +00:00
|
|
|
import eu.siacs.conversations.utils.XmppUri;
|
2016-11-17 10:40:29 +00:00
|
|
|
|
|
|
|
public class WelcomeActivity extends XmppActivity {
|
|
|
|
|
2018-02-14 15:55:45 +00:00
|
|
|
public static final String EXTRA_INVITE_URI = "eu.siacs.conversations.invite_uri";
|
2017-12-16 19:38:14 +00:00
|
|
|
|
2016-11-17 10:40:29 +00:00
|
|
|
@Override
|
|
|
|
protected void refreshUiReal() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
void onBackendConnected() {
|
2016-04-19 16:03:24 +00:00
|
|
|
|
2016-11-17 10:40:29 +00:00
|
|
|
}
|
2016-04-19 16:03:24 +00:00
|
|
|
|
2017-06-30 19:22:35 +00:00
|
|
|
@Override
|
|
|
|
public void onStart() {
|
|
|
|
super.onStart();
|
|
|
|
final int theme = findTheme();
|
|
|
|
if (this.mTheme != theme) {
|
|
|
|
recreate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-16 20:05:56 +00:00
|
|
|
@Override
|
|
|
|
public void onNewIntent(Intent intent) {
|
|
|
|
if (intent != null) {
|
|
|
|
setIntent(intent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-19 16:03:24 +00:00
|
|
|
@Override
|
|
|
|
protected void onCreate(final Bundle savedInstanceState) {
|
2016-08-26 14:05:38 +00:00
|
|
|
if (getResources().getBoolean(R.bool.portrait_only)) {
|
|
|
|
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
|
|
|
}
|
2016-11-17 10:40:29 +00:00
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
setContentView(R.layout.welcome);
|
2018-03-18 08:30:22 +00:00
|
|
|
setSupportActionBar(findViewById(R.id.toolbar));
|
2018-02-16 11:30:46 +00:00
|
|
|
final ActionBar ab = getSupportActionBar();
|
2016-10-08 16:24:20 +00:00
|
|
|
if (ab != null) {
|
|
|
|
ab.setDisplayShowHomeEnabled(false);
|
|
|
|
ab.setDisplayHomeAsUpEnabled(false);
|
|
|
|
}
|
2017-12-16 19:38:14 +00:00
|
|
|
final Button createAccount = findViewById(R.id.create_account);
|
|
|
|
createAccount.setOnClickListener(v -> {
|
|
|
|
final Intent intent = new Intent(WelcomeActivity.this, MagicCreateActivity.class);
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
2018-02-14 15:55:45 +00:00
|
|
|
addInviteUri(intent);
|
2017-12-16 19:38:14 +00:00
|
|
|
startActivity(intent);
|
2016-04-19 16:03:24 +00:00
|
|
|
});
|
2017-12-16 19:38:14 +00:00
|
|
|
final Button useOwnProvider = findViewById(R.id.use_own_provider);
|
|
|
|
useOwnProvider.setOnClickListener(v -> {
|
|
|
|
List<Account> accounts = xmppConnectionService.getAccounts();
|
|
|
|
Intent intent = new Intent(WelcomeActivity.this, EditAccountActivity.class);
|
|
|
|
if (accounts.size() == 1) {
|
2018-03-05 17:30:40 +00:00
|
|
|
intent.putExtra("jid", accounts.get(0).getJid().asBareJid().toString());
|
2017-12-16 19:38:14 +00:00
|
|
|
intent.putExtra("init", true);
|
|
|
|
} else if (accounts.size() >= 1) {
|
|
|
|
intent = new Intent(WelcomeActivity.this, ManageAccountActivity.class);
|
2016-04-19 16:03:24 +00:00
|
|
|
}
|
2018-02-14 15:55:45 +00:00
|
|
|
addInviteUri(intent);
|
2017-12-16 19:38:14 +00:00
|
|
|
startActivity(intent);
|
2016-04-19 16:03:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-02-14 15:55:45 +00:00
|
|
|
public void addInviteUri(Intent intent) {
|
|
|
|
addInviteUri(intent, getIntent());
|
2017-12-16 19:38:14 +00:00
|
|
|
}
|
|
|
|
|
2018-02-14 15:55:45 +00:00
|
|
|
public static void addInviteUri(Intent intent, XmppUri uri) {
|
2017-12-16 19:38:14 +00:00
|
|
|
if (uri.isJidValid()) {
|
2018-02-14 15:55:45 +00:00
|
|
|
intent.putExtra(EXTRA_INVITE_URI, uri.toString());
|
2017-12-16 19:38:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-14 15:55:45 +00:00
|
|
|
public static void addInviteUri(Intent to, Intent from) {
|
|
|
|
if (from != null && from.hasExtra(EXTRA_INVITE_URI)) {
|
|
|
|
to.putExtra(EXTRA_INVITE_URI, from.getStringExtra(EXTRA_INVITE_URI));
|
2017-12-16 19:38:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-16 11:30:46 +00:00
|
|
|
public static void launch(AppCompatActivity activity) {
|
2018-02-10 09:45:33 +00:00
|
|
|
Intent intent = new Intent(activity, WelcomeActivity.class);
|
2018-02-24 19:19:35 +00:00
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
2018-02-10 09:45:33 +00:00
|
|
|
activity.startActivity(intent);
|
|
|
|
activity.overridePendingTransition(0,0);
|
|
|
|
}
|
|
|
|
|
2016-04-19 16:03:24 +00:00
|
|
|
}
|