pull/5/head
fengyuecanzhu 4 years ago
parent e4da857c67
commit 0cf2304b22
  1. 7
      app/src/main/assets/updatelog.fy
  2. 8
      app/src/main/java/xyz/fycz/myreader/model/storage/Backup.kt
  3. 9
      app/src/main/java/xyz/fycz/myreader/model/storage/Restore.kt
  4. 32
      app/src/main/java/xyz/fycz/myreader/ui/activity/ReadActivity.java
  5. 84
      app/src/main/res/layout/gridview_book_item.xml
  6. 4
      app/version_code.properties

@ -1,3 +1,10 @@
2021.06.02
风月读书v2.0.6
更新内容:
1、阅读记录支持备份/恢复
2、修复阅读时切换后台记录异常的问题
3、私密书籍不保存阅读记录
2021.06.01
风月读书v2.0.5
更新内容:

@ -41,6 +41,7 @@ object Backup {
"readStyles.json",
"replaceRule.json",
"bookSource.json",
"readRecord.json",
"config.xml"
)
}
@ -102,6 +103,13 @@ object Backup {
.writeText(json)
}
}
DbManager.getInstance().session.readRecordDao.queryBuilder().list().let {
if (it.isNotEmpty()) {
val json = GSON.toJson(it)
FileUtils.getFile(backupPath + File.separator + "readRecord.json")
.writeText(json)
}
}
try {
val setting = SysManager.getNewSetting()
val readStyles = setting.readStyles

@ -110,6 +110,15 @@ object Restore {
} catch (e: Exception) {
e.printStackTrace()
}
try {
val file = FileUtils.getFile(path + File.separator + "readRecord.json")
val json = file.readText()
GSON.fromJsonArray<ReadRecord>(json)?.let {
DbManager.getInstance().session.readRecordDao.insertOrReplaceInTx(it)
}
} catch (e: Exception) {
e.printStackTrace()
}
try {
val settingFile = FileUtils.getFile(path + File.separator + "setting.json")
val settingJson = settingFile.readText()

@ -185,6 +185,8 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
private long lastRecordTime;//上次记录时间
private boolean isPrivate;//是否私密书籍
// 接收电池信息和时间更新的广播
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
@ -280,6 +282,24 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
super.onCreate(savedInstanceState);
}
@Override
protected void onStop() {
recordReadTime();
super.onStop();
}
@Override
protected void onStart() {
lastRecordTime = System.currentTimeMillis();
super.onStart();
}
@Override
protected void onResume() {
super.onResume();
hideSystemBar();
}
@Override
protected void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
@ -337,7 +357,8 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
if (aBooks != null) {
mSourceDialog.setABooks(aBooks);
}
lastRecordTime = System.currentTimeMillis();
String privateGroupId = SharedPreUtils.getInstance().getString("privateGroupId");
isPrivate = privateGroupId.equals(mBook.getGroupId());
}
@Override
@ -588,9 +609,8 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
intentFilter.addAction(Intent.ACTION_TIME_TICK);
registerReceiver(mReceiver, intentFilter);
//当书籍Collected且书籍id不为空的时候保存上次阅读信息
String privateGroupId = SharedPreUtils.getInstance().getString("privateGroupId");
if (isCollected && !StringHelper.isEmpty(mBook.getId())
&& !privateGroupId.equals(mBook.getGroupId())) {
&& !isPrivate) {
//保存上次阅读信息
SharedPreUtils.getInstance().putString(getString(R.string.lastRead), mBook.getId());
}
@ -599,11 +619,6 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
getData();
}
@Override
protected void onResume() {
super.onResume();
hideSystemBar();
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
@ -2098,6 +2113,7 @@ public class ReadActivity extends BaseActivity implements ColorPickerDialogListe
* 记录阅读时间
*/
private void recordReadTime() {
if (isPrivate) return;
Single.create(emitter -> {
if (mBook == null) return;
if (record == null) {

@ -1,71 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:orientation="vertical"
android:paddingHorizontal="25dp"
android:paddingVertical="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp" >
android:orientation="vertical">
<xyz.fycz.myreader.widget.CoverImageView
android:id="@+id/iv_book_img"
android:layout_width="80dp"
android:layout_height="110dp"
android:layout_gravity="center"
android:scaleType="fitXY"
app:srcCompat="@mipmap/default_cover" />
android:id="@+id/iv_book_img"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="fitXY"
app:srcCompat="@mipmap/default_cover" />
<TextView
android:layout_marginTop="5dp"
android:layout_gravity="center"
android:id="@+id/tv_book_name"
android:layout_width="86dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="1"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:ellipsize="end"
android:text="bookname"
android:gravity="center"
android:textColor="@color/textPrimary"/>
android:maxLines="2"
android:text="@string/app_name"
android:textColor="@color/textPrimary" />
</LinearLayout>
<xyz.fycz.myreader.widget.BadgeView
android:id="@+id/tv_no_read_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="15dp"
android:layout_marginEnd="25dp"
android:includeFontPadding="false" />
android:id="@+id/tv_no_read_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_margin="3dp"
android:includeFontPadding="false" />
<ProgressBar
android:id="@+id/pb_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginEnd="28dp"
android:visibility="gone"
android:layout_alignParentEnd="true"
style="?android:attr/progressBarStyleSmall"
/>
android:id="@+id/pb_loading"
style="?android:attr/progressBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_margin="3dp"
android:visibility="gone" />
<CheckBox
android:id="@+id/cb_book_select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:enabled="true"
android:clickable="false"
android:focusable="true"
android:layout_margin="5dp"
android:paddingEnd="2dp"
android:theme="@style/MyCheckBox"
android:visibility="visible"/>
android:id="@+id/cb_book_select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:clickable="false"
android:enabled="true"
android:focusable="true"
android:theme="@style/MyCheckBox"
android:visibility="visible" />
</RelativeLayout>

@ -1,2 +1,2 @@
#Tue Jun 01 18:16:41 CST 2021
VERSION_CODE=204
#Tue Jun 01 21:40:04 CST 2021
VERSION_CODE=205

Loading…
Cancel
Save