| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.chrome.browser; | 5 package org.chromium.chrome.browser; |
| 6 | 6 |
| 7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
| 8 import android.content.Context; |
| 8 import android.os.Build; | 9 import android.os.Build; |
| 9 import android.os.Bundle; | 10 import android.os.Bundle; |
| 10 import android.speech.tts.TextToSpeech; | 11 import android.speech.tts.TextToSpeech; |
| 11 import android.speech.tts.UtteranceProgressListener; | 12 import android.speech.tts.UtteranceProgressListener; |
| 12 | 13 |
| 13 /** | 14 /** |
| 14 * Subclass of TtsPlatformImpl for Lollipop to make use of newer APIs. | 15 * Subclass of TtsPlatformImpl for Lollipop to make use of newer APIs. |
| 15 */ | 16 */ |
| 16 @TargetApi(Build.VERSION_CODES.LOLLIPOP) | 17 @TargetApi(Build.VERSION_CODES.LOLLIPOP) |
| 17 class LollipopTtsPlatformImpl extends TtsPlatformImpl { | 18 class LollipopTtsPlatformImpl extends TtsPlatformImpl { |
| 18 protected LollipopTtsPlatformImpl(long nativeTtsPlatformImplAndroid) { | 19 protected LollipopTtsPlatformImpl(long nativeTtsPlatformImplAndroid, Context
context) { |
| 19 super(nativeTtsPlatformImplAndroid); | 20 super(nativeTtsPlatformImplAndroid, context); |
| 20 } | 21 } |
| 21 | 22 |
| 22 /** | 23 /** |
| 23 * Overrides TtsPlatformImpl because the API changed in Lollipop. | 24 * Overrides TtsPlatformImpl because the API changed in Lollipop. |
| 24 */ | 25 */ |
| 25 @Override | 26 @Override |
| 26 protected void addOnUtteranceProgressListener() { | 27 protected void addOnUtteranceProgressListener() { |
| 27 mTextToSpeech.setOnUtteranceProgressListener(new UtteranceProgressListen
er() { | 28 mTextToSpeech.setOnUtteranceProgressListener(new UtteranceProgressListen
er() { |
| 28 @Override | 29 @Override |
| 29 public void onDone(final String utteranceId) { | 30 public void onDone(final String utteranceId) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 53 @Override | 54 @Override |
| 54 protected int callSpeak(String text, float volume, int utteranceId) { | 55 protected int callSpeak(String text, float volume, int utteranceId) { |
| 55 Bundle params = new Bundle(); | 56 Bundle params = new Bundle(); |
| 56 if (volume != 1.0) { | 57 if (volume != 1.0) { |
| 57 params.putFloat(TextToSpeech.Engine.KEY_PARAM_VOLUME, volume); | 58 params.putFloat(TextToSpeech.Engine.KEY_PARAM_VOLUME, volume); |
| 58 } | 59 } |
| 59 return mTextToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, params, | 60 return mTextToSpeech.speak(text, TextToSpeech.QUEUE_FLUSH, params, |
| 60 Integer.toString(utteranceId)); | 61 Integer.toString(utteranceId)); |
| 61 } | 62 } |
| 62 } | 63 } |
| OLD | NEW |