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 menu APIs and use Activity as Window.Callbacks implementation
This commit is contained in:
@@ -7,6 +7,8 @@
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
#undef android_view_Window_FEATURE_OPTIONS_PANEL
|
||||||
|
#define android_view_Window_FEATURE_OPTIONS_PANEL 0L
|
||||||
/*
|
/*
|
||||||
* Class: android_view_Window
|
* Class: android_view_Window
|
||||||
* Method: set_widget_as_root
|
* Method: set_widget_as_root
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package android.app;
|
package android.app;
|
||||||
|
|
||||||
import android.R;
|
import android.R;
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -10,27 +11,25 @@ import android.os.Bundle;
|
|||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.view.WindowManagerImpl;
|
import android.view.WindowManagerImpl;
|
||||||
import android.widget.TextView;
|
|
||||||
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
|
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
|
||||||
import java.io.FileReader;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.StringReader;
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
|
||||||
import org.xmlpull.v1.XmlPullParserFactory;
|
|
||||||
|
|
||||||
public class Activity extends Context {
|
public class Activity extends Context implements Window.Callback {
|
||||||
LayoutInflater layout_inflater;
|
LayoutInflater layout_inflater;
|
||||||
Window window = new Window();
|
Window window = new Window(this);
|
||||||
int requested_orientation = -1 /*ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED*/; // dummy
|
int requested_orientation = -1 /*ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED*/; // dummy
|
||||||
private Intent intent;
|
private Intent intent;
|
||||||
private Activity resultActivity;
|
private Activity resultActivity;
|
||||||
@@ -333,4 +332,64 @@ public class Activity extends Context {
|
|||||||
|
|
||||||
private native void nativeFinish(long native_window);
|
private native void nativeFinish(long native_window);
|
||||||
private static native void nativeStartActivity(Activity activity);
|
private static native void nativeStartActivity(Activity activity);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onContentChanged() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("Unimplemented method 'onContentChanged'");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreatePanelMenu(int featureId, Menu menu) {
|
||||||
|
if (featureId == Window.FEATURE_OPTIONS_PANEL) {
|
||||||
|
return onCreateOptionsMenu(menu);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreatePanelView(int featureId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuInflater getMenuInflater() {
|
||||||
|
return new MenuInflater(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onPreparePanel(int featureId, View view, Menu menu) {
|
||||||
|
if (featureId == Window.FEATURE_OPTIONS_PANEL && menu != null) {
|
||||||
|
return onPrepareOptionsMenu(menu);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onMenuItemSelected(int featureId, MenuItem item) {
|
||||||
|
if (featureId == Window.FEATURE_OPTIONS_PANEL) {
|
||||||
|
return onOptionsItemSelected(item);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onOptionsMenuClosed(Menu menu) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPanelClosed(int featureId, Menu menu) {
|
||||||
|
if (featureId == Window.FEATURE_OPTIONS_PANEL) {
|
||||||
|
onOptionsMenuClosed(menu);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,5 +8,9 @@ public interface Menu {
|
|||||||
|
|
||||||
public MenuItem findItem(int id);
|
public MenuItem findItem(int id);
|
||||||
|
|
||||||
|
public MenuItem getItem(int id);
|
||||||
|
|
||||||
public void clear();
|
public void clear();
|
||||||
|
|
||||||
|
public void removeGroup(int groupId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,4 +8,22 @@ public interface MenuItem {
|
|||||||
|
|
||||||
public MenuItem setVisible(boolean visible);
|
public MenuItem setVisible(boolean visible);
|
||||||
|
|
||||||
|
public MenuItem setChecked(boolean checked);
|
||||||
|
|
||||||
|
public MenuItem setEnabled(boolean enabled);
|
||||||
|
|
||||||
|
public MenuItem setCheckable(boolean checkable);
|
||||||
|
|
||||||
|
public MenuItem setTitleCondensed(CharSequence titleCondensed);
|
||||||
|
|
||||||
|
public MenuItem setTitle(CharSequence title);
|
||||||
|
|
||||||
|
public MenuItem setActionView(View actionView);
|
||||||
|
|
||||||
|
public void setShowAsAction(int action);
|
||||||
|
|
||||||
|
public int getItemId();
|
||||||
|
|
||||||
|
public int getGroupId();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,28 +1,20 @@
|
|||||||
package android.view;
|
package android.view;
|
||||||
|
|
||||||
public class Window {
|
public class Window {
|
||||||
|
public static final int FEATURE_OPTIONS_PANEL = 0;
|
||||||
|
|
||||||
public static interface Callback {
|
public static interface Callback {
|
||||||
public void onContentChanged();
|
public void onContentChanged();
|
||||||
|
|
||||||
public abstract boolean onCreatePanelMenu(int featureId, Menu menu);
|
public abstract boolean onCreatePanelMenu(int featureId, Menu menu);
|
||||||
|
|
||||||
public View onCreatePanelView(int featureId);
|
public View onCreatePanelView(int featureId);
|
||||||
}
|
|
||||||
public static class fixme_callback implements Callback {
|
|
||||||
|
|
||||||
@Override
|
public boolean onPreparePanel(int featureId, View view, Menu menu);
|
||||||
public void onContentChanged() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public boolean onMenuItemSelected(int featureId, MenuItem item);
|
||||||
public boolean onCreatePanelMenu(int featureId, Menu menu) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
public void onPanelClosed(int featureId, Menu menu);
|
||||||
public View onCreatePanelView(int featureId) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME private
|
// FIXME private
|
||||||
@@ -31,8 +23,8 @@ public class Window {
|
|||||||
|
|
||||||
private Window.Callback callback;
|
private Window.Callback callback;
|
||||||
|
|
||||||
public Window() {
|
public Window(Window.Callback callback) {
|
||||||
this.callback = new fixme_callback();
|
this.callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addFlags(int flags) {}
|
public void addFlags(int flags) {}
|
||||||
@@ -74,4 +66,10 @@ public class Window {
|
|||||||
public View peekDecorView() {
|
public View peekDecorView() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WindowManager.LayoutParams getAttributes() {
|
||||||
|
return new WindowManager.LayoutParams();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAttributes(WindowManager.LayoutParams params) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,5 +5,7 @@ public interface WindowManager {
|
|||||||
|
|
||||||
public class LayoutParams {
|
public class LayoutParams {
|
||||||
public static final int FLAG_KEEP_SCREEN_ON = 0;
|
public static final int FLAG_KEEP_SCREEN_ON = 0;
|
||||||
|
|
||||||
|
public float screenBrightness;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user