Skip to content

Commit

Permalink
Merge branch 'release-1.1.11'
Browse files Browse the repository at this point in the history
  • Loading branch information
AoEiuV020 committed Nov 24, 2017
2 parents 4fd71bb + 490d632 commit ac6ad23
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 22 deletions.
4 changes: 2 additions & 2 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 13
versionName "1.1.10"
versionCode 14
versionName "1.1.11"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
setProperty("archivesBaseName", "$rootProject.name-$versionName")
vectorDrawables.useSupportLibrary = true
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/assets/ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.1.11:
试着解决阅读页无法退出全屏的问题,
并添加了返回键退出全屏的设置,

1.1.10:
修复分屏或旋转后使用容易崩溃的bug,
修复“飘天文学”搜索有时没有结果的bug,
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/java/cc/aoeiuv020/panovel/local/settings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ package cc.aoeiuv020.panovel.local
* Created by AoEiuV020 on 2017.10.04-14:04:44.
*/
object Settings : LocalSource {
/**
* 阅读界面点击退出全屏的延迟,
* 有点延迟看着顺眼点,
*/
var fullScreenDelay: Int by PrimitiveDelegate(300)
var backPressOutOfFullScreen: Boolean by PrimitiveDelegate(false)
var textSize: Int by PrimitiveDelegate(18)

var lineSpacing: Int by PrimitiveDelegate(2)
var paragraphSpacing: Int by PrimitiveDelegate(4)
var leftSpacing: Int by PrimitiveDelegate(0)
Expand All @@ -17,13 +22,15 @@ object Settings : LocalSource {
var backgroundColor: Int by PrimitiveDelegate(0xffffffff.toInt())
var textColor: Int by PrimitiveDelegate(0xff000000.toInt())


var historyCount: Int by PrimitiveDelegate(200)

var asyncThreadCount: Int by PrimitiveDelegate(30)
var downloadThreadCount: Int by PrimitiveDelegate(4)

var adEnabled: Boolean by PrimitiveDelegate(true)


var bookListAutoSave: Boolean by PrimitiveDelegate(true)
}

2 changes: 2 additions & 0 deletions app/src/main/java/cc/aoeiuv020/panovel/settings/preference.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class EditTextPreference : android.preference.EditTextPreference, AnkoLogger {
"right_spacing" to ({ Settings.rightSpacing.toString() } to { v -> Settings.rightSpacing = v.toInt() }),
"top_spacing" to ({ Settings.topSpacing.toString() } to { v -> Settings.topSpacing = v.toInt() }),
"bottom_spacing" to ({ Settings.bottomSpacing.toString() } to { v -> Settings.bottomSpacing = v.toInt() }),
"full_screen_delay" to ({ Settings.fullScreenDelay.toString() } to { v -> Settings.fullScreenDelay = v.toInt() }),
"text_size" to ({ Settings.textSize.toString() } to { v -> Settings.textSize = v.toInt() })
)
}
Expand Down Expand Up @@ -75,6 +76,7 @@ class SwitchPreference : android.preference.SwitchPreference, AnkoLogger {
companion object {
private val map = mapOf<String, Pair<() -> Boolean, (Boolean) -> Unit>>(
"auto_save" to ({ Settings.bookListAutoSave } to { v -> Settings.bookListAutoSave = v }),
"back_press_out_of_fullScreen" to ({ Settings.backPressOutOfFullScreen } to { v -> Settings.backPressOutOfFullScreen = v }),
"ad_enabled" to ({ Settings.adEnabled } to { v -> Settings.adEnabled = v })
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package cc.aoeiuv020.panovel.text

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import android.widget.FrameLayout
import org.jetbrains.anko.AnkoLogger
import org.jetbrains.anko.verbose

/**
*
* Created by AoEiuV020 on 2017.11.24-19:54:53.
*/
class DispatchTouchFrameLayout : FrameLayout, AnkoLogger {
constructor(context: Context)
: super(context)

constructor(context: Context, attrs: AttributeSet)
: super(context, attrs)

constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int)
: super(context, attrs, defStyleAttr)

var activity: NovelTextActivity? = null

private var previousAction: Int = MotionEvent.ACTION_UP
override fun dispatchTouchEvent(event: MotionEvent): Boolean {
verbose { event }
if (previousAction == MotionEvent.ACTION_DOWN
&& event.action == MotionEvent.ACTION_UP) {
activity?.toggle()
}
previousAction = event.action
return super.dispatchTouchEvent(event)
}
}
11 changes: 11 additions & 0 deletions app/src/main/java/cc/aoeiuv020/panovel/text/NovelTextActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ class NovelTextActivity : NovelTextBaseFullScreenActivity(), IView {
}
})

dtfRoot.activity = this


navigation = NovelTextNavigation(this, novelItem, nav_view)

presenter = NovelTextPresenter(novelItem)
Expand All @@ -104,6 +107,14 @@ class NovelTextActivity : NovelTextBaseFullScreenActivity(), IView {
presenter.start()
}

override fun onBackPressed() {
if (Settings.backPressOutOfFullScreen && !mVisible) {
show()
} else {
super.onBackPressed()
}
}

override fun show() {
super.show()
navigation.reset(ntpAdapter.getCurrentTextCount() ?: 0, ntpAdapter.getCurrentTextProgress() ?: 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import android.view.MenuItem
import android.view.View
import android.view.WindowManager
import cc.aoeiuv020.panovel.R
import cc.aoeiuv020.panovel.local.Settings
import cc.aoeiuv020.panovel.util.hide
import cc.aoeiuv020.panovel.util.show
import kotlinx.android.synthetic.main.activity_novel_text.*
Expand Down Expand Up @@ -35,7 +36,7 @@ abstract class NovelTextBaseFullScreenActivity : AppCompatActivity(), AnkoLogger
app_bar.show()
fullscreen_content_controls.visibility = View.VISIBLE
}
private var mVisible: Boolean = false
protected var mVisible: Boolean = false
private val mHideRunnable = Runnable { hide() }
private val mDelayHideTouchListener = View.OnTouchListener { _, _ ->
@Suppress("ConstantConditionIf")
Expand Down Expand Up @@ -109,6 +110,6 @@ abstract class NovelTextBaseFullScreenActivity : AppCompatActivity(), AnkoLogger
companion object {
private val AUTO_HIDE = true
private val AUTO_HIDE_DELAY_MILLIS = 3000
private val UI_ANIMATION_DELAY = 300
private val UI_ANIMATION_DELAY get() = Settings.fullScreenDelay
}
}
14 changes: 0 additions & 14 deletions app/src/main/java/cc/aoeiuv020/panovel/text/NovelTextViewHolder.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package cc.aoeiuv020.panovel.text

import android.annotation.SuppressLint
import android.support.v7.widget.LinearLayoutManager
import android.view.MotionEvent
import android.view.View
import android.view.ViewGroup
import android.widget.ProgressBar
Expand All @@ -28,18 +26,6 @@ class NovelTextViewHolder(private val ctx: NovelTextActivity, private val presen

init {
textRecyclerView.layoutManager = layoutManager
textRecyclerView.setOnTouchListener(object : View.OnTouchListener {
private var previousAction: Int = MotionEvent.ACTION_UP
@SuppressLint("ClickableViewAccessibility")
override fun onTouch(v: View?, event: MotionEvent): Boolean {
if (previousAction == MotionEvent.ACTION_DOWN
&& event.action == MotionEvent.ACTION_UP) {
ctx.toggle()
}
previousAction = event.action
return false
}
})
textRecyclerView.adapter = textListAdapter
// itemView可能没有初始化高度,所以用decorView,
// 更靠谱的是GlobalOnLayoutListener,但要求api >= 16,
Expand Down
13 changes: 10 additions & 3 deletions app/src/main/res/layout/activity_novel_text.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
android:layout_height="match_parent"
tools:context="cc.aoeiuv020.panovel.text.NovelTextActivity">

<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
<cc.aoeiuv020.panovel.text.DispatchTouchFrameLayout
android:id="@+id/dtfRoot"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent">

<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</cc.aoeiuv020.panovel.text.DispatchTouchFrameLayout>

<FrameLayout
android:layout_width="match_parent"
Expand Down Expand Up @@ -39,6 +45,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@
<string name="library">库</string>
<string name="auto_save">自动保存</string>
<string name="ad_enabled">展示广告</string>
<string name="full_screen_delay">全屏延迟</string>
<string name="back_press_out_of_fullScreen">返回键退出全屏</string>


</resources>
13 changes: 13 additions & 0 deletions app/src/main/res/xml/pref_read.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<cc.aoeiuv020.panovel.settings.EditTextPreference
android:capitalize="words"
android:inputType="number"
android:key="full_screen_delay"
android:maxLines="1"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/full_screen_delay" />

<cc.aoeiuv020.panovel.settings.SwitchPreference
android:key="back_press_out_of_fullScreen"
android:title="@string/back_press_out_of_fullScreen" />

<cc.aoeiuv020.panovel.settings.EditTextPreference
android:capitalize="words"
android:inputType="number"
Expand Down

0 comments on commit ac6ad23

Please sign in to comment.