mirror of
https://github.com/ChronosX88/Influence-P2P.git
synced 2024-11-24 00:02:19 +00:00
Added updating preferences view when username is changed
This commit is contained in:
parent
a5ef1569e6
commit
56297d2290
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,7 +1,7 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/
|
||||
/.idea
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
|
@ -87,5 +87,6 @@ interface CoreContracts {
|
||||
interface ISettingsView {
|
||||
fun loadingScreen(state: Boolean)
|
||||
fun showMessage(message: String)
|
||||
fun refreshScreen()
|
||||
}
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ class SettingsPresenter(private val view: CoreContracts.ISettingsView) : CoreCon
|
||||
UIActions.USERNAME_AVAILABLE -> {
|
||||
view.loadingScreen(false)
|
||||
view.showMessage(AppHelper.getContext().getString(R.string.username_saved))
|
||||
view.refreshScreen()
|
||||
}
|
||||
UIActions.USERNAME_ISNT_AVAILABLE -> {
|
||||
view.loadingScreen(false)
|
||||
|
@ -13,6 +13,9 @@ import android.widget.Toast;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import androidx.preference.PreferenceFragmentCompat;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import io.github.chronosx88.influence.R;
|
||||
import io.github.chronosx88.influence.contracts.CoreContracts;
|
||||
import io.github.chronosx88.influence.helpers.AppHelper;
|
||||
@ -43,6 +46,10 @@ public class SettingsFragment extends PreferenceFragmentCompat implements CoreCo
|
||||
setupUsernameEditDialog().show();
|
||||
return true;
|
||||
});
|
||||
getPreferenceScreen().getPreference(1).setOnPreferenceChangeListener((p, nV) -> {
|
||||
getPreferenceScreen().getPreference(1).setSummary((String) nV);
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -71,11 +78,15 @@ public class SettingsFragment extends PreferenceFragmentCompat implements CoreCo
|
||||
input.setText(AppHelper.getPreferences().getString("username", null));
|
||||
|
||||
alertDialog.setView(input);
|
||||
|
||||
alertDialog.setPositiveButton(getContext().getString(R.string.ok), (dialog, which) -> presenter.updateUsername(input.getText().toString()));
|
||||
|
||||
alertDialog.setNegativeButton(getContext().getString(R.string.cancel), (dialog, which) -> dialog.cancel());
|
||||
|
||||
return alertDialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshScreen() {
|
||||
getPreferenceScreen().getPreference(1).callChangeListener(AppHelper.getPreferences().getString("username", null));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user