diff --git a/twidere/src/main/java/org/mariotaku/twidere/view/NameView.java b/twidere/src/main/java/org/mariotaku/twidere/view/NameView.java deleted file mode 100644 index 1eb98c410..000000000 --- a/twidere/src/main/java/org/mariotaku/twidere/view/NameView.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Twidere - Twitter client for Android - * - * Copyright (C) 2012-2015 Mariotaku Lee - * - * 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 . - */ - -package org.mariotaku.twidere.view; - -import android.content.Context; -import android.content.res.Resources; -import android.content.res.TypedArray; -import android.support.annotation.Nullable; -import android.support.v4.text.BidiFormatter; -import android.support.v7.widget.AppCompatTextView; -import android.text.SpannableStringBuilder; -import android.text.Spanned; -import android.text.TextUtils; -import android.text.style.AbsoluteSizeSpan; -import android.text.style.ForegroundColorSpan; -import android.text.style.StyleSpan; -import android.util.AttributeSet; -import android.util.TypedValue; - -import org.mariotaku.twidere.R; -import org.mariotaku.twidere.text.util.SafeEditableFactory; -import org.mariotaku.twidere.text.util.SafeSpannableFactory; - -/** - * Created by mariotaku on 15/5/28. - */ -public class NameView extends AppCompatTextView { - - private boolean mNameFirst; - private boolean mTwoLine; - - private String mName, mScreenName; - - private ForegroundColorSpan mPrimaryTextColor, mSecondaryTextColor; - private StyleSpan mPrimaryTextStyle, mSecondaryTextStyle; - private AbsoluteSizeSpan mPrimaryTextSize, mSecondaryTextSize; - - public NameView(final Context context) { - this(context, null); - } - - public NameView(final Context context, final AttributeSet attrs) { - this(context, attrs, 0); - } - - public NameView(final Context context, final AttributeSet attrs, final int defStyleAttr) { - super(context, attrs, defStyleAttr); - setSpannableFactory(new SafeSpannableFactory()); - setEditableFactory(new SafeEditableFactory()); - setEllipsize(TextUtils.TruncateAt.END); - final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.NameView, defStyleAttr, 0); - setPrimaryTextColor(a.getColor(R.styleable.NameView_nv_primaryTextColor, 0)); - setSecondaryTextColor(a.getColor(R.styleable.NameView_nv_secondaryTextColor, 0)); - setTwoLine(a.getBoolean(R.styleable.NameView_nv_twoLine, false)); - mPrimaryTextStyle = new StyleSpan(a.getInt(R.styleable.NameView_nv_primaryTextStyle, 0)); - mSecondaryTextStyle = new StyleSpan(a.getInt(R.styleable.NameView_nv_secondaryTextStyle, 0)); - a.recycle(); - setNameFirst(true); - if (isInEditMode()) { - setName("Name"); - setScreenName("@screenname"); - updateText(); - } - } - - public void setPrimaryTextColor(final int color) { - mPrimaryTextColor = new ForegroundColorSpan(color); - } - - public void setSecondaryTextColor(final int color) { - mSecondaryTextColor = new ForegroundColorSpan(color); - } - - public void setName(String name) { - mName = name; - } - - public void setScreenName(String screenName) { - mScreenName = screenName; - } - - public void setNameFirst(final boolean nameFirst) { - mNameFirst = nameFirst; - } - - public void updateText() { - updateText(null); - } - - public void updateText(@Nullable BidiFormatter formatter) { - final SpannableStringBuilder sb = new SpannableStringBuilder(); - final String primaryText = mNameFirst ? mName : mScreenName; - final String secondaryText = mNameFirst ? mScreenName : mName; - if (primaryText != null) { - int start = sb.length(); - if (formatter != null && !isInEditMode()) { - sb.append(formatter.unicodeWrap(primaryText)); - } else { - sb.append(primaryText); - } - int end = sb.length(); - sb.setSpan(mPrimaryTextColor, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - sb.setSpan(mPrimaryTextStyle, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - sb.setSpan(mPrimaryTextSize, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - } - sb.append(mTwoLine ? '\n' : ' '); - if (secondaryText != null) { - int start = sb.length(); - if (formatter != null && !isInEditMode()) { - sb.append(formatter.unicodeWrap(secondaryText)); - } else { - sb.append(secondaryText); - } - int end = sb.length(); - sb.setSpan(mSecondaryTextColor, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - sb.setSpan(mSecondaryTextStyle, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - sb.setSpan(mSecondaryTextSize, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - } - setText(sb); - } - - public void setPrimaryTextSize(final float textSize) { - mPrimaryTextSize = new AbsoluteSizeSpan((int) calculateTextSize(TypedValue.COMPLEX_UNIT_SP, textSize)); - } - - private float calculateTextSize(final int unit, final float size) { - Context c = getContext(); - Resources r; - - if (c == null) - r = Resources.getSystem(); - else - r = c.getResources(); - return TypedValue.applyDimension(unit, size, r.getDisplayMetrics()); - } - - public void setSecondaryTextSize(final float textSize) { - mSecondaryTextSize = new AbsoluteSizeSpan((int) calculateTextSize(TypedValue.COMPLEX_UNIT_SP, textSize)); - } - - public void setTwoLine(boolean twoLine) { - mTwoLine = twoLine; - if (twoLine) { - setSingleLine(false); - setMaxLines(2); - } else { - setSingleLine(true); - } - } - -} diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/MessagesConversationFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/MessagesConversationFragment.kt index f993d6b01..ef7de4762 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/MessagesConversationFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/MessagesConversationFragment.kt @@ -48,6 +48,7 @@ import android.view.* import android.view.View.OnClickListener import android.widget.AdapterView import android.widget.AdapterView.OnItemSelectedListener +import android.widget.EditText import android.widget.Toast import com.squareup.otto.Subscribe import kotlinx.android.synthetic.main.fragment_messages_conversation.* @@ -433,7 +434,7 @@ class MessagesConversationFragment : BaseFragment(), LoaderCallbacks, O val action = handler.getKeyAction(CONTEXT_TAG_NAVIGATION, keyCode, event, metaState) if (ACTION_NAVIGATION_BACK == action) { val showingConversation = isShowingConversation - val editText = if (showingConversation) editText else actionBarCustomView.editUserQuery + val editText: EditText = if (showingConversation) editText else actionBarCustomView.editUserQuery val textChanged = if (showingConversation) textChanged else queryTextChanged if (editText.length() == 0 && !textChanged) { val activity = activity diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/StatusFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/StatusFragment.kt index f9b5ee41e..2299240fe 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/StatusFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/StatusFragment.kt @@ -96,6 +96,8 @@ import org.mariotaku.twidere.loader.ConversationLoader import org.mariotaku.twidere.loader.ParcelableStatusLoader import org.mariotaku.twidere.menu.FavoriteItemProvider import org.mariotaku.twidere.model.* +import org.mariotaku.twidere.model.ParcelableStatusValuesCreator +import org.mariotaku.twidere.model.ParcelableActivityCursorIndices import org.mariotaku.twidere.model.analyzer.Share import org.mariotaku.twidere.model.analyzer.StatusView import org.mariotaku.twidere.model.message.FavoriteTaskEvent @@ -832,9 +834,9 @@ class StatusFragment : BaseFragment(), LoaderCallbacks(adapter) + setAdapter(adapter) updateAccountKey() } @@ -73,6 +73,15 @@ class ComposeEditText @JvmOverloads constructor( adapter = null } + override fun onTextContextMenuItem(id: Int): Boolean { + try { + return super.onTextContextMenuItem(id) + } catch (e: AbstractMethodError) { + // http://crashes.to/s/69acd0ea0de + return true + } + } + private fun updateAccountKey() { adapter?.accountKey = accountKey } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/view/FixedEditText.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/view/FixedEditText.kt new file mode 100644 index 000000000..d586dd68d --- /dev/null +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/view/FixedEditText.kt @@ -0,0 +1,21 @@ +package org.mariotaku.twidere.view + +import android.content.Context +import android.util.AttributeSet +import org.mariotaku.chameleon.view.ChameleonEditText + +/** + * Created by mariotaku on 2017/2/3. + */ + +class FixedEditText(context: Context, attrs: AttributeSet? = null) : ChameleonEditText(context, attrs) { + + override fun onTextContextMenuItem(id: Int): Boolean { + try { + return super.onTextContextMenuItem(id) + } catch (e: AbstractMethodError) { + // http://crashes.to/s/69acd0ea0de + return true + } + } +} diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/view/FixedTextView.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/view/FixedTextView.kt new file mode 100644 index 000000000..16064b236 --- /dev/null +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/view/FixedTextView.kt @@ -0,0 +1,21 @@ +package org.mariotaku.twidere.view + +import android.content.Context +import android.util.AttributeSet +import org.mariotaku.chameleon.view.ChameleonTextView + +/** + * Created by mariotaku on 2017/2/3. + */ + +class FixedTextView(context: Context, attrs: AttributeSet? = null) : ChameleonTextView(context, attrs) { + + override fun onTextContextMenuItem(id: Int): Boolean { + try { + return super.onTextContextMenuItem(id) + } catch (e: AbstractMethodError) { + // http://crashes.to/s/69acd0ea0de + return true + } + } +} diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/view/NameView.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/view/NameView.kt new file mode 100644 index 000000000..33da87020 --- /dev/null +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/view/NameView.kt @@ -0,0 +1,148 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2015 Mariotaku Lee + * + * 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 . + */ + +package org.mariotaku.twidere.view + +import android.content.Context +import android.content.res.Resources +import android.support.v4.text.BidiFormatter +import android.support.v7.widget.AppCompatTextView +import android.text.SpannableStringBuilder +import android.text.Spanned +import android.text.TextUtils +import android.text.style.AbsoluteSizeSpan +import android.text.style.ForegroundColorSpan +import android.text.style.StyleSpan +import android.util.AttributeSet +import android.util.TypedValue +import org.mariotaku.twidere.R +import org.mariotaku.twidere.text.util.SafeEditableFactory +import org.mariotaku.twidere.text.util.SafeSpannableFactory + +/** + * Created by mariotaku on 15/5/28. + */ +class NameView(context: Context, attrs: AttributeSet? = null) : AppCompatTextView(context, attrs, 0) { + + var nameFirst: Boolean = false + var twoLine: Boolean = false + get() { + return maxLines >= 2 + } + set(value) { + field = value + if (value) { + maxLines = 2 + } else { + maxLines = 1 + } + } + + var name: String? = null + var screenName: String? = null + + private val primaryTextStyle: StyleSpan + private val secondaryTextStyle: StyleSpan + private var primaryTextColor: ForegroundColorSpan? = null + private var secondaryTextColor: ForegroundColorSpan? = null + private var primaryTextSize: AbsoluteSizeSpan? = null + private var secondaryTextSize: AbsoluteSizeSpan? = null + + init { + setSpannableFactory(SafeSpannableFactory()) + setEditableFactory(SafeEditableFactory()) + ellipsize = TextUtils.TruncateAt.END + val a = context.obtainStyledAttributes(attrs, R.styleable.NameView, 0, 0) + setPrimaryTextColor(a.getColor(R.styleable.NameView_nv_primaryTextColor, 0)) + setSecondaryTextColor(a.getColor(R.styleable.NameView_nv_secondaryTextColor, 0)) + twoLine = a.getBoolean(R.styleable.NameView_nv_twoLine, false) + primaryTextStyle = StyleSpan(a.getInt(R.styleable.NameView_nv_primaryTextStyle, 0)) + secondaryTextStyle = StyleSpan(a.getInt(R.styleable.NameView_nv_secondaryTextStyle, 0)) + a.recycle() + nameFirst = true + if (isInEditMode) { + name = "Name" + screenName = "@screenname" + updateText() + } + } + + override fun onTextContextMenuItem(id: Int): Boolean { + try { + return super.onTextContextMenuItem(id) + } catch (e: AbstractMethodError) { + // http://crashes.to/s/69acd0ea0de + return true + } + } + + fun setPrimaryTextColor(color: Int) { + primaryTextColor = ForegroundColorSpan(color) + } + + fun setSecondaryTextColor(color: Int) { + secondaryTextColor = ForegroundColorSpan(color) + } + + fun updateText(formatter: BidiFormatter? = null) { + val sb = SpannableStringBuilder() + val primaryText = if (nameFirst) name else screenName + val secondaryText = if (nameFirst) screenName else name + if (primaryText != null) { + val start = sb.length + if (formatter != null && !isInEditMode) { + sb.append(formatter.unicodeWrap(primaryText)) + } else { + sb.append(primaryText) + } + val end = sb.length + sb.setSpan(primaryTextColor, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) + sb.setSpan(primaryTextStyle, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) + sb.setSpan(primaryTextSize, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) + } + sb.append(if (twoLine) '\n' else ' ') + if (secondaryText != null) { + val start = sb.length + if (formatter != null && !isInEditMode) { + sb.append(formatter.unicodeWrap(secondaryText)) + } else { + sb.append(secondaryText) + } + val end = sb.length + sb.setSpan(secondaryTextColor, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) + sb.setSpan(secondaryTextStyle, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) + sb.setSpan(secondaryTextSize, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) + } + text = sb + } + + fun setPrimaryTextSize(textSize: Float) { + primaryTextSize = AbsoluteSizeSpan(calculateTextSize(TypedValue.COMPLEX_UNIT_SP, textSize).toInt()) + } + + fun setSecondaryTextSize(textSize: Float) { + secondaryTextSize = AbsoluteSizeSpan(calculateTextSize(TypedValue.COMPLEX_UNIT_SP, textSize).toInt()) + } + + private fun calculateTextSize(unit: Int, size: Float): Float { + val r = context.resources ?: Resources.getSystem() + return TypedValue.applyDimension(unit, size, r.displayMetrics) + } + +} diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/view/TimelineContentTextView.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/view/TimelineContentTextView.kt index cd270c38c..e034deb68 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/view/TimelineContentTextView.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/view/TimelineContentTextView.kt @@ -76,6 +76,15 @@ class TimelineContentTextView @JvmOverloads constructor( super.setLongClickable(longClickable && isTextSelectable) } + override fun onTextContextMenuItem(id: Int): Boolean { + try { + return super.onTextContextMenuItem(id) + } catch (e: AbstractMethodError) { + // http://crashes.to/s/69acd0ea0de + return true + } + } + internal class InternalMovementMethod : MovementMethod { private var targetSpan: ClickableSpan? = null diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/GroupViewHolder.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/GroupViewHolder.kt index 0a0ba4db9..03f426283 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/GroupViewHolder.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/GroupViewHolder.kt @@ -64,8 +64,8 @@ class GroupViewHolder(private val adapter: IGroupsAdapter<*>, itemView: View) : val loader = adapter.mediaLoader val formatter = adapter.bidiFormatter - nameView.setName(group.fullname) - nameView.setScreenName("!" + group.nickname) + nameView.name = group.fullname + nameView.screenName = "!${group.nickname}" nameView.updateText(formatter) val groupHost = UserKeyUtils.getUserHost(group.url, group.account_key.host) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/MessageEntryViewHolder.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/MessageEntryViewHolder.kt index 45141b681..e10df7eee 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/MessageEntryViewHolder.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/MessageEntryViewHolder.kt @@ -71,8 +71,8 @@ class MessageEntryViewHolder(private val adapter: MessageEntriesAdapter, itemVie val name = cursor.getString(ConversationEntries.IDX_NAME) val screenName = cursor.getString(ConversationEntries.IDX_SCREEN_NAME) - nameView.setName(manager.getUserNickname(conversationId, name)) - nameView.setScreenName("@" + screenName) + nameView.name = manager.getUserNickname(conversationId, name) + nameView.screenName = "@$screenName" nameView.updateText(adapter.bidiFormatter) textView.text = toPlainText(cursor.getString(ConversationEntries.IDX_TEXT_UNESCAPED)) timeView.time = timestamp diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/StatusViewHolder.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/StatusViewHolder.kt index fc06843f1..a91708dec 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/StatusViewHolder.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/StatusViewHolder.kt @@ -12,6 +12,7 @@ import android.widget.ImageView import kotlinx.android.synthetic.main.list_item_status.view.* import org.mariotaku.ktextension.applyFontFamily import org.mariotaku.twidere.Constants +import org.mariotaku.twidere.Constants.* import org.mariotaku.twidere.R import org.mariotaku.twidere.TwidereConstants.USER_TYPE_FANFOU_COM import org.mariotaku.twidere.adapter.iface.IStatusesAdapter @@ -94,14 +95,14 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View) statusContentUpperSpace.visibility = View.VISIBLE profileImageView.setImageResource(R.drawable.ic_profile_image_twidere) - nameView.setName(Constants.TWIDERE_PREVIEW_NAME) - nameView.setScreenName("@" + Constants.TWIDERE_PREVIEW_SCREEN_NAME) + nameView.name = TWIDERE_PREVIEW_NAME + nameView.screenName = "@" + TWIDERE_PREVIEW_SCREEN_NAME nameView.updateText(adapter.bidiFormatter) if (adapter.linkHighlightingStyle == VALUE_LINK_HIGHLIGHT_OPTION_CODE_NONE) { - textView.text = toPlainText(Constants.TWIDERE_PREVIEW_TEXT_HTML) + textView.text = toPlainText(TWIDERE_PREVIEW_TEXT_HTML) } else { val linkify = adapter.twidereLinkify - val text = HtmlSpanBuilder.fromHtml(Constants.TWIDERE_PREVIEW_TEXT_HTML) + val text = HtmlSpanBuilder.fromHtml(TWIDERE_PREVIEW_TEXT_HTML) linkify.applyAllLinks(text, null, -1, false, adapter.linkHighlightingStyle, true) textView.text = text } @@ -194,9 +195,9 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View) quotedTextView.visibility = View.VISIBLE val quoted_user_key = status.quoted_user_key!! - quotedNameView.setName(colorNameManager.getUserNickname(quoted_user_key, - status.quoted_user_name)) - quotedNameView.setScreenName("@${status.quoted_user_screen_name}") + quotedNameView.name = colorNameManager.getUserNickname(quoted_user_key, + status.quoted_user_name) + quotedNameView.screenName = "@${status.quoted_user_screen_name}" var quotedDisplayEnd = -1 if (status.extras.quoted_display_text_range != null) { @@ -285,8 +286,8 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View) status.timestamp } - nameView.setName(colorNameManager.getUserNickname(status.user_key, status.user_name)) - nameView.setScreenName("@${status.user_screen_name}") + nameView.name = colorNameManager.getUserNickname(status.user_key, status.user_name) + nameView.screenName = "@${status.user_screen_name}" if (adapter.profileImageEnabled) { profileImageView.visibility = View.VISIBLE @@ -492,8 +493,8 @@ class StatusViewHolder(private val adapter: IStatusesAdapter<*>, itemView: View) // profileImageView.setStyle(adapter.getProfileImageStyle()); val nameFirst = adapter.nameFirst - nameView.setNameFirst(nameFirst) - quotedNameView.setNameFirst(nameFirst) + nameView.nameFirst = nameFirst + quotedNameView.nameFirst = nameFirst val favIcon: Int val favStyle: Int diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/UserViewHolder.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/UserViewHolder.kt index 134f99bb7..4c722ca87 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/UserViewHolder.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/view/holder/UserViewHolder.kt @@ -129,8 +129,8 @@ class UserViewHolder( } else { profileTypeView.setImageDrawable(null) } - nameView.setName(manager.getUserNickname(user.key, user.name)) - nameView.setScreenName("@${user.screen_name}") + nameView.name = manager.getUserNickname(user.key, user.name) + nameView.screenName = "@${user.screen_name}" nameView.updateText(adapter.bidiFormatter) if (adapter.profileImageEnabled) { @@ -238,10 +238,10 @@ class UserViewHolder( this.requestClickListener = requestClickListener this.friendshipClickListener = friendshipClickListener if (requestClickListener != null || friendshipClickListener != null) { - nameView.setTwoLine(true) + nameView.twoLine = true actionsProgressContainer.visibility = View.VISIBLE } else { - nameView.setTwoLine(false) + nameView.twoLine = false actionsProgressContainer.visibility = View.GONE } nameView.updateText() diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/view/viewer/MediaSwipeCloseContainer.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/view/viewer/MediaSwipeCloseContainer.kt index a7a589369..7299a4d5f 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/view/viewer/MediaSwipeCloseContainer.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/view/viewer/MediaSwipeCloseContainer.kt @@ -15,7 +15,7 @@ import android.view.ViewGroup */ class MediaSwipeCloseContainer(context: Context, attrs: AttributeSet? = null) : ViewGroup(context, attrs) { - private val dragHelper: ViewDragHelper = ViewDragHelper.create(this, object : ViewDragHelper.Callback() { + private val dragHelper: ViewDragHelper = ViewDragHelper.create(this, 0.5f, object : ViewDragHelper.Callback() { override fun onViewPositionChanged(changedView: View?, left: Int, top: Int, dx: Int, dy: Int) { val container = this@MediaSwipeCloseContainer container.childTop = top @@ -45,7 +45,9 @@ class MediaSwipeCloseContainer(context: Context, attrs: AttributeSet? = null) : override fun onViewReleased(releasedChild: View, xvel: Float, yvel: Float) { val container = this@MediaSwipeCloseContainer val minVel = ViewConfiguration.get(context).scaledMinimumFlingVelocity - when { + if (Math.abs(yvel) < Math.abs(xvel)) { + container.dragHelper.smoothSlideViewTo(releasedChild, 0, 0) + } else when { yvel > minVel && childTop > 0 -> { // Settle downward container.dragHelper.settleCapturedViewAt(0, container.height) diff --git a/twidere/src/main/res/layout/activity_compose.xml b/twidere/src/main/res/layout/activity_compose.xml index 594541901..2d741831f 100644 --- a/twidere/src/main/res/layout/activity_compose.xml +++ b/twidere/src/main/res/layout/activity_compose.xml @@ -42,7 +42,7 @@ android:layout_height="wrap_content" android:orientation="vertical"> - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + \ No newline at end of file diff --git a/twidere/src/main/res/layout/dialog_password_sign_in.xml b/twidere/src/main/res/layout/dialog_password_sign_in.xml index 887dac165..4cf9b0db9 100644 --- a/twidere/src/main/res/layout/dialog_password_sign_in.xml +++ b/twidere/src/main/res/layout/dialog_password_sign_in.xml @@ -7,7 +7,7 @@ android:orientation="vertical" android:padding="@dimen/element_spacing_normal"> - - - - - - + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - + \ No newline at end of file diff --git a/twidere/src/main/res/layout/layout_extra_config_user.xml b/twidere/src/main/res/layout/layout_extra_config_user.xml index 848b0a11f..27b1f0b54 100644 --- a/twidere/src/main/res/layout/layout_extra_config_user.xml +++ b/twidere/src/main/res/layout/layout_extra_config_user.xml @@ -10,7 +10,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/twidere/src/main/res/layout/list_item_section_header.xml b/twidere/src/main/res/layout/list_item_section_header.xml index 98810de42..e286e018f 100644 --- a/twidere/src/main/res/layout/list_item_section_header.xml +++ b/twidere/src/main/res/layout/list_item_section_header.xml @@ -1,5 +1,5 @@ -. --> - - - - - - - - - - - - - - - - - - -