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
implement more APIs
This commit is contained in:
@@ -170,12 +170,12 @@ JNIEXPORT jobjectArray JNICALL Java_android_content_res_AssetManager_getArrayStr
|
|||||||
for (i = 0; i < bag_count; i++) {
|
for (i = 0; i < bag_count; i++) {
|
||||||
struct Res_value value = bag[i].map.value;
|
struct Res_value value = bag[i].map.value;
|
||||||
ssize_t block = ResTable_resolveReference(res_table, &value, bag[i].stringBlock, NULL, NULL, NULL);
|
ssize_t block = ResTable_resolveReference(res_table, &value, bag[i].stringBlock, NULL, NULL, NULL);
|
||||||
if (bag[i].map.value.dataType == TYPE_STRING) {
|
if (value.dataType == TYPE_STRING) {
|
||||||
const struct ResStringPool *string_pool = ResTable_getTableStringBlock(res_table, block);
|
const struct ResStringPool *string_pool = ResTable_getTableStringBlock(res_table, block);
|
||||||
if (string_pool == NULL)
|
if (string_pool == NULL)
|
||||||
continue;
|
continue;
|
||||||
size_t len;
|
size_t len;
|
||||||
const char16_t *string = ResStringPool_stringAt(string_pool, bag[i].map.value.data, &len);
|
const char16_t *string = ResStringPool_stringAt(string_pool, value.data, &len);
|
||||||
(*env)->SetObjectArrayElement(env, array, i, (*env)->NewString(env, string, len));
|
(*env)->SetObjectArrayElement(env, array, i, (*env)->NewString(env, string, len));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,6 +231,14 @@ JNIEXPORT void JNICALL Java_android_widget_EditText_native_1addTextChangedListen
|
|||||||
JNIEXPORT void JNICALL Java_android_widget_EditText_native_1setOnEditorActionListener
|
JNIEXPORT void JNICALL Java_android_widget_EditText_native_1setOnEditorActionListener
|
||||||
(JNIEnv *, jobject, jlong, jobject);
|
(JNIEnv *, jobject, jlong, jobject);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Class: android_widget_EditText
|
||||||
|
* Method: native_setText
|
||||||
|
* Signature: (JLjava/lang/String;)V
|
||||||
|
*/
|
||||||
|
JNIEXPORT void JNICALL Java_android_widget_EditText_native_1setText
|
||||||
|
(JNIEnv *, jobject, jlong, jstring);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -77,3 +77,11 @@ JNIEXPORT void JNICALL Java_android_widget_EditText_native_1setOnEditorActionLis
|
|||||||
|
|
||||||
g_signal_connect(entry, "activate", G_CALLBACK(on_activate), callback_data);
|
g_signal_connect(entry, "activate", G_CALLBACK(on_activate), callback_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL Java_android_widget_EditText_native_1setText(JNIEnv *env, jobject this, jlong widget_ptr, jstring text_jstr)
|
||||||
|
{
|
||||||
|
const char *text = (*env)->GetStringUTFChars(env, text_jstr, NULL);
|
||||||
|
jsize length = (*env)->GetStringUTFLength(env, text_jstr);
|
||||||
|
gtk_entry_buffer_set_text(gtk_entry_get_buffer(GTK_ENTRY(_PTR(widget_ptr))), text, length);
|
||||||
|
(*env)->ReleaseStringUTFChars(env, text_jstr, text);
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ package android.content;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
|
||||||
|
import android.database.AbstractCursor;
|
||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
|
|
||||||
@@ -23,4 +25,18 @@ public class ContentResolver {
|
|||||||
public ParcelFileDescriptor openFileDescriptor(Uri uri, String mode) throws FileNotFoundException {
|
public ParcelFileDescriptor openFileDescriptor(Uri uri, String mode) throws FileNotFoundException {
|
||||||
return ParcelFileDescriptor.open(new File(uri.uri), ParcelFileDescriptor.parseMode(mode));
|
return ParcelFileDescriptor.open(new File(uri.uri), ParcelFileDescriptor.parseMode(mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
|
||||||
|
return new AbstractCursor() {
|
||||||
|
public int getCount() { return 0; }
|
||||||
|
public String[] getColumnNames() { return new String[0]; }
|
||||||
|
public String getString(int column) { throw new IndexOutOfBoundsException(); }
|
||||||
|
public short getShort(int column) { throw new IndexOutOfBoundsException(); }
|
||||||
|
public int getInt(int column) { throw new IndexOutOfBoundsException(); }
|
||||||
|
public long getLong(int column) { throw new IndexOutOfBoundsException(); }
|
||||||
|
public float getFloat(int column) { throw new IndexOutOfBoundsException(); }
|
||||||
|
public double getDouble(int column) { throw new IndexOutOfBoundsException(); }
|
||||||
|
public boolean isNull(int column) { throw new IndexOutOfBoundsException(); }
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -419,7 +419,11 @@ public class Context extends Object {
|
|||||||
if (intent.getComponent() == null) {
|
if (intent.getComponent() == null) {
|
||||||
if(intent.getAction() != null && intent.getAction().equals("android.intent.action.SEND")) {
|
if(intent.getAction() != null && intent.getAction().equals("android.intent.action.SEND")) {
|
||||||
Slog.i(TAG, "starting extern activity with intent: " + intent);
|
Slog.i(TAG, "starting extern activity with intent: " + intent);
|
||||||
ClipboardManager.native_set_clipboard(intent.getStringExtra("android.intent.extra.TEXT"));
|
String text = intent.getStringExtra("android.intent.extra.TEXT");
|
||||||
|
if (text == null)
|
||||||
|
text = String.valueOf(intent.getExtras().get("android.intent.extra.STREAM"));
|
||||||
|
if (text != null)
|
||||||
|
ClipboardManager.native_set_clipboard(text);
|
||||||
} else if (intent.getData() != null) {
|
} else if (intent.getData() != null) {
|
||||||
Slog.i(TAG, "starting extern activity with intent: " + intent);
|
Slog.i(TAG, "starting extern activity with intent: " + intent);
|
||||||
Activity.nativeOpenURI(String.valueOf(intent.getData()));
|
Activity.nativeOpenURI(String.valueOf(intent.getData()));
|
||||||
|
|||||||
@@ -294,4 +294,9 @@ public class Intent {
|
|||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Intent setData(Uri uri) {
|
||||||
|
this.data = uri;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -156,4 +156,36 @@ public class BaseBundle {
|
|||||||
public int size() {
|
public int size() {
|
||||||
return mMap.size();
|
return mMap.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value associated with the given key, or defaultValue if
|
||||||
|
* no mapping of the desired type exists for the given key.
|
||||||
|
*
|
||||||
|
* @param key a String
|
||||||
|
* @param defaultValue Value to return if key does not exist
|
||||||
|
* @return an int value
|
||||||
|
*/
|
||||||
|
public int getInt(String key, int defaultValue) {
|
||||||
|
Object o = mMap.get(key);
|
||||||
|
if (o == null) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return (Integer)o;
|
||||||
|
} catch (ClassCastException e) {
|
||||||
|
typeWarning(key, o, "Integer", defaultValue, e);
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value associated with the given key, or 0 if
|
||||||
|
* no mapping of the desired type exists for the given key.
|
||||||
|
*
|
||||||
|
* @param key a String
|
||||||
|
* @return an int value
|
||||||
|
*/
|
||||||
|
public int getInt(String key) {
|
||||||
|
return getInt(key, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,4 +3,6 @@ package android.os;
|
|||||||
public class Binder extends IBinder {
|
public class Binder extends IBinder {
|
||||||
|
|
||||||
public void attachInterface(IInterface owner, String descriptor) {}
|
public void attachInterface(IInterface owner, String descriptor) {}
|
||||||
|
|
||||||
|
public static void flushPendingCommands() {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -752,38 +752,6 @@ public final class Bundle extends BaseBundle implements Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the value associated with the given key, or 0 if
|
|
||||||
* no mapping of the desired type exists for the given key.
|
|
||||||
*
|
|
||||||
* @param key a String
|
|
||||||
* @return an int value
|
|
||||||
*/
|
|
||||||
public int getInt(String key) {
|
|
||||||
return getInt(key, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the value associated with the given key, or defaultValue if
|
|
||||||
* no mapping of the desired type exists for the given key.
|
|
||||||
*
|
|
||||||
* @param key a String
|
|
||||||
* @param defaultValue Value to return if key does not exist
|
|
||||||
* @return an int value
|
|
||||||
*/
|
|
||||||
public int getInt(String key, int defaultValue) {
|
|
||||||
Object o = mMap.get(key);
|
|
||||||
if (o == null) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return (Integer)o;
|
|
||||||
} catch (ClassCastException e) {
|
|
||||||
typeWarning(key, o, "Integer", defaultValue, e);
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the value associated with the given key, or 0L if
|
* Returns the value associated with the given key, or 0L if
|
||||||
* no mapping of the desired type exists for the given key.
|
* no mapping of the desired type exists for the given key.
|
||||||
|
|||||||
11
src/api-impl/android/os/FileObserver.java
Normal file
11
src/api-impl/android/os/FileObserver.java
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package android.os;
|
||||||
|
|
||||||
|
public class FileObserver {
|
||||||
|
|
||||||
|
public FileObserver(String path, int mask) {}
|
||||||
|
|
||||||
|
public void startWatching() {}
|
||||||
|
|
||||||
|
public void stopWatching() {}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,5 +1,9 @@
|
|||||||
package android.text.method;
|
package android.text.method;
|
||||||
|
|
||||||
public class LinkMovementMethod extends MovementMethod {
|
public class LinkMovementMethod extends MovementMethod {
|
||||||
|
|
||||||
|
public static MovementMethod getInstance() {
|
||||||
|
return new LinkMovementMethod();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
7
src/api-impl/android/text/style/StyleSpan.java
Normal file
7
src/api-impl/android/text/style/StyleSpan.java
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
package android.text.style;
|
||||||
|
|
||||||
|
public class StyleSpan {
|
||||||
|
|
||||||
|
public StyleSpan(int style) {}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
package android.text.style;
|
package android.text.style;
|
||||||
|
|
||||||
public class URLSpan {
|
public class URLSpan {
|
||||||
|
|
||||||
|
public URLSpan(String url) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,11 @@ import android.text.Spannable;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
public class Linkify {
|
public class Linkify {
|
||||||
|
|
||||||
|
public static MatchFilter sUrlMatchFilter = null;
|
||||||
|
|
||||||
public static final boolean addLinks(Spannable text, int mask) { return true; }
|
public static final boolean addLinks(Spannable text, int mask) { return true; }
|
||||||
public static final boolean addLinks(TextView text, int mask) { return true; }
|
public static final boolean addLinks(TextView text, int mask) { return true; }
|
||||||
|
|
||||||
|
public class MatchFilter {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1661,4 +1661,8 @@ public class View extends Object {
|
|||||||
public boolean hasOnClickListeners() {return false;}
|
public boolean hasOnClickListeners() {return false;}
|
||||||
|
|
||||||
public void setTextAlignment(int textAlignment) {}
|
public void setTextAlignment(int textAlignment) {}
|
||||||
|
|
||||||
|
public void setHapticFeedbackEnabled(boolean hapticFeedbackEnabled) {}
|
||||||
|
|
||||||
|
public StateListAnimator getStateListAnimator() {return null;}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class EditText extends TextView {
|
|||||||
protected native String native_getText(long widget);
|
protected native String native_getText(long widget);
|
||||||
protected native void native_addTextChangedListener(long widget, TextWatcher watcher);
|
protected native void native_addTextChangedListener(long widget, TextWatcher watcher);
|
||||||
protected native void native_setOnEditorActionListener(long widget, OnEditorActionListener l);
|
protected native void native_setOnEditorActionListener(long widget, OnEditorActionListener l);
|
||||||
|
protected native void native_setText(long widget, String text);
|
||||||
|
|
||||||
public Editable getText() {
|
public Editable getText() {
|
||||||
return new SpannableStringBuilder(native_getText(widget));
|
return new SpannableStringBuilder(native_getText(widget));
|
||||||
@@ -30,7 +31,9 @@ public class EditText extends TextView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setText(CharSequence text) {}
|
public void setText(CharSequence text) {
|
||||||
|
native_setText(widget, String.valueOf(text));
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void setTextSize(float size) {}
|
public void setTextSize(float size) {}
|
||||||
|
|
||||||
|
|||||||
@@ -231,4 +231,6 @@ public class TextView extends View {
|
|||||||
public float getLetterSpacing() {return 0.f;}
|
public float getLetterSpacing() {return 0.f;}
|
||||||
|
|
||||||
public void setCompoundDrawablesRelativeWithIntrinsicBounds(int start, int top, int end, int bottom) {}
|
public void setCompoundDrawablesRelativeWithIntrinsicBounds(int start, int top, int end, int bottom) {}
|
||||||
|
|
||||||
|
public boolean getLinksClickable() {return true;}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -247,6 +247,7 @@ hax_jar = jar('hax', [
|
|||||||
'android/os/Debug.java',
|
'android/os/Debug.java',
|
||||||
'android/os/DropBoxManager.java',
|
'android/os/DropBoxManager.java',
|
||||||
'android/os/Environment.java',
|
'android/os/Environment.java',
|
||||||
|
'android/os/FileObserver.java',
|
||||||
'android/os/Handler.java',
|
'android/os/Handler.java',
|
||||||
'android/os/HandlerThread.java',
|
'android/os/HandlerThread.java',
|
||||||
'android/os/IBinder.java',
|
'android/os/IBinder.java',
|
||||||
@@ -309,6 +310,7 @@ hax_jar = jar('hax', [
|
|||||||
'android/text/method/TransformationMethod.java',
|
'android/text/method/TransformationMethod.java',
|
||||||
'android/text/style/CharacterStyle.java',
|
'android/text/style/CharacterStyle.java',
|
||||||
'android/text/style/ClickableSpan.java',
|
'android/text/style/ClickableSpan.java',
|
||||||
|
'android/text/style/StyleSpan.java',
|
||||||
'android/text/style/URLSpan.java',
|
'android/text/style/URLSpan.java',
|
||||||
'android/text/util/Linkify.java',
|
'android/text/util/Linkify.java',
|
||||||
'android/util/AndroidException.java',
|
'android/util/AndroidException.java',
|
||||||
|
|||||||
Reference in New Issue
Block a user