summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--remoting/android/java/src/org/chromium/chromoting/Desktop.java43
-rw-r--r--remoting/android/java/src/org/chromium/chromoting/DesktopView.java18
-rw-r--r--remoting/remoting_android.gypi3
-rw-r--r--remoting/resources/layout/desktop.xml22
4 files changed, 73 insertions, 13 deletions
diff --git a/remoting/android/java/src/org/chromium/chromoting/Desktop.java b/remoting/android/java/src/org/chromium/chromoting/Desktop.java
index 0eedf3a..dfad7e7 100644
--- a/remoting/android/java/src/org/chromium/chromoting/Desktop.java
+++ b/remoting/android/java/src/org/chromium/chromoting/Desktop.java
@@ -10,7 +10,9 @@ import android.os.Bundle;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
+import android.view.View;
import android.view.inputmethod.InputMethodManager;
+import android.widget.ImageButton;
import org.chromium.chromoting.jni.JniInterface;
@@ -19,14 +21,22 @@ import org.chromium.chromoting.jni.JniInterface;
*/
public class Desktop extends Activity {
/** The surface that displays the remote host's desktop feed. */
- private DesktopView remoteHostDesktop;
+ private DesktopView mRemoteHostDesktop;
+
+ /** The button used to show the action bar. */
+ private ImageButton mOverlayButton;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- remoteHostDesktop = new DesktopView(this);
- setContentView(remoteHostDesktop);
+ setContentView(R.layout.desktop);
+ mRemoteHostDesktop = (DesktopView)findViewById(R.id.desktop_view);
+ mOverlayButton = (ImageButton)findViewById(R.id.desktop_overlay_button);
+ mRemoteHostDesktop.setDesktop(this);
+
+ // Ensure the button is initially hidden.
+ showActionBar();
}
/** Called when the activity is finally finished. */
@@ -40,7 +50,7 @@ public class Desktop extends Activity {
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
- remoteHostDesktop.onScreenConfigurationChanged();
+ mRemoteHostDesktop.onScreenConfigurationChanged();
}
/** Called to initialize the action bar. */
@@ -50,6 +60,21 @@ public class Desktop extends Activity {
return super.onCreateOptionsMenu(menu);
}
+ public void showActionBar() {
+ mOverlayButton.setVisibility(View.INVISIBLE);
+ getActionBar().show();
+ }
+
+ public void hideActionBar() {
+ mOverlayButton.setVisibility(View.VISIBLE);
+ getActionBar().hide();
+ }
+
+ /** The overlay button's onClick handler. */
+ public void onOverlayButtonPressed(View view) {
+ showActionBar();
+ }
+
/** Called whenever an action bar button is pressed. */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
@@ -57,12 +82,15 @@ public class Desktop extends Activity {
case R.id.actionbar_keyboard:
((InputMethodManager)getSystemService(INPUT_METHOD_SERVICE)).toggleSoftInput(0, 0);
return true;
+
case R.id.actionbar_hide:
- getActionBar().hide();
+ hideActionBar();
return true;
+
case R.id.actionbar_disconnect:
JniInterface.disconnectFromHost();
return true;
+
case R.id.actionbar_send_ctrl_alt_del:
{
int[] keys = {
@@ -78,6 +106,7 @@ public class Desktop extends Activity {
}
}
return true;
+
default:
return super.onOptionsItemSelected(item);
}
@@ -97,18 +126,22 @@ public class Desktop extends Activity {
JniInterface.keyboardAction(KeyEvent.KEYCODE_SHIFT_LEFT, depressed);
JniInterface.keyboardAction(KeyEvent.KEYCODE_2, depressed);
break;
+
case KeyEvent.KEYCODE_POUND:
JniInterface.keyboardAction(KeyEvent.KEYCODE_SHIFT_LEFT, depressed);
JniInterface.keyboardAction(KeyEvent.KEYCODE_3, depressed);
break;
+
case KeyEvent.KEYCODE_STAR:
JniInterface.keyboardAction(KeyEvent.KEYCODE_SHIFT_LEFT, depressed);
JniInterface.keyboardAction(KeyEvent.KEYCODE_8, depressed);
break;
+
case KeyEvent.KEYCODE_PLUS:
JniInterface.keyboardAction(KeyEvent.KEYCODE_SHIFT_LEFT, depressed);
JniInterface.keyboardAction(KeyEvent.KEYCODE_EQUALS, depressed);
break;
+
default:
// We try to send all other key codes to the host directly.
JniInterface.keyboardAction(event.getKeyCode(), depressed);
diff --git a/remoting/android/java/src/org/chromium/chromoting/DesktopView.java b/remoting/android/java/src/org/chromium/chromoting/DesktopView.java
index 5dd303b..53741c1 100644
--- a/remoting/android/java/src/org/chromium/chromoting/DesktopView.java
+++ b/remoting/android/java/src/org/chromium/chromoting/DesktopView.java
@@ -4,8 +4,6 @@
package org.chromium.chromoting;
-import android.app.ActionBar;
-import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
@@ -17,6 +15,7 @@ import android.graphics.Shader;
import android.os.Looper;
import android.os.SystemClock;
import android.text.InputType;
+import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
@@ -37,7 +36,9 @@ public class DesktopView extends SurfaceView implements DesktopViewInterface,
SurfaceHolder.Callback {
private RenderData mRenderData;
private TouchInputHandler mInputHandler;
- private ActionBar mActionBar;
+
+ /** The parent Desktop activity. */
+ private Desktop mDesktop;
// Flag to prevent multiple repaint requests from being backed up. Requests for repainting will
// be dropped if this is already set to true. This is used by the main thread and the painting
@@ -119,20 +120,23 @@ public class DesktopView extends SurfaceView implements DesktopViewInterface,
/** Whether the TouchInputHandler has requested animation to be performed. */
private boolean mInputAnimationRunning = false;
- public DesktopView(Activity context) {
- super(context);
+ public DesktopView(Context context, AttributeSet attributes) {
+ super(context, attributes);
// Give this view keyboard focus, allowing us to customize the soft keyboard's settings.
setFocusableInTouchMode(true);
mRenderData = new RenderData();
mInputHandler = new TrackingInputHandler(this, context, mRenderData);
- mActionBar = context.getActionBar();
mRepaintPending = false;
getHolder().addCallback(this);
}
+ public void setDesktop(Desktop desktop) {
+ mDesktop = desktop;
+ }
+
/** Request repainting of the desktop view. */
void requestRepaint() {
synchronized (mRenderData) {
@@ -360,7 +364,7 @@ public class DesktopView extends SurfaceView implements DesktopViewInterface,
@Override
public void showActionBar() {
- mActionBar.show();
+ mDesktop.showActionBar();
}
@Override
diff --git a/remoting/remoting_android.gypi b/remoting/remoting_android.gypi
index 513515e..950bc46 100644
--- a/remoting/remoting_android.gypi
+++ b/remoting/remoting_android.gypi
@@ -54,8 +54,9 @@
{
'destination': '<(SHARED_INTERMEDIATE_DIR)/remoting/android/res/layout',
'files': [
- 'resources/layout/main.xml',
+ 'resources/layout/desktop.xml',
'resources/layout/host.xml',
+ 'resources/layout/main.xml',
'resources/layout/pin_dialog.xml',
],
},
diff --git a/remoting/resources/layout/desktop.xml b/remoting/resources/layout/desktop.xml
new file mode 100644
index 0000000..d4ac3e5
--- /dev/null
+++ b/remoting/resources/layout/desktop.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- Copyright 2014 The Chromium Authors. All rights reserved.
+ Use of this source code is governed by a BSD-style license that can be
+ found in the LICENSE file.
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"
+ android:orientation="vertical">
+ <org.chromium.chromoting.DesktopView android:id="@+id/desktop_view"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent"/>
+ <ImageButton android:id="@+id/desktop_overlay_button"
+ android:background="@android:color/transparent"
+ android:layout_gravity="top|right"
+ android:layout_height="wrap_content"
+ android:layout_width="wrap_content"
+ android:onClick="onOverlayButtonPressed"
+ android:src="@android:drawable/ic_menu_more"/>
+</FrameLayout>