mirror of
https://github.com/ChronosX88/Influence-P2P.git
synced 2024-11-22 15:22:18 +00:00
Fixed issue with usernames (when it's empty)
This commit is contained in:
parent
93a2271be6
commit
a5ef1569e6
@ -23,11 +23,20 @@ class SettingsPresenter(private val view: CoreContracts.ISettingsView) : CoreCon
|
|||||||
|
|
||||||
override fun updateUsername(username: String) {
|
override fun updateUsername(username: String) {
|
||||||
view.loadingScreen(true)
|
view.loadingScreen(true)
|
||||||
|
val editor: SharedPreferences.Editor = AppHelper.getPreferences().edit()
|
||||||
|
|
||||||
GlobalScope.launch {
|
GlobalScope.launch {
|
||||||
|
val oldUsername = AppHelper.getPreferences().getString("username", null)
|
||||||
|
if(username.equals("")) {
|
||||||
|
SettingsLogic.publishUsername(oldUsername, null)
|
||||||
|
editor.remove("username")
|
||||||
|
editor.apply()
|
||||||
|
AppHelper.updateUsername(null)
|
||||||
|
ObservableUtils.notifyUI(UIActions.USERNAME_AVAILABLE)
|
||||||
|
return@launch
|
||||||
|
}
|
||||||
if(!logic.checkUsernameExists(username)) {
|
if(!logic.checkUsernameExists(username)) {
|
||||||
// Save username in SharedPreferences
|
// Save username in SharedPreferences
|
||||||
val editor: SharedPreferences.Editor = AppHelper.getPreferences().edit()
|
|
||||||
val oldUsername = AppHelper.getPreferences().getString("username", null)
|
|
||||||
if(username.equals("")) {
|
if(username.equals("")) {
|
||||||
editor.remove("username")
|
editor.remove("username")
|
||||||
} else {
|
} else {
|
||||||
|
@ -68,6 +68,8 @@ public class SettingsFragment extends PreferenceFragmentCompat implements CoreCo
|
|||||||
LinearLayout.LayoutParams.MATCH_PARENT);
|
LinearLayout.LayoutParams.MATCH_PARENT);
|
||||||
input.setSingleLine();
|
input.setSingleLine();
|
||||||
input.setLayoutParams(lp);
|
input.setLayoutParams(lp);
|
||||||
|
input.setText(AppHelper.getPreferences().getString("username", null));
|
||||||
|
|
||||||
alertDialog.setView(input);
|
alertDialog.setView(input);
|
||||||
|
|
||||||
alertDialog.setPositiveButton(getContext().getString(R.string.ok), (dialog, which) -> presenter.updateUsername(input.getText().toString()));
|
alertDialog.setPositiveButton(getContext().getString(R.string.ok), (dialog, which) -> presenter.updateUsername(input.getText().toString()));
|
||||||
|
Loading…
Reference in New Issue
Block a user