allow skipping some entry screens if you have an existing account (Christian Schneppe)

This commit is contained in:
Arne 2022-01-23 16:40:41 +01:00
parent 3c8ade1a8b
commit fb3951c6ee
3 changed files with 42 additions and 0 deletions

View file

@ -330,6 +330,7 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
if (redirectInProgress.compareAndSet(false, true)) {
Intent intent = new Intent(this, EnterNameActivity.class);
intent.putExtra(EXTRA_ACCOUNT, mAccount.getJid().asBareJid().toString());
intent.putExtra("existing", mExisting);
startActivity(intent);
overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
finish();

View file

@ -19,6 +19,7 @@ public class EnterNameActivity extends XmppActivity implements XmppConnectionSer
private ActivityEnterNameBinding binding;
private Account account;
private boolean mExisting = false;
private AtomicBoolean setNick = new AtomicBoolean(false);
@Override
@ -27,6 +28,7 @@ public class EnterNameActivity extends XmppActivity implements XmppConnectionSer
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_enter_name);
setSupportActionBar((Toolbar) this.binding.toolbar);
this.binding.next.setOnClickListener(this::next);
this.binding.skip.setOnClickListener(this::skip);
updateNextButton();
this.setNick.set(savedInstanceState != null && savedInstanceState.getBoolean("set_nick", false));
}
@ -40,6 +42,18 @@ public class EnterNameActivity extends XmppActivity implements XmppConnectionSer
this.binding.next.setText(R.string.next);
}
}
@Override
protected void onStart() {
super.onStart();
final Intent intent = getIntent();
final int theme = findTheme();
if (this.mTheme != theme) {
recreate();
} else if (intent != null) {
boolean existing = intent.getBooleanExtra("existing", false);
this.mExisting = existing;
}
}
private void next(View view) {
FirstStartManager firstStartManager = new FirstStartManager(this);
@ -62,6 +76,23 @@ public class EnterNameActivity extends XmppActivity implements XmppConnectionSer
}
finish();
}
private void skip(View view) {
if (account != null) {
String name = this.binding.name.getText().toString().trim();
account.setDisplayName(name);
xmppConnectionService.publishDisplayName(account);
final Intent intent = new Intent(getApplicationContext(), StartConversationActivity.class);
if (xmppConnectionService != null && xmppConnectionService.getAccounts().size() == 1) {
intent.putExtra("init", true);
}
StartConversationActivity.addInviteUri(intent, getIntent());
intent.putExtra(EXTRA_ACCOUNT, account.getJid().asBareJid().toEscapedString());
startActivity(intent);
overridePendingTransition(R.animator.fade_in, R.animator.fade_out);
finish();
}
finish();
}
@Override
public void onSaveInstanceState(Bundle savedInstanceState) {

View file

@ -58,6 +58,16 @@
android:layout_alignParentBottom="true"
android:text="@string/next"
android:textColor="?attr/colorAccent" />
<Button
android:id="@+id/skip"
style="@style/Widget.Conversations.Button.Borderless"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:text="@string/skip"
android:textColor="?attr/colorAccent" />
</RelativeLayout>
</ScrollView>
</LinearLayout>