From 902d9a102803052e628595f06c4883f54760ce36 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 31 Aug 2019 13:29:56 +0800 Subject: [PATCH] up --- .../app/ui/readbook/config/BgTextConfigDialog.kt | 12 +++++++++++- .../legado/app/ui/readbook/config/ReadStyleDialog.kt | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/readbook/config/BgTextConfigDialog.kt b/app/src/main/java/io/legado/app/ui/readbook/config/BgTextConfigDialog.kt index c0192ad9c..92b8108d0 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/config/BgTextConfigDialog.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/config/BgTextConfigDialog.kt @@ -1,6 +1,7 @@ package io.legado.app.ui.readbook.config import android.annotation.SuppressLint +import android.app.Activity.RESULT_OK import android.content.Context import android.content.DialogInterface import android.content.Intent @@ -24,6 +25,7 @@ import io.legado.app.help.ReadBookConfig import io.legado.app.help.permission.Permissions import io.legado.app.help.permission.PermissionsCompat import io.legado.app.ui.readbook.Help +import io.legado.app.utils.FileUtils import io.legado.app.utils.getCompatColor import io.legado.app.utils.postEvent import kotlinx.android.synthetic.main.dialog_read_bg_text.* @@ -156,7 +158,15 @@ class BgTextConfigDialog : DialogFragment() { super.onActivityResult(requestCode, resultCode, data) when (requestCode) { resultSelectBg -> { - + if (resultCode == RESULT_OK) { + data?.data?.let { + FileUtils.getPath(requireContext(), it)?.let { path -> + ReadBookConfig.getConfig().setBg(2, path) + ReadBookConfig.upBg() + postEvent(Bus.UP_CONFIG, false) + } + } + } } } } diff --git a/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt b/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt index 7f8281eeb..20851e59f 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/config/ReadStyleDialog.kt @@ -247,7 +247,7 @@ class ReadStyleDialog : DialogFragment() { } ReadBookConfig.getConfig(i).apply { when (bgType()) { - 2 -> ImageLoader.load(requireContext(), bgStr()).centerCrop().setAsFile(iv) + 2 -> ImageLoader.load(requireContext(), bgStr()).centerCrop().setAsDrawable(iv) else -> iv.setImageDrawable(bgDrawable()) } }