Chromium Code Reviews| Index: shell/android/apk/src/org/chromium/mojo/shell/ViewportActivity.java |
| diff --git a/shell/android/apk/src/org/chromium/mojo/shell/ViewportActivity.java b/shell/android/apk/src/org/chromium/mojo/shell/ViewportActivity.java |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c657288d4fb4e2630ff7687a2a97b8b31fca2203 |
| --- /dev/null |
| +++ b/shell/android/apk/src/org/chromium/mojo/shell/ViewportActivity.java |
| @@ -0,0 +1,57 @@ |
| +// Copyright 2015 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. |
| + |
| +package org.chromium.mojo.shell; |
| + |
| +import android.app.Activity; |
| +import android.app.UiModeManager; |
| +import android.content.Intent; |
| +import android.content.res.Configuration; |
| +import android.os.Bundle; |
| +import android.view.WindowManager; |
| + |
| +import org.chromium.mojo.PlatformViewportAndroid; |
| + |
| +/** |
| + * Activity for displaying on the screen from the NativeViewportService. |
| + */ |
| +public class ViewportActivity extends Activity { |
| + private static final String TAG = "ViewportActivity"; |
| + private PlatformViewportAndroid mPlatformViewport; |
| + |
| + @Override |
| + protected void onCreate(final Bundle savedInstanceState) { |
| + super.onCreate(savedInstanceState); |
| + |
| + mPlatformViewport = PlatformViewportAndroid.newActivityStarted(this); |
| + if (mPlatformViewport == null) { |
| + // We have not attached to a viewport, so there's no point continuing. |
| + finishAndRemoveTask(); |
| + } |
| + |
| + // TODO(tonyg): Watch activities go back to the home screen within a |
| + // couple of seconds of detaching from adb. So for demonstration purposes, |
| + // we just keep the screen on. Eventually we'll want a solution for |
| + // allowing the screen to sleep without quitting the shell. |
| + // TODO(etiennej): Verify the above is still true after the switch to a Service model. |
| + UiModeManager uiModeManager = (UiModeManager) getSystemService(UI_MODE_SERVICE); |
| + if (uiModeManager.getCurrentModeType() == Configuration.UI_MODE_TYPE_WATCH) { |
| + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); |
| + } |
| + } |
| + |
| + @Override |
| + public void onNewIntent(Intent intent) { |
| + super.onNewIntent(intent); |
| + new RuntimeException("This activity instance should only ever receive one intent."); |
| + } |
| + |
| + /** |
| + * @see Activity#onActivityResult(int, int, Intent) |
| + */ |
| + @Override |
| + protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
|
qsr
2015/08/07 11:18:01
This seems wrong. We should receive how the intent
etiennej
2015/08/07 12:22:11
Removed for now. Let's just have MojoShellActivity
|
| + IntentReceiverRegistry.getInstance().onActivityResult(requestCode, resultCode, data); |
| + } |
| +} |