mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 04:39:04 +00:00
Improve username display on party screen
This commit is contained in:
parent
762d1faa2c
commit
6d3bb9c10b
19 changed files with 77 additions and 137 deletions
|
|
@ -87,7 +87,7 @@
|
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="35dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginLeft="16dp">
|
||||
android:layout_marginLeft="8dp">
|
||||
<ImageButton
|
||||
android:id="@+id/settingsButton"
|
||||
android:layout_width="wrap_content"
|
||||
|
|
|
|||
|
|
@ -102,6 +102,7 @@
|
|||
android:text="@string/join_party_title"
|
||||
android:gravity="center"/>
|
||||
<TextView
|
||||
android:id="@+id/join_party_description_textview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/Body1"
|
||||
|
|
@ -109,62 +110,16 @@
|
|||
android:textColor="@color/gray_300"
|
||||
android:gravity="center"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/userIdView"
|
||||
<Button
|
||||
android:id="@+id/username_textview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/brand_400"
|
||||
style="@style/HabiticaButton.Gray.600"
|
||||
android:gravity="center"
|
||||
android:layout_marginTop="@dimen/spacing_large"
|
||||
android:layout_marginBottom="@dimen/spacing_large"/>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:id="@+id/qrLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
<FrameLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="300dp"
|
||||
android:id="@+id/qrCodeWrapper">
|
||||
|
||||
<com.facebook.drawee.view.SimpleDraweeView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/QRImageView"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
<RelativeLayout
|
||||
android:orientation="vertical"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_gravity="center"
|
||||
android:background="@color/white"
|
||||
android:clipChildren="true"
|
||||
android:padding="1dp"
|
||||
android:visibility="gone"
|
||||
>
|
||||
<com.habitrpg.android.habitica.ui.AvatarView
|
||||
android:id="@+id/avatarView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_centerVertical="true"
|
||||
/>
|
||||
</RelativeLayout>
|
||||
</FrameLayout>
|
||||
|
||||
<Button
|
||||
android:id="@+id/QRDownloadButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/download"
|
||||
style="@style/HabiticaButton.Gray.600"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_gravity="center_horizontal|bottom"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
|||
|
|
@ -29,15 +29,5 @@
|
|||
android:layout_gravity="right"
|
||||
android:text="@string/add_invites"
|
||||
android:layout_margin="@dimen/row_padding" />
|
||||
|
||||
<Button
|
||||
android:id="@+id/InviteByQR"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Scan a QR Code"
|
||||
style="@style/Widget.AppCompat.Button.Colored"
|
||||
android:layout_margin="20dp"
|
||||
android:layout_gravity="center_horizontal|bottom"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</ScrollView>
|
||||
|
|
@ -2,4 +2,5 @@
|
|||
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
android:id="@+id/viewPager" />
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
android:layout_weight="1" >
|
||||
|
||||
<TextView
|
||||
android:id="@+android:id/title"
|
||||
android:id="@+id/title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="marquee"
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
tools:text="Title"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+android:id/summary"
|
||||
android:id="@+id/summary"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@android:id/title"
|
||||
|
|
|
|||
|
|
@ -381,6 +381,7 @@
|
|||
<string name="send">Send</string>
|
||||
<string name="invite">Invite Friends</string>
|
||||
<string name="invite_id_description">If you have friends already using Habitica, invite them by User ID here.</string>
|
||||
<string name="invite_username_description">If you have friends already using Habitica, invite them by username here.</string>
|
||||
<string name="invite_email_description">If a friend joins Habitica via your email, they\'ll automatically be invited to your party!</string>
|
||||
<string name="add_invites">Add Invites</string>
|
||||
<string name="user_id">User ID</string>
|
||||
|
|
@ -760,7 +761,8 @@
|
|||
<string name="active_world_boss">Active World Boss</string>
|
||||
<string name="no_party_description">Take on quests with friends or on your own. Battle monsters, create Challenges, and help yourself stay accountable through Parties.</string>
|
||||
<string name="no_party_title">Play Habitica in a Party</string>
|
||||
<string name="join_party_description">Give them your User ID or have them scan your QR code while inviting</string>
|
||||
<string name="join_party_description">Give a Party member the username found below and they can send you an invite</string>
|
||||
<string name="join_party_description_id">Give them your User ID or have them scan your QR code while inviting</string>
|
||||
<string name="join_party_title">Want to join a party?</string>
|
||||
<string name="create_party_website">Open website to create party</string>
|
||||
<string name="id_copied">ID copied to clipboard</string>
|
||||
|
|
@ -827,4 +829,5 @@
|
|||
<string name="username_confirmed">Username Confirmed</string>
|
||||
<string name="username_level">%s ・Lvl %d</string>
|
||||
<string name="enter_recipient_username">Enter a Recipient\'s username</string>
|
||||
<string name="username_copied">Username copied to clipboard</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -192,12 +192,12 @@ class FullProfileActivity : BaseActivity() {
|
|||
user.authentication?.timestamps?.lastLoggedIn.notNull { lastLoginView.text = dateFormatter.format(it) }
|
||||
totalCheckinsView.text = user.loginIncentives.toString()
|
||||
|
||||
usernameText.text = userId
|
||||
usernameText.text = user.username
|
||||
copyUsernameButton.visibility = View.VISIBLE
|
||||
copyUsernameButton.setOnClickListener { view ->
|
||||
val clipboard = view.context
|
||||
.getSystemService(Context.CLIPBOARD_SERVICE) as? android.content.ClipboardManager
|
||||
val clip = android.content.ClipData.newPlainText(userId, userId)
|
||||
val clip = android.content.ClipData.newPlainText(user.username, user.username)
|
||||
clipboard?.primaryClip = clip
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import com.habitrpg.android.habitica.models.user.Stats
|
|||
import com.habitrpg.android.habitica.ui.views.HabiticaIconsHelper
|
||||
|
||||
|
||||
class HabiticaClassArrayAdapter(context: Context?, resource: Int, objects: List<CharSequence>?) : ArrayAdapter<CharSequence>(context, resource, R.id.textView, objects) {
|
||||
class HabiticaClassArrayAdapter(context: Context, resource: Int, objects: List<CharSequence>) : ArrayAdapter<CharSequence>(context, resource, R.id.textView, objects) {
|
||||
|
||||
override fun getDropDownView(position: Int, convertView: View?, parent: ViewGroup?): View =
|
||||
createView(position, convertView ?: parent?.inflate(R.layout.class_spinner_dropdown_item, false))
|
||||
|
|
|
|||
|
|
@ -116,19 +116,21 @@ class ShopRecyclerAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
|||
val sectionHolder = holder as? SectionViewHolder ?: return
|
||||
sectionHolder.bind(category?.text ?: "")
|
||||
if (gearCategories.contains(category)) {
|
||||
val adapter = HabiticaClassArrayAdapter(context, R.layout.class_spinner_dropdown_item, gearCategories.map { it.identifier })
|
||||
sectionHolder.spinnerAdapter = adapter
|
||||
sectionHolder.selectedItem = gearCategories.indexOf(category)
|
||||
sectionHolder.spinnerSelectionChanged = {
|
||||
if (selectedGearCategory != gearCategories[holder.selectedItem].identifier) {
|
||||
selectedGearCategory = gearCategories[holder.selectedItem].identifier
|
||||
context.notNull {context ->
|
||||
val adapter = HabiticaClassArrayAdapter(context, R.layout.class_spinner_dropdown_item, gearCategories.map { it.identifier })
|
||||
sectionHolder.spinnerAdapter = adapter
|
||||
sectionHolder.selectedItem = gearCategories.indexOf(category)
|
||||
sectionHolder.spinnerSelectionChanged = {
|
||||
if (selectedGearCategory != gearCategories[holder.selectedItem].identifier) {
|
||||
selectedGearCategory = gearCategories[holder.selectedItem].identifier
|
||||
}
|
||||
}
|
||||
if (user?.stats?.habitClass != category?.identifier) {
|
||||
sectionHolder.notesView?.text = context.getString(R.string.class_gear_disclaimer)
|
||||
sectionHolder.notesView?.visibility = View.VISIBLE
|
||||
} else {
|
||||
sectionHolder.notesView?.visibility = View.GONE
|
||||
}
|
||||
}
|
||||
if (user?.stats?.habitClass != category?.identifier) {
|
||||
sectionHolder.notesView?.text = context?.getString(R.string.class_gear_disclaimer)
|
||||
sectionHolder.notesView?.visibility = View.VISIBLE
|
||||
} else {
|
||||
sectionHolder.notesView?.visibility = View.GONE
|
||||
}
|
||||
} else {
|
||||
sectionHolder.spinnerAdapter = null
|
||||
|
|
@ -136,7 +138,7 @@ class ShopRecyclerAdapter : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
|||
}
|
||||
}
|
||||
ShopItem::class.java -> {
|
||||
val item = obj as ShopItem
|
||||
val item = obj as? ShopItem ?: return
|
||||
val itemHolder = holder as? ShopItemViewHolder ?: return
|
||||
itemHolder.bind(item, item.canAfford(user))
|
||||
if (ownedItems.containsKey(item.key+"-"+item.pinType)) {
|
||||
|
|
|
|||
|
|
@ -176,11 +176,11 @@ class ItemRecyclerFragment : BaseFragment() {
|
|||
"special" -> SpecialItem::class.java
|
||||
else -> Egg::class.java
|
||||
}
|
||||
inventoryRepository.getOwnedItems(itemClass, user).firstElement().subscribe(Consumer { items ->
|
||||
compositeSubscription.add(inventoryRepository.getOwnedItems(itemClass, user).firstElement().subscribe(Consumer { items ->
|
||||
if (items.size > 0) {
|
||||
adapter?.updateData(items as OrderedRealmCollection<Item>)
|
||||
}
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
|
||||
compositeSubscription.add(inventoryRepository.getOwnedPets().subscribe(Consumer { adapter?.setOwnedPets(it) }, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,9 +26,9 @@ abstract class BasePreferencesFragment : PreferenceFragmentCompat() {
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
userRepository.getUser(userId).subscribe(Consumer<User> {
|
||||
compositeSubscription.add(userRepository.getUser(userId).subscribe(Consumer<User> {
|
||||
this.user = it
|
||||
}, RxErrorHandler.handleEmptyError())
|
||||
}, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ import com.habitrpg.android.habitica.R
|
|||
import com.habitrpg.android.habitica.components.AppComponent
|
||||
import com.habitrpg.android.habitica.data.SocialRepository
|
||||
import com.habitrpg.android.habitica.data.UserRepository
|
||||
import com.habitrpg.android.habitica.helpers.QrCodeManager
|
||||
import com.habitrpg.android.habitica.helpers.RxErrorHandler
|
||||
import com.habitrpg.android.habitica.models.invitations.PartyInvite
|
||||
import com.habitrpg.android.habitica.models.members.Member
|
||||
|
|
@ -62,11 +61,6 @@ class GroupInformationFragment : BaseFragment() {
|
|||
|
||||
updateGroup(group)
|
||||
|
||||
if (this.group == null) {
|
||||
val qrCodeManager = QrCodeManager(userRepository, this.context)
|
||||
qrCodeManager.setUpView(qrLayout)
|
||||
}
|
||||
|
||||
buttonPartyInviteAccept.setOnClickListener { _ ->
|
||||
val userId = user?.invitations?.party?.id
|
||||
if (userId != null) {
|
||||
|
|
@ -87,13 +81,13 @@ class GroupInformationFragment : BaseFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
userIdView.setOnClickListener { _ ->
|
||||
username_textview.setOnClickListener { _ ->
|
||||
val clipboard = context?.getSystemService(Context.CLIPBOARD_SERVICE) as? ClipboardManager
|
||||
val clip = ClipData.newPlainText(context?.getString(R.string.user_id), user?.id)
|
||||
val clip = ClipData.newPlainText(context?.getString(R.string.username), user?.username)
|
||||
clipboard?.primaryClip = clip
|
||||
val activity = activity as? MainActivity
|
||||
if (activity != null) {
|
||||
HabiticaSnackbar.showSnackbar(activity.floatingMenuWrapper, getString(R.string.id_copied), HabiticaSnackbar.SnackbarDisplayType.NORMAL)
|
||||
HabiticaSnackbar.showSnackbar(activity.floatingMenuWrapper, getString(R.string.username_copied), HabiticaSnackbar.SnackbarDisplayType.NORMAL)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -105,14 +99,14 @@ class GroupInformationFragment : BaseFragment() {
|
|||
|
||||
private fun refresh() {
|
||||
if (group != null) {
|
||||
socialRepository.retrieveGroup(group?.id ?: "").subscribe(Consumer {}, RxErrorHandler.handleEmptyError())
|
||||
compositeSubscription.add(socialRepository.retrieveGroup(group?.id ?: "").subscribe(Consumer {}, RxErrorHandler.handleEmptyError()))
|
||||
} else {
|
||||
userRepository.retrieveUser(false, forced = true)
|
||||
compositeSubscription.add(userRepository.retrieveUser(false, forced = true)
|
||||
.filter { it.hasParty() }
|
||||
.flatMap { socialRepository.retrieveGroup("party") }
|
||||
.flatMap<List<Member>> { group1 -> socialRepository.retrieveGroupMembers(group1.id, true) }
|
||||
.doOnComplete { refreshLayout.isRefreshing = false }
|
||||
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError())
|
||||
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +116,7 @@ class GroupInformationFragment : BaseFragment() {
|
|||
} else {
|
||||
setInvitation(null)
|
||||
}
|
||||
userIdView.text = user?.id
|
||||
username_textview.text = user?.formattedUsername
|
||||
}
|
||||
|
||||
private fun setInvitation(invitation: PartyInvite?) {
|
||||
|
|
|
|||
|
|
@ -155,21 +155,21 @@ class TavernDetailFragment : BaseFragment() {
|
|||
|
||||
private fun addPlayerTiers() {
|
||||
for (tier in PlayerTier.getTiers()) {
|
||||
val container = FrameLayout(context)
|
||||
context.notNull {
|
||||
val container = FrameLayout(it)
|
||||
container.backgroundCompat = ContextCompat.getDrawable(it, R.drawable.layout_rounded_bg_gray_700)
|
||||
val label = UsernameLabel(context, null)
|
||||
label.tier = tier.id
|
||||
label.username = tier.title
|
||||
val params = FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT,
|
||||
Gravity.CENTER)
|
||||
container.addView(label, params)
|
||||
playerTiersView.addView(container)
|
||||
val padding = context?.resources?.getDimension(R.dimen.spacing_medium)?.toInt() ?: 0
|
||||
container.setPadding(0, padding, 0, padding)
|
||||
}
|
||||
val label = UsernameLabel(context, null)
|
||||
label.tier = tier.id
|
||||
label.username = tier.title
|
||||
val params = FrameLayout.LayoutParams(
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT,
|
||||
FrameLayout.LayoutParams.WRAP_CONTENT,
|
||||
Gravity.CENTER)
|
||||
container.addView(label, params)
|
||||
playerTiersView.addView(container)
|
||||
val padding = context?.resources?.getDimension(R.dimen.spacing_medium)?.toInt() ?: 0
|
||||
container.setPadding(0, padding, 0, padding)
|
||||
}
|
||||
playerTiersView.invalidate()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -71,9 +71,9 @@ class PartyFragment : BaseMainFragment() {
|
|||
|
||||
// Get the full group data
|
||||
if (userHasParty()) {
|
||||
socialRepository.retrieveGroup("party")
|
||||
compositeSubscription.add(socialRepository.retrieveGroup("party")
|
||||
.flatMap { group1 -> socialRepository.retrieveGroupMembers(group1.id, true) }
|
||||
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError())
|
||||
.subscribe(Consumer { }, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
setViewPagerAdapter()
|
||||
|
|
|
|||
|
|
@ -11,20 +11,24 @@ import android.widget.LinearLayout
|
|||
import android.widget.TextView
|
||||
import com.habitrpg.android.habitica.R
|
||||
import com.habitrpg.android.habitica.components.AppComponent
|
||||
import com.habitrpg.android.habitica.helpers.RemoteConfigManager
|
||||
import com.habitrpg.android.habitica.prefs.scanner.IntentIntegrator
|
||||
import com.habitrpg.android.habitica.ui.fragments.BaseFragment
|
||||
import com.habitrpg.android.habitica.ui.helpers.bindView
|
||||
import com.habitrpg.android.habitica.ui.helpers.resetViews
|
||||
import java.util.*
|
||||
import javax.inject.Inject
|
||||
|
||||
class PartyInviteFragment : BaseFragment() {
|
||||
|
||||
@Inject
|
||||
lateinit var configManager: RemoteConfigManager
|
||||
|
||||
var isEmailInvite: Boolean = false
|
||||
|
||||
private val inviteDescription: TextView? by bindView(R.id.inviteDescription)
|
||||
private val invitationWrapper: LinearLayout? by bindView(R.id.invitationWrapper)
|
||||
private val addInviteButton: Button? by bindView(R.id.addInviteButton)
|
||||
private val inviteQRButton: Button? by bindView(R.id.InviteByQR)
|
||||
|
||||
val values: Array<String>
|
||||
get() {
|
||||
|
|
@ -50,6 +54,8 @@ class PartyInviteFragment : BaseFragment() {
|
|||
|
||||
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)
|
||||
}
|
||||
|
|
@ -57,7 +63,6 @@ class PartyInviteFragment : BaseFragment() {
|
|||
addInviteField()
|
||||
|
||||
addInviteButton?.setOnClickListener { addInviteField() }
|
||||
inviteQRButton?.setOnClickListener { startQRInvite() }
|
||||
}
|
||||
|
||||
override fun injectFragment(component: AppComponent) {
|
||||
|
|
@ -70,14 +75,11 @@ class PartyInviteFragment : BaseFragment() {
|
|||
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)
|
||||
}
|
||||
invitationWrapper?.addView(editText)
|
||||
}
|
||||
|
||||
private fun startQRInvite() {
|
||||
val scanIntegrator = IntentIntegrator(activity)
|
||||
scanIntegrator.initiateScan()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -77,8 +77,8 @@ private constructor(parent: ViewGroup, content: View, callback: ContentViewCallb
|
|||
|
||||
private fun setSpecialView(specialView: View?): HabiticaSnackbar {
|
||||
if (specialView != null) {
|
||||
val snackbarView = view.findViewById<View>(R.id.content_container) as LinearLayout
|
||||
snackbarView.addView(specialView)
|
||||
val snackbarView = view.findViewById<View>(R.id.content_container) as? LinearLayout
|
||||
snackbarView?.addView(specialView)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class ValueBar(context: Context, attrs: AttributeSet?) : FrameLayout(context, at
|
|||
init {
|
||||
View.inflate(context, R.layout.value_bar, this)
|
||||
|
||||
val attributes = context?.theme?.obtainStyledAttributes(
|
||||
val attributes = context.theme?.obtainStyledAttributes(
|
||||
attrs,
|
||||
R.styleable.ValueBar,
|
||||
0, 0)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ import net.pherth.android.emoji_library.EmojiTextView
|
|||
|
||||
class ChatBarView : FrameLayout {
|
||||
|
||||
private val chatBarContainer: LinearLayout by bindView(R.id.chatBarContainer)
|
||||
private val sendButton: ImageButton by bindView(R.id.sendButton)
|
||||
private val chatEditText: EmojiEditText by bindView(R.id.chatEditText)
|
||||
private val textIndicator: TextView by bindView(R.id.text_indicator)
|
||||
|
|
|
|||
|
|
@ -103,9 +103,7 @@ class TaskFilterDialog(context: Context, component: AppComponent?) : AlertDialog
|
|||
|
||||
override fun show() {
|
||||
super.show()
|
||||
if (this.window != null) {
|
||||
this.window.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM)
|
||||
}
|
||||
this.window?.clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM)
|
||||
}
|
||||
|
||||
fun setTags(tags: List<Tag>) {
|
||||
|
|
@ -174,9 +172,7 @@ class TaskFilterDialog(context: Context, component: AppComponent?) : AlertDialog
|
|||
tagsList.removeAllViews()
|
||||
createTagEditViews()
|
||||
tagsEditButton.setText(R.string.done)
|
||||
if (this.window != null) {
|
||||
this.window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE)
|
||||
}
|
||||
this.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE)
|
||||
}
|
||||
|
||||
private fun stopEditing() {
|
||||
|
|
@ -184,9 +180,7 @@ class TaskFilterDialog(context: Context, component: AppComponent?) : AlertDialog
|
|||
tagsList.removeAllViews()
|
||||
createTagViews()
|
||||
tagsEditButton.setText(R.string.edit_tag_btn_edit)
|
||||
if (this.window != null) {
|
||||
this.window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN)
|
||||
}
|
||||
this.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN)
|
||||
repository.updateTags(editedTags.values).toObservable().flatMap { tags -> Observable.fromIterable(tags) }.subscribe(Consumer { tag -> editedTags.remove(tag.id) }, RxErrorHandler.handleEmptyError())
|
||||
repository.createTags(createdTags.values).toObservable().flatMap { tags -> Observable.fromIterable(tags) }.subscribe(Consumer { tag -> createdTags.remove(tag.getId()) }, RxErrorHandler.handleEmptyError())
|
||||
repository.deleteTags(deletedTags).subscribe(Consumer { deletedTags.clear() }, RxErrorHandler.handleEmptyError())
|
||||
|
|
@ -202,10 +196,10 @@ class TaskFilterDialog(context: Context, component: AppComponent?) : AlertDialog
|
|||
}
|
||||
|
||||
private fun createTagEditView(inflater: LayoutInflater, index: Int, tag: Tag) {
|
||||
val wrapper = inflater.inflate(R.layout.edit_tag_item, tagsList, false) as LinearLayout
|
||||
val tagEditText = wrapper.findViewById<View>(R.id.edit_text) as EditText
|
||||
tagEditText.setText(tag.name)
|
||||
tagEditText.addTextChangedListener(object : TextWatcher {
|
||||
val wrapper = inflater.inflate(R.layout.edit_tag_item, tagsList, false) as? LinearLayout
|
||||
val tagEditText = wrapper?.findViewById<View>(R.id.edit_text) as? EditText
|
||||
tagEditText?.setText(tag.name)
|
||||
tagEditText?.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
|
||||
|
||||
}
|
||||
|
|
@ -228,7 +222,7 @@ class TaskFilterDialog(context: Context, component: AppComponent?) : AlertDialog
|
|||
|
||||
}
|
||||
})
|
||||
val deleteButton = wrapper.findViewById<View>(R.id.delete_button) as Button
|
||||
val deleteButton = wrapper?.findViewById<View>(R.id.delete_button) as Button
|
||||
deleteButton.setOnClickListener {
|
||||
deletedTags.add(tag.getId())
|
||||
if (createdTags.containsKey(tag.getId())) {
|
||||
|
|
@ -250,12 +244,12 @@ class TaskFilterDialog(context: Context, component: AppComponent?) : AlertDialog
|
|||
this.activeTags = tagIds
|
||||
}
|
||||
for (index in 0 until tagsList.childCount - 1) {
|
||||
(tagsList.getChildAt(index) as AppCompatCheckBox).isChecked = false
|
||||
(tagsList.getChildAt(index) as? AppCompatCheckBox)?.isChecked = false
|
||||
}
|
||||
for (tagId in this.activeTags) {
|
||||
val index = indexForId(tagId)
|
||||
if (index >= 0) {
|
||||
(tagsList.getChildAt(index) as CheckBox).isChecked = true
|
||||
(tagsList.getChildAt(index) as? CheckBox)?.isChecked = true
|
||||
}
|
||||
}
|
||||
filtersChanged()
|
||||
|
|
|
|||
Loading…
Reference in a new issue