mirror of
https://github.com/deltachat/deltachat-android.git
synced 2025-10-03 01:39:18 +02:00
54 lines
1.5 KiB
Java
54 lines
1.5 KiB
Java
package org.thoughtcrime.securesms;
|
|
|
|
import android.content.Context;
|
|
import android.text.SpannableString;
|
|
import android.util.AttributeSet;
|
|
import android.view.View;
|
|
import android.widget.LinearLayout;
|
|
|
|
import org.thoughtcrime.securesms.components.emoji.EmojiTextView;
|
|
import org.thoughtcrime.securesms.util.LongClickMovementMethod;
|
|
|
|
public class ProfileStatusItem extends LinearLayout {
|
|
|
|
private EmojiTextView statusTextView;
|
|
private final PassthroughClickListener passthroughClickListener = new PassthroughClickListener();
|
|
|
|
public ProfileStatusItem(Context context) {
|
|
super(context);
|
|
}
|
|
|
|
public ProfileStatusItem(Context context, AttributeSet attrs) {
|
|
super(context, attrs);
|
|
}
|
|
|
|
@Override
|
|
protected void onFinishInflate() {
|
|
super.onFinishInflate();
|
|
statusTextView = findViewById(R.id.status_text);
|
|
statusTextView.setOnLongClickListener(passthroughClickListener);
|
|
statusTextView.setOnClickListener(passthroughClickListener);
|
|
statusTextView.setMovementMethod(LongClickMovementMethod.getInstance(getContext()));
|
|
}
|
|
|
|
public void set(String status) {
|
|
statusTextView.setText(EmojiTextView.linkify(new SpannableString(status)));
|
|
}
|
|
|
|
private class PassthroughClickListener implements View.OnLongClickListener, View.OnClickListener {
|
|
|
|
@Override
|
|
public boolean onLongClick(View v) {
|
|
if (statusTextView.hasSelection()) {
|
|
return false;
|
|
}
|
|
performLongClick();
|
|
return true;
|
|
}
|
|
|
|
@Override
|
|
public void onClick(View v) {
|
|
performClick();
|
|
}
|
|
}
|
|
}
|