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"
project.ext.set("archivesBaseName", name + "_" + version)
multiDexEnabled true
javaCompileOptions {
annotationProcessorOptions {
arguments = [
"room.incremental" : "true",
"room.expandProjection": "true"
]
}
}
}
buildTypes {
release {

@ -16,6 +16,7 @@ import io.legado.app.R
import io.legado.app.base.VMBaseActivity
import io.legado.app.constant.Bus
import io.legado.app.constant.PreferKey
import io.legado.app.help.coroutine.Coroutine
import io.legado.app.help.storage.Backup
import io.legado.app.lib.theme.ATH
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.utils.*
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.coroutines.launch
class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
BottomNavigationView.OnNavigationItemSelectedListener,
@ -116,25 +116,23 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
override fun finish() {
if (!BuildConfig.DEBUG) {
launch {
backup()
super.finish()
}
} else {
super.finish()
backup()
}
super.finish()
}
private suspend fun backup() {
val backupPath = getPrefString(PreferKey.backupPath)
if (backupPath?.isNotEmpty() == true) {
val uri = Uri.parse(backupPath)
val doc = DocumentFile.fromTreeUri(this, uri)
if (doc?.canWrite() == true) {
Backup.backup(this@MainActivity, uri)
private fun backup() {
Coroutine.async {
val backupPath = getPrefString(PreferKey.backupPath)
if (backupPath?.isNotEmpty() == true) {
val uri = Uri.parse(backupPath)
val doc = DocumentFile.fromTreeUri(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 radios =
typedArray.getDimensionPixelOffset(R.styleable.BadgeView_bv_radius, 8)
typedArray.recycle()
if (layoutParams !is LayoutParams) {
val layoutParams = LayoutParams(
@ -107,17 +108,9 @@ class BadgeView @JvmOverloads constructor(
}
fun setBackground(dipRadius: Float, badgeColor: Int) {
val radius = dip2Px(dipRadius)
val radiusArray = floatArrayOf(
radius.toFloat(),
radius.toFloat(),
radius.toFloat(),
radius.toFloat(),
radius.toFloat(),
radius.toFloat(),
radius.toFloat(),
radius.toFloat()
)
val radius = dip2Px(dipRadius).toFloat()
val radiusArray =
floatArrayOf(radius, radius, radius, radius, radius, radius, radius, radius)
val roundRect = RoundRectShape(radiusArray, null, null)
val bgDrawable = ShapeDrawable(roundRect)

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

@ -44,29 +44,21 @@
android:layout_height="26dp"
android:layout_gravity="right"
android:visibility="invisible"
app:loading_color="@color/colorAccent"
app:loading_width="2dp"
tools:ignore="RtlHardcoded" />
</FrameLayout>
<FrameLayout
android:id="@+id/fl_author"
<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="1dp"
app:layout_constraintLeft_toLeftOf="@id/iv_cover"
app:layout_constraintBottom_toBottomOf="@id/iv_cover">
<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>
app:layout_constraintBottom_toBottomOf="@id/iv_cover"
tools:ignore="RtlHardcoded" />
<TextView
android:id="@+id/tv_name"

Loading…
Cancel
Save