| Index: platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java
|
| diff --git a/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java b/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java
|
| index 49f711d517171556670b14cd8432a3cff7a2e474..ce5bb0dedadae99c950d0a6f01e4b9dc32a9e78f 100644
|
| --- a/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java
|
| +++ b/platform_tools/android/apps/viewer/src/main/java/org/skia/viewer/ViewerActivity.java
|
| @@ -8,9 +8,10 @@
|
| package org.skia.viewer;
|
|
|
| import android.app.Activity;
|
| +import android.content.res.Configuration;
|
| import android.os.Bundle;
|
| -import android.util.Log;
|
| -import android.view.GestureDetector;
|
| +import android.support.v4.widget.DrawerLayout;
|
| +import android.support.v7.app.ActionBarDrawerToggle;
|
| import android.view.KeyEvent;
|
| import android.view.Menu;
|
| import android.view.MenuInflater;
|
| @@ -20,11 +21,17 @@ import android.view.Surface;
|
| import android.view.SurfaceHolder;
|
| import android.view.SurfaceView;
|
| import android.view.View;
|
| +import android.widget.ListView;
|
|
|
| public class ViewerActivity
|
| extends Activity implements SurfaceHolder.Callback, View.OnTouchListener {
|
| private static final float FLING_VELOCITY_THRESHOLD = 1000;
|
|
|
| + private DrawerLayout mDrawerLayout;
|
| + private ActionBarDrawerToggle mDrawerToggle;
|
| + private ListView mDrawerList;
|
| + private StateAdapter mStateAdapter;
|
| +
|
| private SurfaceView mView;
|
| private ViewerApplication mApplication;
|
|
|
| @@ -33,6 +40,7 @@ public class ViewerActivity
|
| private native void onSurfaceDestroyed(long handle);
|
| private native void onKeyPressed(long handle, int keycode);
|
| private native void onTouched(long handle, int owner, int state, float x, float y);
|
| + private native void onUIStateChanged(long handle, String stateName, String stateValue);
|
|
|
| @Override
|
| public boolean onCreateOptionsMenu(Menu menu) {
|
| @@ -43,6 +51,12 @@ public class ViewerActivity
|
|
|
| @Override
|
| public boolean onOptionsItemSelected(MenuItem item) {
|
| + // Pass the event to ActionBarDrawerToggle, if it returns
|
| + // true, then it has handled the app icon touch event
|
| + if (mDrawerToggle.onOptionsItemSelected(item)) {
|
| + return true;
|
| + }
|
| +
|
| switch (item.getItemId()) {
|
| case R.id.action_left:
|
| onKeyPressed(mApplication.getNativeHandle(), KeyEvent.KEYCODE_SOFT_LEFT);
|
| @@ -60,12 +74,36 @@ public class ViewerActivity
|
| super.onCreate(savedInstanceState);
|
| setContentView(R.layout.activity_main);
|
|
|
| - mApplication = (ViewerApplication) getApplication();
|
| - mApplication.setViewerActivity(this);
|
| mView = (SurfaceView) findViewById(R.id.surfaceView);
|
| mView.getHolder().addCallback(this);
|
|
|
| mView.setOnTouchListener(this);
|
| +
|
| + mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerLayout);
|
| + mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
|
| + R.string.drawer_open, R.string.drawer_close);
|
| + mDrawerLayout.addDrawerListener(mDrawerToggle);
|
| + getActionBar().setDisplayHomeAsUpEnabled(true);
|
| + getActionBar().setHomeButtonEnabled(true);
|
| +
|
| + mDrawerList = (ListView) findViewById(R.id.leftDrawer);
|
| + mStateAdapter = new StateAdapter(this);
|
| + mDrawerList.setAdapter(mStateAdapter);
|
| +
|
| + mApplication = (ViewerApplication) getApplication();
|
| + mApplication.setViewerActivity(this);
|
| + }
|
| +
|
| + @Override
|
| + protected void onPostCreate(Bundle savedInstanceState) {
|
| + super.onPostCreate(savedInstanceState);
|
| + mDrawerToggle.syncState();
|
| + }
|
| +
|
| + @Override
|
| + public void onConfigurationChanged(Configuration newConfig) {
|
| + super.onConfigurationChanged(newConfig);
|
| + mDrawerToggle.onConfigurationChanged(newConfig);
|
| }
|
|
|
| @Override
|
| @@ -107,4 +145,12 @@ public class ViewerActivity
|
| }
|
| return true;
|
| }
|
| +
|
| + public void setState(String stateJson) {
|
| + mStateAdapter.setState(stateJson);
|
| + }
|
| +
|
| + public void onStateChanged(String stateName, String stateValue) {
|
| + onUIStateChanged(mApplication.getNativeHandle(), stateName, stateValue);
|
| + }
|
| }
|
|
|