mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-17 11:19:01 +00:00
Hide confirm username button after confirming
This commit is contained in:
parent
436ca59954
commit
5d100deeef
4 changed files with 18 additions and 36 deletions
|
|
@ -24,7 +24,6 @@ public class RemoteConfigManager {
|
|||
private Boolean enableNewShops = false;
|
||||
private String shopSpriteSuffix = "";
|
||||
private Integer maxChatLength = 3000;
|
||||
private Boolean enableChangeUsername = false;
|
||||
private String REMOTE_STRING_KEY = "remote-string";
|
||||
|
||||
public RemoteConfigManager(Context context) {
|
||||
|
|
@ -47,8 +46,6 @@ public class RemoteConfigManager {
|
|||
|
||||
public Integer maxChatLength() { return maxChatLength; }
|
||||
|
||||
public Boolean enableChangeUsername() { return true; }
|
||||
|
||||
private void loadFromPreferences () {
|
||||
String storedPreferences = PreferenceManager.getDefaultSharedPreferences(context)
|
||||
.getString(REMOTE_STRING_KEY, "");
|
||||
|
|
@ -73,9 +70,6 @@ public class RemoteConfigManager {
|
|||
if (obj.has("maxChatLength")) {
|
||||
maxChatLength = obj.getInt("maxChatLength");
|
||||
}
|
||||
if (obj.has("enableChangeUsername")) {
|
||||
enableChangeUsername = obj.getBoolean("enableChangeUsername");
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -399,10 +399,7 @@ open class MainActivity : BaseActivity(), TutorialView.OnTutorialReaction {
|
|||
YesterdailyDialog.showDialogIfNeeded(this, user?.id, userRepository, taskRepository)
|
||||
|
||||
drawerFragment?.setMessagesCount(this.user?.inbox?.newMessages ?: 0)
|
||||
if (remoteConfigManager.enableChangeUsername()) {
|
||||
drawerFragment?.setSettingsCount(if (this.user?.flags?.isVerifiedUsername != true) 1 else 0 )
|
||||
}
|
||||
|
||||
drawerFragment?.setSettingsCount(if (this.user?.flags?.isVerifiedUsername != true) 1 else 0 )
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,15 +45,14 @@ class AuthenticationPreferenceFragment: BasePreferencesFragment() {
|
|||
HabiticaBaseApplication.component?.inject(this)
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
if (configManager.enableChangeUsername()) {
|
||||
findPreference("login_name").title = context?.getString(R.string.username)
|
||||
findPreference("confirm_username").isVisible = user?.flags?.isVerifiedUsername != true
|
||||
}
|
||||
findPreference("login_name").title = context?.getString(R.string.username)
|
||||
findPreference("confirm_username").isVisible = user?.flags?.isVerifiedUsername != true
|
||||
}
|
||||
|
||||
private fun updateUserFields() {
|
||||
configurePreference(findPreference("login_name"), user?.authentication?.localAuthentication?.username)
|
||||
configurePreference(findPreference("email"), user?.authentication?.localAuthentication?.email)
|
||||
findPreference("confirm_username").isVisible = user?.flags?.isVerifiedUsername != true
|
||||
}
|
||||
|
||||
private fun configurePreference(preference: Preference?, value: String?) {
|
||||
|
|
@ -121,23 +120,12 @@ class AuthenticationPreferenceFragment: BasePreferencesFragment() {
|
|||
val view = inflater?.inflate(R.layout.dialog_edittext_confirm_pw, null)
|
||||
val loginNameEditText = view?.findViewById<EditText>(R.id.editText)
|
||||
loginNameEditText?.setText(user?.authentication?.localAuthentication?.username)
|
||||
val passwordEditText = view?.findViewById<EditText>(R.id.passwordEditText)
|
||||
if (configManager.enableChangeUsername()) {
|
||||
passwordEditText?.visibility = View.GONE
|
||||
val passwordTitleTextView = view?.findViewById<TextView>(R.id.passwordTitleTextView)
|
||||
passwordTitleTextView?.visibility = View.GONE
|
||||
}
|
||||
context.notNull { context ->
|
||||
var builder = AlertDialog.Builder(context)
|
||||
builder = if (configManager.enableChangeUsername()) {
|
||||
builder.setTitle(R.string.change_username)
|
||||
} else {
|
||||
builder.setTitle(R.string.change_login_name)
|
||||
}
|
||||
var builder = AlertDialog.Builder(context).setTitle(R.string.change_username)
|
||||
|
||||
val dialog = builder.setPositiveButton(R.string.change) { thisDialog, _ ->
|
||||
thisDialog.dismiss()
|
||||
userRepository.updateLoginName(loginNameEditText?.text.toString(), passwordEditText?.text.toString())
|
||||
userRepository.updateLoginName(loginNameEditText?.text.toString())
|
||||
.subscribe(Consumer {
|
||||
configurePreference(findPreference("login_name"), loginNameEditText?.text.toString())
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
|
|
|
|||
|
|
@ -45,6 +45,11 @@ class PreferencesFragment : BasePreferencesFragment(), SharedPreferences.OnShare
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
HabiticaBaseApplication.component?.inject(this)
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
val userID = preferenceManager.sharedPreferences.getString(context?.getString(R.string.SP_userID), null)
|
||||
if (userID != null) {
|
||||
compositeSubscription.add(userRepository.getUser(userID).subscribe(Consumer { this@PreferencesFragment.setUser(it) }, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
}
|
||||
|
||||
override fun setupPreferences() {
|
||||
|
|
@ -241,15 +246,13 @@ class PreferencesFragment : BasePreferencesFragment(), SharedPreferences.OnShare
|
|||
cdsTimePreference?.text = user?.preferences?.dayStart.toString() + ":00"
|
||||
findPreference("dailyDueDefaultView").setDefaultValue(user?.preferences?.dailyDueDefaultView)
|
||||
|
||||
if (configManager.enableChangeUsername()) {
|
||||
val preference = findPreference("authentication")
|
||||
if (user?.flags?.isVerifiedUsername == true) {
|
||||
preference.layoutResource = R.layout.preference_child_summary
|
||||
preference.summary = context?.getString(R.string.authentication_summary)
|
||||
} else {
|
||||
preference.layoutResource = R.layout.preference_child_summary_error
|
||||
preference.summary = context?.getString(R.string.username_not_confirmed)
|
||||
}
|
||||
val preference = findPreference("authentication")
|
||||
if (user?.flags?.isVerifiedUsername == true) {
|
||||
preference.layoutResource = R.layout.preference_child_summary
|
||||
preference.summary = context?.getString(R.string.authentication_summary)
|
||||
} else {
|
||||
preference.layoutResource = R.layout.preference_child_summary_error
|
||||
preference.summary = context?.getString(R.string.username_not_confirmed)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue