mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
add Print support at the daily view
This commit is contained in:
@@ -30,6 +30,7 @@ class DayEventsAdapter(activity: SimpleActivity, val events: ArrayList<Event>, r
|
|||||||
private val allDayString = resources.getString(R.string.all_day)
|
private val allDayString = resources.getString(R.string.all_day)
|
||||||
private val replaceDescriptionWithLocation = activity.config.replaceDescription
|
private val replaceDescriptionWithLocation = activity.config.replaceDescription
|
||||||
private val dimPastEvents = activity.config.dimPastEvents
|
private val dimPastEvents = activity.config.dimPastEvents
|
||||||
|
private var isPrintVersion = false
|
||||||
|
|
||||||
init {
|
init {
|
||||||
setupDragListener(true)
|
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) {
|
private fun setupView(view: View, event: Event) {
|
||||||
view.apply {
|
view.apply {
|
||||||
event_item_frame.isSelected = selectedKeys.contains(event.id?.toInt())
|
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
|
var newTextColor = textColor
|
||||||
if (dimPastEvents && event.isPastEvent) {
|
if (dimPastEvents && event.isPastEvent && !isPrintVersion) {
|
||||||
newTextColor = newTextColor.adjustAlpha(LOW_ALPHA)
|
newTextColor = newTextColor.adjustAlpha(LOW_ALPHA)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,4 +33,8 @@ class MyDayPagerAdapter(fm: FragmentManager, private val mCodes: List<String>, p
|
|||||||
mFragments[pos + i]?.updateCalendar()
|
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.adapters.DayEventsAdapter
|
||||||
import com.simplemobiletools.calendar.pro.extensions.config
|
import com.simplemobiletools.calendar.pro.extensions.config
|
||||||
import com.simplemobiletools.calendar.pro.extensions.eventsHelper
|
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.DAY_CODE
|
||||||
import com.simplemobiletools.calendar.pro.helpers.EVENT_ID
|
import com.simplemobiletools.calendar.pro.helpers.EVENT_ID
|
||||||
import com.simplemobiletools.calendar.pro.helpers.EVENT_OCCURRENCE_TS
|
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.interfaces.NavigationListener
|
||||||
import com.simplemobiletools.calendar.pro.models.Event
|
import com.simplemobiletools.calendar.pro.models.Event
|
||||||
import com.simplemobiletools.commons.extensions.applyColorFilter
|
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.fragment_day.view.*
|
||||||
import kotlinx.android.synthetic.main.top_navigation.view.*
|
import kotlinx.android.synthetic.main.top_navigation.view.*
|
||||||
import java.util.*
|
import java.util.*
|
||||||
@@ -101,7 +106,7 @@ class DayFragment : Fragment() {
|
|||||||
lastHash = newHash
|
lastHash = newHash
|
||||||
|
|
||||||
val replaceDescription = context!!.config.replaceDescription
|
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
|
if (replaceDescription) it.location else it.description
|
||||||
})))
|
})))
|
||||||
|
|
||||||
@@ -128,4 +133,24 @@ class DayFragment : Fragment() {
|
|||||||
startActivity(this)
|
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 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() {
|
fun printCurrentView() {
|
||||||
val darkColor = resources.getColor(R.color.theme_light_text_color)
|
|
||||||
|
|
||||||
mHolder.apply {
|
mHolder.apply {
|
||||||
top_left_arrow.beGone()
|
top_left_arrow.beGone()
|
||||||
top_right_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()
|
month_view_wrapper.togglePrintMode()
|
||||||
|
|
||||||
context!!.printBitmap(month_calendar_holder.getViewBitmap())
|
context!!.printBitmap(month_calendar_holder.getViewBitmap())
|
||||||
|
Reference in New Issue
Block a user