修复语音朗读部分bug

pull/5/head
fengyuecanzhu 4 years ago
parent 8cd452f303
commit 47f55df815
  1. 2
      README.md
  2. 6
      app/src/main/assets/updatelog.fy
  3. 30
      app/src/main/java/xyz/fycz/myreader/model/audio/ReadAloudService.java
  4. 3
      app/src/main/java/xyz/fycz/myreader/widget/page/PageLoader.java
  5. 4
      app/version_code.properties

@ -2,7 +2,7 @@
风月读书,一款开源、无广告的小说阅读软件。
成品下载【11.11 新增语音朗读】:[https://fycz.lanzoui.com/inZAdibqaaf](https://fycz.lanzoui.com/inZAdibqaaf)
成品下载【11.11 新增语音朗读】:[https://fycz.lanzoui.com/idTvOieckrg](https://fycz.lanzoui.com/idTvOieckrg)
#### 一、关于书源

@ -1,10 +1,10 @@
2020.11.12
风月读书v1.20.1111217
2020.11.14
风月读书v1.20.1111420
1、修复语音朗读定时停止无效的bug
2、修复语音朗读时切换日夜间闪退的bug
3、修复语音朗读时切换章节闪退的bug
4、修复语音朗读时部分安卓版本卡死的bug
5、修复语音朗读时章节首页朗读段落高亮错位的bug
5、修复语音朗读时部分章节朗读段落高亮错位的bug
6、修复语音朗读时章节标题不高亮的bug
7、修复安卓5进入字体界面闪退的bug

@ -16,7 +16,10 @@ import android.os.IBinder;
import android.os.Looper;
import android.speech.tts.TextToSpeech;
import android.speech.tts.UtteranceProgressListener;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.Nullable;
import androidx.core.app.NotificationCompat;
@ -84,6 +87,22 @@ public class ReadAloudService extends Service {
private int progress;
private static ReadEvent mReadEvent;
PhoneStateListener phoneStateListener = new PhoneStateListener() {
@Override
public void onCallStateChanged(int state, String incomingNumber) {
if (state == TelephonyManager.CALL_STATE_RINGING) {
//Incoming call: Pause
pauseReadAloud(true);
} else if(state == TelephonyManager.CALL_STATE_IDLE) {
//Not in call: Play
resumeReadAloud();
} else if(state == TelephonyManager.CALL_STATE_OFFHOOK) {
//A call is dialing, active or on hold
}
super.onCallStateChanged(state, incomingNumber);
}
};
/**
* 朗读
*/
@ -195,6 +214,11 @@ public class ReadAloudService extends Service {
dsRunnable = this::doDs;
initBroadcastReceiver();
updateNotification();
//监听电话状态
TelephonyManager mgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
if(mgr != null) {
mgr.listen(phoneStateListener, PhoneStateListener.LISTEN_CALL_STATE);
}
}
@Override
@ -512,6 +536,11 @@ public class ReadAloudService extends Service {
postEvent(ALOUD_STATE, Status.STOP);
unregisterReceiver(broadcastReceiver);
clearTTS();
//取消监听
TelephonyManager mgr = (TelephonyManager) getSystemService(TELEPHONY_SERVICE);
if(mgr != null) {
mgr.listen(phoneStateListener, PhoneStateListener.LISTEN_NONE);
}
}
private void clearTTS() {
@ -601,6 +630,7 @@ public class ReadAloudService extends Service {
}
private void postEvent(String tag, Object event){
if (mReadEvent != null) {
mReadEvent.onEventOccur(tag, event);

@ -1461,6 +1461,9 @@ public abstract class PageLoader {
}
subStr = paragraph.substring(0, wordCount);
if (paragraph.substring(wordCount).equals("\n")) {
subStr += "\n";
}
if (!subStr.equals("\n")) {
//将一行字节,存储到lines中
lines.add(subStr);

@ -1,2 +1,2 @@
#Thu Nov 12 17:37:14 CST 2020
VERSION_CODE=158
#Sat Nov 14 20:36:25 CST 2020
VERSION_CODE=159

Loading…
Cancel
Save