Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(373)

Unified Diff: remoting/android/java/src/org/chromium/chromoting/cardboard/DesktopActivity.java

Issue 2252123002: [Remoting Android] Remove Cardboard Code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reviewer's Feedback - Removed unused const and strings Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: remoting/android/java/src/org/chromium/chromoting/cardboard/DesktopActivity.java
diff --git a/remoting/android/java/src/org/chromium/chromoting/cardboard/DesktopActivity.java b/remoting/android/java/src/org/chromium/chromoting/cardboard/DesktopActivity.java
deleted file mode 100644
index 8f42c4ae9156707c9c7acc748ff67d96021ec49b..0000000000000000000000000000000000000000
--- a/remoting/android/java/src/org/chromium/chromoting/cardboard/DesktopActivity.java
+++ /dev/null
@@ -1,207 +0,0 @@
-// 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.chromoting.cardboard;
-
-import android.content.Intent;
-import android.graphics.PointF;
-import android.os.Bundle;
-import android.speech.RecognitionListener;
-import android.speech.RecognizerIntent;
-import android.speech.SpeechRecognizer;
-
-import com.google.vrtoolkit.cardboard.CardboardActivity;
-import com.google.vrtoolkit.cardboard.CardboardView;
-
-import org.chromium.chromoting.InputStub;
-import org.chromium.chromoting.R;
-import org.chromium.chromoting.jni.Client;
-
-import java.util.ArrayList;
-
-/**
- * Virtual desktop activity for Cardboard.
- */
-public class DesktopActivity extends CardboardActivity {
- // Flag to indicate whether the current activity is going to switch to normal
- // desktop activity.
- private boolean mSwitchToDesktopActivity;
-
- private Client mClient;
- private CardboardRenderer mRenderer;
- private SpeechRecognizer mSpeechRecognizer;
-
- // Flag to indicate whether the speech recognizer is listening or not.
- private boolean mIsListening;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.cardboard_desktop);
-
- mClient = Client.getInstance();
-
- mSwitchToDesktopActivity = false;
- CardboardView cardboardView = (CardboardView) findViewById(R.id.cardboard_view);
-
- // THE CODE BELOW IS BROKEN.
- // To make it work, you have to somehow get the reference to the Display object and pass
- // it into the constructor.
- mRenderer = new CardboardRenderer(this, mClient, null);
- mIsListening = false;
-
- // Associate a CardboardView.StereoRenderer with cardboard view.
- cardboardView.setRenderer(mRenderer);
-
- // Associate the cardboard view with this activity.
- setCardboardView(cardboardView);
- }
-
- @Override
- public void onCardboardTrigger() {
- if (mRenderer.isMenuBarVisible()) {
- if (mRenderer.isLookingAtMenuBar()) {
- switch (mRenderer.getMenuItem().getType()) {
- case BACK:
- mSwitchToDesktopActivity = true;
- finish();
- break;
- case VOICE_INPUT:
- listenForVoiceInput();
- break;
- case ZOOM_IN:
- mRenderer.moveTowardsDesktop();
- break;
- case ZOOM_OUT:
- mRenderer.moveAwayFromDesktop();
- break;
- }
- } else {
- mRenderer.setMenuBarVisible(false);
- }
- } else {
- if (mRenderer.isLookingAtDesktop()) {
- PointF coordinates = mRenderer.getMouseCoordinates();
- mClient.sendMouseEvent((int) coordinates.x, (int) coordinates.y,
- InputStub.BUTTON_LEFT, true);
- mClient.sendMouseEvent((int) coordinates.x, (int) coordinates.y,
- InputStub.BUTTON_LEFT, false);
- } else {
- if (mRenderer.isLookingFarawayFromDesktop()) {
- getCardboardView().resetHeadTracker();
- } else {
- mRenderer.setMenuBarVisible(true);
- }
- }
- }
- }
-
- @Override
- protected void onStart() {
- super.onStart();
- mClient.enableVideoChannel(true);
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- if (!mSwitchToDesktopActivity) {
- mClient.enableVideoChannel(false);
- }
- if (mSpeechRecognizer != null) {
- mSpeechRecognizer.stopListening();
- }
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- mClient.enableVideoChannel(true);
- }
-
- @Override
- protected void onStop() {
- super.onStop();
- if (mSwitchToDesktopActivity) {
- mSwitchToDesktopActivity = false;
- } else {
- mClient.enableVideoChannel(false);
- }
- if (mSpeechRecognizer != null) {
- mSpeechRecognizer.stopListening();
- }
- }
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- if (mSpeechRecognizer != null) {
- mSpeechRecognizer.cancel();
- mSpeechRecognizer.destroy();
- }
- }
-
- private void listenForVoiceInput() {
- if (mIsListening) {
- return;
- }
-
- if (mSpeechRecognizer == null) {
- if (SpeechRecognizer.isRecognitionAvailable(this)) {
- mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);
- mSpeechRecognizer.setRecognitionListener(new VoiceInputRecognitionListener());
- } else {
- return;
- }
- }
-
- mIsListening = true;
-
- Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
-
- // LANGUAGE_MODEL_FREE_FORM is used to improve dictation accuracy
- // for the voice keyboard.
- intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
- RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
-
- mSpeechRecognizer.startListening(intent);
- }
-
- private class VoiceInputRecognitionListener implements RecognitionListener {
- public void onReadyForSpeech(Bundle params) {
- }
-
- public void onBeginningOfSpeech() {
- }
-
- public void onRmsChanged(float rmsdB){
- }
-
- public void onBufferReceived(byte[] buffer) {
- }
-
- public void onEndOfSpeech() {
- mIsListening = false;
- }
-
- public void onError(int error) {
- mIsListening = false;
- }
-
- public void onResults(Bundle results) {
- // TODO(shichengfeng): If necessary, provide a list of choices for user to pick.
- ArrayList<String> data =
- results.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION);
- if (!data.isEmpty()) {
- mClient.sendTextEvent(data.get(0));
- }
- }
-
- public void onPartialResults(Bundle partialResults) {
- }
-
- public void onEvent(int eventType, Bundle params) {
- }
- }
-}

Powered by Google App Engine
This is Rietveld 408576698