|
|
@ -1,6 +1,7 @@ |
|
|
|
package io.legado.app.ui.font |
|
|
|
package io.legado.app.ui.font |
|
|
|
|
|
|
|
|
|
|
|
import android.net.Uri |
|
|
|
import android.net.Uri |
|
|
|
|
|
|
|
import android.os.Build |
|
|
|
import android.os.Bundle |
|
|
|
import android.os.Bundle |
|
|
|
import android.view.MenuItem |
|
|
|
import android.view.MenuItem |
|
|
|
import android.view.View |
|
|
|
import android.view.View |
|
|
@ -9,6 +10,7 @@ import androidx.documentfile.provider.DocumentFile |
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.R |
|
|
|
import io.legado.app.base.BaseDialogFragment |
|
|
|
import io.legado.app.base.BaseDialogFragment |
|
|
|
|
|
|
|
import io.legado.app.constant.AppLog |
|
|
|
import io.legado.app.constant.PreferKey |
|
|
|
import io.legado.app.constant.PreferKey |
|
|
|
import io.legado.app.databinding.DialogFontSelectBinding |
|
|
|
import io.legado.app.databinding.DialogFontSelectBinding |
|
|
|
import io.legado.app.help.config.AppConfig |
|
|
|
import io.legado.app.help.config.AppConfig |
|
|
@ -113,7 +115,9 @@ class FontSelectDialog : BaseDialogFragment(R.layout.dialog_font_select), |
|
|
|
launch(Main) { |
|
|
|
launch(Main) { |
|
|
|
val defaultPath = "SD${File.separator}Fonts" |
|
|
|
val defaultPath = "SD${File.separator}Fonts" |
|
|
|
selectFontDir.launch { |
|
|
|
selectFontDir.launch { |
|
|
|
otherActions = arrayListOf(SelectItem(defaultPath, -1)) |
|
|
|
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.Q) { |
|
|
|
|
|
|
|
otherActions = arrayListOf(SelectItem(defaultPath, -1)) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -141,11 +145,12 @@ class FontSelectDialog : BaseDialogFragment(R.layout.dialog_font_select), |
|
|
|
execute { |
|
|
|
execute { |
|
|
|
val fontItems = fileDoc.list { |
|
|
|
val fontItems = fileDoc.list { |
|
|
|
it.name.matches(fontRegex) |
|
|
|
it.name.matches(fontRegex) |
|
|
|
} |
|
|
|
} ?: ArrayList() |
|
|
|
mergeFontItems(fontItems!!, getLocalFonts()) |
|
|
|
mergeFontItems(fontItems, getLocalFonts()) |
|
|
|
}.onSuccess { |
|
|
|
}.onSuccess { |
|
|
|
adapter.setItems(it) |
|
|
|
adapter.setItems(it) |
|
|
|
}.onError { |
|
|
|
}.onError { |
|
|
|
|
|
|
|
AppLog.put("加载字体文件失败\n${it.localizedMessage}", it) |
|
|
|
toastOnUi("getFontFiles:${it.localizedMessage}") |
|
|
|
toastOnUi("getFontFiles:${it.localizedMessage}") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|