suggest previously assigned nick in Enter Name Activity
This commit is contained in:
parent
5012ff3545
commit
e335c59600
|
@ -6,7 +6,6 @@ import android.util.Pair;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -20,7 +19,6 @@ import eu.siacs.conversations.crypto.axolotl.AxolotlService;
|
||||||
import eu.siacs.conversations.crypto.axolotl.NotEncryptedForThisDeviceException;
|
import eu.siacs.conversations.crypto.axolotl.NotEncryptedForThisDeviceException;
|
||||||
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage;
|
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
import eu.siacs.conversations.entities.Bookmark;
|
|
||||||
import eu.siacs.conversations.entities.Contact;
|
import eu.siacs.conversations.entities.Contact;
|
||||||
import eu.siacs.conversations.entities.Conversation;
|
import eu.siacs.conversations.entities.Conversation;
|
||||||
import eu.siacs.conversations.entities.Message;
|
import eu.siacs.conversations.entities.Message;
|
||||||
|
|
|
@ -724,6 +724,7 @@ public abstract class XmppActivity extends ActionBarActivity {
|
||||||
SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText);
|
SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText);
|
||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}));
|
}));
|
||||||
|
dialog.setCanceledOnTouchOutside(false);
|
||||||
dialog.setOnDismissListener(dialog1 -> {
|
dialog.setOnDismissListener(dialog1 -> {
|
||||||
SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText);
|
SoftKeyboardUtils.hideSoftKeyboard(binding.inputEditText);
|
||||||
});
|
});
|
||||||
|
@ -776,10 +777,6 @@ public abstract class XmppActivity extends ActionBarActivity {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean neverCompressPictures() {
|
|
||||||
return getPreferences().getString("picture_compression", getResources().getString(R.string.picture_compression)).equals("never");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected boolean manuallyChangePresence() {
|
protected boolean manuallyChangePresence() {
|
||||||
return getBooleanPreference(SettingsActivity.MANUALLY_CHANGE_PRESENCE, R.bool.manually_change_presence);
|
return getBooleanPreference(SettingsActivity.MANUALLY_CHANGE_PRESENCE, R.bool.manually_change_presence);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,23 +6,29 @@ import android.os.Bundle;
|
||||||
import android.support.v7.widget.Toolbar;
|
import android.support.v7.widget.Toolbar;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import eu.siacs.conversations.R;
|
import eu.siacs.conversations.R;
|
||||||
import eu.siacs.conversations.databinding.ActivityEnterNameBinding;
|
import eu.siacs.conversations.databinding.ActivityEnterNameBinding;
|
||||||
import eu.siacs.conversations.entities.Account;
|
import eu.siacs.conversations.entities.Account;
|
||||||
|
import eu.siacs.conversations.services.XmppConnectionService;
|
||||||
import eu.siacs.conversations.utils.AccountUtils;
|
import eu.siacs.conversations.utils.AccountUtils;
|
||||||
|
|
||||||
public class EnterNameActivity extends XmppActivity {
|
public class EnterNameActivity extends XmppActivity implements XmppConnectionService.OnAccountUpdate {
|
||||||
|
|
||||||
private ActivityEnterNameBinding binding;
|
private ActivityEnterNameBinding binding;
|
||||||
|
|
||||||
private Account account;
|
private Account account;
|
||||||
|
|
||||||
|
private AtomicBoolean setNick = new AtomicBoolean(false);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(final Bundle savedInstanceState) {
|
protected void onCreate(final Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_enter_name);
|
this.binding = DataBindingUtil.setContentView(this, R.layout.activity_enter_name);
|
||||||
setSupportActionBar((Toolbar) this.binding.toolbar);
|
setSupportActionBar((Toolbar) this.binding.toolbar);
|
||||||
this.binding.next.setOnClickListener(this::next);
|
this.binding.next.setOnClickListener(this::next);
|
||||||
|
this.setNick.set(savedInstanceState != null && savedInstanceState.getBoolean("set_nick",false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void next(View view) {
|
private void next(View view) {
|
||||||
|
@ -43,12 +49,33 @@ public class EnterNameActivity extends XmppActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void refreshUiReal() {
|
public void onSaveInstanceState(Bundle savedInstanceState) {
|
||||||
|
savedInstanceState.putBoolean("set_nick", this.setNick.get());
|
||||||
|
super.onSaveInstanceState(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void refreshUiReal() {
|
||||||
|
checkSuggestPreviousNick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void onBackendConnected() {
|
void onBackendConnected() {
|
||||||
this.account = AccountUtils.getFirst(xmppConnectionService);
|
this.account = AccountUtils.getFirst(xmppConnectionService);
|
||||||
|
checkSuggestPreviousNick();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkSuggestPreviousNick() {
|
||||||
|
String displayName = this.account == null ? null : this.account.getDisplayName();
|
||||||
|
if (displayName != null) {
|
||||||
|
if (setNick.compareAndSet(false, true) && this.binding.name.getText().length() == 0) {
|
||||||
|
this.binding.name.getText().append(displayName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onAccountUpdate() {
|
||||||
|
refreshUi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue