use simple ui on mutes/blocks list

This commit is contained in:
Mariotaku Lee 2016-12-11 15:38:33 +08:00
parent 0cc1ca39da
commit 62ca1ecff5
19 changed files with 215 additions and 200 deletions

View File

@ -219,4 +219,5 @@ public interface IntentConstants {
String EXTRA_START_INTENT = "start_intent";
String EXTRA_SELECT_ONLY_ITEM = "select_only_item";
String EXTRA_OBJECT = "object";
String EXTRA_SIMPLE_LAYOUT = "simple_layout";
}

View File

@ -233,8 +233,8 @@ public class AsyncTwitterWrapper extends TwitterWrapper {
return asyncTaskManager.add(task, true);
}
public void createMuteAsync(final UserKey accountKey, final UserKey userKey) {
final CreateUserMuteTask task = new CreateUserMuteTask(context);
public void createMuteAsync(final UserKey accountKey, final UserKey userKey, boolean filterEverywhere) {
final CreateUserMuteTask task = new CreateUserMuteTask(context, filterEverywhere);
task.setup(accountKey, userKey);
TaskStarter.execute(task);
}

View File

@ -34,12 +34,14 @@ import android.view.KeyEvent
import android.view.MenuItem
import android.view.Window
import org.mariotaku.ktextension.convert
import org.mariotaku.ktextension.set
import org.mariotaku.ktextension.toDoubleOrNull
import org.mariotaku.twidere.Constants.*
import org.mariotaku.twidere.R
import org.mariotaku.twidere.activity.iface.IControlBarActivity
import org.mariotaku.twidere.activity.iface.IControlBarActivity.ControlBarShowHideHelper
import org.mariotaku.twidere.constant.CompatibilityConstants
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_SIMPLE_LAYOUT
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_USER_KEY
import org.mariotaku.twidere.constant.KeyboardShortcutConstants
import org.mariotaku.twidere.constant.SharedPreferenceConstants
@ -553,9 +555,11 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IContro
}
LINK_ID_USER_BLOCKS -> {
fragment = UserBlocksListFragment()
args[EXTRA_SIMPLE_LAYOUT] = true
}
LINK_ID_MUTES_USERS -> {
fragment = MutesUsersListFragment()
args[EXTRA_SIMPLE_LAYOUT] = true
}
LINK_ID_DIRECT_MESSAGES_CONVERSATION -> {
fragment = MessagesConversationFragment()

View File

@ -50,6 +50,7 @@ class DummyItemAdapter @JvmOverloads constructor(
override var userClickListener: IUsersAdapter.UserClickListener? = null
override var showAccountsColor: Boolean = false
override var useStarsForLikes: Boolean = false
override var simpleLayout: Boolean = false
private var showCardActions: Boolean = false
private var showingActionCardPosition = RecyclerView.NO_POSITION

View File

@ -47,7 +47,7 @@ class ParcelableUsersAdapter(context: Context) : LoadMoreSupportAdapter<Recycler
override var userClickListener: IUsersAdapter.UserClickListener? = null
override var requestClickListener: IUsersAdapter.RequestClickListener? = null
override var followClickListener: IUsersAdapter.FriendshipClickListener? = null
override var simpleLayout: Boolean = false
init {
inflater = LayoutInflater.from(context)
@ -177,7 +177,7 @@ class ParcelableUsersAdapter(context: Context) : LoadMoreSupportAdapter<Recycler
fun createUserViewHolder(adapter: IUsersAdapter<*>, inflater: LayoutInflater, parent: ViewGroup): UserViewHolder {
val view = inflater.inflate(R.layout.list_item_user, parent, false)
val holder = UserViewHolder(adapter, view)
val holder = UserViewHolder(view, adapter, adapter.simpleLayout)
holder.setOnClickListeners()
holder.setupViewOptions()
return holder

View File

@ -37,6 +37,8 @@ interface IUsersAdapter<in Data> : IContentCardAdapter {
val showAccountsColor: Boolean
val simpleLayout: Boolean
fun setData(data: Data?): Boolean
fun getUser(position: Int): ParcelableUser?

View File

@ -0,0 +1,70 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2014 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mariotaku.twidere.fragment
import android.app.Dialog
import android.content.DialogInterface
import android.os.Bundle
import android.support.v7.app.AlertDialog
import android.widget.CheckBox
import android.widget.TextView
import org.mariotaku.twidere.R
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_USER
import org.mariotaku.twidere.model.ParcelableUser
abstract class AbsUserMuteBlockDialogFragment : BaseDialogFragment(), DialogInterface.OnClickListener {
private val user: ParcelableUser by lazy { arguments.getParcelable<ParcelableUser>(EXTRA_USER) }
override fun onClick(dialog: DialogInterface, which: Int) {
when (which) {
DialogInterface.BUTTON_POSITIVE -> {
val filterEverywhere = ((dialog as Dialog).findViewById(R.id.filterEverywhereToggle) as CheckBox).isChecked
performUserAction(user, filterEverywhere)
}
else -> {
}
}
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context)
builder.setTitle(getTitle(user))
builder.setView(R.layout.dialog_block_mute_filter_user_confirm)
builder.setPositiveButton(android.R.string.ok, this)
builder.setNegativeButton(android.R.string.cancel, null)
val dialog = builder.create()
dialog.setOnShowListener {
val confirmMessageView = dialog.findViewById(R.id.confirmMessage) as TextView
val filterEverywhereHelp = dialog.findViewById(R.id.filterEverywhereHelp)!!
filterEverywhereHelp.setOnClickListener {
MessageDialogFragment.show(childFragmentManager, title = getString(R.string.filter_everywhere),
message = getString(R.string.filter_everywhere_description), tag = "filter_everywhere_help")
}
confirmMessageView.text = getMessage(user)
}
return dialog
}
abstract fun performUserAction(user: ParcelableUser, filterEverywhere: Boolean)
abstract fun getTitle(user: ParcelableUser): String
abstract fun getMessage(user: ParcelableUser): String
}

View File

@ -19,60 +19,32 @@
package org.mariotaku.twidere.fragment
import android.app.Dialog
import android.content.DialogInterface
import android.os.Bundle
import android.support.v4.app.FragmentManager
import android.support.v7.app.AlertDialog
import android.widget.CheckBox
import android.widget.TextView
import android.widget.Toast
import org.mariotaku.twidere.R
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_USER
import org.mariotaku.twidere.constant.SharedPreferenceConstants.KEY_NAME_FIRST
import org.mariotaku.twidere.constant.nameFirstKey
import org.mariotaku.twidere.model.ParcelableUser
import org.mariotaku.twidere.model.message.FriendshipTaskEvent
import org.mariotaku.twidere.util.DataStoreUtils
class AddUserFilterDialogFragment : BaseDialogFragment(), DialogInterface.OnClickListener {
private val user: ParcelableUser by lazy { arguments.getParcelable<ParcelableUser>(EXTRA_USER) }
override fun onClick(dialog: DialogInterface, which: Int) {
when (which) {
DialogInterface.BUTTON_POSITIVE -> {
val filterEverywhere = ((dialog as Dialog).findViewById(R.id.filterEverywhereToggle) as CheckBox).isChecked
DataStoreUtils.addToFilter(context, user, filterEverywhere)
bus.post(FriendshipTaskEvent(FriendshipTaskEvent.Action.FILTER, user.account_key, user.key).apply {
isFinished = true
isSucceeded = true
})
Toast.makeText(context, R.string.message_toast_added_to_filter, Toast.LENGTH_SHORT).show()
}
else -> {
}
}
class AddUserFilterDialogFragment : AbsUserMuteBlockDialogFragment() {
override fun getMessage(user: ParcelableUser): String {
return getString(R.string.filter_user_confirm_message, userColorNameManager.getDisplayName(user, kPreferences[nameFirstKey]))
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context)
val nameFirst = preferences.getBoolean(KEY_NAME_FIRST)
val displayName = userColorNameManager.getDisplayName(user, nameFirst)
builder.setTitle(R.string.add_to_filter)
builder.setView(R.layout.dialog_filter_user_confirm)
builder.setPositiveButton(android.R.string.ok, this)
builder.setNegativeButton(android.R.string.cancel, null)
val dialog = builder.create()
dialog.setOnShowListener {
val confirmMessageView = dialog.findViewById(R.id.confirmMessage) as TextView
val filterEverywhereHelp = dialog.findViewById(R.id.filterEverywhereHelp)!!
filterEverywhereHelp.setOnClickListener {
MessageDialogFragment.show(childFragmentManager, title = getString(R.string.filter_everywhere),
message = getString(R.string.filter_everywhere_description), tag = "filter_everywhere_help")
}
confirmMessageView.text = getString(R.string.filter_user_confirm_message, displayName)
}
return dialog
override fun getTitle(user: ParcelableUser): String {
return getString(R.string.add_to_filter)
}
override fun performUserAction(user: ParcelableUser, filterEverywhere: Boolean) {
DataStoreUtils.addToFilter(context, user, filterEverywhere)
bus.post(FriendshipTaskEvent(FriendshipTaskEvent.Action.FILTER, user.account_key, user.key).apply {
isFinished = true
isSucceeded = true
})
Toast.makeText(context, R.string.message_toast_added_to_filter, Toast.LENGTH_SHORT).show()
}
companion object {

View File

@ -22,6 +22,7 @@ package org.mariotaku.twidere.fragment
import android.content.Context
import android.support.v4.app.DialogFragment
import com.squareup.otto.Bus
import org.mariotaku.kpreferences.KPreferences
import org.mariotaku.twidere.Constants
import org.mariotaku.twidere.util.*
import org.mariotaku.twidere.util.dagger.GeneralComponentHelper
@ -36,6 +37,8 @@ open class BaseDialogFragment : DialogFragment(), Constants {
@Inject
lateinit var preferences: SharedPreferencesWrapper
@Inject
lateinit var kPreferences: KPreferences
@Inject
lateinit var validator: TwidereValidator
@Inject
lateinit var keyboardShortcutsHandler: KeyboardShortcutsHandler

View File

@ -19,52 +19,26 @@
package org.mariotaku.twidere.fragment
import android.app.Dialog
import android.content.DialogInterface
import android.os.Bundle
import android.support.v4.app.FragmentManager
import android.support.v7.app.AlertDialog
import android.widget.CheckBox
import android.widget.TextView
import org.mariotaku.twidere.R
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_USER
import org.mariotaku.twidere.constant.SharedPreferenceConstants.KEY_NAME_FIRST
import org.mariotaku.twidere.constant.nameFirstKey
import org.mariotaku.twidere.model.ParcelableUser
class CreateUserBlockDialogFragment : BaseDialogFragment(), DialogInterface.OnClickListener {
private val user: ParcelableUser by lazy { arguments.getParcelable<ParcelableUser>(EXTRA_USER) }
override fun onClick(dialog: DialogInterface, which: Int) {
when (which) {
DialogInterface.BUTTON_POSITIVE -> {
val filterEverywhere = ((dialog as Dialog).findViewById(R.id.filterEverywhereToggle) as CheckBox).isChecked
twitterWrapper.createBlockAsync(user.account_key, user.key, filterEverywhere)
}
else -> {
}
}
class CreateUserBlockDialogFragment : AbsUserMuteBlockDialogFragment() {
override fun getMessage(user: ParcelableUser): String {
val displayName = userColorNameManager.getDisplayName(user, kPreferences[nameFirstKey])
return getString(R.string.block_user_confirm_message, displayName)
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val builder = AlertDialog.Builder(context)
val nameFirst = preferences.getBoolean(KEY_NAME_FIRST)
val displayName = userColorNameManager.getDisplayName(user, nameFirst)
builder.setTitle(getString(R.string.block_user, displayName))
builder.setView(R.layout.dialog_block_user_confirm)
builder.setPositiveButton(android.R.string.ok, this)
builder.setNegativeButton(android.R.string.cancel, null)
val dialog = builder.create()
dialog.setOnShowListener {
val confirmMessageView = dialog.findViewById(R.id.confirmMessage) as TextView
val filterEverywhereHelp = dialog.findViewById(R.id.filterEverywhereHelp)!!
filterEverywhereHelp.setOnClickListener {
MessageDialogFragment.show(childFragmentManager, title = getString(R.string.filter_everywhere),
message = getString(R.string.filter_everywhere_description), tag = "filter_everywhere_help")
}
confirmMessageView.text = getString(R.string.block_user_confirm_message, displayName)
}
return dialog
override fun getTitle(user: ParcelableUser): String {
val displayName = userColorNameManager.getDisplayName(user, kPreferences[nameFirstKey])
return getString(R.string.block_user, displayName)
}
override fun performUserAction(user: ParcelableUser, filterEverywhere: Boolean) {
twitterWrapper.createBlockAsync(user.account_key, user.key, filterEverywhere)
}
companion object {

View File

@ -19,52 +19,28 @@
package org.mariotaku.twidere.fragment
import android.app.Dialog
import android.content.DialogInterface
import android.os.Bundle
import android.support.v4.app.FragmentManager
import android.support.v7.app.AlertDialog
import org.mariotaku.twidere.R
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_USER
import org.mariotaku.twidere.constant.SharedPreferenceConstants.KEY_NAME_FIRST
import org.mariotaku.twidere.constant.nameFirstKey
import org.mariotaku.twidere.model.ParcelableUser
class CreateUserMuteDialogFragment : BaseDialogFragment(), DialogInterface.OnClickListener {
class CreateUserMuteDialogFragment : AbsUserMuteBlockDialogFragment() {
override fun onClick(dialog: DialogInterface, which: Int) {
when (which) {
DialogInterface.BUTTON_POSITIVE -> {
val user = user
val twitter = twitterWrapper
if (user == null) return
twitter.createMuteAsync(user.account_key, user.key)
}
else -> {
}
}
override fun getMessage(user: ParcelableUser): String {
val displayName = userColorNameManager.getDisplayName(user, kPreferences[nameFirstKey])
return getString(R.string.mute_user_confirm_message, displayName)
}
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val context = context
val builder = AlertDialog.Builder(context)
val user = user
if (user != null) {
val nameFirst = preferences.getBoolean(KEY_NAME_FIRST)
val displayName = userColorNameManager.getDisplayName(user, nameFirst)
builder.setTitle(getString(R.string.mute_user, displayName))
builder.setMessage(getString(R.string.mute_user_confirm_message, displayName))
}
builder.setPositiveButton(android.R.string.ok, this)
builder.setNegativeButton(android.R.string.cancel, null)
return builder.create()
override fun getTitle(user: ParcelableUser): String {
val displayName = userColorNameManager.getDisplayName(user, kPreferences[nameFirstKey])
return getString(R.string.mute_user, displayName)
}
private val user: ParcelableUser?
get() {
val args = arguments
if (!args.containsKey(EXTRA_USER)) return null
return args.getParcelable<ParcelableUser>(EXTRA_USER)
}
override fun performUserAction(user: ParcelableUser, filterEverywhere: Boolean) {
twitterWrapper.createMuteAsync(user.account_key, user.key, filterEverywhere)
}
companion object {

View File

@ -25,6 +25,7 @@ import org.mariotaku.twidere.constant.IntentConstants.EXTRA_ACCOUNT_KEY
import org.mariotaku.twidere.loader.CursorSupportUsersLoader
import org.mariotaku.twidere.loader.MutesUsersLoader
import org.mariotaku.twidere.model.UserKey
import org.mariotaku.twidere.model.message.FriendshipTaskEvent
class MutesUsersListFragment : CursorSupportUsersListFragment() {
@ -38,4 +39,13 @@ class MutesUsersListFragment : CursorSupportUsersListFragment() {
return loader
}
override fun shouldRemoveUser(position: Int, event: FriendshipTaskEvent): Boolean {
if (!event.isSucceeded) return false
when (event.action) {
FriendshipTaskEvent.Action.UNMUTE -> {
return true
}
}
return false
}
}

View File

@ -38,6 +38,7 @@ import org.mariotaku.twidere.adapter.iface.IUsersAdapter
import org.mariotaku.twidere.adapter.iface.IUsersAdapter.UserClickListener
import org.mariotaku.twidere.annotation.Referral
import org.mariotaku.twidere.constant.IntentConstants
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_SIMPLE_LAYOUT
import org.mariotaku.twidere.constant.SharedPreferenceConstants
import org.mariotaku.twidere.loader.iface.IExtendedLoader
import org.mariotaku.twidere.model.ParcelableUser
@ -93,6 +94,7 @@ abstract class ParcelableUsersFragment : AbsContentListRecyclerViewFragment<Parc
override fun onCreateAdapter(context: Context): ParcelableUsersAdapter {
val adapter = ParcelableUsersAdapter(context)
adapter.simpleLayout = simpleLayout
adapter.followClickListener = this
return adapter
}
@ -171,6 +173,9 @@ abstract class ParcelableUsersFragment : AbsContentListRecyclerViewFragment<Parc
@Referral
get() = null
protected val simpleLayout: Boolean
get() = arguments.getBoolean(EXTRA_SIMPLE_LAYOUT)
override fun onUserLongClick(holder: UserViewHolder, position: Int): Boolean {
return true
}

View File

@ -18,7 +18,10 @@ import org.mariotaku.twidere.util.Utils
/**
* Created by mariotaku on 16/3/11.
*/
class CreateUserMuteTask(context: Context) : AbsFriendshipOperationTask(context, FriendshipTaskEvent.Action.MUTE) {
class CreateUserMuteTask(
context: Context,
val filterEverywhere: Boolean
) : AbsFriendshipOperationTask(context, FriendshipTaskEvent.Action.MUTE) {
@Throws(MicroBlogException::class)
override fun perform(twitter: MicroBlog, details: AccountDetails,
@ -55,6 +58,9 @@ class CreateUserMuteTask(context: Context) : AbsFriendshipOperationTask(context,
values.put(CachedRelationships.USER_KEY, args.userKey.toString())
values.put(CachedRelationships.MUTING, true)
resolver.insert(CachedRelationships.CONTENT_URI, values)
if (filterEverywhere) {
DataStoreUtils.addToFilter(context, user, true)
}
}
override fun showSucceededMessage(params: AbsFriendshipOperationTask.Arguments, user: ParcelableUser) {

View File

@ -24,24 +24,23 @@ import android.text.TextUtils
import android.view.View
import android.view.View.OnClickListener
import android.view.View.OnLongClickListener
import android.widget.ImageButton
import android.widget.ImageView
import android.widget.TextView
import android.widget.*
import kotlinx.android.synthetic.main.list_item_user.view.*
import org.mariotaku.twidere.R
import org.mariotaku.twidere.adapter.iface.IUsersAdapter
import org.mariotaku.twidere.adapter.iface.IUsersAdapter.*
import org.mariotaku.twidere.model.ParcelableUser
import org.mariotaku.twidere.model.util.UserKeyUtils
import org.mariotaku.twidere.util.Utils.getLocalizedNumber
import org.mariotaku.twidere.util.Utils
import org.mariotaku.twidere.util.Utils.getUserTypeIconRes
import org.mariotaku.twidere.view.NameView
import org.mariotaku.twidere.view.iface.IColorLabelView
import java.util.*
class UserViewHolder(
itemView: View,
private val adapter: IUsersAdapter<*>,
itemView: View
private val simple: Boolean = false
) : ViewHolder(itemView), OnClickListener, OnLongClickListener {
private val itemContent: IColorLabelView
@ -64,31 +63,55 @@ class UserViewHolder(
private val actionsProgressContainer: View
private val actionsContainer: View
private val processingRequestProgress: View
private val countsContainer: LinearLayout
private var userClickListener: UserClickListener? = null
private var requestClickListener: RequestClickListener? = null
private var friendshipClickListener: FriendshipClickListener? = null
init {
itemContent = itemView.findViewById(R.id.itemContent) as IColorLabelView
profileImageView = itemView.findViewById(R.id.profileImage) as ImageView
profileTypeView = itemView.findViewById(R.id.profileType) as ImageView
nameView = itemView.findViewById(R.id.name) as NameView
externalIndicator = itemView.findViewById(R.id.externalIndicator) as TextView
descriptionView = itemView.findViewById(R.id.description) as TextView
locationView = itemView.findViewById(R.id.location) as TextView
urlView = itemView.findViewById(R.id.url) as TextView
statusesCountView = itemView.findViewById(R.id.statusesCount) as TextView
followersCountView = itemView.findViewById(R.id.followersCount) as TextView
friendsCountView = itemView.findViewById(R.id.friendsCount) as TextView
actionsProgressContainer = itemView.findViewById(R.id.actionsProgressContainer)
actionsContainer = itemView.findViewById(R.id.actionsContainer)
itemContent = itemView.itemContent
profileImageView = itemView.profileImage
profileTypeView = itemView.profileType
nameView = itemView.name
externalIndicator = itemView.externalIndicator
descriptionView = itemView.description
locationView = itemView.location
urlView = itemView.url
statusesCountView = itemView.statusesCount
followersCountView = itemView.followersCount
friendsCountView = itemView.friendsCount
actionsProgressContainer = itemView.actionsProgressContainer
actionsContainer = itemView.actionsContainer
acceptRequestButton = itemView.acceptRequest
denyRequestButton = itemView.denyRequest
unblockButton = itemView.unblock
unmuteButton = itemView.unmute
followButton = itemView.follow
countsContainer = itemView.countsContainer
processingRequestProgress = itemView.findViewById(R.id.processingRequest)
if (simple) {
externalIndicator.visibility = View.GONE
descriptionView.visibility = View.GONE
locationView.visibility = View.GONE
urlView.visibility = View.GONE
countsContainer.visibility = View.GONE
itemView.profileImageContainer.layoutParams.apply {
(this as RelativeLayout.LayoutParams).clearVerticalRules()
this.addRule(RelativeLayout.CENTER_VERTICAL)
}
nameView.layoutParams.apply {
(this as RelativeLayout.LayoutParams).clearVerticalRules()
this.addRule(RelativeLayout.CENTER_VERTICAL)
}
actionsProgressContainer.layoutParams.apply {
(this as RelativeLayout.LayoutParams).clearVerticalRules()
this.addRule(RelativeLayout.CENTER_VERTICAL)
}
}
}
fun displayUser(user: ParcelableUser) {
@ -98,7 +121,6 @@ class UserViewHolder(
val manager = adapter.userColorNameManager
val twitter = adapter.twitterWrapper
itemContent.drawStart(manager.getUserColor(user.key))
val userTypeRes = getUserTypeIconRes(user.is_verified, user.is_protected)
@ -110,16 +132,7 @@ class UserViewHolder(
nameView.setName(manager.getUserNickname(user.key, user.name))
nameView.setScreenName("@${user.screen_name}")
nameView.updateText(adapter.bidiFormatter)
descriptionView.visibility = if (TextUtils.isEmpty(user.description_unescaped)) View.GONE else View.VISIBLE
descriptionView.text = user.description_unescaped
locationView.visibility = if (TextUtils.isEmpty(user.location)) View.GONE else View.VISIBLE
locationView.text = user.location
urlView.visibility = if (TextUtils.isEmpty(user.url_expanded)) View.GONE else View.VISIBLE
urlView.text = user.url_expanded
val locale = Locale.getDefault()
statusesCountView.text = getLocalizedNumber(locale, user.statuses_count)
followersCountView.text = getLocalizedNumber(locale, user.followers_count)
friendsCountView.text = getLocalizedNumber(locale, user.friends_count)
if (adapter.profileImageEnabled) {
profileImageView.visibility = View.VISIBLE
loader.displayProfileImage(profileImageView, user)
@ -142,10 +155,7 @@ class UserViewHolder(
externalIndicator.text = context.getString(R.string.external_user_host_format, user.key.host)
}
followButton.setImageResource(if (user.is_following)
R.drawable.ic_action_confirm
else
R.drawable.ic_action_add)
followButton.setImageResource(if (user.is_following) R.drawable.ic_action_confirm else R.drawable.ic_action_add)
followButton.isActivated = user.is_following
val isMySelf = user.account_key == user.key
@ -171,6 +181,19 @@ class UserViewHolder(
unblockButton.visibility = View.GONE
unmuteButton.visibility = View.GONE
}
if (!simple) {
descriptionView.visibility = if (TextUtils.isEmpty(user.description_unescaped)) View.GONE else View.VISIBLE
descriptionView.text = user.description_unescaped
locationView.visibility = if (TextUtils.isEmpty(user.location)) View.GONE else View.VISIBLE
locationView.text = user.location
urlView.visibility = if (TextUtils.isEmpty(user.url_expanded)) View.GONE else View.VISIBLE
urlView.text = user.url_expanded
val locale = Locale.getDefault()
statusesCountView.text = Utils.getLocalizedNumber(locale, user.statuses_count)
followersCountView.text = Utils.getLocalizedNumber(locale, user.followers_count)
friendsCountView.text = Utils.getLocalizedNumber(locale, user.friends_count)
}
}
override fun onClick(v: View) {
@ -190,6 +213,9 @@ class UserViewHolder(
R.id.unblock -> {
friendshipClickListener?.onUnblockClicked(this, layoutPosition)
}
R.id.unmute -> {
friendshipClickListener?.onUnmuteClicked(this, layoutPosition)
}
}
}
@ -249,3 +275,10 @@ class UserViewHolder(
}
}
private fun RelativeLayout.LayoutParams.clearVerticalRules() {
intArrayOf(RelativeLayout.ABOVE, RelativeLayout.BELOW, RelativeLayout.ALIGN_BASELINE,
RelativeLayout.ALIGN_TOP, RelativeLayout.ALIGN_BOTTOM).forEach { verb ->
removeRule(verb)
}
}

View File

@ -1,45 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/element_spacing_large">
<TextView
android:id="@+id/confirmMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="?android:textColorPrimary"
tools:text="@string/block_user_confirm_message"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingBottom="@dimen/element_spacing_normal"
android:paddingTop="@dimen/element_spacing_normal">
<CheckBox
android:id="@+id/filterEverywhereToggle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/filter_everywhere"
android:textAppearance="?android:textAppearanceMedium"/>
<org.mariotaku.twidere.view.IconActionButton
android:id="@+id/filterEverywhereHelp"
android:layout_width="@dimen/button_size_content_card_action"
android:layout_height="@dimen/button_size_content_card_action"
android:layout_marginLeft="@dimen/element_spacing_normal"
android:layout_marginStart="@dimen/element_spacing_normal"
android:layout_weight="0"
android:background="?selectableItemBackgroundBorderless"
android:src="@drawable/ic_action_info"
app:iabColor="?android:textColorSecondary"/>
</LinearLayout>
</LinearLayout>

View File

@ -26,6 +26,7 @@
android:layout_height="wrap_content"
android:background="?selectableItemBackground"
android:clipChildren="false"
android:clipToPadding="false"
android:padding="@dimen/element_spacing_normal"
app:ignorePadding="true"
tools:context=".adapter.ParcelableUsersAdapter">
@ -41,6 +42,7 @@
android:layout_marginEnd="@dimen/element_spacing_normal"
android:layout_marginRight="@dimen/element_spacing_normal"
android:clipChildren="false"
android:clipToPadding="false"
tools:visibility="visible">
<org.mariotaku.twidere.view.ProfileImageView
@ -68,7 +70,6 @@
tools:visibility="visible"/>
</RelativeLayout>
<org.mariotaku.twidere.view.NameView
android:id="@+id/name"
android:layout_width="match_parent"
@ -224,6 +225,7 @@
tools:text="https://github.com/TwidereProject"/>
<LinearLayout
android:id="@+id/countsContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/name"

View File

@ -49,6 +49,7 @@
android:title="@string/enable_retweets"/>
<item
android:id="@id/add_to_filter"
android:checkable="true"
android:icon="@drawable/ic_action_speaker_muted"
android:title="@string/add_to_filter"/>
<item