Merge pull request #10 from gedoor/master

up
pull/70/head
口口吕 5 years ago committed by GitHub
commit 6515d53214
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      app/build.gradle
  2. 30
      app/src/main/java/io/legado/app/ui/main/MainActivity.kt
  3. 15
      app/src/main/java/io/legado/app/ui/widget/BadgeView.kt
  4. 6
      app/src/main/java/io/legado/app/ui/widget/font/FontSelectDialog.kt
  5. 24
      app/src/main/res/layout/item_bookshelf_grid.xml

@ -38,6 +38,14 @@ android {
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
project.ext.set("archivesBaseName", name + "_" + version) project.ext.set("archivesBaseName", name + "_" + version)
multiDexEnabled true multiDexEnabled true
javaCompileOptions {
annotationProcessorOptions {
arguments = [
"room.incremental" : "true",
"room.expandProjection": "true"
]
}
}
} }
buildTypes { buildTypes {
release { release {

@ -16,6 +16,7 @@ import io.legado.app.R
import io.legado.app.base.VMBaseActivity import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.Bus import io.legado.app.constant.Bus
import io.legado.app.constant.PreferKey import io.legado.app.constant.PreferKey
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.help.storage.Backup import io.legado.app.help.storage.Backup
import io.legado.app.lib.theme.ATH import io.legado.app.lib.theme.ATH
import io.legado.app.service.BaseReadAloudService import io.legado.app.service.BaseReadAloudService
@ -27,7 +28,6 @@ import io.legado.app.ui.main.my.MyFragment
import io.legado.app.ui.main.rss.RssFragment import io.legado.app.ui.main.rss.RssFragment
import io.legado.app.utils.* import io.legado.app.utils.*
import kotlinx.android.synthetic.main.activity_main.* import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.coroutines.launch
class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main), class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
BottomNavigationView.OnNavigationItemSelectedListener, BottomNavigationView.OnNavigationItemSelectedListener,
@ -116,25 +116,23 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
override fun finish() { override fun finish() {
if (!BuildConfig.DEBUG) { if (!BuildConfig.DEBUG) {
launch { backup()
backup()
super.finish()
}
} else {
super.finish()
} }
super.finish()
} }
private suspend fun backup() { private fun backup() {
val backupPath = getPrefString(PreferKey.backupPath) Coroutine.async {
if (backupPath?.isNotEmpty() == true) { val backupPath = getPrefString(PreferKey.backupPath)
val uri = Uri.parse(backupPath) if (backupPath?.isNotEmpty() == true) {
val doc = DocumentFile.fromTreeUri(this, uri) val uri = Uri.parse(backupPath)
if (doc?.canWrite() == true) { val doc = DocumentFile.fromTreeUri(this@MainActivity, uri)
Backup.backup(this@MainActivity, uri) if (doc?.canWrite() == true) {
Backup.backup(this@MainActivity, uri)
}
} else {
Backup.backup(this@MainActivity, null)
} }
} else {
Backup.backup(this@MainActivity, null)
} }
} }

@ -77,6 +77,7 @@ class BadgeView @JvmOverloads constructor(
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.BadgeView) val typedArray = context.obtainStyledAttributes(attrs, R.styleable.BadgeView)
val radios = val radios =
typedArray.getDimensionPixelOffset(R.styleable.BadgeView_bv_radius, 8) typedArray.getDimensionPixelOffset(R.styleable.BadgeView_bv_radius, 8)
typedArray.recycle()
if (layoutParams !is LayoutParams) { if (layoutParams !is LayoutParams) {
val layoutParams = LayoutParams( val layoutParams = LayoutParams(
@ -107,17 +108,9 @@ class BadgeView @JvmOverloads constructor(
} }
fun setBackground(dipRadius: Float, badgeColor: Int) { fun setBackground(dipRadius: Float, badgeColor: Int) {
val radius = dip2Px(dipRadius) val radius = dip2Px(dipRadius).toFloat()
val radiusArray = floatArrayOf( val radiusArray =
radius.toFloat(), floatArrayOf(radius, radius, radius, radius, radius, radius, radius, radius)
radius.toFloat(),
radius.toFloat(),
radius.toFloat(),
radius.toFloat(),
radius.toFloat(),
radius.toFloat(),
radius.toFloat()
)
val roundRect = RoundRectShape(radiusArray, null, null) val roundRect = RoundRectShape(radiusArray, null, null)
val bgDrawable = ShapeDrawable(roundRect) val bgDrawable = ShapeDrawable(roundRect)

@ -41,11 +41,11 @@ class FontSelectDialog : DialogFragment(),
FontAdapter.CallBack { FontAdapter.CallBack {
lateinit var job: Job lateinit var job: Job
private val fontFolderRequestCode = 35485 private val fontFolderRequestCode = 35485
private lateinit var adapter: FontAdapter
private val fontFolder = private val fontFolder =
App.INSTANCE.filesDir.absolutePath + File.separator + "Fonts" + File.separator App.INSTANCE.filesDir.absolutePath + File.separator + "Fonts" + File.separator
override val coroutineContext: CoroutineContext override val coroutineContext: CoroutineContext
get() = job + Main get() = job + Main
private var adapter: FontAdapter? = null
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
@ -144,7 +144,7 @@ class FontSelectDialog : DialogFragment(),
pathName.name.toLowerCase().matches(".*\\.[ot]tf".toRegex()) pathName.name.toLowerCase().matches(".*\\.[ot]tf".toRegex())
}?.let { }?.let {
withContext(Main) { withContext(Main) {
adapter.setItems(it.toList()) adapter?.setItems(it.toList())
} }
} }
} catch (e: Exception) { } catch (e: Exception) {
@ -161,7 +161,7 @@ class FontSelectDialog : DialogFragment(),
file.listFiles { pathName -> file.listFiles { pathName ->
pathName.name.toLowerCase().matches(".*\\.[ot]tf".toRegex()) pathName.name.toLowerCase().matches(".*\\.[ot]tf".toRegex())
}?.let { }?.let {
adapter.setItems(it.toList()) adapter?.setItems(it.toList())
} }
} catch (e: Exception) { } catch (e: Exception) {
toast(e.localizedMessage ?: "") toast(e.localizedMessage ?: "")

@ -44,29 +44,21 @@
android:layout_height="26dp" android:layout_height="26dp"
android:layout_gravity="right" android:layout_gravity="right"
android:visibility="invisible" android:visibility="invisible"
app:loading_color="@color/colorAccent"
app:loading_width="2dp" app:loading_width="2dp"
tools:ignore="RtlHardcoded" /> tools:ignore="RtlHardcoded" />
</FrameLayout> </FrameLayout>
<FrameLayout <io.legado.app.ui.widget.BadgeView
android:id="@+id/fl_author" android:id="@+id/bv_author"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center"
android:includeFontPadding="false"
android:singleLine="true"
app:bv_radius="1dp"
app:layout_constraintLeft_toLeftOf="@id/iv_cover" app:layout_constraintLeft_toLeftOf="@id/iv_cover"
app:layout_constraintBottom_toBottomOf="@id/iv_cover"> app:layout_constraintBottom_toBottomOf="@id/iv_cover"
tools:ignore="RtlHardcoded" />
<io.legado.app.ui.widget.BadgeView
android:id="@+id/bv_author"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:includeFontPadding="false"
android:singleLine="true"
app:bv_radius="0dp"
tools:ignore="RtlHardcoded" />
</FrameLayout>
<TextView <TextView
android:id="@+id/tv_name" android:id="@+id/tv_name"

Loading…
Cancel
Save