mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-04-28 12:17:57 +03:00
make K-9 Mail launch
This commit is contained in:
parent
17713781d0
commit
0e078894ce
14 changed files with 101 additions and 45 deletions
|
@ -1,5 +1,6 @@
|
|||
package android.animation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
public class AnimatorSet extends Animator {
|
||||
|
@ -29,4 +30,8 @@ public class AnimatorSet extends Animator {
|
|||
|
||||
public void playTogether(Animator[] animators) {}
|
||||
|
||||
public ArrayList<Animator> getChildAnimations() {
|
||||
return new ArrayList<Animator>(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ public class Activity extends ContextThemeWrapper implements Window.Callback {
|
|||
public static final int RESULT_CANCELED = 0;
|
||||
public static final int RESULT_OK = -1;
|
||||
|
||||
LayoutInflater layout_inflater;
|
||||
Window window = new Window(this, this);
|
||||
int requested_orientation = -1 /*ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED*/; // dummy
|
||||
public Intent intent;
|
||||
|
@ -51,6 +50,33 @@ public class Activity extends ContextThemeWrapper implements Window.Callback {
|
|||
List<Fragment> fragments = new ArrayList<>();
|
||||
boolean destroyed = false;
|
||||
|
||||
public static Activity internalCreateActivity(String className, long native_window, Intent intent) throws ReflectiveOperationException {
|
||||
int themeResId = 0;
|
||||
CharSequence label = null;
|
||||
CharSequence app_label = null;
|
||||
for (PackageParser.Activity activity: pkg.activities) {
|
||||
if (className.equals(activity.className)) {
|
||||
label = r.getText(activity.info.labelRes);
|
||||
themeResId = activity.info.getThemeResource();
|
||||
break;
|
||||
}
|
||||
}
|
||||
Class<? extends Activity> cls = Class.forName(className).asSubclass(Activity.class);
|
||||
Constructor<? extends Activity> constructor = cls.getConstructor();
|
||||
Activity activity = constructor.newInstance();
|
||||
activity.window.native_window = native_window;
|
||||
activity.intent = intent;
|
||||
activity.attachBaseContext(new Context());
|
||||
activity.setTheme(themeResId);
|
||||
app_label = r.getText(pkg.applicationInfo.labelRes);
|
||||
if (label != null) {
|
||||
activity.setTitle(label);
|
||||
} else if (app_label != null) {
|
||||
activity.setTitle(app_label);
|
||||
}
|
||||
return activity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to be called from native code to construct main activity
|
||||
*
|
||||
|
@ -80,39 +106,11 @@ public class Activity extends ContextThemeWrapper implements Window.Callback {
|
|||
System.err.println("Failed to find Activity to launch URI: " + uri);
|
||||
System.exit(1);
|
||||
}
|
||||
Class<? extends Activity> cls = Class.forName(className).asSubclass(Activity.class);
|
||||
Constructor<? extends Activity> constructor = cls.getConstructor();
|
||||
Activity activity = constructor.newInstance();
|
||||
activity.window.native_window = native_window;
|
||||
if (uri != null)
|
||||
activity.setIntent(new Intent("android.intent.action.VIEW", uri));
|
||||
return activity;
|
||||
return internalCreateActivity(className, native_window, uri != null ? new Intent("android.intent.action.VIEW", uri) : new Intent());
|
||||
}
|
||||
|
||||
public Activity() {
|
||||
super(null);
|
||||
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 = r.getText(activity.info.labelRes);
|
||||
themeResId = activity.info.getThemeResource();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -262,7 +260,7 @@ public class Activity extends ContextThemeWrapper implements Window.Callback {
|
|||
public void setContentView(int layoutResID) throws Exception {
|
||||
Slog.i(TAG, "- setContentView - yay!");
|
||||
|
||||
root_view = layout_inflater.inflate(layoutResID, null, false);
|
||||
root_view = getLayoutInflater().inflate(layoutResID, null, false);
|
||||
|
||||
System.out.println("~~~~~~~~~~~");
|
||||
System.out.println(root_view.toString());
|
||||
|
@ -411,7 +409,7 @@ public class Activity extends ContextThemeWrapper implements Window.Callback {
|
|||
}
|
||||
|
||||
public LayoutInflater getLayoutInflater() {
|
||||
return layout_inflater;
|
||||
return new LayoutInflater(this);
|
||||
}
|
||||
|
||||
public boolean isChangingConfigurations() {return false;}
|
||||
|
@ -511,14 +509,10 @@ public class Activity extends ContextThemeWrapper implements Window.Callback {
|
|||
public void recreate() {
|
||||
try {
|
||||
/* TODO: check if this is a toplevel activity */
|
||||
Class<? extends Activity> cls = this.getClass();
|
||||
Constructor<? extends Activity> constructor = cls.getConstructor();
|
||||
Activity activity = constructor.newInstance();
|
||||
activity.getWindow().native_window = getWindow().native_window;
|
||||
Slog.i(TAG, "activity.getWindow().native_window >"+activity.getWindow().native_window+"<");
|
||||
Activity activity = internalCreateActivity(this.getClass().getName(), getWindow().native_window, intent);
|
||||
nativeFinish(0);
|
||||
nativeStartActivity(activity);
|
||||
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
} catch (ReflectiveOperationException e) {
|
||||
Slog.i(TAG, "exception in Activity.recreate, this is kinda sus");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
|
@ -538,11 +538,7 @@ public class Context extends Object {
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Class<? extends Activity> cls = Class.forName(intent_.getComponent().getClassName()).asSubclass(Activity.class);
|
||||
Constructor<? extends Activity> constructor = cls.getConstructor();
|
||||
Activity activity = constructor.newInstance();
|
||||
activity.intent = intent_;
|
||||
activity.getWindow().native_window = this_application.native_window;
|
||||
Activity activity = Activity.internalCreateActivity(intent_.getComponent().getClassName(), this_application.native_window, intent_);
|
||||
Activity.nativeStartActivity(activity);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -5,6 +5,8 @@ import android.os.Bundle;
|
|||
import android.os.Parcelable;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
public class Intent implements Parcelable {
|
||||
public static final String ACTION_MAIN = "android.intent.action.MAIN";
|
||||
|
@ -350,4 +352,16 @@ public class Intent implements Parcelable {
|
|||
public Intent setClassName(Context packageContext, String className) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public String resolveTypeIfNeeded(ContentResolver resolver) {
|
||||
return type;
|
||||
}
|
||||
|
||||
public Set<String> getCategories() {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
public byte[] getByteArrayExtra(String name) {
|
||||
return extras.getByteArray(name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,9 @@ import java.util.ArrayList;
|
|||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class IntentFilter {
|
||||
|
@ -64,4 +67,12 @@ public class IntentFilter {
|
|||
public final Iterator<String> actionsIterator() {
|
||||
return actions.iterator();
|
||||
}
|
||||
|
||||
public boolean hasAction(String action) {
|
||||
return actions.contains(action);
|
||||
}
|
||||
|
||||
public int match(String action, String type, String scheme, Uri data, Set<String> categories, String logTag) {
|
||||
return -1/*NO_MATCH_TYPE*/;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1814,10 +1814,10 @@ public class PackageManager {
|
|||
// TODO: we shouldn't just automatically grant these once we have bubblewrap set up
|
||||
// for now, the app can access anything it wants, so no point telling it otherwise
|
||||
case "android.permission.WRITE_EXTERNAL_STORAGE":
|
||||
return PERMISSION_GRANTED;
|
||||
case "android.permission.READ_EXTERNAL_STORAGE":
|
||||
return PERMISSION_GRANTED;
|
||||
case "com.google.android.c2dm.permission.SEND":
|
||||
case "com.fsck.k9.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION":
|
||||
case "net.thunderbird.android.DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION":
|
||||
return PERMISSION_GRANTED;
|
||||
default:
|
||||
System.out.println("PackageManager.checkPermission: >" + permName + "< not handled\n");
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package android.content.pm;
|
||||
|
||||
import android.content.IntentFilter;
|
||||
|
||||
public class ResolveInfo {
|
||||
public ActivityInfo activityInfo = new ActivityInfo();
|
||||
public ServiceInfo serviceInfo = new ServiceInfo();
|
||||
public IntentFilter filter = new IntentFilter();
|
||||
|
||||
public static class DisplayNameComparator {
|
||||
|
||||
|
|
|
@ -1466,6 +1466,10 @@ public class Resources {
|
|||
theme = mAssets.createTheme();
|
||||
}
|
||||
|
||||
public Resources getResources() {
|
||||
return Resources.this;
|
||||
}
|
||||
|
||||
private final AssetManager mAssets;
|
||||
}
|
||||
|
||||
|
|
10
src/api-impl/android/graphics/Picture.java
Normal file
10
src/api-impl/android/graphics/Picture.java
Normal file
|
@ -0,0 +1,10 @@
|
|||
package android.graphics;
|
||||
|
||||
public class Picture {
|
||||
|
||||
public Canvas beginRecording(int width, int height) {
|
||||
return new Canvas(Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888));
|
||||
}
|
||||
|
||||
public void endRecording() {}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
package android.net;
|
||||
|
||||
public class SSLCertificateSocketFactory {
|
||||
}
|
|
@ -1,5 +1,9 @@
|
|||
package android.text.style;
|
||||
|
||||
import android.text.TextPaint;
|
||||
|
||||
public class MetricAffectingSpan {
|
||||
|
||||
public void updateMeasureState(TextPaint paint) {}
|
||||
|
||||
}
|
||||
|
|
6
src/api-impl/android/view/HardwareCanvas.java
Normal file
6
src/api-impl/android/view/HardwareCanvas.java
Normal file
|
@ -0,0 +1,6 @@
|
|||
package android.view;
|
||||
|
||||
import android.graphics.Canvas;
|
||||
|
||||
public class HardwareCanvas extends Canvas {
|
||||
}
|
|
@ -11,4 +11,6 @@ public class ViewAnimator extends ViewGroup {
|
|||
}
|
||||
|
||||
public void setDisplayedChild(int index) {}
|
||||
|
||||
public int getDisplayedChild() { return 0; }
|
||||
}
|
||||
|
|
|
@ -191,6 +191,7 @@ srcs = [
|
|||
'android/graphics/Path.java',
|
||||
'android/graphics/PathEffect.java',
|
||||
'android/graphics/PathMeasure.java',
|
||||
'android/graphics/Picture.java',
|
||||
'android/graphics/PixelFormat.java',
|
||||
'android/graphics/Point.java',
|
||||
'android/graphics/PointF.java',
|
||||
|
@ -262,6 +263,7 @@ srcs = [
|
|||
'android/net/ConnectivityManager.java',
|
||||
'android/net/NetworkInfo.java',
|
||||
'android/net/NetworkRequest.java',
|
||||
'android/net/SSLCertificateSocketFactory.java',
|
||||
'android/net/SSLSessionCache.java',
|
||||
'android/net/TrafficStats.java',
|
||||
'android/net/Uri.java',
|
||||
|
@ -439,6 +441,7 @@ srcs = [
|
|||
'android/view/ContextThemeWrapper.java',
|
||||
'android/view/Display.java',
|
||||
'android/view/GestureDetector.java',
|
||||
'android/view/HardwareCanvas.java',
|
||||
'android/view/Gravity.java',
|
||||
'android/view/InflateException.java',
|
||||
'android/view/InputDevice.java',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue