mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 04:39:04 +00:00
Merge pull request #1907 from ByeongsuPark/bugfix-self-block
Fix user self-block in FullProfileActivity
This commit is contained in:
commit
42ae47bbd6
1 changed files with 10 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package com.habitrpg.android.habitica.ui.activities
|
||||
|
||||
import android.content.Context
|
||||
import android.content.SharedPreferences
|
||||
import android.graphics.Typeface
|
||||
import android.os.Bundle
|
||||
import android.text.method.LinkMovementMethod
|
||||
|
|
@ -58,6 +59,8 @@ class FullProfileActivity : BaseActivity() {
|
|||
lateinit var apiClient: ApiClient
|
||||
@Inject
|
||||
lateinit var socialRepository: SocialRepository
|
||||
@Inject
|
||||
lateinit var sharedPrefs: SharedPreferences
|
||||
|
||||
private var userID = ""
|
||||
private var username: String? = null
|
||||
|
|
@ -120,6 +123,9 @@ class FullProfileActivity : BaseActivity() {
|
|||
val inflater = menuInflater
|
||||
inflater.inflate(R.menu.menu_full_profile, menu)
|
||||
val item = menu.findItem(R.id.block_user)
|
||||
|
||||
if (isMyProfile()) item.isVisible = false
|
||||
|
||||
if (isUserBlocked()) {
|
||||
item?.title = getString(R.string.unblock_user)
|
||||
} else {
|
||||
|
|
@ -128,6 +134,10 @@ class FullProfileActivity : BaseActivity() {
|
|||
return super.onCreateOptionsMenu(menu)
|
||||
}
|
||||
|
||||
private fun isMyProfile(): Boolean {
|
||||
return sharedPrefs.getString("UserID", "") == userID
|
||||
}
|
||||
|
||||
private fun isUserBlocked(): Boolean {
|
||||
return blocks.contains(userID)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue