add Print support at the daily view
This commit is contained in:
parent
0cb88a1405
commit
bc8c9fd1f6
|
@ -30,6 +30,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
|
|||
private val allDayString = resources.getString(R.string.all_day)
|
||||
private val replaceDescriptionWithLocation = activity.config.replaceDescription
|
||||
private val dimPastEvents = activity.config.dimPastEvents
|
||||
private var isPrintVersion = false
|
||||
|
||||
init {
|
||||
setupDragListener(true)
|
||||
|
@ -96,6 +97,16 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
|
|||
}
|
||||
}
|
||||
|
||||
fun togglePrintMode() {
|
||||
isPrintVersion = !isPrintVersion
|
||||
textColor = if (isPrintVersion) {
|
||||
resources.getColor(R.color.theme_light_text_color)
|
||||
} else {
|
||||
baseConfig.textColor
|
||||
}
|
||||
notifyDataSetChanged()
|
||||
}
|
||||
|
||||
private fun setupView(view: View, event: Event) {
|
||||
view.apply {
|
||||
event_item_frame.isSelected = selectedKeys.contains(event.id?.toInt())
|
||||
|
@ -124,7 +135,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
|
|||
}
|
||||
|
||||
var newTextColor = textColor
|
||||
if (dimPastEvents && event.isPastEvent) {
|
||||
if (dimPastEvents && event.isPastEvent && !isPrintVersion) {
|
||||
newTextColor = newTextColor.adjustAlpha(LOW_ALPHA)
|
||||
}
|
||||
|
||||
|
|
|
@ -33,4 +33,8 @@ class MyDayPagerAdapter(fm: FragmentManager, private val mCodes: List<String>, p
|
|||
mFragments[pos + i]?.updateCalendar()
|
||||
}
|
||||
}
|
||||
|
||||
fun printCurrentView(pos: Int) {
|
||||
mFragments[pos].printCurrentView()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ import com.simplemobiletools.calendar.pro.activities.SimpleActivity
|
|||
import com.simplemobiletools.calendar.pro.adapters.DayEventsAdapter
|
||||
import com.simplemobiletools.calendar.pro.extensions.config
|
||||
import com.simplemobiletools.calendar.pro.extensions.eventsHelper
|
||||
import com.simplemobiletools.calendar.pro.extensions.getViewBitmap
|
||||
import com.simplemobiletools.calendar.pro.extensions.printBitmap
|
||||
import com.simplemobiletools.calendar.pro.helpers.DAY_CODE
|
||||
import com.simplemobiletools.calendar.pro.helpers.EVENT_ID
|
||||
import com.simplemobiletools.calendar.pro.helpers.EVENT_OCCURRENCE_TS
|
||||
|
@ -21,6 +23,9 @@ import com.simplemobiletools.calendar.pro.helpers.Formatter
|
|||
import com.simplemobiletools.calendar.pro.interfaces.NavigationListener
|
||||
import com.simplemobiletools.calendar.pro.models.Event
|
||||
import com.simplemobiletools.commons.extensions.applyColorFilter
|
||||
import com.simplemobiletools.commons.extensions.beGone
|
||||
import com.simplemobiletools.commons.extensions.beVisible
|
||||
import com.simplemobiletools.commons.extensions.onGlobalLayout
|
||||
import kotlinx.android.synthetic.main.fragment_day.view.*
|
||||
import kotlinx.android.synthetic.main.top_navigation.view.*
|
||||
import java.util.*
|
||||
|
@ -101,7 +106,7 @@ class DayFragment : Fragment() {
|
|||
lastHash = newHash
|
||||
|
||||
val replaceDescription = context!!.config.replaceDescription
|
||||
val sorted = ArrayList<Event>(events.sortedWith(compareBy({ !it.getIsAllDay() }, { it.startTS }, { it.endTS }, { it.title }, {
|
||||
val sorted = ArrayList(events.sortedWith(compareBy({ !it.getIsAllDay() }, { it.startTS }, { it.endTS }, { it.title }, {
|
||||
if (replaceDescription) it.location else it.description
|
||||
})))
|
||||
|
||||
|
@ -128,4 +133,24 @@ class DayFragment : Fragment() {
|
|||
startActivity(this)
|
||||
}
|
||||
}
|
||||
|
||||
fun printCurrentView() {
|
||||
mHolder.apply {
|
||||
top_left_arrow.beGone()
|
||||
top_right_arrow.beGone()
|
||||
top_value.setTextColor(resources.getColor(R.color.theme_light_text_color))
|
||||
(day_events.adapter as? DayEventsAdapter)?.togglePrintMode()
|
||||
|
||||
day_events.onGlobalLayout {
|
||||
context!!.printBitmap(day_holder.getViewBitmap())
|
||||
|
||||
day_events.onGlobalLayout {
|
||||
top_left_arrow.beVisible()
|
||||
top_right_arrow.beVisible()
|
||||
top_value.setTextColor(context!!.config.textColor)
|
||||
(day_events.adapter as? DayEventsAdapter)?.togglePrintMode()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,5 +139,7 @@ class DayFragmentsHolder : MyFragmentHolder(), NavigationListener {
|
|||
|
||||
override fun getNewEventDayCode() = currentDayCode
|
||||
|
||||
override fun printView() {}
|
||||
override fun printView() {
|
||||
(viewPager?.adapter as? MyDayPagerAdapter)?.printCurrentView(viewPager?.currentItem ?: 0)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,12 +148,10 @@ class MonthFragment : Fragment(), MonthlyCalendar {
|
|||
}
|
||||
|
||||
fun printCurrentView() {
|
||||
val darkColor = resources.getColor(R.color.theme_light_text_color)
|
||||
|
||||
mHolder.apply {
|
||||
top_left_arrow.beGone()
|
||||
top_right_arrow.beGone()
|
||||
top_value.setTextColor(darkColor)
|
||||
top_value.setTextColor(resources.getColor(R.color.theme_light_text_color))
|
||||
month_view_wrapper.togglePrintMode()
|
||||
|
||||
context!!.printBitmap(month_calendar_holder.getViewBitmap())
|
||||
|
|
Loading…
Reference in New Issue