Fix LinkedTextView breaking XML layout editor
This commit is contained in:
parent
477a691c9e
commit
43bbe9be0f
|
@ -3,6 +3,7 @@ package org.joinmastodon.android.ui.text;
|
||||||
import android.content.ClipData;
|
import android.content.ClipData;
|
||||||
import android.content.ClipboardManager;
|
import android.content.ClipboardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.CornerPathEffect;
|
import android.graphics.CornerPathEffect;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
|
@ -18,13 +19,12 @@ import android.view.SoundEffectConstants;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
|
|
||||||
import org.joinmastodon.android.R;
|
import org.joinmastodon.android.R;
|
||||||
|
|
||||||
import me.grishka.appkit.utils.V;
|
import androidx.annotation.NonNull;
|
||||||
|
import me.grishka.appkit.utils.CustomViewHelper;
|
||||||
|
|
||||||
public class ClickableLinksDelegate {
|
public class ClickableLinksDelegate implements CustomViewHelper{
|
||||||
|
|
||||||
private final Paint hlPaint;
|
private final Paint hlPaint;
|
||||||
private Path hlPath;
|
private Path hlPath;
|
||||||
|
@ -37,8 +37,7 @@ public class ClickableLinksDelegate {
|
||||||
this.view=view;
|
this.view=view;
|
||||||
hlPaint=new Paint();
|
hlPaint=new Paint();
|
||||||
hlPaint.setAntiAlias(true);
|
hlPaint.setAntiAlias(true);
|
||||||
hlPaint.setPathEffect(new CornerPathEffect(V.dp(3)));
|
hlPaint.setPathEffect(new CornerPathEffect(dp(3)));
|
||||||
// view.setHighlightColor(view.getResources().getColor(android.R.color.holo_blue_light));
|
|
||||||
gestureDetector = new GestureDetector(view.getContext(), new LinkGestureListener(), view.getHandler());
|
gestureDetector = new GestureDetector(view.getContext(), new LinkGestureListener(), view.getHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,6 +68,11 @@ public class ClickableLinksDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Resources getResources(){
|
||||||
|
return view.getResources();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GestureListener for spans that represent URLs.
|
* GestureListener for spans that represent URLs.
|
||||||
* onDown: on start of touch event, set highlighting
|
* onDown: on start of touch event, set highlighting
|
||||||
|
@ -124,7 +128,7 @@ public class ClickableLinksDelegate {
|
||||||
CharSequence lineChars=view.getText().subSequence(l.getLineStart(j), l.getLineEnd(j));
|
CharSequence lineChars=view.getText().subSequence(l.getLineStart(j), l.getLineEnd(j));
|
||||||
bounds.right=Math.round(view.getPaint().measureText(lineChars.toString()))/*+view.getPaddingRight()*/;
|
bounds.right=Math.round(view.getPaint().measureText(lineChars.toString()))/*+view.getPaddingRight()*/;
|
||||||
}
|
}
|
||||||
bounds.inset(V.dp(-2), V.dp(-2));
|
bounds.inset(dp(-2), dp(-2));
|
||||||
hlPath.addRect(new RectF(bounds), Path.Direction.CW);
|
hlPath.addRect(new RectF(bounds), Path.Direction.CW);
|
||||||
}
|
}
|
||||||
hlPath.offset(view.getPaddingLeft(), 0);
|
hlPath.offset(view.getPaddingLeft(), 0);
|
||||||
|
|
Loading…
Reference in New Issue