Skip to content

Commit

Permalink
Merge branch 'release-1.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
AoEiuV020 committed Nov 26, 2017
2 parents cf7ea85 + a45c54e commit f53039b
Show file tree
Hide file tree
Showing 15 changed files with 121 additions and 18 deletions.
5 changes: 2 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ android {
applicationId "cc.aoeiuv020.panovel"
minSdkVersion min_version
targetSdkVersion target_version
versionCode 15
versionName "1.2.0"
versionCode 16
versionName "1.2.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
setProperty("archivesBaseName", "$rootProject.name-$versionName")
vectorDrawables.useSupportLibrary = true
Expand Down Expand Up @@ -60,7 +60,6 @@ dependencies {
implementation project(':RefreshRecyclerView')
implementation 'com.github.hackware1993:MagicIndicator:1.5.0'
implementation project(':api')
implementation 'com.github.didikee:AndroidDonate:0.1.0'
}


Expand Down
7 changes: 4 additions & 3 deletions app/src/main/assets/ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
更新日志:
1.2.1:
添加背景图片设置,
修复精确搜索时一个网站小说详情加载失败导致剩下网站停止加载的bug,

1.2.0:
添加捐赠界面,
离开捐赠界面五秒后回来就去广告,重启生效,
Expand All @@ -21,11 +25,8 @@

1.1.9:
添加书单功能,
需要的话,书单可以直接在私有目录下/BookList/取出来发给别人,
如,/sdcard/Android/data/cc.aoeiuv020.panovel/files/BookList/
另外解决上一版阅读退出全屏时上跳一段的bug,

1.1.7:
添加导出小说到.txt的功能,
在,/sdcard/Android/data/cc.aoeiuv020.panovel/files/Text/
书架中的书籍右上角长按出功能选项,
5 changes: 4 additions & 1 deletion app/src/main/assets/Explain.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
/sdcard/Android/data/cc.aoeiuv020.panovel/files
有点深,但想必用户也不喜欢什么app都往sd根目录建文件夹,
其中Cache可以删除,包含缓存和不在书架中的书的阅读进度,
导出的书在Text下,
导出的书在Text下,
书单在BookList下,

书架里书的右上角小图标长按有更多菜单,其中有导出,
4 changes: 2 additions & 2 deletions app/src/main/java/cc/aoeiuv020/panovel/Presenter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ abstract class Presenter<T : IView> : AnkoLogger {
}

protected fun addDisposable(disposable: Disposable, index: Int = 0) {
debug { "$this add disposable $disposable" }
debug { "$this add disposable ${disposable.hashCode()} at $index" }
while (index >= disposableList.size) {
disposableList.add(null)
}
val old = disposableList[index]
disposableList[index] = disposable
old?.dispose()
old?.let {
debug { "old $old dispose" }
debug { "old ${old.hashCode()} dispose" }
it.dispose()
}
}
Expand Down
25 changes: 25 additions & 0 deletions app/src/main/java/cc/aoeiuv020/panovel/local/delegate.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package cc.aoeiuv020.panovel.local

import android.net.Uri
import cc.aoeiuv020.panovel.App
import org.jetbrains.anko.AnkoLogger
import org.jetbrains.anko.debug
import java.io.Serializable
Expand Down Expand Up @@ -71,3 +73,26 @@ class GsonDelegate<T>(private val default: T? = null, private val type: Class<T>
}
}

class UriDelegate : AnkoLogger {
private var backingField: Uri? = null
operator fun getValue(thisRef: LocalSource, property: KProperty<*>): Uri? {
return backingField ?: thisRef.openFile(property.name).takeIf { it.exists() }?.let { Uri.fromFile(it) }.also {
debug { "${property.name} > $it" }
}
}

operator fun setValue(thisRef: LocalSource, property: KProperty<*>, value: Uri?) {
debug { "${property.name} < $value" }
if (backingField != value) {
backingField = null
val file = thisRef.openFile(property.name)
if (value == null) {
file.delete()
} else {
App.ctx.contentResolver.openInputStream(value).copyTo(file.outputStream())
backingField = getValue(thisRef, property)
}
}
}
}

5 changes: 4 additions & 1 deletion app/src/main/java/cc/aoeiuv020/panovel/local/settings.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package cc.aoeiuv020.panovel.local

import android.net.Uri

/**
* 设置,
* Created by AoEiuV020 on 2017.10.04-14:04:44.
Expand All @@ -19,8 +21,9 @@ object Settings : LocalSource {
var rightSpacing: Int by PrimitiveDelegate(0)
var bottomSpacing: Int by PrimitiveDelegate(0)

var backgroundColor: Int by PrimitiveDelegate(0xffffffff.toInt())
var textColor: Int by PrimitiveDelegate(0xff000000.toInt())
var backgroundColor: Int by PrimitiveDelegate(0xffffffff.toInt())
var backgroundImage: Uri? by UriDelegate()


var historyCount: Int by PrimitiveDelegate(200)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class RefineSearchActivity : AppCompatActivity(), BaseItemListView, AnkoLogger {
override fun showError(message: String, e: Throwable) {
snack.setText(message + e.message)
snack.show()
showOnComplete()
recyclerView.dismissSwipeRefresh()
}

override fun onCreateOptionsMenu(menu: Menu): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import cc.aoeiuv020.panovel.api.NovelItem
import cc.aoeiuv020.panovel.base.item.DefaultItemListPresenter
import cc.aoeiuv020.panovel.local.Cache
import cc.aoeiuv020.panovel.local.NovelId
import cc.aoeiuv020.panovel.local.bookId
import cc.aoeiuv020.panovel.util.async
import io.reactivex.Observable
import org.jetbrains.anko.debug
Expand Down Expand Up @@ -34,7 +35,7 @@ class RefineSearchPresenter : DefaultItemListPresenter<RefineSearchActivity>() {
debug { "search <$name, $author>" }
Observable.create<NovelItem> { em ->
fun next(novelItem: NovelItem) {
debug { "search result <${novelItem.name}, ${novelItem.author}>" }
debug { "search result <${novelItem.bookId}>" }
em.onNext(novelItem)
}
NovelContext.getNovelContexts().forEach { context ->
Expand Down Expand Up @@ -65,6 +66,7 @@ class RefineSearchPresenter : DefaultItemListPresenter<RefineSearchActivity>() {
val message = "搜索小说失败,"
error(message, e)
view?.showError(message, e)
view?.showOnComplete()
}, {
view?.showOnComplete()
}).let { addDisposable(it) }
Expand Down
28 changes: 26 additions & 2 deletions app/src/main/java/cc/aoeiuv020/panovel/text/NovelTextActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ package cc.aoeiuv020.panovel.text

import android.app.ProgressDialog
import android.content.Context
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.os.Handler
import android.support.v4.view.ViewPager
Expand Down Expand Up @@ -144,8 +146,30 @@ class NovelTextActivity : NovelTextBaseFullScreenActivity(), IView {
ntpAdapter.setTextColor(color)
}

fun setBackgroundColor(color: Int) {
viewPager.setBackgroundColor(color)
fun setBackgroundColor(color: Int, fromUser: Boolean = false) {
if (fromUser) {
ivBackground.setImageDrawable(null)
}
ivBackground.setBackgroundColor(color)
}

fun requestBackgroundImage() {
val intent = Intent(Intent.ACTION_GET_CONTENT)
intent.type = "image/*"
startActivityForResult(intent, 0)
}

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
when (requestCode) {
0 -> data?.data?.let {
Settings.backgroundImage = it
setBackgroundImage(it)
}
}
}

fun setBackgroundImage(uri: Uri?) {
ivBackground.setImageURI(uri)
}

fun setParagraphSpacing(progress: Int) {
Expand Down
13 changes: 10 additions & 3 deletions app/src/main/java/cc/aoeiuv020/panovel/text/NovelTextNavigation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,28 @@ class NovelTextNavigation(val view: NovelTextActivity, val novelItem: NovelItem,
}
})

// 设置背景图,
view.setBackgroundImage(Settings.backgroundImage)
lBackgroundImage.setOnClickListener {
view.requestBackgroundImage()
}

// 设置背景色,
val backgroundColor = Settings.backgroundColor
view.setBackgroundColor(backgroundColor)
backgroundColorTextView.text = view.getString(R.string.background_color_placeholder, backgroundColor)
backgroundColorTextView.setOnClickListener {
lBackgroundColor.setOnClickListener {
view.alertColorPicker(Settings.backgroundColor) { color ->
Settings.backgroundColor = color
Settings.backgroundImage = null
backgroundColorTextView.text = view.getString(R.string.background_color_placeholder, color)
view.setBackgroundColor(color)
view.setBackgroundColor(color, true)
}
}

// 设置文字颜色,
textColorTextView.text = view.getString(R.string.text_color_placeholder, Settings.textColor)
textColorTextView.setOnClickListener {
lTextColor.setOnClickListener {
view.alertColorPicker(Settings.textColor) { color ->
Settings.textColor = color
textColorTextView.text = view.getString(R.string.text_color_placeholder, color)
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/cc/aoeiuv020/panovel/util/presenter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,10 @@ private val asyncExecutor = object : Executor {
fun <T : Any?> Observable<T>.async(): Observable<T> = this
.subscribeOn(Schedulers.from(asyncExecutor))
.observeOn(AndroidSchedulers.mainThread())

fun <T> ignoreException(block: () -> T?) {
try {
block()
} catch (_: Exception) {
}
}
7 changes: 7 additions & 0 deletions app/src/main/res/layout/activity_novel_text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/ivBackground"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
tools:ignore="ContentDescription" />

<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
Expand Down
24 changes: 24 additions & 0 deletions app/src/main/res/layout/novel_text_read_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,29 @@


<LinearLayout
android:id="@+id/lBackgroundImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="horizontal">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxEms="4"
android:minEms="4"
android:singleLine="true"
android:text="@string/background_image"
android:textColor="@android:color/primary_text_dark" />

<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>

<LinearLayout
android:id="@+id/lBackgroundColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
Expand Down Expand Up @@ -75,6 +98,7 @@
</LinearLayout>

<LinearLayout
android:id="@+id/lTextColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
<string name="line_spacing">行间距</string>
<string name="paragraph_spacing_placeholder">%ddp</string>
<string name="paragraph_spacing">段间距</string>
<string name="background_image">背景图</string>
<string name="background_color_placeholder">0x%08X</string>
<string name="background_color">背景色</string>
<string name="text_color_placeholder">0x%08X</string>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
min_version = 15
target_version = compile_version
support_version = '26.1.0'
kotlin_version = '1.1.60'
kotlin_version = '1.1.61'
anko_version = '0.10.1'
junit_version = '4.12'
slf4j_version = '1.7.25'
Expand Down

0 comments on commit f53039b

Please sign in to comment.