Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
gedoor committed Jan 22, 2020
1 parent 61f3eec commit be3b884
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ private ReadBookControl() {
updateReaderSettings();
}

void updateReaderSettings() {
public void updateReaderSettings() {
this.hideStatusBar = preferences.getBoolean("hide_status_bar", false);
this.hideNavigationBar = preferences.getBoolean("hide_navigation_bar", false);
this.indent = preferences.getInt("indent", 2);
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/com/kunfei/bookshelf/help/storage/Restore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import android.net.Uri
import androidx.documentfile.provider.DocumentFile
import com.kunfei.bookshelf.DbHelper
import com.kunfei.bookshelf.MApplication
import com.kunfei.bookshelf.R
import com.kunfei.bookshelf.bean.*
import com.kunfei.bookshelf.help.FileHelp
import com.kunfei.bookshelf.help.LauncherIcon
import com.kunfei.bookshelf.help.ReadBookControl
import com.kunfei.bookshelf.model.BookSourceManager
import com.kunfei.bookshelf.model.ReplaceRuleManager
import com.kunfei.bookshelf.model.TxtChapterRuleManager
Expand Down Expand Up @@ -82,6 +85,8 @@ object Restore {
} catch (e: Exception) {
e.printStackTrace()
}
var donateHb = MApplication.getConfigPreferences().getLong("DonateHb", 0)
donateHb = if (donateHb > System.currentTimeMillis()) 0 else donateHb
Preferences.getSharedPreferences(MApplication.getInstance(), path, "config")?.all?.map {
val edit = MApplication.getConfigPreferences().edit()
when (val value = it.value) {
Expand All @@ -92,6 +97,13 @@ object Restore {
is String -> edit.putString(it.key, value)
else -> Unit
}
edit.putLong("DonateHb", donateHb)
edit.putInt("versionCode", MApplication.getVersionCode())
edit.apply()
LauncherIcon.ChangeIcon(MApplication.getConfigPreferences().getString("launcher_icon", MApplication.getInstance().getString(R.string.icon_main)))
ReadBookControl.getInstance().updateReaderSettings()
MApplication.getInstance().upThemeStore()
MApplication.getInstance().initNightTheme()
edit.commit()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package com.kunfei.bookshelf.help.storage

import android.content.Context
import android.widget.Toast
import com.hwangjr.rxbus.RxBus
import com.kunfei.bookshelf.MApplication
import com.kunfei.bookshelf.R
import com.kunfei.bookshelf.base.observer.MySingleObserver
import com.kunfei.bookshelf.constant.AppConstant
import com.kunfei.bookshelf.constant.RxBusTag
import com.kunfei.bookshelf.help.FileHelp
import com.kunfei.bookshelf.utils.ZipUtils
import com.kunfei.bookshelf.utils.webdav.WebDav
Expand Down Expand Up @@ -85,6 +87,7 @@ object WebDavHelp {
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : MySingleObserver<Boolean>() {
override fun onSuccess(t: Boolean) {
RxBus.get().post(RxBusTag.RECREATE, true)
Toast.makeText(MApplication.getInstance(), R.string.restore_success, Toast.LENGTH_SHORT).show()
}
})
Expand Down

0 comments on commit be3b884

Please sign in to comment.