diff --git a/app/src/main/java/io/legado/app/constant/AppConst.kt b/app/src/main/java/io/legado/app/constant/AppConst.kt index b414786c6..3d86a738b 100644 --- a/app/src/main/java/io/legado/app/constant/AppConst.kt +++ b/app/src/main/java/io/legado/app/constant/AppConst.kt @@ -1,12 +1,15 @@ package io.legado.app.constant +import android.annotation.SuppressLint import com.google.gson.Gson import com.google.gson.GsonBuilder import io.legado.app.App import io.legado.app.R +import java.text.SimpleDateFormat import javax.script.ScriptEngine import javax.script.ScriptEngineManager +@SuppressLint("SimpleDateFormat") object AppConst { const val channelIdDownload = "channel_download" const val channelIdReadAloud = "channel_read_aloud" @@ -21,9 +24,15 @@ object AppConst { val NOT_AVAILABLE = App.INSTANCE.getString(R.string.not_available) - val GSON_CONVERTER: Gson = GsonBuilder() - .disableHtmlEscaping() - .setPrettyPrinting() - .setDateFormat("yyyy-MM-dd HH:mm:ssZ") - .create() + val TIME_FORMAT: SimpleDateFormat by lazy { + SimpleDateFormat("HH:mm") + } + + val GSON_CONVERTER: Gson by lazy { + GsonBuilder() + .disableHtmlEscaping() + .setPrettyPrinting() + .setDateFormat("yyyy-MM-dd HH:mm:ssZ") + .create() + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt b/app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt index a5868195a..63bc0a8c9 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt @@ -6,13 +6,13 @@ import android.util.AttributeSet import android.widget.FrameLayout import androidx.appcompat.widget.AppCompatImageView import io.legado.app.R +import io.legado.app.constant.AppConst.TIME_FORMAT import io.legado.app.help.ImageLoader import io.legado.app.help.ReadBookConfig -import io.legado.app.utils.dp -import io.legado.app.utils.getPrefBoolean -import io.legado.app.utils.getStatusBarHeight +import io.legado.app.utils.* import kotlinx.android.synthetic.main.view_book_page.view.* import org.jetbrains.anko.matchParent +import java.util.* class ContentView : FrameLayout { @@ -34,8 +34,10 @@ class ContentView : FrameLayout { fun upStyle() { ReadBookConfig.getConfig().apply { val pt = if (context.getPrefBoolean("hideStatusBar", false)) { + top_bar.visible() paddingTop.dp } else { + top_bar.gone() paddingTop.dp + context.getStatusBarHeight() } page_panel.setPadding(paddingLeft.dp, pt, paddingRight.dp, paddingBottom.dp) @@ -54,11 +56,15 @@ class ContentView : FrameLayout { } fun upTime() { - + tv_top_left.text = TIME_FORMAT.format(Date(System.currentTimeMillis())) } fun upBattery(battery: Int) { + tv_top_right.text = context.getString(R.string.battery_show, battery) + } + fun setChapterTile(tile: String) { + tv_bottom_left.text = tile } fun setContent(page: TextPage?) { diff --git a/app/src/main/res/layout/view_book_page.xml b/app/src/main/res/layout/view_book_page.xml index 3ffff8da2..c764d4884 100644 --- a/app/src/main/res/layout/view_book_page.xml +++ b/app/src/main/res/layout/view_book_page.xml @@ -9,6 +9,7 @@ app:showDividers="middle"> @@ -33,6 +34,7 @@ android:layout_weight="1" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8a70911dd..02f36623c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -481,6 +481,6 @@ ]]> 阅读 - + %d%%