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. 12
      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. 14
      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,20 +116,17 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
override fun finish() {
if (!BuildConfig.DEBUG) {
launch {
backup()
super.finish()
}
} else {
super.finish()
}
}
private suspend fun backup() {
private fun backup() {
Coroutine.async {
val backupPath = getPrefString(PreferKey.backupPath)
if (backupPath?.isNotEmpty() == true) {
val uri = Uri.parse(backupPath)
val doc = DocumentFile.fromTreeUri(this, uri)
val doc = DocumentFile.fromTreeUri(this@MainActivity, uri)
if (doc?.canWrite() == true) {
Backup.backup(this@MainActivity, uri)
}
@ -137,6 +134,7 @@ class MainActivity : VMBaseActivity<MainViewModel>(R.layout.activity_main),
Backup.backup(this@MainActivity, null)
}
}
}
override fun onDestroy() {
super.onDestroy()

@ -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,18 +44,10 @@
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"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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"
@ -63,11 +55,11 @@
android:layout_gravity="center"
android:includeFontPadding="false"
android:singleLine="true"
app:bv_radius="0dp"
app:bv_radius="1dp"
app:layout_constraintLeft_toLeftOf="@id/iv_cover"
app:layout_constraintBottom_toBottomOf="@id/iv_cover"
tools:ignore="RtlHardcoded" />
</FrameLayout>
<TextView
android:id="@+id/tv_name"
android:layout_width="0dp"

Loading…
Cancel
Save