mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-04-28 20:27:58 +03:00
add menu APIs and use Activity as Window.Callbacks implementation
This commit is contained in:
parent
ad83271080
commit
f968bcd7c4
6 changed files with 105 additions and 22 deletions
|
@ -7,6 +7,8 @@
|
|||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#undef android_view_Window_FEATURE_OPTIONS_PANEL
|
||||
#define android_view_Window_FEATURE_OPTIONS_PANEL 0L
|
||||
/*
|
||||
* Class: android_view_Window
|
||||
* Method: set_widget_as_root
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package android.app;
|
||||
|
||||
import android.R;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
@ -10,27 +11,25 @@ import android.os.Bundle;
|
|||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.view.WindowManagerImpl;
|
||||
import android.widget.TextView;
|
||||
import com.reandroid.arsc.chunk.xml.AndroidManifestBlock;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringReader;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
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;
|
||||
Window window = new Window();
|
||||
Window window = new Window(this);
|
||||
int requested_orientation = -1 /*ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED*/; // dummy
|
||||
private Intent intent;
|
||||
private Activity resultActivity;
|
||||
|
@ -333,4 +332,64 @@ public class Activity extends Context {
|
|||
|
||||
private native void nativeFinish(long native_window);
|
||||
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 getItem(int id);
|
||||
|
||||
public void clear();
|
||||
|
||||
public void removeGroup(int groupId);
|
||||
}
|
||||
|
|
|
@ -8,4 +8,22 @@ public interface MenuItem {
|
|||
|
||||
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;
|
||||
|
||||
public class Window {
|
||||
public static final int FEATURE_OPTIONS_PANEL = 0;
|
||||
|
||||
public static interface Callback {
|
||||
public void onContentChanged();
|
||||
|
||||
public abstract boolean onCreatePanelMenu(int featureId, Menu menu);
|
||||
|
||||
public View onCreatePanelView(int featureId);
|
||||
}
|
||||
public static class fixme_callback implements Callback {
|
||||
|
||||
@Override
|
||||
public void onContentChanged() {
|
||||
}
|
||||
public boolean onPreparePanel(int featureId, View view, Menu menu);
|
||||
|
||||
@Override
|
||||
public boolean onCreatePanelMenu(int featureId, Menu menu) {
|
||||
return false;
|
||||
}
|
||||
public boolean onMenuItemSelected(int featureId, MenuItem item);
|
||||
|
||||
@Override
|
||||
public View onCreatePanelView(int featureId) {
|
||||
return null;
|
||||
}
|
||||
public void onPanelClosed(int featureId, Menu menu);
|
||||
}
|
||||
|
||||
// FIXME private
|
||||
|
@ -31,8 +23,8 @@ public class Window {
|
|||
|
||||
private Window.Callback callback;
|
||||
|
||||
public Window() {
|
||||
this.callback = new fixme_callback();
|
||||
public Window(Window.Callback callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public void addFlags(int flags) {}
|
||||
|
@ -74,4 +66,10 @@ public class Window {
|
|||
public View peekDecorView() {
|
||||
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 static final int FLAG_KEEP_SCREEN_ON = 0;
|
||||
|
||||
public float screenBrightness;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue