improved compact status card appearance
This commit is contained in:
parent
25d7491b40
commit
21a4b1046f
|
@ -56,6 +56,7 @@ import android.support.v7.widget.RecyclerView.ViewHolder;
|
|||
import android.text.Html;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -86,7 +87,6 @@ import org.mariotaku.twidere.model.ParcelableLocation;
|
|||
import org.mariotaku.twidere.model.ParcelableMedia;
|
||||
import org.mariotaku.twidere.model.ParcelableStatus;
|
||||
import org.mariotaku.twidere.model.SingleResponse;
|
||||
import org.mariotaku.twidere.text.method.StatusContentMovementMethod;
|
||||
import org.mariotaku.twidere.util.AsyncTaskUtils;
|
||||
import org.mariotaku.twidere.util.AsyncTwitterWrapper;
|
||||
import org.mariotaku.twidere.util.CompareUtils;
|
||||
|
@ -754,7 +754,7 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
} else if (!TextUtils.isEmpty(timeString) && TextUtils.isEmpty(source)) {
|
||||
timeSourceView.setText(timeString);
|
||||
}
|
||||
timeSourceView.setMovementMethod(StatusContentMovementMethod.getInstance());
|
||||
timeSourceView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
textView.setText(Html.fromHtml(status.text_html));
|
||||
linkify.applyAllLinks(textView, status.account_id, layoutPosition, status.is_possibly_sensitive);
|
||||
|
@ -826,8 +826,8 @@ public class StatusFragment extends BaseSupportFragment implements LoaderCallbac
|
|||
quoteTextView.setTextIsSelectable(true);
|
||||
textView.setTextIsSelectable(true);
|
||||
|
||||
quoteTextView.setMovementMethod(StatusContentMovementMethod.getInstance());
|
||||
textView.setMovementMethod(StatusContentMovementMethod.getInstance());
|
||||
quoteTextView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
textView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,110 +0,0 @@
|
|||
/*
|
||||
* 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.text.method;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.Layout;
|
||||
import android.text.NoCopySpan;
|
||||
import android.text.Selection;
|
||||
import android.text.Spannable;
|
||||
import android.text.method.ArrowKeyMovementMethod;
|
||||
import android.text.method.MovementMethod;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.widget.TextView;
|
||||
|
||||
/**
|
||||
* A movement method that traverses links in the text buffer and scrolls if
|
||||
* necessary. Supports clicking on links with DPad Center or Enter.
|
||||
*/
|
||||
public class StatusContentMovementMethod extends ArrowKeyMovementMethod {
|
||||
|
||||
private static StatusContentMovementMethod sInstance;
|
||||
|
||||
private static Object FROM_BELOW = new NoCopySpan.Concrete();
|
||||
|
||||
@Override
|
||||
public void initialize(final TextView widget, final Spannable text) {
|
||||
Selection.removeSelection(text);
|
||||
text.removeSpan(FROM_BELOW);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTakeFocus(@NonNull final TextView view, @NonNull final Spannable text, final int dir) {
|
||||
Selection.removeSelection(text);
|
||||
|
||||
if ((dir & View.FOCUS_BACKWARD) != 0) {
|
||||
text.setSpan(FROM_BELOW, 0, 0, Spannable.SPAN_POINT_POINT);
|
||||
} else {
|
||||
text.removeSpan(FROM_BELOW);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(@NonNull final TextView widget, @NonNull final Spannable buffer, @NonNull final MotionEvent event) {
|
||||
final int action = event.getActionMasked();
|
||||
|
||||
if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_DOWN) {
|
||||
int x = (int) event.getX();
|
||||
int y = (int) event.getY();
|
||||
|
||||
x -= widget.getTotalPaddingLeft();
|
||||
y -= widget.getTotalPaddingTop();
|
||||
|
||||
x += widget.getScrollX();
|
||||
y += widget.getScrollY();
|
||||
|
||||
final Layout layout = widget.getLayout();
|
||||
final int line = layout.getLineForVertical(y);
|
||||
final int off = layout.getOffsetForHorizontal(line, x);
|
||||
|
||||
final ClickableSpan[] link = buffer.getSpans(off, off, ClickableSpan.class);
|
||||
|
||||
|
||||
if (link.length != 0) {
|
||||
if (action == MotionEvent.ACTION_DOWN) {
|
||||
Selection.setSelection(buffer, buffer.getSpanStart(link[0]), buffer.getSpanEnd(link[0]));
|
||||
return true;
|
||||
} else {
|
||||
if ((!widget.isLongClickable() || (event.getEventTime() - event.getDownTime()) < ViewConfiguration.getLongPressTimeout())) {
|
||||
link[0].onClick(widget);
|
||||
}
|
||||
Selection.removeSelection(buffer);
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
Selection.removeSelection(buffer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return super.onTouchEvent(widget, buffer, event);
|
||||
}
|
||||
|
||||
public static MovementMethod getInstance() {
|
||||
if (sInstance == null) {
|
||||
sInstance = new StatusContentMovementMethod();
|
||||
}
|
||||
|
||||
return sInstance;
|
||||
}
|
||||
}
|
|
@ -40,10 +40,10 @@
|
|||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignTop="@+id/reply_retweet_status"
|
||||
android:layout_marginEnd="@dimen/element_spacing_small"
|
||||
android:layout_marginLeft="@dimen/element_spacing_normal"
|
||||
android:layout_marginStart="@dimen/element_spacing_normal"
|
||||
android:layout_marginRight="@dimen/element_spacing_small"
|
||||
android:layout_marginEnd="@dimen/element_spacing_small" />
|
||||
android:layout_marginStart="@dimen/element_spacing_normal" />
|
||||
|
||||
<org.mariotaku.twidere.view.ActionIconView
|
||||
android:id="@+id/reply_retweet_icon"
|
||||
|
@ -68,8 +68,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/element_spacing_normal"
|
||||
android:layout_marginRight="@dimen/element_spacing_normal"
|
||||
android:layout_toRightOf="@+id/reply_retweet_space"
|
||||
android:layout_toEndOf="@+id/reply_retweet_space"
|
||||
android:layout_toRightOf="@+id/reply_retweet_space"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical|start"
|
||||
android:minHeight="@dimen/element_size_small"
|
||||
|
@ -98,8 +98,8 @@
|
|||
android:layout_height="@dimen/icon_size_status_profile_image"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginBottom="@dimen/element_spacing_small"
|
||||
android:layout_marginRight="@dimen/element_spacing_small"
|
||||
android:layout_marginEnd="@dimen/element_spacing_small"
|
||||
android:layout_marginRight="@dimen/element_spacing_small"
|
||||
android:layout_marginTop="@dimen/element_spacing_small"
|
||||
android:contentDescription="@string/profile_image"
|
||||
android:scaleType="centerCrop" />
|
||||
|
@ -109,8 +109,8 @@
|
|||
android:layout_width="@dimen/icon_size_profile_type"
|
||||
android:layout_height="@dimen/icon_size_profile_type"
|
||||
android:layout_alignBottom="@id/profile_image"
|
||||
android:layout_alignRight="@id/profile_image"
|
||||
android:layout_alignEnd="@id/profile_image"
|
||||
android:layout_alignRight="@id/profile_image"
|
||||
android:scaleType="fitCenter" />
|
||||
|
||||
<LinearLayout
|
||||
|
@ -119,10 +119,10 @@
|
|||
android:layout_centerVertical="true"
|
||||
android:layout_marginLeft="@dimen/element_spacing_normal"
|
||||
android:layout_marginStart="@dimen/element_spacing_normal"
|
||||
android:layout_toLeftOf="@+id/extra_type"
|
||||
android:layout_toStartOf="@+id/extra_type"
|
||||
android:layout_toRightOf="@id/profile_image"
|
||||
android:layout_toEndOf="@id/profile_image"
|
||||
android:layout_toLeftOf="@+id/extra_type"
|
||||
android:layout_toRightOf="@id/profile_image"
|
||||
android:layout_toStartOf="@+id/extra_type"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
|
@ -176,8 +176,8 @@
|
|||
android:id="@+id/extra_type"
|
||||
android:layout_width="@dimen/element_size_small"
|
||||
android:layout_height="@dimen/element_size_small"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginBottom="@dimen/element_spacing_normal"
|
||||
android:layout_marginLeft="@dimen/element_spacing_mlarge"
|
||||
|
@ -222,8 +222,8 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/quote_text"
|
||||
android:layout_toRightOf="@+id/quote_indicator"
|
||||
android:layout_toEndOf="@+id/quote_indicator"
|
||||
android:layout_toRightOf="@+id/quote_indicator"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="@dimen/element_spacing_normal"
|
||||
|
@ -260,8 +260,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/quoted_name_container"
|
||||
android:layout_marginTop="@dimen/element_spacing_normal"
|
||||
android:layout_toRightOf="@+id/quote_indicator"
|
||||
android:layout_toEndOf="@+id/quote_indicator"
|
||||
android:layout_toRightOf="@+id/quote_indicator"
|
||||
android:horizontalSpacing="@dimen/element_spacing_xsmall"
|
||||
android:verticalSpacing="@dimen/element_spacing_xsmall">
|
||||
|
||||
|
@ -276,8 +276,8 @@
|
|||
android:layout_below="@id/media_preview"
|
||||
android:layout_marginBottom="@dimen/element_spacing_normal"
|
||||
android:layout_marginTop="@dimen/element_spacing_normal"
|
||||
android:layout_toRightOf="@+id/quote_indicator"
|
||||
android:layout_toEndOf="@+id/quote_indicator"
|
||||
android:layout_toRightOf="@+id/quote_indicator"
|
||||
android:paddingLeft="@dimen/element_spacing_normal"
|
||||
android:paddingRight="@dimen/element_spacing_normal"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
|
@ -346,12 +346,11 @@
|
|||
android:id="@+id/item_menu"
|
||||
style="?cardActionButtonStyle"
|
||||
android:layout_width="@dimen/element_size_normal"
|
||||
android:layout_height="@dimen/element_size_normal"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@+id/action_buttons"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignTop="@+id/action_buttons"
|
||||
android:layout_marginBottom="@dimen/element_spacing_small"
|
||||
android:layout_marginLeft="@dimen/element_spacing_normal"
|
||||
android:layout_marginRight="@dimen/element_spacing_normal"
|
||||
android:color="?android:textColorTertiary"
|
||||
|
|
|
@ -32,19 +32,17 @@
|
|||
android:focusableInTouchMode="false"
|
||||
android:orientation="horizontal"
|
||||
android:paddingLeft="@dimen/element_spacing_normal"
|
||||
android:paddingRight="@dimen/element_spacing_normal"
|
||||
android:paddingTop="@dimen/element_spacing_normal">
|
||||
android:paddingRight="@dimen/element_spacing_normal">
|
||||
|
||||
<org.mariotaku.twidere.view.ActionIconView
|
||||
android:id="@+id/reply_retweet_icon"
|
||||
style="?profileImageStyle"
|
||||
android:layout_width="@dimen/element_size_small"
|
||||
android:layout_height="@dimen/element_size_small"
|
||||
android:layout_alignEnd="@id/profile_image_space"
|
||||
android:layout_alignRight="@id/profile_image_space"
|
||||
android:layout_alignBottom="@id/reply_retweet_status"
|
||||
android:layout_alignEnd="@id/profile_image"
|
||||
android:layout_alignRight="@id/profile_image"
|
||||
android:layout_alignTop="@id/reply_retweet_status"
|
||||
android:layout_marginLeft="@dimen/element_spacing_small"
|
||||
android:layout_marginStart="@dimen/element_spacing_small"
|
||||
android:color="?android:textColorSecondary"
|
||||
android:padding="@dimen/element_spacing_small"
|
||||
android:scaleType="centerInside"
|
||||
|
@ -56,12 +54,11 @@
|
|||
android:id="@+id/reply_retweet_status"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignLeft="@+id/status_content"
|
||||
android:layout_alignStart="@+id/status_content"
|
||||
android:layout_marginBottom="@dimen/element_spacing_small"
|
||||
android:layout_marginEnd="@dimen/element_spacing_normal"
|
||||
android:layout_marginRight="@dimen/element_spacing_normal"
|
||||
android:layout_marginTop="@dimen/element_spacing_minus_small"
|
||||
android:layout_marginBottom="@dimen/element_spacing_minus_small"
|
||||
android:layout_marginLeft="@dimen/element_spacing_small"
|
||||
android:layout_marginStart="@dimen/element_spacing_small"
|
||||
android:layout_toEndOf="@id/reply_retweet_icon"
|
||||
android:layout_toRightOf="@id/reply_retweet_icon"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center_vertical|start"
|
||||
android:minHeight="@dimen/element_size_small"
|
||||
|
@ -72,14 +69,6 @@
|
|||
tools:textSize="@dimen/text_size_extra_small"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<Space
|
||||
android:id="@+id/profile_image_space"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="@dimen/icon_size_status_profile_image"
|
||||
android:layout_alignEnd="@id/profile_image"
|
||||
android:layout_alignRight="@id/profile_image"
|
||||
android:layout_below="@+id/reply_retweet_icon" />
|
||||
|
||||
<org.mariotaku.twidere.view.ShapedImageView
|
||||
android:id="@+id/profile_image"
|
||||
style="?profileImageStyle"
|
||||
|
@ -87,10 +76,14 @@
|
|||
android:layout_height="@dimen/icon_size_status_profile_image"
|
||||
android:layout_alignParentLeft="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_alignTop="@+id/status_content"
|
||||
android:layout_alignWithParentIfMissing="true"
|
||||
android:layout_below="@+id/reply_retweet_status"
|
||||
android:layout_marginEnd="@dimen/element_spacing_small"
|
||||
android:layout_marginRight="@dimen/element_spacing_small"
|
||||
android:contentDescription="@string/profile_image"
|
||||
android:scaleType="centerCrop" />
|
||||
android:scaleType="centerCrop"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<org.mariotaku.twidere.view.BoundsImageView
|
||||
android:id="@+id/profile_type"
|
||||
|
@ -102,18 +95,17 @@
|
|||
android:layout_marginBottom="@dimen/element_spacing_minus_small"
|
||||
android:layout_marginEnd="@dimen/element_spacing_minus_small"
|
||||
android:layout_marginRight="@dimen/element_spacing_minus_small"
|
||||
android:scaleType="fitCenter" />
|
||||
android:scaleType="fitCenter"
|
||||
tools:visibility="gone" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/status_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignTop="@id/profile_image_space"
|
||||
android:layout_marginBottom="@dimen/element_spacing_normal"
|
||||
android:layout_marginLeft="@dimen/element_spacing_normal"
|
||||
android:layout_marginStart="@dimen/element_spacing_normal"
|
||||
android:layout_toEndOf="@id/profile_image_space"
|
||||
android:layout_toRightOf="@id/profile_image_space"
|
||||
android:layout_below="@id/reply_retweet_status"
|
||||
android:layout_marginTop="@dimen/element_spacing_small"
|
||||
android:layout_toEndOf="@id/profile_image"
|
||||
android:layout_toRightOf="@id/profile_image"
|
||||
android:minHeight="@dimen/icon_size_status_profile_image"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
@ -160,6 +152,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
tools:text="42 mins ago"
|
||||
tools:textSize="@dimen/text_size_extra_small" />
|
||||
|
||||
<org.mariotaku.twidere.view.ActionIconView
|
||||
|
@ -179,8 +172,8 @@
|
|||
android:layout_alignLeft="@+id/profile_container"
|
||||
android:layout_alignStart="@+id/profile_container"
|
||||
android:layout_below="@id/profile_container"
|
||||
android:layout_marginBottom="@dimen/element_spacing_small"
|
||||
android:layout_marginTop="@dimen/element_spacing_normal"
|
||||
android:paddingBottom="@dimen/element_spacing_normal"
|
||||
android:paddingTop="@dimen/element_spacing_small"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
android:visibility="gone"
|
||||
|
@ -193,6 +186,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@+id/text"
|
||||
android:layout_alignTop="@+id/quoted_name_container"
|
||||
android:layout_marginBottom="@dimen/element_spacing_normal"
|
||||
android:layout_marginEnd="@dimen/element_spacing_normal"
|
||||
android:layout_marginRight="@dimen/element_spacing_normal"
|
||||
android:background="?android:dividerHorizontal"
|
||||
|
@ -230,9 +224,8 @@
|
|||
android:singleLine="true"
|
||||
android:textAppearance="?android:textAppearanceSmall"
|
||||
android:textColor="?android:textColorSecondary"
|
||||
tools:ignore="SmallSp"
|
||||
tools:text="\@user"
|
||||
tools:textSize="10sp" />
|
||||
tools:text="\@username"
|
||||
tools:textSize="@dimen/text_size_extra_small" />
|
||||
</LinearLayout>
|
||||
|
||||
<org.mariotaku.twidere.view.CardMediaContainer
|
||||
|
@ -255,9 +248,10 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/media_preview"
|
||||
android:layout_marginTop="@dimen/element_spacing_small"
|
||||
android:layout_toEndOf="@+id/quote_indicator"
|
||||
android:layout_toRightOf="@+id/quote_indicator"
|
||||
android:paddingBottom="@dimen/element_spacing_normal"
|
||||
android:paddingTop="@dimen/element_spacing_small"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="?android:attr/textColorPrimary"
|
||||
tools:text="@string/sample_status_text" />
|
||||
|
@ -276,8 +270,8 @@
|
|||
android:layout_toLeftOf="@+id/item_menu"
|
||||
android:layout_toStartOf="@+id/item_menu"
|
||||
android:gravity="center_vertical|start"
|
||||
android:orientation="horizontal">
|
||||
|
||||
android:orientation="horizontal"
|
||||
tools:visibility="visible">
|
||||
|
||||
<org.mariotaku.twidere.view.ActionIconThemedTextView
|
||||
android:id="@+id/reply_count"
|
||||
|
@ -338,10 +332,10 @@
|
|||
android:layout_alignParentEnd="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignTop="@+id/action_buttons"
|
||||
android:layout_marginTop="@dimen/element_spacing_minus_normal"
|
||||
android:color="?android:textColorTertiary"
|
||||
android:focusable="false"
|
||||
android:src="@drawable/ic_action_more_horizontal" />
|
||||
android:src="@drawable/ic_action_more_horizontal"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</RelativeLayout>
|
||||
</org.mariotaku.twidere.view.ColorLabelFrameLayout>
|
Loading…
Reference in New Issue