This commit is contained in:
lunaticbum 2023-04-06 19:18:02 +09:00
parent 271e0c66dc
commit ae743bf784
13 changed files with 722 additions and 511 deletions

View File

@ -6,31 +6,36 @@ import android.content.DialogInterface
import android.content.Intent import android.content.Intent
import android.content.pm.ActivityInfo import android.content.pm.ActivityInfo
import android.content.res.Configuration import android.content.res.Configuration
import android.graphics.Color
import android.hardware.display.DisplayManager import android.hardware.display.DisplayManager
import android.net.Uri import android.net.Uri
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.os.Handler import android.os.Handler
import android.os.Message import android.os.Message
import android.text.InputType
import android.util.Log import android.util.Log
import android.view.KeyEvent import android.view.KeyEvent
import android.view.View import android.view.View
import android.view.View.* import android.view.View.*
import android.webkit.WebView import android.webkit.WebView
import android.widget.ArrayAdapter import android.widget.ArrayAdapter
import android.widget.EditText
import android.widget.ImageButton import android.widget.ImageButton
import android.widget.ProgressBar import android.widget.ProgressBar
import android.widget.TextView
import android.widget.Toast import android.widget.Toast
import androidx.annotation.RequiresApi
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.appcompat.widget.AppCompatButton import androidx.appcompat.widget.AppCompatButton
import com.google.gson.Gson import com.google.gson.Gson
import com.lge.display.DisplayManagerHelper import com.lge.display.DisplayManagerHelper
import com.mime.dualscreenview.R import com.mime.dualscreenview.R
import com.mime.dualscreenview.common.Blog import com.mime.dualscreenview.common.Blog
import com.mime.dualscreenview.common.PairArray
import com.mime.dualscreenview.common.colorz
import com.mime.dualscreenview.common.getIndex
import com.mime.dualscreenview.common.typesfacez
import com.mime.dualscreenview.data.HistoryManager import com.mime.dualscreenview.data.HistoryManager
import com.mime.dualscreenview.dialog.StyleSelectInterface
import com.mime.dualscreenview.dialog.Stylez
import com.mime.dualscreenview.data.model.BookPageInfo import com.mime.dualscreenview.data.model.BookPageInfo
import com.mime.dualscreenview.data.model.BookPageInfos import com.mime.dualscreenview.data.model.BookPageInfos
import com.mime.dualscreenview.data.model.HistoryItem import com.mime.dualscreenview.data.model.HistoryItem
@ -48,6 +53,8 @@ import io.realm.kotlin.UpdatePolicy
import io.realm.kotlin.ext.copyFromRealm import io.realm.kotlin.ext.copyFromRealm
import io.realm.kotlin.ext.query import io.realm.kotlin.ext.query
import kotlinx.android.synthetic.main.intro.paged_layer import kotlinx.android.synthetic.main.intro.paged_layer
import kotlinx.android.synthetic.main.intro.textview_title
import kotlinx.android.synthetic.main.settings.preview
import java.lang.System.currentTimeMillis import java.lang.System.currentTimeMillis
import java.text.SimpleDateFormat import java.text.SimpleDateFormat
import java.util.Date import java.util.Date
@ -181,15 +188,15 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
super.onResume() super.onResume()
var realm = HistoryManager.openRealm() var realm = HistoryManager.openRealm()
realm.query<ReaderConfig>()?.find()?.let { realm.query<ReaderConfig>()?.find()?.let {
if (it.size > 0) { if (it.size > 0) {
realm.copyFromRealm(it.first())?.let { realm.copyFromRealm(it.first())?.let {
var msg = handle.obtainMessage() var msg = handle.obtainMessage()
msg.what = 0 msg.what = 0
msg.obj = it msg.obj = it
handle.sendMessageDelayed(msg, 200) handle.sendMessageDelayed(msg, 200)
}
} }
} }
}
realm.close() realm.close()
reloadLastInfo() reloadLastInfo()
reloadTo(lastInfo) reloadTo(lastInfo)
@ -234,7 +241,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
dialog, which -> dialog, which ->
var realm = openRealm() var realm = openRealm()
realm?.writeBlocking { realm?.writeBlocking {
this.query<HistoryItem>().query("title == '${item.title}'", ).find()?.last()?.let{ this.query<HistoryItem>().query("title == '${item.title}'").find()?.last()?.let{
this.delete(it) this.delete(it)
} }
} }
@ -267,416 +274,439 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
} }
private fun moveTo(item: BookPageInfo?) { private fun moveTo(item: BookPageInfo?) {
item?.link?.let {newPath -> item?.link?.let { newPath ->
mBaseWebContentsViewer?.webview?.url?.let{currentUrl -> mBaseWebContentsViewer?.webview?.url?.let { currentUrl ->
Uri.parse(currentUrl)?.lastPathSegment?.let { Uri.parse(currentUrl)?.lastPathSegment?.let {
currentUrl.replace(it,newPath)?.let { currentUrl.replace(it, newPath)?.let {
mBaseWebContentsViewer?.webview?.loadUrl(it) mBaseWebContentsViewer?.webview?.loadUrl(it)
} }
} }
} }
} }
} }
fun showStyleList() { // fun showStyleList() {
var mStylez = Stylez(this@Intro) // var mStylez = Stylez(this@Intro)
mStylez.styleSelectInterface = object : StyleSelectInterface { // mStylez.styleSelectInterface = object : StyleSelectInterface {
override fun onSelectStyle(bgColor: String, textColor: String) { // override fun onSelectStyle(bgColor: String, textColor: String) {
paged_layer?.setColorStyle(arrayOf(textColor,bgColor)) // paged_layer?.setColorStyle(arrayOf(textColor,bgColor))
// }
// }
// mStylez.show()
// }
override fun onDestroy() {
// Remove all callbacks when this activity is destroyed
displayManagerHelper?.unregisterCoverDisplayEnabledCallback(applicationContext.packageName)
displayManagerHelper?.unregisterSmartCoverCallback(smartCoverCallback)
super.onDestroy()
}
/**
* Convert cover display states to string to serve for logging
*
* @param state is the value integer of state
* @return a string for this state
*/
private fun coverDisplayStateToString(state: Int): String {
return when (state) {
DisplayManagerHelper.STATE_UNMOUNT -> "STATE_UNMOUNT"
DisplayManagerHelper.STATE_DISABLED -> "STATE_DISABLED"
DisplayManagerHelper.STATE_ENABLED -> "STATE_ENABLED"
else -> "UNKNOWN_STATE"
} }
} }
mStylez.show()
}
/**
override fun onDestroy() { * Convert smart cover display states to string to serve for logging
// Remove all callbacks when this activity is destroyed *
displayManagerHelper?.unregisterCoverDisplayEnabledCallback(applicationContext.packageName) * @param state is the value integer of state
displayManagerHelper?.unregisterSmartCoverCallback(smartCoverCallback) * @return a string for this state
super.onDestroy() */
} private fun smartCoverStateToString(state: Int): String {
return when (state) {
/** DisplayManagerHelper.STATE_COVER_OPENED -> "STATE_COVER_OPENED"
* Convert cover display states to string to serve for logging DisplayManagerHelper.STATE_COVER_CLOSED -> "STATE_COVER_CLOSED"
* DisplayManagerHelper.STATE_COVER_FLIPPED_OVER -> "STATE_COVER_FLIPPED_OVER"
* @param state is the value integer of state else -> "UNKNOWN_STATE"
* @return a string for this state
*/
private fun coverDisplayStateToString(state: Int): String {
return when (state) {
DisplayManagerHelper.STATE_UNMOUNT -> "STATE_UNMOUNT"
DisplayManagerHelper.STATE_DISABLED -> "STATE_DISABLED"
DisplayManagerHelper.STATE_ENABLED -> "STATE_ENABLED"
else -> "UNKNOWN_STATE"
}
}
/**
* Convert smart cover display states to string to serve for logging
*
* @param state is the value integer of state
* @return a string for this state
*/
private fun smartCoverStateToString(state: Int): String {
return when (state) {
DisplayManagerHelper.STATE_COVER_OPENED -> "STATE_COVER_OPENED"
DisplayManagerHelper.STATE_COVER_CLOSED -> "STATE_COVER_CLOSED"
DisplayManagerHelper.STATE_COVER_FLIPPED_OVER -> "STATE_COVER_FLIPPED_OVER"
else -> "UNKNOWN_STATE"
}
}
/**
* Navigate to the second screen.
*
* See more at https://developer.android.com/guide/topics/ui/foldables?#using_secondary_screens
*/
private fun toSecondScreen(screenNumStr : String) {
var screenNum = screenNumStr.toInt()
// DisplayManager manages the properties of attached displays.
val displayManager = getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
// List displays was attached
val displays = displayManager.displays
if (displays.size > screenNum) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Activity options are used to select the display screen.
val options = ActivityOptions.makeBasic()
// Select the display screen that you want to show the second activity
options.launchDisplayId = displays[screenNum].displayId
// To display on the second screen that your intent must be set flag to make
// single task (combine FLAG_ACTIVITY_CLEAR_TOP and FLAG_ACTIVITY_NEW_TASK)
// or you also set it in the manifest (see more at the manifest file)
startActivity(
Intent(this@Intro, Main::class.java).apply {
},
options.toBundle()
)
} }
} else {
Toast.makeText(this, "Not found the second screen", Toast.LENGTH_SHORT).show()
} }
}
private inner class MainCoverDisplayCallback : DisplayManagerHelper.CoverDisplayCallback() { /**
override fun onCoverDisplayEnabledChangedCallback(state: Int) { * Navigate to the second screen.
displayManagerHelper?.coverDisplayState?.let { *
Log.i(TAG, "Current DualScreen Callback state: ${coverDisplayStateToString(it)}") * See more at https://developer.android.com/guide/topics/ui/foldables?#using_secondary_screens
*/
private fun toSecondScreen(screenNumStr : String) {
var screenNum = screenNumStr.toInt()
// DisplayManager manages the properties of attached displays.
val displayManager = getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
// List displays was attached
val displays = displayManager.displays
if (displays.size > screenNum) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Activity options are used to select the display screen.
val options = ActivityOptions.makeBasic()
// Select the display screen that you want to show the second activity
options.launchDisplayId = displays[screenNum].displayId
// To display on the second screen that your intent must be set flag to make
// single task (combine FLAG_ACTIVITY_CLEAR_TOP and FLAG_ACTIVITY_NEW_TASK)
// or you also set it in the manifest (see more at the manifest file)
startActivity(
Intent(this@Intro, Main::class.java).apply {
},
options.toBundle()
)
}
} else {
Toast.makeText(this, "Not found the second screen", Toast.LENGTH_SHORT).show()
} }
if (prevDualScreenState != state) { }
when (state) {
DisplayManagerHelper.STATE_UNMOUNT -> { private inner class MainCoverDisplayCallback : DisplayManagerHelper.CoverDisplayCallback() {
Log.i(TAG, "Changed DualScreen State to STATE_UNMOUNT") override fun onCoverDisplayEnabledChangedCallback(state: Int) {
} displayManagerHelper?.coverDisplayState?.let {
DisplayManagerHelper.STATE_DISABLED -> { Log.i(TAG, "Current DualScreen Callback state: ${coverDisplayStateToString(it)}")
Log.i(TAG, "Changed DualScreen State to STATE_DISABLED") }
} if (prevDualScreenState != state) {
DisplayManagerHelper.STATE_ENABLED -> { when (state) {
DisplayManagerHelper.STATE_UNMOUNT -> {
Log.i(TAG, "Changed DualScreen State to STATE_UNMOUNT")
}
DisplayManagerHelper.STATE_DISABLED -> {
Log.i(TAG, "Changed DualScreen State to STATE_DISABLED")
}
DisplayManagerHelper.STATE_ENABLED -> {
// toSecondScreen() // toSecondScreen()
Log.i(TAG, "Changed DualScreen State to STATE_ENABLED") Log.i(TAG, "Changed DualScreen State to STATE_ENABLED")
}
}
prevDualScreenState = state
}
}
}
private inner class MainSmartCoverCallback : DisplayManagerHelper.SmartCoverCallback() {
override fun onTypeChanged(type: Int) {
Log.i(TAG, "SmartCoverCallback type: ${displayManagerHelper?.coverType}")
}
override fun onStateChanged(state: Int) {
displayManagerHelper?.coverState?.let {
Log.i(TAG, "Current SmartCoverCallback state: ${smartCoverStateToString(it)}")
}
when (state) {
DisplayManagerHelper.STATE_COVER_OPENED -> {
Log.i(TAG, "Received SmartCoverCallback is STATE_COVER_OPENED")
}
DisplayManagerHelper.STATE_COVER_CLOSED -> {
Log.i(TAG, "Received SmartCoverCallback is STATE_COVER_CLOSED")
}
DisplayManagerHelper.STATE_COVER_FLIPPED_OVER -> {
Log.i(TAG, "Received SmartCoverCallback is STATE_COVER_FLIPPED_OVER")
} }
} }
prevDualScreenState = state
} }
} }
}
private inner class MainSmartCoverCallback : DisplayManagerHelper.SmartCoverCallback() { var onNextClickAction: GotoSomeWhere? = null
override fun onTypeChanged(type: Int) { override fun showNextBtn(find : Boolean , onClickAction: GotoSomeWhere) {
Log.i(TAG, "SmartCoverCallback type: ${displayManagerHelper?.coverType}") onNextClickAction = onClickAction
} findViewById<AppCompatButton>(R.id.btn_right)?.let{
it.text = "다음 페이지"
override fun onStateChanged(state: Int) { it.setOnClickListener {
displayManagerHelper?.coverState?.let { actionNextEvent()
Log.i(TAG, "Current SmartCoverCallback state: ${smartCoverStateToString(it)}")
}
when (state) {
DisplayManagerHelper.STATE_COVER_OPENED -> {
Log.i(TAG, "Received SmartCoverCallback is STATE_COVER_OPENED")
} }
DisplayManagerHelper.STATE_COVER_CLOSED -> { it.visibility= if(find) VISIBLE else GONE
Log.i(TAG, "Received SmartCoverCallback is STATE_COVER_CLOSED") }
} }
DisplayManagerHelper.STATE_COVER_FLIPPED_OVER -> {
Log.i(TAG, "Received SmartCoverCallback is STATE_COVER_FLIPPED_OVER") fun actionNextEvent() {
if (paged_layer != null && paged_layer!!.visibility == View.VISIBLE && paged_layer!!.size() > 0 && (paged_layer!!.current() < paged_layer!!.size() - 1) ) {
paged_layer!!.doNext()
updateLastInfo(paged_layer!!)
}else {
onNextClickAction?.let { it() }
}
}
var onPrevClickAction: GotoSomeWhere? = null
override fun showPrevBtn(find : Boolean, onClickAction: GotoSomeWhere) {
onPrevClickAction = onClickAction
findViewById<AppCompatButton>(R.id.btn_left)?.let{
it.text = "이전 페이지"
it.setOnClickListener {
actionPrevEvent()
} }
it.visibility= if(find) VISIBLE else GONE
} }
} }
}
var onNextClickAction: GotoSomeWhere? = null
override fun showNextBtn(find : Boolean , onClickAction: GotoSomeWhere) { fun actionPrevEvent() {
onNextClickAction = onClickAction if (paged_layer != null && paged_layer!!.visibility == View.VISIBLE && paged_layer!!.size() > 0 && paged_layer!!.current() > 0 ) {
findViewById<AppCompatButton>(R.id.btn_right)?.let{ paged_layer!!.doPrev()
it.text = "다음 페이지" updateLastInfo(paged_layer!!)
it.setOnClickListener { } else {
actionNextEvent() onPrevClickAction?.let{ it() }
} }
it.visibility= if(find) VISIBLE else GONE
} }
}
fun actionNextEvent() { override fun onBackPressed() {
if (paged_layer != null && paged_layer!!.visibility == View.VISIBLE && paged_layer!!.size() > 0 && (paged_layer!!.current() < paged_layer!!.size() - 1) ) { var layer = findViewById<PagedTextLayout>(R.id.paged_layer)
paged_layer!!.doNext()
updateLastInfo(paged_layer!!)
}else {
onNextClickAction?.let { it() }
}
}
var onPrevClickAction: GotoSomeWhere? = null if (!didBackPress) {
override fun showPrevBtn(find : Boolean, onClickAction: GotoSomeWhere) { firstBackPress()
onPrevClickAction = onClickAction return
findViewById<AppCompatButton>(R.id.btn_left)?.let{
it.text = "이전 페이지"
it.setOnClickListener {
actionPrevEvent()
} }
it.visibility= if(find) VISIBLE else GONE
}
}
if (layer != null && layer.visibility == View.VISIBLE) {
didBackPress = false
layer.visibility = GONE
onTouch(TouchArea.Center)
return
}
fun actionPrevEvent() { if (mBaseWebContentsViewer.webview.canGoBack()) {
if (paged_layer != null && paged_layer!!.visibility == View.VISIBLE && paged_layer!!.size() > 0 && paged_layer!!.current() > 0 ) { mBaseWebContentsViewer.webview.goBack()
paged_layer!!.doPrev() return
updateLastInfo(paged_layer!!) }
} else {
onPrevClickAction?.let{ it() }
}
}
override fun onBackPressed() { if (!didBackPress) {
var layer = findViewById<PagedTextLayout>(R.id.paged_layer) firstBackPress()
return
if (!didBackPress) { }
firstBackPress() finish()
return
}
if (layer != null && layer.visibility == View.VISIBLE) {
didBackPress = false didBackPress = false
layer.visibility = GONE
onTouch(TouchArea.Center)
return
} }
if (mBaseWebContentsViewer.webview.canGoBack()) {
mBaseWebContentsViewer.webview.goBack() override fun showAlert(alert: String) {
return Log.i(TAG,"showAlert >> " + alert)
} }
if (!didBackPress) { @RequiresApi(Build.VERSION_CODES.O)
firstBackPress() override fun onLoadedContents(contents: String) {
return paged_layer.apply {
} if (contents != null) {
finish() visibility = VISIBLE
didBackPress = false mPagedTextViewInterface = this@Intro
} var realm = HistoryManager.openRealm()
realm.query<ReaderConfig>()?.find()?.let {
if (it.size > 0) {
realm.copyFromRealm(it.first())?.let {
paged_layer?.setTextSize(it.textSize?.toFloat()?: 14f)
paged_layer?.setLineSpacing(it.lineSpace?.toFloat() ?: 1f)
paged_layer?.setLetterSpacing(it.letterSpace?.toFloat() ?: 1f)
paged_layer?.setPadding(
it.padding ?: 1,
it.padding ?: 1,
it.padding ?: 1,
it.padding ?: 1)
var typeface = typesfacez.get(getIndex(typesfacez as PairArray<Any>,it.font ?: ""))
override fun showAlert(alert: String) { paged_layer?.setTypeface(resources.getFont(typeface.second))
Log.i(TAG,"showAlert >> " + alert) val color = colorz.get(it.style ?: 0)
} paged_layer?.setColorStyle(color.second)
}
override fun onLoadedContents(contents: String) {
paged_layer.apply {
if (contents != null) {
visibility = VISIBLE
mPagedTextViewInterface = this@Intro
var realm = HistoryManager.openRealm()
realm.query<ReaderConfig>()?.find()?.let {
if (it.size > 0) {
realm.copyFromRealm(it.first())?.let {
paged_layer?.setTextSize(it.textSize?.toFloat()?: 14f)
paged_layer?.setLineSpacing(it.lineSpace?.toFloat() ?: 1f)
paged_layer?.setLetterSpacing(it.letterSpace?.toFloat() ?: 1f)
paged_layer?.setPadding(
it.padding ?: 1,
it.padding ?: 1,
it.padding ?: 1,
it.padding ?: 1)
} }
} }
realm.close()
setText(contents.replace("\\n", System.getProperty("line.separator")))
if(lastInfo != null && lastInfo!!.pageUrl.equals(mBaseWebContentsViewer.webview.url)) {
this@Intro.findViewById<ProgressBar>(R.id.progress)?.visibility = VISIBLE
paged_layer?.postDelayed({
next(lastInfo!!.pageIndex)
paged_layer?.post {
this@Intro.findViewById<ProgressBar>(R.id.progress)?.visibility = GONE
}
},1000)
}
forceUpdateUI()
} }
realm.close() }
Log.i(TAG,"onLoadedContents >> " + contents)
}
var currentTitle : String = ""
var currentChapter : Int = 0
override fun onFindTitle(contents: String) {
textview_title.text = contents
setText(contents.replace("\\n", System.getProperty("line.separator"))) textview_title.setOnClickListener {
if(lastInfo != null && lastInfo!!.pageUrl.equals(mBaseWebContentsViewer.webview.url)) { val builder = AlertDialog.Builder(this)
this@Intro.findViewById<ProgressBar>(R.id.progress)?.visibility = VISIBLE builder.setTitle("Title")
paged_layer?.postDelayed({ val input = EditText(this)
next(lastInfo!!.pageIndex) input.setText(mBaseWebContentsViewer?.webview?.url ?: "")
paged_layer?.post { input.inputType = InputType.TYPE_CLASS_TEXT
this@Intro.findViewById<ProgressBar>(R.id.progress)?.visibility = GONE builder.setView(input)
} builder.setPositiveButton(
},1000) "OK"
) { dialog, which ->
var m_Text = input.text.toString()
mBaseWebContentsViewer?.webview?.loadUrl(m_Text.trim())
} }
forceUpdateUI() builder.setNegativeButton(
"Cancel"
) { dialog, which -> dialog.cancel() }
builder.show()
} }
} var testRegex = """[^0-9]""".toRegex();
Log.i(TAG,"onLoadedContents >> " + contents) Blog.LOGI(TAG,"onFindTitle >> " + contents + " ::: ${testRegex.replace(contents,"")}")
} if(contents.contains("-")) {
currentTitle = contents.split("-")[0]
var currentTitle : String = "" try {
var currentChapter : Int = 0 currentChapter = testRegex.replace(contents.split("-")[1],"").toInt()
} catch (e : Exception) {
override fun onFindTitle(contents: String) { currentChapter = 0
findViewById<TextView>(R.id.textView).text = contents }
var testRegex = """[^0-9]""".toRegex(); } else if(testRegex.replace(contents,"").length > 0){
Blog.LOGI(TAG,"onFindTitle >> " + contents + " ::: ${testRegex.replace(contents,"")}") currentChapter = testRegex.replace(contents,"").toInt()
if(contents.contains("-")) { currentTitle = contents.split(testRegex.replace(contents,""))[0]
currentTitle = contents.split("-")[0] } else {
try { val dateFormat = "yyyyMMdd-HH"
currentChapter = testRegex.replace(contents.split("-")[1],"").toInt() val date = Date(currentTimeMillis())
} catch (e : Exception) { val simpleDateFormat = SimpleDateFormat(dateFormat)
currentChapter = 0 currentTitle = simpleDateFormat.format(date)
} }
} else if(testRegex.replace(contents,"").length > 0){
currentChapter = testRegex.replace(contents,"").toInt()
currentTitle = contents.split(testRegex.replace(contents,""))[0]
} else {
val dateFormat = "yyyyMMdd-HH"
val date = Date(currentTimeMillis())
val simpleDateFormat = SimpleDateFormat(dateFormat)
currentTitle = simpleDateFormat.format(date)
} }
} override fun onStartLoad() {
findViewById<ProgressBar>(R.id.progress).visibility = VISIBLE
override fun onStartLoad() {
findViewById<ProgressBar>(R.id.progress).visibility = VISIBLE
}
override fun completePageLoad(lastInfo: LastInfo) {
val configuration: Configuration = getResources().getConfiguration()
if(this.lastInfo == null || !(this.lastInfo?.pageUrl.equals(lastInfo?.pageUrl)) || this.lastInfo?.displayOrientation != configuration?.orientation) {
lastInfo.displayOrientation = configuration?.orientation ?: ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
saveLastInfo(lastInfo)
} }
findViewById<ProgressBar>(R.id.progress).visibility = GONE
}
fun saveLastInfo(lastInfo: LastInfo) { override fun completePageLoad(lastInfo: LastInfo) {
val realm = openRealm() val configuration: Configuration = getResources().getConfiguration()
if((realm.query<LastInfo>()?.count()?.find() ?: 0) > 0) {
if(this.lastInfo == null || !(this.lastInfo?.pageUrl.equals(lastInfo?.pageUrl)) || this.lastInfo?.displayOrientation != configuration?.orientation) {
lastInfo.displayOrientation = configuration?.orientation ?: ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
saveLastInfo(lastInfo)
}
findViewById<ProgressBar>(R.id.progress).visibility = GONE
}
fun saveLastInfo(lastInfo: LastInfo) {
val realm = openRealm()
if((realm.query<LastInfo>()?.count()?.find() ?: 0) > 0) {
realm.writeBlocking {
this.query<LastInfo>()?.find()?.last()?.let{
it.pageUrl = lastInfo.pageUrl
it.title = currentTitle
it.chapter = currentChapter
it.pageIndex = lastInfo.pageIndex
it.contentsName = lastInfo.contentsName
it.displayOrientation = lastInfo.displayOrientation
this@Intro.lastInfo = copyFromRealm(it)
}
}
} else {
realm.writeBlocking {
copyToRealm(lastInfo)
}
}
Blog.LOGD(log ="Successfully opened realm: ${realm.configuration.name}")
realm.close()
}
fun updateLastInfo(pagedTextLayout: PagedTextLayout) {
val configuration: Configuration = getResources().getConfiguration()
val realm = openRealm()
realm.writeBlocking { realm.writeBlocking {
this.query<LastInfo>()?.find()?.last()?.let{ this.query<LastInfo>()?.find()?.last()?.let{
it.pageUrl = lastInfo.pageUrl it.displayOrientation = configuration.orientation
it.title = currentTitle it.title = currentTitle
it.chapter = currentChapter it.chapter = currentChapter
it.pageIndex = lastInfo.pageIndex it.pageIndex = pagedTextLayout.current()
it.contentsName = lastInfo.contentsName
it.displayOrientation = lastInfo.displayOrientation
this@Intro.lastInfo = copyFromRealm(it) this@Intro.lastInfo = copyFromRealm(it)
} }
} if (currentTitle.length > 0 && currentChapter > 0) {
} else { this@Intro.lastInfo?.makeHistoryItem()?.let{
realm.writeBlocking { copyToRealm(it, UpdatePolicy.ALL)
copyToRealm(lastInfo) }
}
}
Blog.LOGD(log ="Successfully opened realm: ${realm.configuration.name}")
realm.close()
}
fun updateLastInfo(pagedTextLayout: PagedTextLayout) {
val configuration: Configuration = getResources().getConfiguration()
val realm = openRealm()
realm.writeBlocking {
this.query<LastInfo>()?.find()?.last()?.let{
it.displayOrientation = configuration.orientation
it.title = currentTitle
it.chapter = currentChapter
it.pageIndex = pagedTextLayout.current()
this@Intro.lastInfo = copyFromRealm(it)
}
if (currentTitle.length > 0 && currentChapter > 0) {
this@Intro.lastInfo?.makeHistoryItem()?.let{
copyToRealm(it, UpdatePolicy.ALL)
} }
} }
Blog.LOGD(log ="Successfully opened realm: ${realm.configuration.name}")
realm.close()
}
override fun onKeyClick(keyCode: Int): Boolean {
when(keyCode) {
KeyEvent.KEYCODE_VOLUME_DOWN ->{actionNextEvent()}
KeyEvent.KEYCODE_VOLUME_UP ->{actionPrevEvent()}
KeyEvent.KEYCODE_VOLUME_MUTE -> {actionNextEvent()}
}
return super.onKeyClick(keyCode)
} }
Blog.LOGD(log ="Successfully opened realm: ${realm.configuration.name}") override fun onTouch(touchArea: TouchArea) {
realm.close() Blog.LOGD(log="onTouch")
} when (touchArea) {
override fun onKeyClick(keyCode: Int): Boolean { TouchArea.Center-> {
when(keyCode) { findViewById<View>(R.id.btn_right).visibility = VISIBLE
KeyEvent.KEYCODE_VOLUME_DOWN ->{actionNextEvent()} findViewById<View>(R.id.btn_left).visibility = VISIBLE
KeyEvent.KEYCODE_VOLUME_UP ->{actionPrevEvent()} findViewById<View>(R.id.btn_setting).visibility = VISIBLE
KeyEvent.KEYCODE_VOLUME_MUTE -> {actionNextEvent()}
textview_title.visibility = VISIBLE
findViewById<View>(R.id.btn_home).visibility = VISIBLE
findViewById<View>(R.id.btn_list).visibility = VISIBLE
findViewById<View>(R.id.btn_history).visibility = VISIBLE
findViewById<View>(R.id.btn_rotate).visibility = VISIBLE
}
TouchArea.Right -> {
actionNextEvent()
}
TouchArea.Left-> {
actionPrevEvent()
}
else -> {
}
}
} }
return super.onKeyClick(keyCode)
}
override fun onTouch(touchArea: TouchArea) { override fun onSwipeLeft() {
Blog.LOGD(log="onTouch") Blog.LOGD(log="onSwipeLeft")
when (touchArea) { actionNextEvent()
TouchArea.Center-> {
findViewById<View>(R.id.btn_right).visibility = VISIBLE
findViewById<View>(R.id.btn_left).visibility = VISIBLE
findViewById<View>(R.id.btn_setting).visibility = VISIBLE
findViewById<View>(R.id.textView).visibility = VISIBLE }
findViewById<View>(R.id.btn_home).visibility = VISIBLE
findViewById<View>(R.id.btn_list).visibility = VISIBLE
findViewById<View>(R.id.btn_history).visibility = VISIBLE
findViewById<View>(R.id.btn_rotate).visibility = VISIBLE
} override fun onSwipeRight() {
TouchArea.Right -> { Blog.LOGD(log="onSwipeRight")
actionNextEvent() actionPrevEvent()
}
TouchArea.Left-> {
actionPrevEvent()
}
else -> {
}
} }
} override fun onTimeoverTouch() {
Blog.LOGD(log="onTimeoverTouch")
findViewById<View>(R.id.btn_right).visibility = GONE
findViewById<View>(R.id.btn_left).visibility = GONE
findViewById<View>(R.id.btn_setting).visibility = GONE
override fun onSwipeLeft() { textview_title.visibility = GONE
Blog.LOGD(log="onSwipeLeft") findViewById<View>(R.id.btn_home).visibility = GONE
actionNextEvent() findViewById<View>(R.id.btn_list).visibility = GONE
findViewById<View>(R.id.btn_history).visibility = GONE
findViewById<View>(R.id.btn_rotate).visibility = GONE
} }
override fun onSwipeRight() { companion object {
Blog.LOGD(log="onSwipeRight") private const val TAG = "DualScreenStatus"
actionPrevEvent() }
} }
override fun onTimeoverTouch() {
Blog.LOGD(log="onTimeoverTouch")
findViewById<View>(R.id.btn_right).visibility = GONE
findViewById<View>(R.id.btn_left).visibility = GONE
findViewById<View>(R.id.btn_setting).visibility = GONE
findViewById<View>(R.id.textView).visibility = GONE
findViewById<View>(R.id.btn_home).visibility = GONE
findViewById<View>(R.id.btn_list).visibility = GONE
findViewById<View>(R.id.btn_history).visibility = GONE
findViewById<View>(R.id.btn_rotate).visibility = GONE
}
companion object {
private const val TAG = "DualScreenStatus"
}
}

View File

@ -1,7 +1,14 @@
package com.mime.dualscreenview.activity package com.mime.dualscreenview.activity
import android.graphics.Color
import android.os.Build
import android.os.Bundle import android.os.Bundle
import androidx.annotation.RequiresApi
import com.mime.dualscreenview.R import com.mime.dualscreenview.R
import com.mime.dualscreenview.common.PairArray
import com.mime.dualscreenview.common.colorz
import com.mime.dualscreenview.common.getIndex
import com.mime.dualscreenview.common.typesfacez
import com.mime.dualscreenview.data.HistoryManager import com.mime.dualscreenview.data.HistoryManager
import com.mime.dualscreenview.data.model.ReaderConfig import com.mime.dualscreenview.data.model.ReaderConfig
import io.realm.kotlin.UpdatePolicy import io.realm.kotlin.UpdatePolicy
@ -9,6 +16,8 @@ import io.realm.kotlin.ext.query
import kotlinx.android.synthetic.main.settings.letter_space import kotlinx.android.synthetic.main.settings.letter_space
import kotlinx.android.synthetic.main.settings.line_space import kotlinx.android.synthetic.main.settings.line_space
import kotlinx.android.synthetic.main.settings.page_padding import kotlinx.android.synthetic.main.settings.page_padding
import kotlinx.android.synthetic.main.settings.page_style
import kotlinx.android.synthetic.main.settings.page_typesface
import kotlinx.android.synthetic.main.settings.preview import kotlinx.android.synthetic.main.settings.preview
import kotlinx.android.synthetic.main.settings.text_size import kotlinx.android.synthetic.main.settings.text_size
@ -32,6 +41,7 @@ class Settings : Base() {
realm.close() realm.close()
} }
@RequiresApi(Build.VERSION_CODES.O)
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()
text_size.displayFormat = "글자 크기 : %d" text_size.displayFormat = "글자 크기 : %d"
@ -77,14 +87,42 @@ class Settings : Base() {
} }
} }
page_typesface.displayFormat = "폰트 : %s"
page_typesface.titleArray = typesfacez.map { it.first }.toTypedArray()
page_typesface.value = getIndex(typesfacez as PairArray<Any>,readerConfig?.font ?: "")
page_typesface.mValueChange = {
val pair = typesfacez.get(it)
preview.setTypeface(resources.getFont(pair.second))
if (readerConfig?.font != pair.first) {
readerConfig?.font = pair.first ?: ""
configSave()
}
}
page_style.displayFormat = "스타일 : %s"
page_style.titleArray = colorz.map { it.first }.toTypedArray()
page_style.value = readerConfig?.style ?: 0
page_style.mValueChange = {
val pair = colorz.get(it)
preview.setBackgroundColor(Color.parseColor(pair.second.last()))
preview.setTextColor(Color.parseColor(pair.second.first()))
if (readerConfig?.style != it) {
readerConfig?.style = it ?: 0
configSave()
}
}
} }
fun configSave() { fun configSave() {
var realm = HistoryManager.openRealm() var realm = HistoryManager.openRealm()
realm.writeBlocking { realm.writeBlocking {
copyToRealm(readerConfig!!, UpdatePolicy.ALL) copyToRealm(readerConfig!!, UpdatePolicy.ALL)
} }
realm.close() realm.close()
} }
} }

View File

@ -1,15 +1,39 @@
package com.mime.dualscreenview.common package com.mime.dualscreenview.common
import com.mime.dualscreenview.R
val colorz = arrayOf<Array<String>>( typealias PairArray<T> = Array<Pair<String,T>>
arrayOf<String>("#E1F5FE", "#263238"), val colorz : PairArray<Array<String>> = arrayOf<Pair<String,Array<String>>>(
arrayOf<String>("#F0F4C3", "#37474F"), Pair("color set 01",arrayOf<String>("#E1F5FE", "#263238")),
arrayOf<String>("#ECEFF1", "#455A64"), Pair("color set 02",arrayOf<String>("#F0F4C3", "#37474F")),
arrayOf<String>("#E0F7FA", "#263238"), Pair("color set 03",arrayOf<String>("#ECEFF1", "#455A64")),
arrayOf<String>("#F5F5F5", "#263238"), Pair("color set 04",arrayOf<String>("#E0F7FA", "#263238")),
arrayOf<String>("#ECEFF1", "#263238"), Pair("color set 05",arrayOf<String>("#F5F5F5", "#263238")),
arrayOf<String>("#F8BBD0", "#263238"), Pair("color set 06",arrayOf<String>("#ECEFF1", "#263238")),
arrayOf<String>("#E6EE9C", "#455A64"), Pair("color set 07",arrayOf<String>("#F8BBD0", "#263238")),
arrayOf<String>("#CFD8DC", "#455A64"), Pair("color set 08",arrayOf<String>("#E6EE9C", "#455A64")),
arrayOf<String>("#FFF59D", "#37474F") Pair("color set 09",arrayOf<String>("#CFD8DC", "#455A64")),
) Pair("color set 10",arrayOf<String>("#FFF59D", "#37474F"))
)
val typesfacez : PairArray<Int> = arrayOf<Pair<String,Int>>(
Pair("정선 아리랑 혼", R.font.jsarirang_hon),
Pair("정선 아리랑 뿌리", R.font.jsarirang_ppuri),
Pair("정선 동강 레귤러", R.font.jsdongkang_regular),
Pair("손기정체", R.font.kcc_sonkeechung),
Pair("교보 손글씨", R.font.kyobo_handwriting_2021sjy),
Pair("태백 은하수", R.font.taebaek_milkyway),
)
@JvmName("getIndexAny")
fun PairArray<Any>.getIndex(key : String) = getIndex(this, key)
fun getIndex(collection : PairArray<Any>, key : String) : Int {
var index = 0
var returns = 0
for (item in collection) {
if(item.first.equals(key)) {
returns = index
}
index = index.inc()
}
return returns
}

View File

@ -11,10 +11,10 @@ import kotlin.reflect.KClass
object HistoryManager { object HistoryManager {
val clazz : Set<KClass<out BaseRealmObject>> = setOf(LastInfo::class, HistoryItem::class, ReaderConfig::class) val clazz : Set<KClass<out BaseRealmObject>> = setOf(LastInfo::class, HistoryItem::class, ReaderConfig::class)
val schemaVersion : Long = 1 val schemaVersion : Long = 3
fun openRealm() : Realm = Realm.open(RealmConfiguration.Builder(clazz) fun openRealm() : Realm = Realm.open(RealmConfiguration.Builder(clazz)
.schemaVersion(2) .schemaVersion(schemaVersion)
.build()) .build())
fun save(lastInfo: LastInfo) { fun save(lastInfo: LastInfo) {

View File

@ -9,6 +9,7 @@ class ReaderConfig() : RealmObject {
var textSize : Int? = 14 var textSize : Int? = 14
var textColor : String? = "#FFFFFF" var textColor : String? = "#FFFFFF"
var bgColor : String? = "#000000" var bgColor : String? = "#000000"
var style : Int? = 0
var lineSpace : Int? = 1 var lineSpace : Int? = 1
var letterSpace : Int? = 1 var letterSpace : Int? = 1
var font : String? = "" var font : String? = ""

View File

@ -1,99 +1,97 @@
package com.mime.dualscreenview.dialog //package com.mime.dualscreenview.dialog
//
import android.app.Dialog //import android.app.Dialog
import android.content.Context //import android.content.Context
import android.content.DialogInterface //import android.content.DialogInterface
import android.graphics.Color //import android.graphics.Color
import android.os.Bundle //import android.os.Bundle
import android.view.LayoutInflater //import android.view.LayoutInflater
import android.view.View //import android.view.View
import android.view.ViewGroup //import android.view.ViewGroup
import android.view.Window //import android.view.Window
import android.widget.TextView //import android.widget.TextView
import androidx.recyclerview.widget.GridLayoutManager //import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager //import androidx.recyclerview.widget.RecyclerView
import androidx.recyclerview.widget.RecyclerView //import com.mime.dualscreenview.R
import com.mime.dualscreenview.R //import kotlin.random.Random
import com.mime.dualscreenview.common.colorz //
import kotlin.random.Random //interface StyleSelectInterface {
// fun onSelectStyle(bgColor : String, textColor : String)
interface StyleSelectInterface { //}
fun onSelectStyle(bgColor : String, textColor : String) //class Stylez : Dialog {
} // constructor(context: Context) : super(context) {initView(context)}
class Stylez : Dialog { // constructor(context: Context, themeResId: Int) : super(context, themeResId) {initView(context)}
constructor(context: Context) : super(context) {initView(context)} // constructor(
constructor(context: Context, themeResId: Int) : super(context, themeResId) {initView(context)} // context: Context,
constructor( // cancelable: Boolean,
context: Context, // cancelListener: DialogInterface.OnCancelListener?
cancelable: Boolean, // ) : super(context, cancelable, cancelListener) {initView(context)}
cancelListener: DialogInterface.OnCancelListener? //
) : super(context, cancelable, cancelListener) {initView(context)} // var styleSelectInterface : StyleSelectInterface? = null
//
var styleSelectInterface : StyleSelectInterface? = null // fun initView(context: Context) {
//
fun initView(context: Context) { // }
//
} // override fun onCreate(savedInstanceState: Bundle?) {
// super.onCreate(savedInstanceState)
override fun onCreate(savedInstanceState: Bundle?) { // this.requestWindowFeature(Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState) // setCancelable(true)
this.requestWindowFeature(Window.FEATURE_NO_TITLE); // setContentView(R.layout.dialog_stylesz)
setCancelable(true) // val recyclerView: RecyclerView = findViewById(R.id.stylez_recyclerview)
setContentView(R.layout.dialog_stylesz) // val adapterRe = AdapterRe(context, colorz)
val recyclerView: RecyclerView = findViewById(R.id.stylez_recyclerview) // recyclerView.adapter = adapterRe
val adapterRe = AdapterRe(context, colorz) // recyclerView.layoutManager =
recyclerView.adapter = adapterRe // GridLayoutManager(context, 2, GridLayoutManager.VERTICAL, false)
recyclerView.layoutManager = // }
GridLayoutManager(context, 2, GridLayoutManager.VERTICAL, false) //
} // inner class AdapterRe(ctx: Context, myImageNameList: Array<Array<String>>) :
// RecyclerView.Adapter<StylezViewHolder>() {
inner class AdapterRe(ctx: Context, myImageNameList: Array<Array<String>>) : // private val inflater: LayoutInflater
RecyclerView.Adapter<StylezViewHolder>() { // private val myImageNameList: Array<Array<String>>
private val inflater: LayoutInflater // private val ctx : Context
private val myImageNameList: Array<Array<String>> // init {
private val ctx : Context // inflater = LayoutInflater.from(ctx)
init { // this.ctx = ctx
inflater = LayoutInflater.from(ctx) // this.myImageNameList = myImageNameList
this.ctx = ctx // }
this.myImageNameList = myImageNameList //
} // override fun onCreateViewHolder (
// parent: ViewGroup,
override fun onCreateViewHolder ( // viewType: Int
parent: ViewGroup, // ): StylezViewHolder {
viewType: Int // val view: View = inflater.inflate(R.layout.item_colorz, parent, false)
): StylezViewHolder { // return StylezViewHolder(view)
val view: View = inflater.inflate(R.layout.item_colorz, parent, false) // }
return StylezViewHolder(view) //
} // override fun onBindViewHolder(holder: StylezViewHolder, position: Int) {
// var colorz = myImageNameList.get(position)
override fun onBindViewHolder(holder: StylezViewHolder, position: Int) { // var sampleTextz = ctx.resources.getStringArray(R.array.sample_textz)
var colorz = myImageNameList.get(position) // holder?.setStyle(bgColor = colorz.get(1), textColor = colorz.get(0),sampleTextz.get(Random.nextInt(9876) % sampleTextz.size))
var sampleTextz = ctx.resources.getStringArray(R.array.sample_textz) // }
holder?.setStyle(bgColor = colorz.get(1), textColor = colorz.get(0),sampleTextz.get(Random.nextInt(9876) % sampleTextz.size)) //
} //
// override fun getItemCount(): Int {
// return myImageNameList.size
override fun getItemCount(): Int { // }
return myImageNameList.size //
} // }
//
} // inner class StylezViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
// var textView: TextView
inner class StylezViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) { // var bg : View
var textView: TextView // init {
var bg : View // textView = itemView.findViewById(R.id.textview_sample)
init { // bg = itemView.findViewById(R.id.bg_sample)
textView = itemView.findViewById(R.id.textview_sample) // }
bg = itemView.findViewById(R.id.bg_sample) // fun setStyle(bgColor : String, textColor : String, sampleText : String ) {
} // bg.setBackgroundColor(Color.parseColor(bgColor))
fun setStyle(bgColor : String, textColor : String, sampleText : String ) { // textView.setTextColor(Color.parseColor(textColor))
bg.setBackgroundColor(Color.parseColor(bgColor)) // textView.text = sampleText
textView.setTextColor(Color.parseColor(textColor)) // itemView?.setOnClickListener { v ->
textView.text = sampleText // styleSelectInterface?.onSelectStyle(bgColor,textColor)
itemView?.setOnClickListener { v -> // dismiss()
styleSelectInterface?.onSelectStyle(bgColor,textColor) // }
dismiss() // }
} // }
} //}
}
}

View File

@ -0,0 +1,62 @@
package com.mime.dualscreenview.view
import android.content.Context
import android.util.AttributeSet
import com.mime.dualscreenview.R
import kotlinx.android.synthetic.main.layout_steps_editor.view.btn_decrement
import kotlinx.android.synthetic.main.layout_steps_editor.view.btn_increment
import kotlinx.android.synthetic.main.layout_steps_editor.view.text_value
class ScopeEditor: SideButtonTextView {
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 titleArray : Array<String>? = null
set(value) {
if(value != null && value.size < 1) {
Error("titleArray는 최소 한개 이상이여야됨.")
return
}
field = value
maxValue = field!!.size
}
var maxValue : Int = 1
set(value) {
if (value < 1) {
Error("maxValue는 무조건 0보다 커야하눈뎅....")
return
}
field = value
}
override var value : Int = 14
set(newValue) {
field = newValue
text_value.text = displayFormat.format(titleArray?.get(field) ?:"defulat")
mValueChange?.invoke(field)
}
constructor(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
) : super(context, attrs, defStyleAttr, defStyleRes)
init {
inflate(context, R.layout.layout_steps_editor,this)
btn_decrement.setOnClickListener { value = Math.abs(value.dec()).rem(maxValue) }
btn_increment.setOnClickListener { value = value.inc().rem(maxValue) }
leftButtonTitle = "<"
rightButtonTitle = ">"
}
}

View File

@ -0,0 +1,70 @@
package com.mime.dualscreenview.view
import android.content.Context
import android.util.AttributeSet
import androidx.constraintlayout.widget.ConstraintLayout
import com.mime.dualscreenview.R
import kotlinx.android.synthetic.main.layout_steps_editor.view.btn_decrement
import kotlinx.android.synthetic.main.layout_steps_editor.view.btn_increment
import kotlinx.android.synthetic.main.layout_steps_editor.view.text_value
import java.lang.Exception
open class SideButtonTextView : ConstraintLayout {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr
)
constructor(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
) : super(context, attrs, defStyleAttr, defStyleRes)
var leftButtonTitle : String = ""
set(value) {
field = value
btn_decrement.text = field
}
var rightButtonTitle : String = ""
set(value) {
field = value
btn_increment.text = field
}
open var value : Int = 14
set(newValue) {
field = newValue
text_value.text = displayFormat.format(field)
mValueChange?.invoke(field)
}
var displayFormat = "글자 크기 : %d"
set(newValue) {
field = newValue
try {
text_value.text = displayFormat.format(value)
} catch (e : Exception) {
}
}
var mValueChange : ValueChange? = null
set(newValue) {
field = newValue
if (newValue != null) {
newValue(value)
}
}
init {
// inflate(context, R.layout.layout_steps_editor,this)
// btn_decrement.setOnClickListener { value = value.dec() }
// btn_increment.setOnClickListener { value = value.inc() }
}
}

View File

@ -11,7 +11,7 @@ import java.lang.Exception
typealias ValueChange = (Int)->Unit typealias ValueChange = (Int)->Unit
class StepsEditor : ConstraintLayout { class StepsEditor : SideButtonTextView {
constructor(context: Context) : super(context) constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super( constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
@ -27,33 +27,11 @@ class StepsEditor : ConstraintLayout {
defStyleRes: Int defStyleRes: Int
) : super(context, attrs, defStyleAttr, defStyleRes) ) : super(context, attrs, defStyleAttr, defStyleRes)
var value : Int = 14
set(newValue) {
field = newValue
text_value.text = displayFormat.format(field)
mValueChange?.invoke(field)
}
var displayFormat = "글자 크기 : %d"
set(newValue) {
field = newValue
try {
text_value.text = displayFormat.format(value)
} catch (e : Exception) {
}
}
var mValueChange : ValueChange? = null
set(newValue) {
field = newValue
if (newValue != null) {
newValue(value)
}
}
init { init {
inflate(context, R.layout.layout_steps_editor,this) inflate(context, R.layout.layout_steps_editor,this)
btn_decrement.setOnClickListener { value = value.dec() } btn_decrement.setOnClickListener { value = value.dec() }
btn_increment.setOnClickListener { value = value.inc() } btn_increment.setOnClickListener { value = value.inc() }
leftButtonTitle = "-"
rightButtonTitle = "+"
} }
} }

View File

@ -2,8 +2,10 @@ package com.mime.dualscreenview.webcontents
import android.app.AlertDialog import android.app.AlertDialog
import android.graphics.Bitmap import android.graphics.Bitmap
import android.net.http.SslError
import android.util.Log import android.util.Log
import android.webkit.* import android.webkit.*
import com.mime.dualscreenview.common.Blog
import com.mime.dualscreenview.data.model.LastInfo import com.mime.dualscreenview.data.model.LastInfo
import com.mime.dualscreenview.webcontents.contentsinfo.DidFindContents import com.mime.dualscreenview.webcontents.contentsinfo.DidFindContents
@ -119,21 +121,23 @@ open class BaseWebContentsViewer {
// //
// } // }
// //
// override fun onReceivedSslError( override fun onReceivedSslError(
// view: WebView?, view: WebView?,
// handler: SslErrorHandler?, handler: SslErrorHandler?,
// error: SslError? error: SslError?
// ) { ) {
//// super.onReceivedSslError(view, handler, error) // super.onReceivedSslError(view, handler, error)
// handler?.proceed() Blog.LOGE(log= "onReceivedSslError >> ${error}")
// } handler?.proceed()
// override fun onReceivedHttpError( }
// view: WebView?, override fun onReceivedHttpError(
// request: WebResourceRequest?, view: WebView?,
// errorResponse: WebResourceResponse? request: WebResourceRequest?,
// ) { errorResponse: WebResourceResponse?
) {
Blog.LOGE(log= "onReceivedHttpError >> ${errorResponse}")
// super.onReceivedHttpError(view, request, errorResponse) // super.onReceivedHttpError(view, request, errorResponse)
// } }
override fun onPageFinished(view: WebView?, url: String?) { override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url) super.onPageFinished(view, url)

View File

@ -4,7 +4,7 @@ import com.mime.dualscreenview.webcontents.BaseWebContents
object Booktoki : BaseWebContents() { object Booktoki : BaseWebContents() {
override var lastNumber : Int = 222 override var lastNumber : Int = 283
override fun getWebcontentsName(): String { override fun getWebcontentsName(): String {
return "Booktoki" return "Booktoki"

View File

@ -15,7 +15,7 @@
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toTopOf="@id/btn_left" app:layout_constraintBottom_toTopOf="@id/btn_left"
app:layout_constraintTop_toBottomOf="@id/textView" /> app:layout_constraintTop_toBottomOf="@id/textview_title" />
<com.mime.dualscreenview.view.PagedTextLayout <com.mime.dualscreenview.view.PagedTextLayout
@ -28,7 +28,7 @@
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toTopOf="@id/btn_setting" app:layout_constraintBottom_toTopOf="@id/btn_setting"
app:layout_constraintTop_toBottomOf="@id/textView" /> app:layout_constraintTop_toBottomOf="@id/textview_title" />
<ImageButton <ImageButton
android:id="@+id/btn_home" android:id="@+id/btn_home"
@ -38,14 +38,14 @@
android:scaleType="centerInside" android:scaleType="centerInside"
android:background="#8FFF" android:background="#8FFF"
android:src="@drawable/home" android:src="@drawable/home"
app:layout_constraintRight_toLeftOf="@id/textView" app:layout_constraintRight_toLeftOf="@id/textview_title"
app:layout_constraintHorizontal_chainStyle="spread_inside" app:layout_constraintHorizontal_chainStyle="spread_inside"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
tools:ignore="MissingConstraints" /> tools:ignore="MissingConstraints" />
<TextView <TextView
android:id="@+id/textView" android:id="@+id/textview_title"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="@dimen/main_top_height" android:layout_height="@dimen/main_top_height"
android:text="@string/app_name" android:text="@string/app_name"
@ -65,7 +65,7 @@
android:background="#8FFF" android:background="#8FFF"
android:src="@drawable/invoice" android:src="@drawable/invoice"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toRightOf="@id/textView" app:layout_constraintLeft_toRightOf="@id/textview_title"
app:layout_constraintRight_toLeftOf="@+id/btn_rotate" app:layout_constraintRight_toLeftOf="@+id/btn_rotate"
app:layout_constraintHorizontal_chainStyle="spread_inside" app:layout_constraintHorizontal_chainStyle="spread_inside"
/> />

View File

@ -44,6 +44,12 @@
<com.mime.dualscreenview.view.StepsEditor <com.mime.dualscreenview.view.StepsEditor
android:id="@+id/page_padding" android:id="@+id/page_padding"
style="@style/StepsEditorStyle" /> style="@style/StepsEditorStyle" />
<com.mime.dualscreenview.view.ScopeEditor
android:id="@+id/page_typesface"
style="@style/StepsEditorStyle" />
<com.mime.dualscreenview.view.ScopeEditor
android:id="@+id/page_style"
style="@style/StepsEditorStyle" />
</LinearLayout> </LinearLayout>
</ScrollView> </ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>