You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
fix Layout.getLineStart() / Layout.getLineEnd()
These methods are supposed to return the String index and not coordinates as accidently assumed when originally implementing it.
This commit is contained in:
@@ -47,6 +47,22 @@ JNIEXPORT jint JNICALL Java_android_text_Layout_native_1get_1height
|
|||||||
JNIEXPORT jint JNICALL Java_android_text_Layout_native_1get_1line_1count
|
JNIEXPORT jint JNICALL Java_android_text_Layout_native_1get_1line_1count
|
||||||
(JNIEnv *, jobject, jlong);
|
(JNIEnv *, jobject, jlong);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: android_text_Layout
|
||||||
|
* Method: native_get_line_start
|
||||||
|
* Signature: (JI)I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_android_text_Layout_native_1get_1line_1start
|
||||||
|
(JNIEnv *, jobject, jlong, jint);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: android_text_Layout
|
||||||
|
* Method: native_get_line_end
|
||||||
|
* Signature: (JI)I
|
||||||
|
*/
|
||||||
|
JNIEXPORT jint JNICALL Java_android_text_Layout_native_1get_1line_1end
|
||||||
|
(JNIEnv *, jobject, jlong, jint);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class: android_text_Layout
|
* Class: android_text_Layout
|
||||||
* Method: native_get_line_top
|
* Method: native_get_line_top
|
||||||
|
|||||||
@@ -47,6 +47,25 @@ JNIEXPORT jint JNICALL Java_android_text_Layout_native_1get_1line_1count(JNIEnv
|
|||||||
return pango_layout_get_line_count(pango_layout);
|
return pango_layout_get_line_count(pango_layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL Java_android_text_Layout_native_1get_1line_1start(JNIEnv *env, jobject object, jlong layout, jint line)
|
||||||
|
{
|
||||||
|
PangoLayout *pango_layout = _PTR(layout);
|
||||||
|
PangoLayoutIter *pango_iter = pango_layout_get_iter(pango_layout);
|
||||||
|
while (line--)
|
||||||
|
pango_layout_iter_next_line(pango_iter);
|
||||||
|
return pango_layout_iter_get_index(pango_iter);
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jint JNICALL Java_android_text_Layout_native_1get_1line_1end(JNIEnv *env, jobject object, jlong layout, jint line)
|
||||||
|
{
|
||||||
|
PangoLayout *pango_layout = _PTR(layout);
|
||||||
|
PangoLayoutIter *pango_iter = pango_layout_get_iter(pango_layout);
|
||||||
|
while (line--)
|
||||||
|
pango_layout_iter_next_line(pango_iter);
|
||||||
|
pango_layout_iter_next_line(pango_iter);
|
||||||
|
return pango_layout_iter_get_index(pango_iter);
|
||||||
|
}
|
||||||
|
|
||||||
static void get_line_extends(PangoLayout *pango_layout, int line, PangoRectangle *logical_rect) {
|
static void get_line_extends(PangoLayout *pango_layout, int line, PangoRectangle *logical_rect) {
|
||||||
PangoRectangle ink_rect;
|
PangoRectangle ink_rect;
|
||||||
PangoLayoutIter *pango_iter = pango_layout_get_iter(pango_layout);
|
PangoLayoutIter *pango_iter = pango_layout_get_iter(pango_layout);
|
||||||
|
|||||||
@@ -155,13 +155,13 @@ public class Layout {
|
|||||||
public int getLineStart(int line) {
|
public int getLineStart(int line) {
|
||||||
if (line < 0 || line >= getLineCount())
|
if (line < 0 || line >= getLineCount())
|
||||||
throw new ArrayIndexOutOfBoundsException();
|
throw new ArrayIndexOutOfBoundsException();
|
||||||
return native_get_line_left(layout, line);
|
return native_get_line_start(layout, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getLineEnd(int line) {
|
public int getLineEnd(int line) {
|
||||||
if (line < 0 || line >= getLineCount())
|
if (line < 0 || line >= getLineCount())
|
||||||
throw new ArrayIndexOutOfBoundsException();
|
throw new ArrayIndexOutOfBoundsException();
|
||||||
return native_get_line_right(layout, line);
|
return native_get_line_end(layout, line);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSpanned() {
|
public boolean isSpanned() {
|
||||||
@@ -238,6 +238,8 @@ public class Layout {
|
|||||||
protected native int native_get_width(long layout);
|
protected native int native_get_width(long layout);
|
||||||
protected native int native_get_height(long layout);
|
protected native int native_get_height(long layout);
|
||||||
protected native int native_get_line_count(long layout);
|
protected native int native_get_line_count(long layout);
|
||||||
|
protected native int native_get_line_start(long layout, int line);
|
||||||
|
protected native int native_get_line_end(long layout, int line);
|
||||||
protected native int native_get_line_top(long layout, int line);
|
protected native int native_get_line_top(long layout, int line);
|
||||||
protected native int native_get_line_bottom(long layout, int line);
|
protected native int native_get_line_bottom(long layout, int line);
|
||||||
protected native int native_get_line_left(long layout, int line);
|
protected native int native_get_line_left(long layout, int line);
|
||||||
|
|||||||
Reference in New Issue
Block a user