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
multiple additions and fixes for the Java APIs
Stuff needed for WhatsApp support
This commit is contained in:
@@ -27,7 +27,9 @@ import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Activity extends ContextThemeWrapper implements Window.Callback {
|
||||
LayoutInflater layout_inflater;
|
||||
@@ -337,8 +339,30 @@ public class Activity extends ContextThemeWrapper implements Window.Callback {
|
||||
setResult(resultCode, null);
|
||||
}
|
||||
|
||||
protected Dialog onCreateDialog(int id) {
|
||||
System.out.println("Activity.onCreateDialog(" + id + ") called");
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void onPrepareDialog(int id, Dialog dialog) {
|
||||
System.out.println("Activity.onPrepareDialog(" + id + ") called");
|
||||
}
|
||||
|
||||
private Map<Integer, Dialog> dialogs = new HashMap<Integer, Dialog>();
|
||||
|
||||
public final void showDialog(int id) {
|
||||
System.out.println("Activity.showDialog(" + id + ") called");
|
||||
Dialog dialog = dialogs.get(id);
|
||||
if (dialog == null)
|
||||
dialogs.put(id, dialog = onCreateDialog(id));
|
||||
onPrepareDialog(id, dialog);
|
||||
dialog.show();
|
||||
}
|
||||
|
||||
public void removeDialog(int id) {
|
||||
Dialog dialog = dialogs.remove(id);
|
||||
if (dialog != null)
|
||||
dialog.dismiss();
|
||||
}
|
||||
|
||||
public void finish() {
|
||||
@@ -501,6 +525,8 @@ public class Activity extends ContextThemeWrapper implements Window.Callback {
|
||||
finish();
|
||||
}
|
||||
|
||||
public void overridePendingTransition(int enterAnim, int exitAnim) {}
|
||||
|
||||
private native void nativeFinish(long native_window);
|
||||
public static native void nativeRecreateActivity(Activity activity);
|
||||
public static native void nativeStartActivity(Activity activity);
|
||||
|
||||
@@ -34,4 +34,6 @@ public class ActivityManager {
|
||||
public int getMemoryClass() {return 20;} // suggested heap size in MB
|
||||
|
||||
public static void getMyMemoryState(RunningAppProcessInfo outInfo) {}
|
||||
|
||||
public boolean clearApplicationUserData() {return false;}
|
||||
}
|
||||
|
||||
@@ -6,4 +6,6 @@ public class AlarmManager {
|
||||
public void setInexactRepeating(int type, long triggerTime, long interval, PendingIntent operation) {}
|
||||
|
||||
public void setExact(int type, long triggerTime, PendingIntent operation) {}
|
||||
|
||||
public void set(int type, long triggerTime, PendingIntent operation) {}
|
||||
}
|
||||
|
||||
@@ -47,9 +47,13 @@ public class AlertDialog extends Dialog implements DialogInterface {
|
||||
|
||||
public AlertDialog.Builder setNegativeButton (CharSequence text, DialogInterface.OnClickListener listener) {
|
||||
System.out.println("AlertDialog.Builder setNegativeButton called with text: '" + text + "'");
|
||||
dialog.setButton(DialogInterface.BUTTON_NEGATIVE, text, listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
public AlertDialog.Builder setNegativeButton(int textId, DialogInterface.OnClickListener listener) {
|
||||
return setNegativeButton(dialog.getContext().getText(textId), listener);
|
||||
}
|
||||
|
||||
public AlertDialog.Builder setCancelable(boolean cancelable) {
|
||||
return this;
|
||||
@@ -95,5 +99,10 @@ public class AlertDialog extends Dialog implements DialogInterface {
|
||||
public AlertDialog create() {
|
||||
return dialog;
|
||||
}
|
||||
|
||||
public AlertDialog show() {
|
||||
dialog.show();
|
||||
return dialog;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
10
src/api-impl/android/app/AppGlobals.java
Normal file
10
src/api-impl/android/app/AppGlobals.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package android.app;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class AppGlobals {
|
||||
|
||||
public static Application getInitialApplication() {
|
||||
return Context.this_application;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
package android.app;
|
||||
|
||||
public abstract class IntentService {
|
||||
public abstract class IntentService extends Service {
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ public class PendingIntent {
|
||||
+ new String[] { "activity", "service", "broadcast" }[type] + "]";
|
||||
}
|
||||
|
||||
public void cancel() {}
|
||||
|
||||
public class CanceledException extends Exception {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,10 @@ public abstract class Service extends Context {
|
||||
|
||||
public abstract IBinder onBind(Intent intent);
|
||||
|
||||
public abstract int onStartCommand(Intent intent, int flags, int startId);
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
System.out.println("Service.onStartCommand(" + intent + ", " + flags + ", " + startId + ") called");
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void startForeground(int id, Notification notification) {
|
||||
System.out.println("startForeground(" + id + ", " + notification + ") called");
|
||||
|
||||
Reference in New Issue
Block a user