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 some APIs needed for OctoDroid
This commit is contained in:
@@ -113,6 +113,8 @@ void activity_close_all(void)
|
|||||||
g_list_free(activities);
|
g_list_free(activities);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static jobject activity_not_created = NULL;
|
||||||
|
|
||||||
void _activity_start(JNIEnv *env, jobject activity_object, bool recreate)
|
void _activity_start(JNIEnv *env, jobject activity_object, bool recreate)
|
||||||
{
|
{
|
||||||
/* -- run the activity's onCreate -- */
|
/* -- run the activity's onCreate -- */
|
||||||
@@ -120,6 +122,12 @@ void _activity_start(JNIEnv *env, jobject activity_object, bool recreate)
|
|||||||
if((*env)->ExceptionCheck(env))
|
if((*env)->ExceptionCheck(env))
|
||||||
(*env)->ExceptionDescribe(env);
|
(*env)->ExceptionDescribe(env);
|
||||||
|
|
||||||
|
if ((*env)->IsSameObject(env, activity_object, activity_not_created)) { // finish() was called before the activity was created
|
||||||
|
_UNREF(activity_not_created);
|
||||||
|
activity_not_created = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(recreate) // only allowed for toplevel, so we know for sure where in the stack it belongs
|
if(recreate) // only allowed for toplevel, so we know for sure where in the stack it belongs
|
||||||
activity_backlog = g_list_append(activity_backlog, _REF(activity_object));
|
activity_backlog = g_list_append(activity_backlog, _REF(activity_object));
|
||||||
else
|
else
|
||||||
@@ -146,9 +154,12 @@ JNIEXPORT void JNICALL Java_android_app_Activity_nativeFinish(JNIEnv *env, jobje
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
activity_update_current(env);
|
activity_update_current(env);
|
||||||
activity_close(env, this);
|
if (removed_activity) {
|
||||||
if (removed_activity)
|
activity_close(env, removed_activity);
|
||||||
_UNREF(removed_activity);
|
_UNREF(removed_activity);
|
||||||
|
} else {
|
||||||
|
activity_not_created = _REF(this);
|
||||||
|
}
|
||||||
if (activity_backlog == NULL && window)
|
if (activity_backlog == NULL && window)
|
||||||
gtk_window_close(GTK_WINDOW(_PTR(window)));
|
gtk_window_close(GTK_WINDOW(_PTR(window)));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,6 +190,8 @@ JNIEXPORT void JNICALL Java_android_graphics_Matrix_native_1mapPoints(JNIEnv *en
|
|||||||
dst[dst_idx + i * 2] = res.x;
|
dst[dst_idx + i * 2] = res.x;
|
||||||
dst[dst_idx + i * 2 + 1] = res.y;
|
dst[dst_idx + i * 2 + 1] = res.y;
|
||||||
}
|
}
|
||||||
|
(*env)->ReleaseFloatArrayElements(env, src_ref, src, 0);
|
||||||
|
(*env)->ReleaseFloatArrayElements(env, dst_ref, dst, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_android_graphics_Matrix_native_1setTranslate(JNIEnv *env, jclass class, jlong matrix_ptr, jfloat x, jfloat y)
|
JNIEXPORT void JNICALL Java_android_graphics_Matrix_native_1setTranslate(JNIEnv *env, jclass class, jlong matrix_ptr, jfloat x, jfloat y)
|
||||||
@@ -213,3 +215,12 @@ JNIEXPORT jboolean JNICALL Java_android_graphics_Matrix_native_1invert(JNIEnv *e
|
|||||||
{
|
{
|
||||||
return graphene_matrix_inverse((graphene_matrix_t *)_PTR(matrix_ptr), (graphene_matrix_t *)_PTR(inverse_ptr));
|
return graphene_matrix_inverse((graphene_matrix_t *)_PTR(matrix_ptr), (graphene_matrix_t *)_PTR(inverse_ptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jboolean JNICALL Java_android_graphics_Matrix_native_1preScale__JFF(JNIEnv *env, jclass class, jlong matrix_ptr, jfloat x, jfloat y)
|
||||||
|
{
|
||||||
|
graphene_matrix_t *matrix = (graphene_matrix_t *)_PTR(matrix_ptr);
|
||||||
|
graphene_matrix_t scale;
|
||||||
|
graphene_matrix_init_scale(&scale, x, y, 1);
|
||||||
|
graphene_matrix_multiply(&scale, matrix, matrix);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -19,4 +19,12 @@ public class Animator {
|
|||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void cancel() {}
|
||||||
|
|
||||||
|
public long getStartDelay() { return 0; }
|
||||||
|
|
||||||
|
public long getDuration() { return 0; }
|
||||||
|
|
||||||
|
public Animator setDuration(long duration) { return this; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package android.animation;
|
package android.animation;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
public class AnimatorSet extends Animator {
|
public class AnimatorSet extends Animator {
|
||||||
|
|
||||||
public class Builder {
|
public class Builder {
|
||||||
@@ -17,4 +19,14 @@ public class AnimatorSet extends Animator {
|
|||||||
|
|
||||||
public void playSequentially(Animator[] animators) {}
|
public void playSequentially(Animator[] animators) {}
|
||||||
|
|
||||||
|
public boolean isStarted() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playTogether(Collection<Animator> animators) {}
|
||||||
|
|
||||||
|
public AnimatorSet setDuration(long duration) { return this; }
|
||||||
|
|
||||||
|
public void playTogether(Animator[] animators) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ public class ObjectAnimator extends ValueAnimator {
|
|||||||
return new ObjectAnimator();
|
return new ObjectAnimator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static <T> ObjectAnimator ofInt(T target, String propertyName, int... values) {
|
||||||
|
return new ObjectAnimator();
|
||||||
|
}
|
||||||
|
|
||||||
public ObjectAnimator setDuration(long duration) {return this;}
|
public ObjectAnimator setDuration(long duration) {return this;}
|
||||||
|
|
||||||
public void setAutoCancel(boolean autoCancel) {}
|
public void setAutoCancel(boolean autoCancel) {}
|
||||||
|
|||||||
@@ -12,6 +12,10 @@ public class ValueAnimator extends Animator {
|
|||||||
return new ValueAnimator();
|
return new ValueAnimator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ValueAnimator ofInt(int... values) {
|
||||||
|
return new ValueAnimator();
|
||||||
|
}
|
||||||
|
|
||||||
public ValueAnimator setDuration(long duration) {
|
public ValueAnimator setDuration(long duration) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@@ -38,6 +42,7 @@ public class ValueAnimator extends Animator {
|
|||||||
public void setRepeatCount(int value) {}
|
public void setRepeatCount(int value) {}
|
||||||
public void setRepeatMode(int value) {}
|
public void setRepeatMode(int value) {}
|
||||||
public void cancel() {}
|
public void cancel() {}
|
||||||
|
public void setEvaluator(TypeEvaluator evaluator) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementors of this interface can add themselves as update listeners
|
* Implementors of this interface can add themselves as update listeners
|
||||||
|
|||||||
@@ -62,13 +62,18 @@ public class Dialog implements Window.Callback, DialogInterface {
|
|||||||
|
|
||||||
public void show() {
|
public void show() {
|
||||||
System.out.println("showing the Dialog " + this);
|
System.out.println("showing the Dialog " + this);
|
||||||
new Handler(Looper.getMainLooper()).post(new Runnable() {
|
Runnable action = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
onCreate(null);
|
onCreate(null);
|
||||||
nativeShow(nativePtr);
|
nativeShow(nativePtr);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
if(Looper.myLooper() == Looper.getMainLooper()) {
|
||||||
|
action.run();
|
||||||
|
} else {
|
||||||
|
new Handler(Looper.getMainLooper()).post(action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowing() {
|
public boolean isShowing() {
|
||||||
@@ -142,4 +147,9 @@ public class Dialog implements Window.Callback, DialogInterface {
|
|||||||
System.out.println("hiding the Dialog " + this);
|
System.out.println("hiding the Dialog " + this);
|
||||||
nativeClose(nativePtr);
|
nativeClose(nativePtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancel() {
|
||||||
|
dismiss();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import android.database.AbstractCursor;
|
|||||||
import android.database.ContentObserver;
|
import android.database.ContentObserver;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.CancellationSignal;
|
||||||
import android.os.ParcelFileDescriptor;
|
import android.os.ParcelFileDescriptor;
|
||||||
|
|
||||||
public class ContentResolver {
|
public class ContentResolver {
|
||||||
@@ -39,4 +40,8 @@ public class ContentResolver {
|
|||||||
public boolean isNull(int column) { throw new IndexOutOfBoundsException(); }
|
public boolean isNull(int column) { throw new IndexOutOfBoundsException(); }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder, CancellationSignal cancellationSignal) {
|
||||||
|
return query(uri, projection, selection, selectionArgs, sortOrder);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import android.media.MediaRouter;
|
|||||||
import android.net.ConnectivityManager;
|
import android.net.ConnectivityManager;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
@@ -443,6 +444,10 @@ public class Context extends Object {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void startActivity(Intent intent, Bundle options) {
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
public final TypedArray obtainStyledAttributes(AttributeSet set, int[] attrs) {
|
public final TypedArray obtainStyledAttributes(AttributeSet set, int[] attrs) {
|
||||||
return getTheme().obtainStyledAttributes(set, attrs, 0, 0);
|
return getTheme().obtainStyledAttributes(set, attrs, 0, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ public interface DialogInterface {
|
|||||||
|
|
||||||
public void dismiss();
|
public void dismiss();
|
||||||
|
|
||||||
|
public void cancel();
|
||||||
|
|
||||||
public interface OnDismissListener {
|
public interface OnDismissListener {
|
||||||
void onDismiss(DialogInterface dialog);
|
void onDismiss(DialogInterface dialog);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import android.util.DisplayMetrics;
|
|||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
|
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
|
||||||
@@ -2226,7 +2227,9 @@ public class PackageManager {
|
|||||||
*/
|
*/
|
||||||
public List<ResolveInfo> queryIntentActivities(Intent intent,
|
public List<ResolveInfo> queryIntentActivities(Intent intent,
|
||||||
int flags) {
|
int flags) {
|
||||||
return new ArrayList<ResolveInfo>();
|
ResolveInfo info = new ResolveInfo();
|
||||||
|
info.activityInfo.exported = true;
|
||||||
|
return Arrays.asList(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -2,4 +2,10 @@ package android.content.pm;
|
|||||||
|
|
||||||
public class ResolveInfo {
|
public class ResolveInfo {
|
||||||
public ActivityInfo activityInfo = new ActivityInfo();
|
public ActivityInfo activityInfo = new ActivityInfo();
|
||||||
|
|
||||||
|
public static class DisplayNameComparator {
|
||||||
|
|
||||||
|
public DisplayNameComparator(PackageManager pm) {}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
8
src/api-impl/android/graphics/BitmapShader.java
Normal file
8
src/api-impl/android/graphics/BitmapShader.java
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package android.graphics;
|
||||||
|
|
||||||
|
public class BitmapShader extends Shader {
|
||||||
|
|
||||||
|
public BitmapShader(Bitmap bitmap, TileMode tileX, TileMode tileY) {}
|
||||||
|
|
||||||
|
public void setLocalMatrix(Matrix matrix) {}
|
||||||
|
}
|
||||||
@@ -402,6 +402,20 @@ public class Canvas {
|
|||||||
|
|
||||||
public void drawCircle(float cx, float cy, float radius, Paint paint) {}
|
public void drawCircle(float cx, float cy, float radius, Paint paint) {}
|
||||||
|
|
||||||
|
public Rect getClipBounds() {
|
||||||
|
return new Rect(0, 0, 10, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean clipRect(Rect rect, Region.Op op) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void concat(Matrix matrix) {}
|
||||||
|
|
||||||
|
public boolean clipPath(Path path, Region.Op op) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private static native long native_canvas_from_bitmap(long pixbuf);
|
private static native long native_canvas_from_bitmap(long pixbuf);
|
||||||
|
|
||||||
private static native void native_save(long skia_canvas, long widget);
|
private static native void native_save(long skia_canvas, long widget);
|
||||||
|
|||||||
6
src/api-impl/android/graphics/LinearGradient.java
Normal file
6
src/api-impl/android/graphics/LinearGradient.java
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
package android.graphics;
|
||||||
|
|
||||||
|
public class LinearGradient extends Shader {
|
||||||
|
|
||||||
|
public LinearGradient(float x0, float y0, float x1, float y1, int[] colors, float[] positions, TileMode mode) {}
|
||||||
|
}
|
||||||
@@ -209,6 +209,12 @@ public class Paint {
|
|||||||
private Join(int nativeInt) {}
|
private Join(int nativeInt) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum Align {
|
||||||
|
CENTER,
|
||||||
|
LEFT,
|
||||||
|
RIGHT,
|
||||||
|
}
|
||||||
|
|
||||||
public void setStrokeCap(Cap cap) {}
|
public void setStrokeCap(Cap cap) {}
|
||||||
|
|
||||||
public void setStrokeJoin(Join join) {}
|
public void setStrokeJoin(Join join) {}
|
||||||
@@ -217,6 +223,12 @@ public class Paint {
|
|||||||
return new Typeface();
|
return new Typeface();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setTextAlign(Align align) {}
|
||||||
|
|
||||||
|
public Shader getShader() {
|
||||||
|
return new Shader();
|
||||||
|
}
|
||||||
|
|
||||||
private native long native_constructor();
|
private native long native_constructor();
|
||||||
private native void native_set_color(long skia_paint, int color);
|
private native void native_set_color(long skia_paint, int color);
|
||||||
private native int native_get_color(long skia_paint);
|
private native int native_get_color(long skia_paint);
|
||||||
|
|||||||
6
src/api-impl/android/graphics/RadialGradient.java
Normal file
6
src/api-impl/android/graphics/RadialGradient.java
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
package android.graphics;
|
||||||
|
|
||||||
|
public class RadialGradient extends Shader {
|
||||||
|
|
||||||
|
public RadialGradient(float x, float y, float radius, int[] colors, float[] positions, android.graphics.Shader.TileMode tileMode) {}
|
||||||
|
}
|
||||||
@@ -2,4 +2,10 @@ package android.graphics;
|
|||||||
|
|
||||||
public class Shader {
|
public class Shader {
|
||||||
|
|
||||||
|
public enum TileMode {
|
||||||
|
CLAMP,
|
||||||
|
MIRROR,
|
||||||
|
REPEAT
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,10 @@ public class Drawable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBounds(int left, int top, int right, int bottom) {
|
public void setBounds(int left, int top, int right, int bottom) {
|
||||||
|
boolean changed = left != mBounds.left || top != mBounds.top || right != mBounds.right || bottom != mBounds.bottom;
|
||||||
mBounds.set(left, top, right, bottom);
|
mBounds.set(left, top, right, bottom);
|
||||||
|
if (changed)
|
||||||
|
onBoundsChange(mBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Rect getBounds() {
|
public final Rect getBounds() {
|
||||||
@@ -206,6 +209,8 @@ public class Drawable {
|
|||||||
bounds.set(mBounds);
|
bounds.set(mBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void onBoundsChange(Rect bounds) {}
|
||||||
|
|
||||||
protected static native long native_paintable_from_path(String path);
|
protected static native long native_paintable_from_path(String path);
|
||||||
protected native long native_constructor();
|
protected native long native_constructor();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,10 @@
|
|||||||
package android.graphics.drawable.shapes;
|
package android.graphics.drawable.shapes;
|
||||||
|
|
||||||
|
import android.graphics.RectF;
|
||||||
|
|
||||||
public class Shape {
|
public class Shape {
|
||||||
|
|
||||||
|
protected RectF rect() {
|
||||||
|
return new RectF();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user