| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chromecast.shell; | 5 package org.chromium.chromecast.shell; |
| 6 | 6 |
| 7 import android.app.Activity; | 7 import android.app.Activity; |
| 8 import android.content.BroadcastReceiver; | 8 import android.content.BroadcastReceiver; |
| 9 import android.content.Context; | 9 import android.content.Context; |
| 10 import android.content.Intent; | 10 import android.content.Intent; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // For more information read: | 73 // For more information read: |
| 74 // http://developer.android.com/training/managing-audio/volume-playback.
html | 74 // http://developer.android.com/training/managing-audio/volume-playback.
html |
| 75 setVolumeControlStream(AudioManager.STREAM_MUSIC); | 75 setVolumeControlStream(AudioManager.STREAM_MUSIC); |
| 76 | 76 |
| 77 // Set flags to both exit sleep mode when this activity starts and | 77 // Set flags to both exit sleep mode when this activity starts and |
| 78 // avoid entering sleep mode while playing media. We cannot distinguish | 78 // avoid entering sleep mode while playing media. We cannot distinguish |
| 79 // between video and audio so this applies to both. | 79 // between video and audio so this applies to both. |
| 80 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); | 80 getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); |
| 81 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); | 81 getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); |
| 82 | 82 |
| 83 mAudioManager = (AudioManager)getSystemService(Context.AUDIO_SERVICE); | 83 mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); |
| 84 | 84 |
| 85 setContentView(R.layout.cast_shell_activity); | 85 setContentView(R.layout.cast_shell_activity); |
| 86 mCastWindowManager = (CastWindowManager) findViewById(R.id.shell_contain
er); | 86 mCastWindowManager = (CastWindowManager) findViewById(R.id.shell_contain
er); |
| 87 mCastWindowManager.setDelegate(new CastWindowManager.Delegate() { | 87 mCastWindowManager.setDelegate(new CastWindowManager.Delegate() { |
| 88 @Override | 88 @Override |
| 89 public void onCreated() { | 89 public void onCreated() { |
| 90 } | 90 } |
| 91 | 91 |
| 92 @Override | 92 @Override |
| 93 public void onClosed() { | 93 public void onClosed() { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 broadcastManager.unregisterReceiver(mBroadcastReceiver); | 209 broadcastManager.unregisterReceiver(mBroadcastReceiver); |
| 210 } | 210 } |
| 211 | 211 |
| 212 private void setResolution() { | 212 private void setResolution() { |
| 213 int requestedHeight = getIntent().getIntExtra( | 213 int requestedHeight = getIntent().getIntExtra( |
| 214 ACTION_EXTRA_RESOLUTION_HEIGHT, DEFAULT_HEIGHT_PIXELS); | 214 ACTION_EXTRA_RESOLUTION_HEIGHT, DEFAULT_HEIGHT_PIXELS); |
| 215 int displayHeight = getResources().getDisplayMetrics().heightPixels; | 215 int displayHeight = getResources().getDisplayMetrics().heightPixels; |
| 216 // Clamp within [DEFAULT_HEIGHT_PIXELS, displayHeight] | 216 // Clamp within [DEFAULT_HEIGHT_PIXELS, displayHeight] |
| 217 int desiredHeight = | 217 int desiredHeight = |
| 218 Math.min(displayHeight, Math.max(DEFAULT_HEIGHT_PIXELS, requeste
dHeight)); | 218 Math.min(displayHeight, Math.max(DEFAULT_HEIGHT_PIXELS, requeste
dHeight)); |
| 219 double deviceScaleFactor = ((double)displayHeight) / desiredHeight; | 219 double deviceScaleFactor = ((double) displayHeight) / desiredHeight; |
| 220 Log.d(TAG, "Using scale factor " + deviceScaleFactor + " to set height "
+ desiredHeight); | 220 Log.d(TAG, "Using scale factor " + deviceScaleFactor + " to set height "
+ desiredHeight); |
| 221 CommandLine.getInstance().appendSwitchWithValue("force-device-scale-fact
or", | 221 CommandLine.getInstance().appendSwitchWithValue("force-device-scale-fact
or", |
| 222 String.valueOf(deviceScaleFactor)); | 222 String.valueOf(deviceScaleFactor)); |
| 223 } | 223 } |
| 224 | 224 |
| 225 private void exitIfUrlMissing() { | 225 private void exitIfUrlMissing() { |
| 226 Intent intent = getIntent(); | 226 Intent intent = getIntent(); |
| 227 if (intent != null && intent.getData() != null && !intent.getData().equa
ls(Uri.EMPTY)) { | 227 if (intent != null && intent.getData() != null && !intent.getData().equa
ls(Uri.EMPTY)) { |
| 228 return; | 228 return; |
| 229 } | 229 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 @Override | 282 @Override |
| 283 public boolean dispatchTouchEvent(MotionEvent ev) { | 283 public boolean dispatchTouchEvent(MotionEvent ev) { |
| 284 return false; | 284 return false; |
| 285 } | 285 } |
| 286 | 286 |
| 287 @Override | 287 @Override |
| 288 public boolean dispatchTrackballEvent(MotionEvent ev) { | 288 public boolean dispatchTrackballEvent(MotionEvent ev) { |
| 289 return false; | 289 return false; |
| 290 } | 290 } |
| 291 } | 291 } |
| OLD | NEW |