mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-17 19:29:02 +00:00
Fix username issues
This commit is contained in:
parent
6e2bed6779
commit
1dfc43dfd2
6 changed files with 55 additions and 22 deletions
|
|
@ -296,6 +296,9 @@ class UserRepositoryImpl(localRepository: UserLocalRepository, apiClient: ApiCli
|
|||
if (newUser.stats != null) {
|
||||
copiedUser.stats?.merge(newUser.stats)
|
||||
}
|
||||
if (newUser.profile != null) {
|
||||
copiedUser.profile = newUser.profile
|
||||
}
|
||||
|
||||
localRepository.saveUser(copiedUser)
|
||||
return oldUser
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import com.habitrpg.android.habitica.models.user.User
|
|||
import com.habitrpg.android.habitica.modules.AppModule
|
||||
import com.habitrpg.android.habitica.prefs.scanner.IntentIntegrator
|
||||
import com.habitrpg.android.habitica.ui.fragments.social.party.PartyInviteFragment
|
||||
import com.habitrpg.android.habitica.ui.helpers.KeyboardUtil
|
||||
import com.habitrpg.android.habitica.ui.helpers.bindView
|
||||
import io.reactivex.functions.Consumer
|
||||
import java.util.*
|
||||
|
|
@ -73,6 +74,7 @@ class PartyInviteActivity : BaseActivity() {
|
|||
|
||||
if (id == R.id.action_send_invites) {
|
||||
setResult(Activity.RESULT_OK, createResultIntent())
|
||||
KeyboardUtil.dismissKeyboard(this)
|
||||
finish()
|
||||
return true
|
||||
}
|
||||
|
|
@ -83,7 +85,7 @@ class PartyInviteActivity : BaseActivity() {
|
|||
private fun createResultIntent(): Intent {
|
||||
val intent = Intent()
|
||||
val fragment = fragments[viewPager.currentItem]
|
||||
if (viewPager.currentItem == 0) {
|
||||
if (viewPager.currentItem == 1) {
|
||||
intent.putExtra(PartyInviteActivity.IS_EMAIL_KEY, true)
|
||||
intent.putExtra(PartyInviteActivity.EMAILS_KEY, fragment.values)
|
||||
} else {
|
||||
|
|
@ -101,7 +103,7 @@ class PartyInviteActivity : BaseActivity() {
|
|||
override fun getItem(position: Int): Fragment {
|
||||
|
||||
val fragment = PartyInviteFragment()
|
||||
fragment.isEmailInvite = position == 0
|
||||
fragment.isEmailInvite = position == 1
|
||||
if (fragments.size > position) {
|
||||
fragments[position] = fragment
|
||||
} else {
|
||||
|
|
@ -117,8 +119,8 @@ class PartyInviteActivity : BaseActivity() {
|
|||
|
||||
override fun getPageTitle(position: Int): CharSequence? {
|
||||
return when (position) {
|
||||
0 -> getString(R.string.by_email)
|
||||
1 -> getString(R.string.invite_existing_users)
|
||||
0 -> getString(R.string.invite_existing_users)
|
||||
1 -> getString(R.string.by_email)
|
||||
else -> ""
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,10 +56,31 @@ class ProfilePreferencesFragment: BasePreferencesFragment(), SharedPreferences.O
|
|||
val profileCategory = findPreference("profile") as? PreferenceCategory
|
||||
configurePreference(profileCategory?.findPreference(key), sharedPreferences?.getString(key, ""))
|
||||
if (sharedPreferences != null) {
|
||||
val newValue = sharedPreferences.getString(key, "") ?: ""
|
||||
val observable: Flowable<User>? = when (key) {
|
||||
"display_name" -> userRepository.updateUser(user, "profile.name", sharedPreferences.getString(key, "") ?: "")
|
||||
"photo_url" -> userRepository.updateUser(user, "profile.photo", sharedPreferences.getString(key, "") ?: "")
|
||||
"about" -> userRepository.updateUser(user, "profile.blurb", sharedPreferences.getString(key, "") ?: "")
|
||||
"display_name" -> {
|
||||
if (newValue != user?.profile?.name) {
|
||||
userRepository.updateUser(user, "profile.name", newValue)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
"photo_url" -> {
|
||||
val newName = sharedPreferences.getString(key, "") ?: ""
|
||||
if (newName != user?.profile?.imageUrl) {
|
||||
userRepository.updateUser(user, "profile.photo", newValue)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
"about" -> {
|
||||
val newName = sharedPreferences.getString(key, "") ?: ""
|
||||
if (newName != user?.profile?.blurb) {
|
||||
userRepository.updateUser(user, "profile.blurb", newValue)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
observable?.subscribe(Consumer {}, RxErrorHandler.handleEmptyError()).notNull { compositeSubscription.add(it) }
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ class InboxFragment : BaseMainFragment(), androidx.swiperefreshlayout.widget.Swi
|
|||
}
|
||||
|
||||
override fun onCreateOptionsMenu(menu: Menu?, inflater: MenuInflater?) {
|
||||
this.activity?.menuInflater?.inflate(R.menu.inbox, menu)
|
||||
//this.activity?.menuInflater?.inflate(R.menu.inbox, menu)
|
||||
super.onCreateOptionsMenu(menu, inflater)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ import androidx.viewpager.widget.ViewPager
|
|||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.AppComponent
|
||||
import com.habitrpg.android.habitica.extensions.notNull
|
||||
import com.habitrpg.android.habitica.helpers.RemoteConfigManager
|
||||
import com.habitrpg.android.habitica.models.social.Group
|
||||
import com.habitrpg.android.habitica.ui.activities.GroupFormActivity
|
||||
import com.habitrpg.android.habitica.ui.activities.PartyInviteActivity
|
||||
|
|
@ -25,9 +26,13 @@ import com.habitrpg.android.habitica.ui.helpers.resetViews
|
|||
import com.habitrpg.android.habitica.ui.viewmodels.GroupViewType
|
||||
import com.habitrpg.android.habitica.ui.viewmodels.PartyViewModel
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class PartyFragment : BaseMainFragment() {
|
||||
|
||||
@Inject
|
||||
lateinit var configRepository: RemoteConfigManager
|
||||
|
||||
private val viewPager: ViewPager? by bindView(R.id.viewPager)
|
||||
private var partyMemberListFragment: PartyMemberListFragment? = null
|
||||
private var chatFragment: ChatFragment? = null
|
||||
|
|
@ -185,7 +190,11 @@ class PartyFragment : BaseMainFragment() {
|
|||
val userIDs = data?.getStringArrayExtra(PartyInviteActivity.USER_IDS_KEY)
|
||||
val invites = ArrayList<String>()
|
||||
Collections.addAll(invites, *userIDs)
|
||||
inviteData["uuids"] = invites
|
||||
if (configRepository.enableUsernameRelease()) {
|
||||
inviteData["usernames"] = invites
|
||||
} else {
|
||||
inviteData["uuids"] = invites
|
||||
}
|
||||
}
|
||||
viewModel.inviteToGroup(inviteData)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,12 +52,10 @@ class PartyInviteFragment : BaseFragment() {
|
|||
|
||||
resetViews()
|
||||
|
||||
if (isEmailInvite) {
|
||||
inviteDescription?.text = getString(R.string.invite_email_description)
|
||||
} else if (configManager.enableUsernameRelease()) {
|
||||
inviteDescription?.text = getString(R.string.invite_username_description)
|
||||
} else {
|
||||
inviteDescription?.text = getString(R.string.invite_id_description)
|
||||
when {
|
||||
isEmailInvite -> inviteDescription?.text = getString(R.string.invite_email_description)
|
||||
configManager.enableUsernameRelease() -> inviteDescription?.text = getString(R.string.invite_username_description)
|
||||
else -> inviteDescription?.text = getString(R.string.invite_id_description)
|
||||
}
|
||||
|
||||
addInviteField()
|
||||
|
|
@ -72,13 +70,13 @@ class PartyInviteFragment : BaseFragment() {
|
|||
private fun addInviteField() {
|
||||
val editText = EditText(context)
|
||||
|
||||
if (isEmailInvite) {
|
||||
editText.setHint(R.string.email)
|
||||
editText.inputType = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
|
||||
} else if (configManager.enableUsernameRelease()) {
|
||||
editText.setHint(R.string.username)
|
||||
} else {
|
||||
editText.setHint(R.string.user_id)
|
||||
when {
|
||||
isEmailInvite -> {
|
||||
editText.setHint(R.string.email)
|
||||
editText.inputType = InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
|
||||
}
|
||||
configManager.enableUsernameRelease() -> editText.setHint(R.string.username)
|
||||
else -> editText.setHint(R.string.user_id)
|
||||
}
|
||||
invitationWrapper?.addView(editText)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue