.
This commit is contained in:
parent
271e0c66dc
commit
ae743bf784
@ -6,31 +6,36 @@ import android.content.DialogInterface
|
||||
import android.content.Intent
|
||||
import android.content.pm.ActivityInfo
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.Color
|
||||
import android.hardware.display.DisplayManager
|
||||
import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Message
|
||||
import android.text.InputType
|
||||
import android.util.Log
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.View.*
|
||||
import android.webkit.WebView
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.EditText
|
||||
import android.widget.ImageButton
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.appcompat.widget.AppCompatButton
|
||||
import com.google.gson.Gson
|
||||
import com.lge.display.DisplayManagerHelper
|
||||
import com.mime.dualscreenview.R
|
||||
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.dialog.StyleSelectInterface
|
||||
import com.mime.dualscreenview.dialog.Stylez
|
||||
import com.mime.dualscreenview.data.model.BookPageInfo
|
||||
import com.mime.dualscreenview.data.model.BookPageInfos
|
||||
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.query
|
||||
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.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
@ -181,15 +188,15 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
|
||||
super.onResume()
|
||||
var realm = HistoryManager.openRealm()
|
||||
realm.query<ReaderConfig>()?.find()?.let {
|
||||
if (it.size > 0) {
|
||||
realm.copyFromRealm(it.first())?.let {
|
||||
var msg = handle.obtainMessage()
|
||||
msg.what = 0
|
||||
msg.obj = it
|
||||
handle.sendMessageDelayed(msg, 200)
|
||||
}
|
||||
if (it.size > 0) {
|
||||
realm.copyFromRealm(it.first())?.let {
|
||||
var msg = handle.obtainMessage()
|
||||
msg.what = 0
|
||||
msg.obj = it
|
||||
handle.sendMessageDelayed(msg, 200)
|
||||
}
|
||||
}
|
||||
}
|
||||
realm.close()
|
||||
reloadLastInfo()
|
||||
reloadTo(lastInfo)
|
||||
@ -234,7 +241,7 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
|
||||
dialog, which ->
|
||||
var realm = openRealm()
|
||||
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)
|
||||
}
|
||||
}
|
||||
@ -267,416 +274,439 @@ class Intro : Base() , MainControllInterface, PagedTextViewInterface {
|
||||
}
|
||||
|
||||
private fun moveTo(item: BookPageInfo?) {
|
||||
item?.link?.let {newPath ->
|
||||
mBaseWebContentsViewer?.webview?.url?.let{currentUrl ->
|
||||
item?.link?.let { newPath ->
|
||||
mBaseWebContentsViewer?.webview?.url?.let { currentUrl ->
|
||||
Uri.parse(currentUrl)?.lastPathSegment?.let {
|
||||
currentUrl.replace(it,newPath)?.let {
|
||||
currentUrl.replace(it, newPath)?.let {
|
||||
mBaseWebContentsViewer?.webview?.loadUrl(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
fun showStyleList() {
|
||||
var mStylez = Stylez(this@Intro)
|
||||
mStylez.styleSelectInterface = object : StyleSelectInterface {
|
||||
override fun onSelectStyle(bgColor: String, textColor: String) {
|
||||
paged_layer?.setColorStyle(arrayOf(textColor,bgColor))
|
||||
// fun showStyleList() {
|
||||
// var mStylez = Stylez(this@Intro)
|
||||
// mStylez.styleSelectInterface = object : StyleSelectInterface {
|
||||
// override fun onSelectStyle(bgColor: String, textColor: String) {
|
||||
// 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() {
|
||||
// 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"
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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()
|
||||
)
|
||||
/**
|
||||
* 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"
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(this, "Not found the second screen", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
|
||||
private inner class MainCoverDisplayCallback : DisplayManagerHelper.CoverDisplayCallback() {
|
||||
override fun onCoverDisplayEnabledChangedCallback(state: Int) {
|
||||
displayManagerHelper?.coverDisplayState?.let {
|
||||
Log.i(TAG, "Current DualScreen Callback state: ${coverDisplayStateToString(it)}")
|
||||
/**
|
||||
* 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()
|
||||
}
|
||||
if (prevDualScreenState != state) {
|
||||
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 -> {
|
||||
}
|
||||
|
||||
private inner class MainCoverDisplayCallback : DisplayManagerHelper.CoverDisplayCallback() {
|
||||
override fun onCoverDisplayEnabledChangedCallback(state: Int) {
|
||||
displayManagerHelper?.coverDisplayState?.let {
|
||||
Log.i(TAG, "Current DualScreen Callback state: ${coverDisplayStateToString(it)}")
|
||||
}
|
||||
if (prevDualScreenState != state) {
|
||||
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()
|
||||
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() {
|
||||
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")
|
||||
var onNextClickAction: GotoSomeWhere? = null
|
||||
override fun showNextBtn(find : Boolean , onClickAction: GotoSomeWhere) {
|
||||
onNextClickAction = onClickAction
|
||||
findViewById<AppCompatButton>(R.id.btn_right)?.let{
|
||||
it.text = "다음 페이지"
|
||||
it.setOnClickListener {
|
||||
actionNextEvent()
|
||||
}
|
||||
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")
|
||||
it.visibility= if(find) VISIBLE else GONE
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
onNextClickAction = onClickAction
|
||||
findViewById<AppCompatButton>(R.id.btn_right)?.let{
|
||||
it.text = "다음 페이지"
|
||||
it.setOnClickListener {
|
||||
actionNextEvent()
|
||||
|
||||
fun actionPrevEvent() {
|
||||
if (paged_layer != null && paged_layer!!.visibility == View.VISIBLE && paged_layer!!.size() > 0 && paged_layer!!.current() > 0 ) {
|
||||
paged_layer!!.doPrev()
|
||||
updateLastInfo(paged_layer!!)
|
||||
} else {
|
||||
onPrevClickAction?.let{ it() }
|
||||
}
|
||||
it.visibility= if(find) VISIBLE else GONE
|
||||
}
|
||||
}
|
||||
|
||||
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() }
|
||||
}
|
||||
}
|
||||
override fun onBackPressed() {
|
||||
var layer = findViewById<PagedTextLayout>(R.id.paged_layer)
|
||||
|
||||
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()
|
||||
if (!didBackPress) {
|
||||
firstBackPress()
|
||||
return
|
||||
}
|
||||
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 (paged_layer != null && paged_layer!!.visibility == View.VISIBLE && paged_layer!!.size() > 0 && paged_layer!!.current() > 0 ) {
|
||||
paged_layer!!.doPrev()
|
||||
updateLastInfo(paged_layer!!)
|
||||
} else {
|
||||
onPrevClickAction?.let{ it() }
|
||||
}
|
||||
}
|
||||
if (mBaseWebContentsViewer.webview.canGoBack()) {
|
||||
mBaseWebContentsViewer.webview.goBack()
|
||||
return
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
var layer = findViewById<PagedTextLayout>(R.id.paged_layer)
|
||||
|
||||
if (!didBackPress) {
|
||||
firstBackPress()
|
||||
return
|
||||
}
|
||||
|
||||
if (layer != null && layer.visibility == View.VISIBLE) {
|
||||
if (!didBackPress) {
|
||||
firstBackPress()
|
||||
return
|
||||
}
|
||||
finish()
|
||||
didBackPress = false
|
||||
layer.visibility = GONE
|
||||
onTouch(TouchArea.Center)
|
||||
return
|
||||
}
|
||||
|
||||
if (mBaseWebContentsViewer.webview.canGoBack()) {
|
||||
mBaseWebContentsViewer.webview.goBack()
|
||||
return
|
||||
|
||||
override fun showAlert(alert: String) {
|
||||
Log.i(TAG,"showAlert >> " + alert)
|
||||
}
|
||||
|
||||
if (!didBackPress) {
|
||||
firstBackPress()
|
||||
return
|
||||
}
|
||||
finish()
|
||||
didBackPress = false
|
||||
}
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
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)
|
||||
|
||||
|
||||
override fun showAlert(alert: String) {
|
||||
Log.i(TAG,"showAlert >> " + alert)
|
||||
}
|
||||
|
||||
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)
|
||||
var typeface = typesfacez.get(getIndex(typesfacez as PairArray<Any>,it.font ?: ""))
|
||||
paged_layer?.setTypeface(resources.getFont(typeface.second))
|
||||
val color = colorz.get(it.style ?: 0)
|
||||
paged_layer?.setColorStyle(color.second)
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
|
||||
|
||||
|
||||
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)
|
||||
override fun onFindTitle(contents: String) {
|
||||
textview_title.text = contents
|
||||
textview_title.setOnClickListener {
|
||||
val builder = AlertDialog.Builder(this)
|
||||
builder.setTitle("Title")
|
||||
val input = EditText(this)
|
||||
input.setText(mBaseWebContentsViewer?.webview?.url ?: "")
|
||||
input.inputType = InputType.TYPE_CLASS_TEXT
|
||||
builder.setView(input)
|
||||
builder.setPositiveButton(
|
||||
"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()
|
||||
}
|
||||
}
|
||||
Log.i(TAG,"onLoadedContents >> " + contents)
|
||||
}
|
||||
|
||||
var currentTitle : String = ""
|
||||
var currentChapter : Int = 0
|
||||
|
||||
override fun onFindTitle(contents: String) {
|
||||
findViewById<TextView>(R.id.textView).text = contents
|
||||
var testRegex = """[^0-9]""".toRegex();
|
||||
Blog.LOGI(TAG,"onFindTitle >> " + contents + " ::: ${testRegex.replace(contents,"")}")
|
||||
if(contents.contains("-")) {
|
||||
currentTitle = contents.split("-")[0]
|
||||
try {
|
||||
currentChapter = testRegex.replace(contents.split("-")[1],"").toInt()
|
||||
} catch (e : Exception) {
|
||||
currentChapter = 0
|
||||
var testRegex = """[^0-9]""".toRegex();
|
||||
Blog.LOGI(TAG,"onFindTitle >> " + contents + " ::: ${testRegex.replace(contents,"")}")
|
||||
if(contents.contains("-")) {
|
||||
currentTitle = contents.split("-")[0]
|
||||
try {
|
||||
currentChapter = testRegex.replace(contents.split("-")[1],"").toInt()
|
||||
} catch (e : Exception) {
|
||||
currentChapter = 0
|
||||
}
|
||||
} 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)
|
||||
}
|
||||
} 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 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)
|
||||
override fun onStartLoad() {
|
||||
findViewById<ProgressBar>(R.id.progress).visibility = VISIBLE
|
||||
}
|
||||
findViewById<ProgressBar>(R.id.progress).visibility = GONE
|
||||
}
|
||||
|
||||
fun saveLastInfo(lastInfo: LastInfo) {
|
||||
val realm = openRealm()
|
||||
if((realm.query<LastInfo>()?.count()?.find() ?: 0) > 0) {
|
||||
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) {
|
||||
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 {
|
||||
this.query<LastInfo>()?.find()?.last()?.let{
|
||||
it.pageUrl = lastInfo.pageUrl
|
||||
it.displayOrientation = configuration.orientation
|
||||
it.title = currentTitle
|
||||
it.chapter = currentChapter
|
||||
it.pageIndex = lastInfo.pageIndex
|
||||
it.contentsName = lastInfo.contentsName
|
||||
it.displayOrientation = lastInfo.displayOrientation
|
||||
it.pageIndex = pagedTextLayout.current()
|
||||
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 {
|
||||
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)
|
||||
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}")
|
||||
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()}
|
||||
override fun onTouch(touchArea: TouchArea) {
|
||||
Blog.LOGD(log="onTouch")
|
||||
when (touchArea) {
|
||||
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
|
||||
|
||||
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) {
|
||||
Blog.LOGD(log="onTouch")
|
||||
when (touchArea) {
|
||||
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
|
||||
override fun onSwipeLeft() {
|
||||
Blog.LOGD(log="onSwipeLeft")
|
||||
actionNextEvent()
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
TouchArea.Right -> {
|
||||
actionNextEvent()
|
||||
}
|
||||
TouchArea.Left-> {
|
||||
actionPrevEvent()
|
||||
}
|
||||
else -> {
|
||||
|
||||
}
|
||||
override fun onSwipeRight() {
|
||||
Blog.LOGD(log="onSwipeRight")
|
||||
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
|
||||
|
||||
textview_title.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"
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSwipeLeft() {
|
||||
Blog.LOGD(log="onSwipeLeft")
|
||||
actionNextEvent()
|
||||
|
||||
}
|
||||
|
||||
override fun onSwipeRight() {
|
||||
Blog.LOGD(log="onSwipeRight")
|
||||
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"
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,14 @@
|
||||
package com.mime.dualscreenview.activity
|
||||
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import androidx.annotation.RequiresApi
|
||||
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.model.ReaderConfig
|
||||
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.line_space
|
||||
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.text_size
|
||||
|
||||
@ -32,6 +41,7 @@ class Settings : Base() {
|
||||
realm.close()
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.O)
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
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() {
|
||||
var realm = HistoryManager.openRealm()
|
||||
realm.writeBlocking {
|
||||
copyToRealm(readerConfig!!, UpdatePolicy.ALL)
|
||||
}
|
||||
copyToRealm(readerConfig!!, UpdatePolicy.ALL)
|
||||
}
|
||||
realm.close()
|
||||
}
|
||||
}
|
||||
@ -1,15 +1,39 @@
|
||||
package com.mime.dualscreenview.common
|
||||
|
||||
import com.mime.dualscreenview.R
|
||||
|
||||
val colorz = arrayOf<Array<String>>(
|
||||
arrayOf<String>("#E1F5FE", "#263238"),
|
||||
arrayOf<String>("#F0F4C3", "#37474F"),
|
||||
arrayOf<String>("#ECEFF1", "#455A64"),
|
||||
arrayOf<String>("#E0F7FA", "#263238"),
|
||||
arrayOf<String>("#F5F5F5", "#263238"),
|
||||
arrayOf<String>("#ECEFF1", "#263238"),
|
||||
arrayOf<String>("#F8BBD0", "#263238"),
|
||||
arrayOf<String>("#E6EE9C", "#455A64"),
|
||||
arrayOf<String>("#CFD8DC", "#455A64"),
|
||||
arrayOf<String>("#FFF59D", "#37474F")
|
||||
typealias PairArray<T> = Array<Pair<String,T>>
|
||||
val colorz : PairArray<Array<String>> = arrayOf<Pair<String,Array<String>>>(
|
||||
Pair("color set 01",arrayOf<String>("#E1F5FE", "#263238")),
|
||||
Pair("color set 02",arrayOf<String>("#F0F4C3", "#37474F")),
|
||||
Pair("color set 03",arrayOf<String>("#ECEFF1", "#455A64")),
|
||||
Pair("color set 04",arrayOf<String>("#E0F7FA", "#263238")),
|
||||
Pair("color set 05",arrayOf<String>("#F5F5F5", "#263238")),
|
||||
Pair("color set 06",arrayOf<String>("#ECEFF1", "#263238")),
|
||||
Pair("color set 07",arrayOf<String>("#F8BBD0", "#263238")),
|
||||
Pair("color set 08",arrayOf<String>("#E6EE9C", "#455A64")),
|
||||
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
|
||||
}
|
||||
@ -11,10 +11,10 @@ import kotlin.reflect.KClass
|
||||
|
||||
object HistoryManager {
|
||||
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)
|
||||
.schemaVersion(2)
|
||||
.schemaVersion(schemaVersion)
|
||||
.build())
|
||||
|
||||
fun save(lastInfo: LastInfo) {
|
||||
|
||||
@ -9,6 +9,7 @@ class ReaderConfig() : RealmObject {
|
||||
var textSize : Int? = 14
|
||||
var textColor : String? = "#FFFFFF"
|
||||
var bgColor : String? = "#000000"
|
||||
var style : Int? = 0
|
||||
var lineSpace : Int? = 1
|
||||
var letterSpace : Int? = 1
|
||||
var font : String? = ""
|
||||
|
||||
@ -1,99 +1,97 @@
|
||||
package com.mime.dualscreenview.dialog
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.content.DialogInterface
|
||||
import android.graphics.Color
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.Window
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.mime.dualscreenview.R
|
||||
import com.mime.dualscreenview.common.colorz
|
||||
import kotlin.random.Random
|
||||
|
||||
interface StyleSelectInterface {
|
||||
fun onSelectStyle(bgColor : String, textColor : String)
|
||||
}
|
||||
class Stylez : Dialog {
|
||||
constructor(context: Context) : super(context) {initView(context)}
|
||||
constructor(context: Context, themeResId: Int) : super(context, themeResId) {initView(context)}
|
||||
constructor(
|
||||
context: Context,
|
||||
cancelable: Boolean,
|
||||
cancelListener: DialogInterface.OnCancelListener?
|
||||
) : super(context, cancelable, cancelListener) {initView(context)}
|
||||
|
||||
var styleSelectInterface : StyleSelectInterface? = null
|
||||
|
||||
fun initView(context: Context) {
|
||||
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
setCancelable(true)
|
||||
setContentView(R.layout.dialog_stylesz)
|
||||
val recyclerView: RecyclerView = findViewById(R.id.stylez_recyclerview)
|
||||
val adapterRe = AdapterRe(context, colorz)
|
||||
recyclerView.adapter = adapterRe
|
||||
recyclerView.layoutManager =
|
||||
GridLayoutManager(context, 2, GridLayoutManager.VERTICAL, false)
|
||||
}
|
||||
|
||||
inner class AdapterRe(ctx: Context, myImageNameList: Array<Array<String>>) :
|
||||
RecyclerView.Adapter<StylezViewHolder>() {
|
||||
private val inflater: LayoutInflater
|
||||
private val myImageNameList: Array<Array<String>>
|
||||
private val ctx : Context
|
||||
init {
|
||||
inflater = LayoutInflater.from(ctx)
|
||||
this.ctx = ctx
|
||||
this.myImageNameList = myImageNameList
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder (
|
||||
parent: ViewGroup,
|
||||
viewType: Int
|
||||
): StylezViewHolder {
|
||||
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)
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inner class StylezViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
var textView: TextView
|
||||
var bg : View
|
||||
init {
|
||||
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))
|
||||
textView.setTextColor(Color.parseColor(textColor))
|
||||
textView.text = sampleText
|
||||
itemView?.setOnClickListener { v ->
|
||||
styleSelectInterface?.onSelectStyle(bgColor,textColor)
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.mime.dualscreenview.dialog
|
||||
//
|
||||
//import android.app.Dialog
|
||||
//import android.content.Context
|
||||
//import android.content.DialogInterface
|
||||
//import android.graphics.Color
|
||||
//import android.os.Bundle
|
||||
//import android.view.LayoutInflater
|
||||
//import android.view.View
|
||||
//import android.view.ViewGroup
|
||||
//import android.view.Window
|
||||
//import android.widget.TextView
|
||||
//import androidx.recyclerview.widget.GridLayoutManager
|
||||
//import androidx.recyclerview.widget.RecyclerView
|
||||
//import com.mime.dualscreenview.R
|
||||
//import kotlin.random.Random
|
||||
//
|
||||
//interface StyleSelectInterface {
|
||||
// fun onSelectStyle(bgColor : String, textColor : String)
|
||||
//}
|
||||
//class Stylez : Dialog {
|
||||
// constructor(context: Context) : super(context) {initView(context)}
|
||||
// constructor(context: Context, themeResId: Int) : super(context, themeResId) {initView(context)}
|
||||
// constructor(
|
||||
// context: Context,
|
||||
// cancelable: Boolean,
|
||||
// cancelListener: DialogInterface.OnCancelListener?
|
||||
// ) : super(context, cancelable, cancelListener) {initView(context)}
|
||||
//
|
||||
// var styleSelectInterface : StyleSelectInterface? = null
|
||||
//
|
||||
// fun initView(context: Context) {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// override fun onCreate(savedInstanceState: Bundle?) {
|
||||
// super.onCreate(savedInstanceState)
|
||||
// this.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
// setCancelable(true)
|
||||
// setContentView(R.layout.dialog_stylesz)
|
||||
// val recyclerView: RecyclerView = findViewById(R.id.stylez_recyclerview)
|
||||
// val adapterRe = AdapterRe(context, colorz)
|
||||
// recyclerView.adapter = adapterRe
|
||||
// recyclerView.layoutManager =
|
||||
// GridLayoutManager(context, 2, GridLayoutManager.VERTICAL, false)
|
||||
// }
|
||||
//
|
||||
// inner class AdapterRe(ctx: Context, myImageNameList: Array<Array<String>>) :
|
||||
// RecyclerView.Adapter<StylezViewHolder>() {
|
||||
// private val inflater: LayoutInflater
|
||||
// private val myImageNameList: Array<Array<String>>
|
||||
// private val ctx : Context
|
||||
// init {
|
||||
// inflater = LayoutInflater.from(ctx)
|
||||
// this.ctx = ctx
|
||||
// this.myImageNameList = myImageNameList
|
||||
// }
|
||||
//
|
||||
// override fun onCreateViewHolder (
|
||||
// parent: ViewGroup,
|
||||
// viewType: Int
|
||||
// ): StylezViewHolder {
|
||||
// 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)
|
||||
// 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
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// inner class StylezViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
// var textView: TextView
|
||||
// var bg : View
|
||||
// init {
|
||||
// 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))
|
||||
// textView.setTextColor(Color.parseColor(textColor))
|
||||
// textView.text = sampleText
|
||||
// itemView?.setOnClickListener { v ->
|
||||
// styleSelectInterface?.onSelectStyle(bgColor,textColor)
|
||||
// dismiss()
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@ -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 = ">"
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -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() }
|
||||
}
|
||||
}
|
||||
@ -11,7 +11,7 @@ import java.lang.Exception
|
||||
|
||||
typealias ValueChange = (Int)->Unit
|
||||
|
||||
class StepsEditor : ConstraintLayout {
|
||||
class StepsEditor : SideButtonTextView {
|
||||
constructor(context: Context) : super(context)
|
||||
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(
|
||||
@ -27,33 +27,11 @@ class StepsEditor : ConstraintLayout {
|
||||
defStyleRes: Int
|
||||
) : 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 {
|
||||
inflate(context, R.layout.layout_steps_editor,this)
|
||||
btn_decrement.setOnClickListener { value = value.dec() }
|
||||
btn_increment.setOnClickListener { value = value.inc() }
|
||||
leftButtonTitle = "-"
|
||||
rightButtonTitle = "+"
|
||||
}
|
||||
}
|
||||
@ -2,8 +2,10 @@ package com.mime.dualscreenview.webcontents
|
||||
|
||||
import android.app.AlertDialog
|
||||
import android.graphics.Bitmap
|
||||
import android.net.http.SslError
|
||||
import android.util.Log
|
||||
import android.webkit.*
|
||||
import com.mime.dualscreenview.common.Blog
|
||||
import com.mime.dualscreenview.data.model.LastInfo
|
||||
import com.mime.dualscreenview.webcontents.contentsinfo.DidFindContents
|
||||
|
||||
@ -119,21 +121,23 @@ open class BaseWebContentsViewer {
|
||||
//
|
||||
// }
|
||||
//
|
||||
// override fun onReceivedSslError(
|
||||
// view: WebView?,
|
||||
// handler: SslErrorHandler?,
|
||||
// error: SslError?
|
||||
// ) {
|
||||
//// super.onReceivedSslError(view, handler, error)
|
||||
// handler?.proceed()
|
||||
// }
|
||||
// override fun onReceivedHttpError(
|
||||
// view: WebView?,
|
||||
// request: WebResourceRequest?,
|
||||
// errorResponse: WebResourceResponse?
|
||||
// ) {
|
||||
override fun onReceivedSslError(
|
||||
view: WebView?,
|
||||
handler: SslErrorHandler?,
|
||||
error: SslError?
|
||||
) {
|
||||
// super.onReceivedSslError(view, handler, error)
|
||||
Blog.LOGE(log= "onReceivedSslError >> ${error}")
|
||||
handler?.proceed()
|
||||
}
|
||||
override fun onReceivedHttpError(
|
||||
view: WebView?,
|
||||
request: WebResourceRequest?,
|
||||
errorResponse: WebResourceResponse?
|
||||
) {
|
||||
Blog.LOGE(log= "onReceivedHttpError >> ${errorResponse}")
|
||||
// super.onReceivedHttpError(view, request, errorResponse)
|
||||
// }
|
||||
}
|
||||
|
||||
override fun onPageFinished(view: WebView?, url: String?) {
|
||||
super.onPageFinished(view, url)
|
||||
|
||||
@ -4,7 +4,7 @@ import com.mime.dualscreenview.webcontents.BaseWebContents
|
||||
|
||||
object Booktoki : BaseWebContents() {
|
||||
|
||||
override var lastNumber : Int = 222
|
||||
override var lastNumber : Int = 283
|
||||
|
||||
override fun getWebcontentsName(): String {
|
||||
return "Booktoki"
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
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
|
||||
@ -28,7 +28,7 @@
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintBottom_toTopOf="@id/btn_setting"
|
||||
app:layout_constraintTop_toBottomOf="@id/textView" />
|
||||
app:layout_constraintTop_toBottomOf="@id/textview_title" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/btn_home"
|
||||
@ -38,14 +38,14 @@
|
||||
android:scaleType="centerInside"
|
||||
android:background="#8FFF"
|
||||
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_constraintStart_toStartOf="parent"
|
||||
tools:ignore="MissingConstraints" />
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView"
|
||||
android:id="@+id/textview_title"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/main_top_height"
|
||||
android:text="@string/app_name"
|
||||
@ -65,7 +65,7 @@
|
||||
android:background="#8FFF"
|
||||
android:src="@drawable/invoice"
|
||||
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_constraintHorizontal_chainStyle="spread_inside"
|
||||
/>
|
||||
|
||||
@ -44,6 +44,12 @@
|
||||
<com.mime.dualscreenview.view.StepsEditor
|
||||
android:id="@+id/page_padding"
|
||||
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>
|
||||
</ScrollView>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Loading…
x
Reference in New Issue
Block a user