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 lots of java APIs needed for Whatsapp
This commit is contained in:
@@ -3,7 +3,7 @@ package android.app;
|
||||
import android.R;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.pm.PackageParser;
|
||||
@@ -12,6 +12,7 @@ import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
@@ -28,7 +29,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class Activity extends ContextWrapper implements Window.Callback {
|
||||
public class Activity extends ContextThemeWrapper implements Window.Callback {
|
||||
LayoutInflater layout_inflater;
|
||||
Window window = new Window(this);
|
||||
int requested_orientation = -1 /*ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED*/; // dummy
|
||||
@@ -54,7 +55,7 @@ public class Activity extends ContextWrapper implements Window.Callback {
|
||||
if (className == null) {
|
||||
for (PackageParser.Activity activity: pkg.activities) {
|
||||
for (PackageParser.IntentInfo intent: activity.intents) {
|
||||
if (intent.matchAction("android.intent.action.MAIN")) {
|
||||
if (intent.hasCategory("android.intent.category.LAUNCHER")) {
|
||||
className = activity.className;
|
||||
break;
|
||||
}
|
||||
@@ -74,23 +75,27 @@ public class Activity extends ContextWrapper implements Window.Callback {
|
||||
|
||||
public Activity() {
|
||||
super(null);
|
||||
layout_inflater = new LayoutInflater();
|
||||
layout_inflater = new LayoutInflater(this);
|
||||
intent = new Intent();
|
||||
|
||||
CharSequence label = null;
|
||||
CharSequence app_label = null;
|
||||
int themeResId = 0;
|
||||
for (PackageParser.Activity activity: pkg.activities) {
|
||||
if (getClass().getName().equals(activity.className)) {
|
||||
label = getText(activity.info.labelRes);
|
||||
label = r.getText(activity.info.labelRes);
|
||||
themeResId = activity.info.getThemeResource();
|
||||
break;
|
||||
}
|
||||
}
|
||||
app_label = getText(pkg.applicationInfo.labelRes);
|
||||
app_label = r.getText(pkg.applicationInfo.labelRes);
|
||||
if (label != null) {
|
||||
setTitle(label);
|
||||
} else if (app_label != null) {
|
||||
setTitle(app_label);
|
||||
}
|
||||
attachBaseContext(new Context());
|
||||
setTheme(themeResId);
|
||||
}
|
||||
|
||||
public View root_view;
|
||||
@@ -422,6 +427,10 @@ public class Activity extends ContextWrapper implements Window.Callback {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void setTitle(int titleId) {
|
||||
this.title = getText(titleId);
|
||||
}
|
||||
|
||||
public CharSequence getTitle() {
|
||||
return title;
|
||||
}
|
||||
@@ -488,6 +497,10 @@ public class Activity extends ContextWrapper implements Window.Callback {
|
||||
return destroyed;
|
||||
}
|
||||
|
||||
public void finishAffinity() {
|
||||
finish();
|
||||
}
|
||||
|
||||
private native void nativeFinish(long native_window);
|
||||
public static native void nativeRecreateActivity(Activity activity);
|
||||
public static native void nativeStartActivity(Activity activity);
|
||||
|
||||
@@ -5,7 +5,9 @@ import java.util.List;
|
||||
|
||||
public class ActivityManager {
|
||||
|
||||
public static class RunningAppProcessInfo{}
|
||||
public static class RunningAppProcessInfo{
|
||||
public int importance;
|
||||
}
|
||||
|
||||
public List<RunningAppProcessInfo> getRunningAppProcesses() {
|
||||
return null;
|
||||
@@ -16,6 +18,8 @@ public class ActivityManager {
|
||||
public static class MemoryInfo {
|
||||
/* For now, just always report there's 10GB free RAM */
|
||||
public long availMem = 10000;
|
||||
|
||||
public long totalMem = 10000;
|
||||
}
|
||||
|
||||
public void getMemoryInfo(MemoryInfo outInfo)
|
||||
@@ -26,4 +30,8 @@ public class ActivityManager {
|
||||
public ConfigurationInfo getDeviceConfigurationInfo() {
|
||||
return new ConfigurationInfo();
|
||||
}
|
||||
|
||||
public int getMemoryClass() {return 20;} // suggested heap size in MB
|
||||
|
||||
public static void getMyMemoryState(RunningAppProcessInfo outInfo) {}
|
||||
}
|
||||
|
||||
@@ -2,4 +2,8 @@ package android.app;
|
||||
|
||||
public class AlarmManager {
|
||||
public void cancel(PendingIntent operation) {}
|
||||
|
||||
public void setInexactRepeating(int type, long triggerTime, long interval, PendingIntent operation) {}
|
||||
|
||||
public void setExact(int type, long triggerTime, PendingIntent operation) {}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class Application extends ContextWrapper {
|
||||
}
|
||||
|
||||
public Application() {
|
||||
super(new Context());
|
||||
super(null);
|
||||
}
|
||||
/**
|
||||
* Called when the application is starting, before any activity, service,
|
||||
|
||||
@@ -22,6 +22,7 @@ public class Dialog implements Window.Callback, DialogInterface {
|
||||
private Context context;
|
||||
private Window window;
|
||||
private OnDismissListener onDismissListener;
|
||||
private OnShowListener onShowListener;
|
||||
|
||||
public Dialog(Context context, int themeResId) {
|
||||
this.context = context;
|
||||
@@ -75,6 +76,8 @@ public class Dialog implements Window.Callback, DialogInterface {
|
||||
public void run() {
|
||||
onCreate(null);
|
||||
nativeShow(nativePtr);
|
||||
if (onShowListener != null)
|
||||
onShowListener.onShow(Dialog.this);
|
||||
}
|
||||
};
|
||||
if(Looper.myLooper() == Looper.getMainLooper()) {
|
||||
@@ -160,4 +163,8 @@ public class Dialog implements Window.Callback, DialogInterface {
|
||||
public void cancel() {
|
||||
dismiss();
|
||||
}
|
||||
|
||||
public void setOnShowListener(OnShowListener onShowListener) {
|
||||
this.onShowListener = onShowListener;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,4 +4,8 @@ public class KeyguardManager {
|
||||
public boolean inKeyguardRestrictedInputMode() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isKeyguardLocked() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
|
||||
public class NotificationManager {
|
||||
public void cancelAll() {}
|
||||
@@ -40,7 +41,7 @@ public class NotificationManager {
|
||||
public void cancel(String tag, final int id) {
|
||||
// remove_notification doesn't work reliably when sent directly after add_notification in GNOME session.
|
||||
// So we give some extra delay here.
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
nativeCancel(id);
|
||||
|
||||
@@ -25,4 +25,12 @@ public abstract class Service extends Context {
|
||||
public Application getApplication() {
|
||||
return this_application;
|
||||
}
|
||||
|
||||
public void stopSelf(int startId) {
|
||||
System.out.println("Service.stopSelf(" + startId + ") called");
|
||||
}
|
||||
|
||||
public void stopSelf() {
|
||||
System.out.println("Service.stopSelf() called");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user