fix problems with selectable text in detailed status

main
Konrad Pozniak 7 years ago
parent fd5190af30
commit 8894908a9d
  1. 4
      app/src/main/java/com/keylesspalace/tusky/adapter/StatusBaseViewHolder.java
  2. 27
      app/src/main/java/com/keylesspalace/tusky/adapter/StatusDetailedViewHolder.java
  3. 2
      app/src/main/res/layout/item_status_detailed.xml
  4. 2
      app/src/main/res/values-de/strings.xml
  5. 1
      app/src/main/res/values/strings.xml

@ -41,7 +41,6 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
private View container; private View container;
private TextView displayName; private TextView displayName;
private TextView username; private TextView username;
private TextView content;
private ImageButton replyButton; private ImageButton replyButton;
private SparkButton reblogButton; private SparkButton reblogButton;
private SparkButton favouriteButton; private SparkButton favouriteButton;
@ -59,11 +58,12 @@ abstract class StatusBaseViewHolder extends RecyclerView.ViewHolder {
private TextView sensitiveMediaWarning; private TextView sensitiveMediaWarning;
private View sensitiveMediaShow; private View sensitiveMediaShow;
private TextView mediaLabel; private TextView mediaLabel;
private TextView contentWarningDescription;
private ToggleButton contentWarningButton; private ToggleButton contentWarningButton;
ImageView avatar; ImageView avatar;
TextView timestampInfo; TextView timestampInfo;
TextView content;
TextView contentWarningDescription;
StatusBaseViewHolder(View itemView) { StatusBaseViewHolder(View itemView) {
super(itemView); super(itemView);

@ -1,5 +1,7 @@
package com.keylesspalace.tusky.adapter; package com.keylesspalace.tusky.adapter;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
import android.os.Build; import android.os.Build;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
@ -13,6 +15,7 @@ import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.TextView; import android.widget.TextView;
import android.widget.Toast;
import com.keylesspalace.tusky.R; import com.keylesspalace.tusky.R;
import com.keylesspalace.tusky.entity.Card; import com.keylesspalace.tusky.entity.Card;
@ -93,6 +96,20 @@ class StatusDetailedViewHolder extends StatusBaseViewHolder {
favourites.setText(numberFormat.format(status.getFavouritesCount())); favourites.setText(numberFormat.format(status.getFavouritesCount()));
setApplication(status.getApplication()); setApplication(status.getApplication());
View.OnLongClickListener longClickListener = view -> {
TextView textView = (TextView)view;
ClipboardManager clipboard = (ClipboardManager) view.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText("toot", textView.getText());
clipboard.setPrimaryClip(clip);
Toast.makeText(view.getContext(), R.string.copy_to_clipboard_success, Toast.LENGTH_SHORT).show();
return true;
};
content.setOnLongClickListener(longClickListener);
contentWarningDescription.setOnLongClickListener(longClickListener);
if(status.getAttachments().length == 0 && status.getCard() != null && !TextUtils.isEmpty(status.getCard().getUrl())) { if(status.getAttachments().length == 0 && status.getCard() != null && !TextUtils.isEmpty(status.getCard().getUrl())) {
final Card card = status.getCard(); final Card card = status.getCard();
cardView.setVisibility(View.VISIBLE); cardView.setVisibility(View.VISIBLE);
@ -134,15 +151,7 @@ class StatusDetailedViewHolder extends StatusBaseViewHolder {
cardImage.setVisibility(View.GONE); cardImage.setVisibility(View.GONE);
} }
cardView.setOnClickListener(new View.OnClickListener() { cardView.setOnClickListener(v -> LinkHelper.openLink(card.getUrl(), v.getContext()));
@Override
public void onClick(View v) {
LinkHelper.openLink(card.getUrl(), v.getContext());
}
});
} else { } else {
cardView.setVisibility(View.GONE); cardView.setVisibility(View.GONE);

@ -59,7 +59,6 @@
android:layout_below="@id/status_name_bar" android:layout_below="@id/status_name_bar"
android:lineSpacingMultiplier="1.1" android:lineSpacingMultiplier="1.1"
android:textColor="?android:textColorPrimary" android:textColor="?android:textColorPrimary"
android:textIsSelectable="true"
android:textSize="?attr/status_text_large" android:textSize="?attr/status_text_large"
tools:text="CW this is a long long long long long long long long content warning" /> tools:text="CW this is a long long long long long long long long content warning" />
@ -91,7 +90,6 @@
android:focusable="true" android:focusable="true"
android:lineSpacingMultiplier="1.1" android:lineSpacingMultiplier="1.1"
android:textColor="?android:textColorPrimary" android:textColor="?android:textColorPrimary"
android:textIsSelectable="true"
android:textSize="?attr/status_text_large" /> android:textSize="?attr/status_text_large" />
<LinearLayout <LinearLayout

@ -265,6 +265,6 @@
<string name="send_toot_notification_channel_name">Beiträge senden</string> <string name="send_toot_notification_channel_name">Beiträge senden</string>
<string name="error_no_custom_emojis">Deine Instanz %s hat keine Emojis definiert</string> <string name="error_no_custom_emojis">Deine Instanz %s hat keine Emojis definiert</string>
<string name="copy_to_clipboard_success">In die Zwischenablage kopiert</string>
</resources> </resources>

@ -302,5 +302,6 @@
<string name="send_toot_notification_saved_content">A copy of the toot has been saved to your drafts</string> <string name="send_toot_notification_saved_content">A copy of the toot has been saved to your drafts</string>
<string name="error_no_custom_emojis">Your instance %s does not have any custom emojis</string> <string name="error_no_custom_emojis">Your instance %s does not have any custom emojis</string>
<string name="copy_to_clipboard_success">Copied to clipboard</string>
</resources> </resources>

Loading…
Cancel
Save