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
handle 'SEND' intent by copying to clipboard, make Activity subclass ContextWrapper, code style fixes
This commit is contained in:
@@ -4,6 +4,7 @@ import android.R;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Configuration;
|
||||
import android.content.res.XmlResourceParser;
|
||||
@@ -27,7 +28,7 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class Activity extends Context implements Window.Callback {
|
||||
public class Activity extends ContextWrapper implements Window.Callback {
|
||||
LayoutInflater layout_inflater;
|
||||
Window window = new Window(this);
|
||||
int requested_orientation = -1 /*ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED*/; // dummy
|
||||
@@ -64,6 +65,7 @@ public class Activity extends Context implements Window.Callback {
|
||||
}
|
||||
|
||||
public Activity() {
|
||||
super(null);
|
||||
layout_inflater = new LayoutInflater();
|
||||
intent = new Intent();
|
||||
}
|
||||
@@ -320,10 +322,6 @@ public class Activity extends Context implements Window.Callback {
|
||||
|
||||
public boolean isChangingConfigurations() {return false;}
|
||||
|
||||
private native void nativeFinish(long native_window);
|
||||
public static native void nativeStartActivity(Activity activity);
|
||||
public static native void nativeOpenURI(String uri);
|
||||
|
||||
@Override
|
||||
public void onContentChanged() {
|
||||
// TODO Auto-generated method stub
|
||||
@@ -393,4 +391,9 @@ public class Activity extends Context implements Window.Callback {
|
||||
public void setIntent(Intent newIntent) {}
|
||||
|
||||
public void unregisterReceiver(BroadcastReceiver receiver) {}
|
||||
|
||||
private native void nativeFinish(long native_window);
|
||||
public static native void nativeStartActivity(Activity activity);
|
||||
public static native void nativeOpenURI(String uri);
|
||||
public static native void nativeShare(String text);
|
||||
}
|
||||
|
||||
@@ -393,12 +393,17 @@ public class Context extends Object {
|
||||
|
||||
public void startActivity(Intent intent) {
|
||||
Slog.i(TAG, "startActivity(" + intent + ") called");
|
||||
if ("android.intent.action.CHOOSER".equals(intent.getAction())) {
|
||||
if (intent.getAction() != null && intent.getAction().equals("android.intent.action.CHOOSER")) {
|
||||
intent = (Intent) intent.getExtras().get("android.intent.extra.INTENT");
|
||||
}
|
||||
if (intent.getComponent() == null) {
|
||||
Slog.i(TAG, "starting extern activity with intent: " + intent);
|
||||
Activity.nativeOpenURI(String.valueOf(intent.getData()));
|
||||
if(intent.getAction() != null && intent.getAction().equals("android.intent.action.SEND")) {
|
||||
Slog.i(TAG, "starting extern activity with intent: " + intent);
|
||||
Activity.nativeShare((String) intent.getExtras().get("android.intent.extra.TEXT"));
|
||||
} else if (intent.getData() != null) {
|
||||
Slog.i(TAG, "starting extern activity with intent: " + intent);
|
||||
Activity.nativeOpenURI(String.valueOf(intent.getData()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -10,5 +10,4 @@ public class ContextWrapper extends Context {
|
||||
public Context getBaseContext() {
|
||||
return baseContext;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ public class Intent {
|
||||
private String action;
|
||||
private Uri data;
|
||||
private int flags;
|
||||
private String type;
|
||||
|
||||
public Intent() {}
|
||||
public Intent(Intent o) {
|
||||
@@ -43,10 +44,20 @@ public class Intent {
|
||||
this.flags = flags;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getFlags() {
|
||||
return flags;
|
||||
}
|
||||
|
||||
public Intent setPackage(String packageName) {
|
||||
return this; //??
|
||||
}
|
||||
|
||||
public Intent setType(String type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Intent putExtra(String name, Parcelable value) {
|
||||
extras.putParcelable(name, value);
|
||||
return this;
|
||||
@@ -220,7 +231,7 @@ public class Intent {
|
||||
this.component = component;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public ComponentName getComponent() {
|
||||
return component;
|
||||
}
|
||||
@@ -255,15 +266,10 @@ public class Intent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Intent [component=" + component + ", extras=" + extras + ", action=" + action + ", uri=" + data + "]";
|
||||
return "Intent [component=" + component + ", extras=" + extras + ", action=" + action + ", type=" + type + ", uri=" + data + "]";
|
||||
}
|
||||
|
||||
public static Intent createChooser(Intent target, CharSequence title) {
|
||||
return target;
|
||||
}
|
||||
|
||||
public int getFlags() {
|
||||
return flags;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user