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
add Java APIs needed for WhatsApp MainActivity and ConversationActivity
This commit is contained in:
@@ -29,4 +29,8 @@ public class Animator {
|
||||
|
||||
public void setInterpolator(TimeInterpolator i) {}
|
||||
|
||||
public void setStartDelay(long startDelay) {}
|
||||
|
||||
public boolean isStarted() { return false; }
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import java.util.Map;
|
||||
|
||||
public class Activity extends ContextThemeWrapper implements Window.Callback {
|
||||
LayoutInflater layout_inflater;
|
||||
Window window = new Window(this);
|
||||
Window window = new Window(this, this);
|
||||
int requested_orientation = -1 /*ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED*/; // dummy
|
||||
public Intent intent;
|
||||
private Activity resultActivity;
|
||||
@@ -369,9 +369,10 @@ public class Activity extends ContextThemeWrapper implements Window.Callback {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
nativeFinish(getWindow().native_window);
|
||||
getWindow().setContentView(null);
|
||||
window = null;
|
||||
if (window != null) {
|
||||
nativeFinish(getWindow().native_window);
|
||||
window = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -529,6 +530,14 @@ public class Activity extends ContextThemeWrapper implements Window.Callback {
|
||||
|
||||
public void overridePendingTransition(int enterAnim, int exitAnim) {}
|
||||
|
||||
public boolean isTaskRoot() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void postponeEnterTransition() {}
|
||||
|
||||
public void startPostponedEnterTransition() {}
|
||||
|
||||
private native void nativeFinish(long native_window);
|
||||
public static native void nativeRecreateActivity(Activity activity);
|
||||
public static native void nativeStartActivity(Activity activity);
|
||||
|
||||
@@ -20,6 +20,10 @@ public class ActivityManager {
|
||||
public long availMem = 10000;
|
||||
|
||||
public long totalMem = 10000;
|
||||
|
||||
public long threshold = 200;
|
||||
|
||||
public boolean lowMemory = false;
|
||||
}
|
||||
|
||||
public void getMemoryInfo(MemoryInfo outInfo)
|
||||
|
||||
6
src/api-impl/android/app/DatePickerDialog.java
Normal file
6
src/api-impl/android/app/DatePickerDialog.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package android.app;
|
||||
|
||||
public class DatePickerDialog {
|
||||
|
||||
public interface OnDateSetListener {}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class Dialog implements Window.Callback, DialogInterface {
|
||||
public Dialog(Context context, int themeResId) {
|
||||
this.context = context;
|
||||
nativePtr = nativeInit();
|
||||
window = new Window(this);
|
||||
window = new Window(context, this);
|
||||
window.native_window = nativePtr;
|
||||
}
|
||||
|
||||
|
||||
@@ -188,6 +188,8 @@ public class Notification implements Parcelable {
|
||||
|
||||
public Builder addExtras(Bundle extras) {return this;}
|
||||
|
||||
public Builder addRemoteInput(RemoteInput remoteInput) {return this;}
|
||||
|
||||
public Action build() {
|
||||
return action;
|
||||
}
|
||||
@@ -210,5 +212,19 @@ public class Notification implements Parcelable {
|
||||
public BigTextStyle setBigContentTitle(CharSequence title) {return this;}
|
||||
|
||||
public BigTextStyle bigText(CharSequence text) {return this;}
|
||||
|
||||
public BigTextStyle setSummaryText(CharSequence summaryText) {return this;}
|
||||
}
|
||||
|
||||
public static class InboxStyle extends Style {
|
||||
|
||||
public InboxStyle(Notification.Builder builder) {}
|
||||
|
||||
public InboxStyle setBigContentTitle(CharSequence title) {return this;}
|
||||
|
||||
public InboxStyle setSummaryText(CharSequence summaryText) {return this;}
|
||||
|
||||
public InboxStyle addLine(CharSequence line) {return this;}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
23
src/api-impl/android/app/RemoteInput.java
Normal file
23
src/api-impl/android/app/RemoteInput.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package android.app;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
public class RemoteInput {
|
||||
|
||||
public static class Builder {
|
||||
|
||||
public Builder(String resultKey) {}
|
||||
|
||||
public Builder setLabel(CharSequence label) {return this;}
|
||||
|
||||
public Builder setChoices(CharSequence[] choices) {return this;}
|
||||
|
||||
public Builder setAllowFreeFormInput(boolean allowFreeFormInput) {return this;}
|
||||
|
||||
public Builder addExtras(Bundle extras) {return this;}
|
||||
|
||||
public RemoteInput build() {
|
||||
return new RemoteInput();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,4 +40,8 @@ public abstract class Service extends Context {
|
||||
public void stopSelf() {
|
||||
System.out.println("Service.stopSelf() called");
|
||||
}
|
||||
|
||||
public void attachBaseContext(Context newBase) {
|
||||
System.out.println("Service.attachBaseContext(" + newBase + ") called");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package android.appwidget;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
|
||||
public class AppWidgetManager {
|
||||
|
||||
public static AppWidgetManager getInstance(Context context) {
|
||||
return new AppWidgetManager();
|
||||
}
|
||||
public static AppWidgetManager getInstance(Context context) {
|
||||
return new AppWidgetManager();
|
||||
}
|
||||
|
||||
public int[] getAppWidgetIds(ComponentName provider) {
|
||||
return new int[0];
|
||||
}
|
||||
}
|
||||
|
||||
4
src/api-impl/android/appwidget/AppWidgetProvider.java
Normal file
4
src/api-impl/android/appwidget/AppWidgetProvider.java
Normal file
@@ -0,0 +1,4 @@
|
||||
package android.appwidget;
|
||||
|
||||
public class AppWidgetProvider {
|
||||
}
|
||||
@@ -418,6 +418,7 @@ public class Context extends Object {
|
||||
Class<? extends Service> cls = Class.forName(component.getClassName()).asSubclass(Service.class);
|
||||
if (!runningServices.containsKey(cls)) {
|
||||
Service service = cls.getConstructor().newInstance();
|
||||
service.attachBaseContext(new Context());
|
||||
service.onCreate();
|
||||
runningServices.put(cls, service);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import android.os.Parcelable;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Intent {
|
||||
public class Intent implements Parcelable {
|
||||
private ComponentName component;
|
||||
private Bundle extras = new Bundle();
|
||||
private String action;
|
||||
@@ -316,13 +316,26 @@ public class Intent {
|
||||
}
|
||||
|
||||
public String getPackage() {
|
||||
return component.getPackageName();
|
||||
return component == null ? null : component.getPackageName();
|
||||
}
|
||||
|
||||
public String getScheme() {
|
||||
return data == null ? null : data.getScheme();
|
||||
}
|
||||
|
||||
public Intent putStringArrayListExtra(String name, ArrayList<String> value) {
|
||||
extras.putStringArrayList(name, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ArrayList<String> getStringArrayListExtra(String name) {
|
||||
return extras.getStringArrayList(name);
|
||||
}
|
||||
|
||||
public ClipData getClipData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static class ShortcutIconResource {
|
||||
|
||||
public static ShortcutIconResource fromContext(Context context, int id) {
|
||||
|
||||
216
src/api-impl/android/database/CursorWrapper.java
Normal file
216
src/api-impl/android/database/CursorWrapper.java
Normal file
@@ -0,0 +1,216 @@
|
||||
package android.database;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class CursorWrapper implements Cursor {
|
||||
|
||||
private Cursor cursor;
|
||||
|
||||
public CursorWrapper(Cursor cursor) {
|
||||
this.cursor = cursor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return cursor.getCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPosition() {
|
||||
return cursor.getPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean move(int offset) {
|
||||
return cursor.move(offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveToPosition(int position) {
|
||||
return cursor.moveToPosition(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveToFirst() {
|
||||
return cursor.moveToFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveToLast() {
|
||||
return cursor.moveToLast();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveToNext() {
|
||||
return cursor.moveToNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean moveToPrevious() {
|
||||
return cursor.moveToPrevious();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFirst() {
|
||||
return cursor.isFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLast() {
|
||||
return cursor.isLast();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBeforeFirst() {
|
||||
return cursor.isBeforeFirst();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAfterLast() {
|
||||
return cursor.isAfterLast();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnIndex(String columnName) {
|
||||
return cursor.getColumnIndex(columnName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnIndexOrThrow(String columnName) throws IllegalArgumentException {
|
||||
return cursor.getColumnIndexOrThrow(columnName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int columnIndex) {
|
||||
return cursor.getColumnName(columnIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getColumnNames() {
|
||||
return cursor.getColumnNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return cursor.getColumnCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getBlob(int columnIndex) {
|
||||
return cursor.getBlob(columnIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString(int columnIndex) {
|
||||
return cursor.getString(columnIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyStringToBuffer(int columnIndex, CharArrayBuffer buffer) {
|
||||
cursor.copyStringToBuffer(columnIndex, buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public short getShort(int columnIndex) {
|
||||
return cursor.getShort(columnIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInt(int columnIndex) {
|
||||
return cursor.getInt(columnIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLong(int columnIndex) {
|
||||
return cursor.getLong(columnIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFloat(int columnIndex) {
|
||||
return cursor.getFloat(columnIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(int columnIndex) {
|
||||
return cursor.getDouble(columnIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType(int columnIndex) {
|
||||
return cursor.getType(columnIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNull(int columnIndex) {
|
||||
return cursor.isNull(columnIndex);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void deactivate() {
|
||||
cursor.deactivate();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean requery() {
|
||||
return cursor.requery();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
cursor.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
return cursor.isClosed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerContentObserver(ContentObserver observer) {
|
||||
cursor.registerContentObserver(observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterContentObserver(ContentObserver observer) {
|
||||
cursor.unregisterContentObserver(observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerDataSetObserver(DataSetObserver observer) {
|
||||
cursor.registerDataSetObserver(observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterDataSetObserver(DataSetObserver observer) {
|
||||
cursor.unregisterDataSetObserver(observer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNotificationUri(ContentResolver cr, Uri uri) {
|
||||
cursor.setNotificationUri(cr, uri);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uri getNotificationUri() {
|
||||
return cursor.getNotificationUri();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getWantsAllOnMoveCalls() {
|
||||
return cursor.getWantsAllOnMoveCalls();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bundle getExtras() {
|
||||
return cursor.getExtras();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bundle respond(Bundle extras) {
|
||||
return cursor.respond(extras);
|
||||
}
|
||||
}
|
||||
@@ -566,6 +566,10 @@ public class BitmapFactory {
|
||||
}
|
||||
|
||||
setDensityFromOptions(bm, opts);
|
||||
if (bm != null && opts != null) {
|
||||
opts.outWidth = bm.getWidth();
|
||||
opts.outHeight = bm.getHeight();
|
||||
}
|
||||
} finally {
|
||||
Trace.traceEnd(Trace.TRACE_TAG_GRAPHICS);
|
||||
}
|
||||
|
||||
@@ -399,7 +399,14 @@ public class Canvas {
|
||||
native_drawLine(skia_canvas, widget, startX, startY, stopX, stopY, paint.skia_paint);
|
||||
}
|
||||
|
||||
public void setBitmap(Bitmap bitmap) {}
|
||||
public void setBitmap(Bitmap bitmap) {
|
||||
if (skia_canvas != 0) {
|
||||
native_destroy_canvas(skia_canvas);
|
||||
}
|
||||
bitmap.destroyTexture(); // invalidate cached texture
|
||||
this.skia_canvas = native_canvas_from_bitmap(bitmap.pixbuf);
|
||||
this.widget = 0;
|
||||
}
|
||||
|
||||
public void drawPath(Path path, Paint paint) {
|
||||
native_drawPath(skia_canvas, path.mNativePath, paint.skia_paint);
|
||||
@@ -445,6 +452,20 @@ public class Canvas {
|
||||
|
||||
public void drawColor(int dummy) {}
|
||||
|
||||
public void drawARGB(int a, int r, int g, int b) {}
|
||||
|
||||
public int saveLayer(RectF bounds, Paint paint, int flags) {
|
||||
return save();
|
||||
}
|
||||
|
||||
public void drawOval(RectF oval, Paint paint) {}
|
||||
|
||||
public boolean clipRect(int left, int top, int right, int bottom) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void drawColor(int color, PorterDuff.Mode mode) {}
|
||||
|
||||
private static native long native_canvas_from_bitmap(long pixbuf);
|
||||
|
||||
private static native void native_save(long skia_canvas, long widget);
|
||||
|
||||
@@ -423,6 +423,10 @@ public class Path {
|
||||
native_arcTo(mNativePath, oval, startAngle, sweepAngle, false);
|
||||
}
|
||||
|
||||
public void arcTo(float left, float top, float right, float bottom, float startAngle, float sweepAngle, boolean forceMoveTo) {
|
||||
arcTo(new RectF(left, top, right, bottom), startAngle, sweepAngle, forceMoveTo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the current contour. If the current point is not equal to the
|
||||
* first point of the contour, a line segment is automatically added.
|
||||
|
||||
@@ -28,6 +28,11 @@ public class BitmapDrawable extends Drawable {
|
||||
this.paintable = bitmap.getTexture();
|
||||
}
|
||||
|
||||
public BitmapDrawable(Bitmap bitmap) {
|
||||
this.bitmap = bitmap;
|
||||
this.paintable = bitmap.getTexture();
|
||||
}
|
||||
|
||||
public Bitmap getBitmap() {
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.content.res.ColorStateList;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.content.res.Resources.Theme;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
@@ -54,7 +55,24 @@ public class Drawable {
|
||||
public void setChangingConfigurations(int bitmap) {}
|
||||
|
||||
public ConstantState getConstantState() {
|
||||
return null;
|
||||
return new ConstantState() {
|
||||
|
||||
@Override
|
||||
public Drawable newDrawable(Resources res) {
|
||||
return Drawable.this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable newDrawable() {
|
||||
return Drawable.this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChangingConfigurations() {
|
||||
return Drawable.this.getChangingConfigurations();
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
public static abstract class ConstantState {
|
||||
@@ -220,12 +238,17 @@ public class Drawable {
|
||||
LayerDrawable drawable = new LayerDrawable();
|
||||
drawable.inflate(resources, parser, attrs);
|
||||
return drawable;
|
||||
} else if ("nine-patch".equals(parser.getName())) {
|
||||
return new NinePatchDrawable(resources, null, null, null, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Drawable createFromResourceStream(Resources resources, TypedValue value, InputStream is, String file,
|
||||
Object object) {
|
||||
if (!file.endsWith(".9.png")) {
|
||||
return new BitmapDrawable(resources, BitmapFactory.decodeStream(is));
|
||||
}
|
||||
Path path = Paths.get(android.os.Environment.getExternalStorageDirectory().getPath(), file);
|
||||
if (!Files.exists(path)) {
|
||||
try (InputStream inputStream = ClassLoader.getSystemClassLoader().getResourceAsStream(file)) {
|
||||
|
||||
@@ -4,14 +4,22 @@ import android.graphics.Rect;
|
||||
|
||||
public class InsetDrawable extends Drawable {
|
||||
|
||||
private Drawable drawable;
|
||||
|
||||
public InsetDrawable(Drawable drawable, int insetLeft, int insetTop, int insetRight, int insetBottom) {
|
||||
super();
|
||||
this.drawable = drawable;
|
||||
}
|
||||
|
||||
public InsetDrawable(Drawable drawable, int inset) {
|
||||
super();
|
||||
this.drawable = drawable;
|
||||
}
|
||||
|
||||
public boolean getPadding(Rect padding) { return false; }
|
||||
|
||||
|
||||
public Drawable getDrawable() {
|
||||
return drawable;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package android.graphics.drawable;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Rect;
|
||||
|
||||
public class NinePatchDrawable extends Drawable {
|
||||
|
||||
public NinePatchDrawable(Resources res, Bitmap bitmap, byte[] data, Rect padding, String name) {}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user