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