summaryrefslogtreecommitdiffstats
path: root/remoting/android
diff options
context:
space:
mode:
authorlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-04 02:05:50 +0000
committerlambroslambrou@chromium.org <lambroslambrou@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-04 02:05:50 +0000
commit45ae70b2f0b46bfe27ad81406cac7a34ef15389d (patch)
treece695830058c5901a22fb21238daccd108380c46 /remoting/android
parentae52c0b0946fe8b91658bbc08f6007e354cf4eed (diff)
downloadchromium_src-45ae70b2f0b46bfe27ad81406cac7a34ef15389d.zip
chromium_src-45ae70b2f0b46bfe27ad81406cac7a34ef15389d.tar.gz
chromium_src-45ae70b2f0b46bfe27ad81406cac7a34ef15389d.tar.bz2
Add a button to bring back the action-bar if hidden.
BUG=333129 R=sergeyu@chromium.org Review URL: https://codereview.chromium.org/135193005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248662 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/android')
-rw-r--r--remoting/android/java/src/org/chromium/chromoting/Desktop.java43
-rw-r--r--remoting/android/java/src/org/chromium/chromoting/DesktopView.java18
2 files changed, 49 insertions, 12 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