rewrite the monthly widget implementation
This commit is contained in:
parent
7a7b22b702
commit
615780f67f
|
@ -2,6 +2,7 @@ package com.simplemobiletools.calendar.activities
|
||||||
|
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
import android.appwidget.AppWidgetManager
|
import android.appwidget.AppWidgetManager
|
||||||
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
@ -187,7 +188,7 @@ class WidgetMonthlyConfigureActivity : AppCompatActivity(), MonthlyCalendar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateMonthlyCalendar(month: String, days: List<DayMonthly>) {
|
override fun updateMonthlyCalendar(context: Context, month: String, days: List<DayMonthly>) {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
mDays = days
|
mDays = days
|
||||||
top_value.text = month
|
top_value.text = month
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.simplemobiletools.calendar.fragments
|
package com.simplemobiletools.calendar.fragments
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.res.Resources
|
import android.content.res.Resources
|
||||||
import android.graphics.PorterDuff
|
import android.graphics.PorterDuff
|
||||||
|
@ -61,9 +62,6 @@ class MonthFragment : Fragment(), MonthlyCalendar {
|
||||||
setupLabels()
|
setupLabels()
|
||||||
mCalendar = MonthlyCalendarImpl(this, context)
|
mCalendar = MonthlyCalendarImpl(this, context)
|
||||||
|
|
||||||
val padding = mRes.getDimension(R.dimen.activity_margin).toInt()
|
|
||||||
view.calendar_holder.setPadding(padding, padding, padding, padding)
|
|
||||||
|
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +83,7 @@ class MonthFragment : Fragment(), MonthlyCalendar {
|
||||||
mCalendar.updateMonthlyCalendar(Formatter.getDateTimeFromCode(mDayCode))
|
mCalendar.updateMonthlyCalendar(Formatter.getDateTimeFromCode(mDayCode))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun updateMonthlyCalendar(month: String, days: List<DayMonthly>) {
|
override fun updateMonthlyCalendar(context: Context, month: String, days: List<DayMonthly>) {
|
||||||
activity?.runOnUiThread {
|
activity?.runOnUiThread {
|
||||||
mHolder.top_value.apply {
|
mHolder.top_value.apply {
|
||||||
text = month
|
text = month
|
||||||
|
|
|
@ -79,7 +79,7 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context)
|
||||||
if (markDaysWithEvents) {
|
if (markDaysWithEvents) {
|
||||||
markDaysWithEvents(days)
|
markDaysWithEvents(days)
|
||||||
} else {
|
} else {
|
||||||
mCallback.updateMonthlyCalendar(monthName, days)
|
mCallback.updateMonthlyCalendar(mContext, monthName, days)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ class MonthlyCalendarImpl(val mCallback: MonthlyCalendar, val mContext: Context)
|
||||||
days.filter { dayEvents.keys.contains(it.code) }.forEach {
|
days.filter { dayEvents.keys.contains(it.code) }.forEach {
|
||||||
it.dayEvents = dayEvents[it.code]!!
|
it.dayEvents = dayEvents[it.code]!!
|
||||||
}
|
}
|
||||||
mCallback.updateMonthlyCalendar(monthName, days)
|
mCallback.updateMonthlyCalendar(mContext, monthName, days)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ import android.appwidget.AppWidgetProvider
|
||||||
import android.content.ComponentName
|
import android.content.ComponentName
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.res.Resources
|
|
||||||
import android.graphics.*
|
import android.graphics.*
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.widget.RemoteViews
|
import android.widget.RemoteViews
|
||||||
|
@ -22,151 +21,129 @@ import com.simplemobiletools.commons.extensions.setBackgroundColor
|
||||||
import com.simplemobiletools.commons.extensions.setTextSize
|
import com.simplemobiletools.commons.extensions.setTextSize
|
||||||
import org.joda.time.DateTime
|
import org.joda.time.DateTime
|
||||||
|
|
||||||
class MyWidgetMonthlyProvider : AppWidgetProvider(), MonthlyCalendar {
|
class MyWidgetMonthlyProvider : AppWidgetProvider() {
|
||||||
private val PREV = "prev"
|
private val PREV = "prev"
|
||||||
private val NEXT = "next"
|
private val NEXT = "next"
|
||||||
private val NEW_EVENT = "new_event"
|
private val NEW_EVENT = "new_event"
|
||||||
|
|
||||||
private var mTextColor = 0
|
|
||||||
private var mCalendar: MonthlyCalendarImpl? = null
|
|
||||||
|
|
||||||
private var mSmallerFontSize = 0f
|
|
||||||
private var mMediumFontSize = 0f
|
|
||||||
private var mLargerFontSize = 0f
|
|
||||||
|
|
||||||
lateinit var mRes: Resources
|
|
||||||
lateinit var mContext: Context
|
|
||||||
lateinit var mWidgetManager: AppWidgetManager
|
|
||||||
lateinit var mIntent: Intent
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private var mTargetDate = DateTime()
|
var targetDate = DateTime.now()
|
||||||
private var mRemoteViews: RemoteViews? = null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
|
override fun onUpdate(context: Context, appWidgetManager: AppWidgetManager, appWidgetIds: IntArray) {
|
||||||
initVariables(context)
|
performUpdate(context)
|
||||||
updateWidget()
|
|
||||||
super.onUpdate(context, appWidgetManager, appWidgetIds)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun initVariables(context: Context) {
|
private fun performUpdate(context: Context) {
|
||||||
mContext = context
|
val largerFontSize = context.config.getFontSize() + 3f
|
||||||
mRes = mContext.resources
|
val textColor = context.config.widgetTextColor
|
||||||
mCalendar = MonthlyCalendarImpl(this, mContext)
|
|
||||||
mWidgetManager = AppWidgetManager.getInstance(mContext)
|
|
||||||
|
|
||||||
context.config.apply {
|
val appWidgetManager = AppWidgetManager.getInstance(context)
|
||||||
mTextColor = widgetTextColor
|
appWidgetManager.getAppWidgetIds(getComponentName(context)).forEach {
|
||||||
mMediumFontSize = getFontSize()
|
val views = RemoteViews(context.packageName, R.layout.fragment_month_widget)
|
||||||
mSmallerFontSize = getFontSize() - 3f
|
views.setBackgroundColor(R.id.calendar_holder, context.config.widgetBgColor)
|
||||||
mLargerFontSize = getFontSize() + 3f
|
|
||||||
|
|
||||||
mRemoteViews = RemoteViews(mContext.packageName, R.layout.fragment_month_widget)
|
views.setTextColor(R.id.top_value, textColor)
|
||||||
mRemoteViews?.setBackgroundColor(R.id.calendar_holder, widgetBgColor)
|
views.setTextSize(R.id.top_value, largerFontSize)
|
||||||
}
|
|
||||||
|
|
||||||
mIntent = Intent(mContext, MyWidgetMonthlyProvider::class.java)
|
var bmp = getColoredIcon(context, textColor, R.drawable.ic_pointer_left)
|
||||||
setupButtons()
|
views.setImageViewBitmap(R.id.top_left_arrow, bmp)
|
||||||
updateLabelColor()
|
|
||||||
updateTopViews()
|
|
||||||
mCalendar?.updateMonthlyCalendar(mTargetDate, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateWidget() {
|
bmp = getColoredIcon(context, textColor, R.drawable.ic_pointer_right)
|
||||||
val thisWidget = ComponentName(mContext, MyWidgetMonthlyProvider::class.java)
|
views.setImageViewBitmap(R.id.top_right_arrow, bmp)
|
||||||
try {
|
|
||||||
AppWidgetManager.getInstance(mContext).updateAppWidget(thisWidget, mRemoteViews)
|
bmp = getColoredIcon(context, textColor, R.drawable.ic_plus)
|
||||||
} catch (ignored: Exception) {
|
views.setImageViewBitmap(R.id.top_new_event, bmp)
|
||||||
|
|
||||||
|
setupIntent(context, views, PREV, R.id.top_left_arrow)
|
||||||
|
setupIntent(context, views, NEXT, R.id.top_right_arrow)
|
||||||
|
setupIntent(context, views, NEW_EVENT, R.id.top_new_event)
|
||||||
|
setupAppOpenIntent(context, views, R.id.top_value)
|
||||||
|
updateDayLabels(context, views, textColor)
|
||||||
|
|
||||||
|
appWidgetManager.updateAppWidget(it, views)
|
||||||
|
MonthlyCalendarImpl(monthlyCalendar, context).getMonth(targetDate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupIntent(action: String, id: Int) {
|
private fun setupIntent(context: Context, views: RemoteViews, action: String, id: Int) {
|
||||||
mIntent.action = action
|
Intent(context, MyWidgetMonthlyProvider::class.java).apply {
|
||||||
val pendingIntent = PendingIntent.getBroadcast(mContext, 0, mIntent, 0)
|
this.action = action
|
||||||
mRemoteViews?.setOnClickPendingIntent(id, pendingIntent)
|
val pendingIntent = PendingIntent.getBroadcast(context, 0, this, 0)
|
||||||
}
|
views.setOnClickPendingIntent(id, pendingIntent)
|
||||||
|
|
||||||
private fun setupAppOpenIntent(id: Int) {
|
|
||||||
Intent(mContext, SplashActivity::class.java).apply {
|
|
||||||
val pendingIntent = PendingIntent.getActivity(mContext, 0, this, 0)
|
|
||||||
mRemoteViews?.setOnClickPendingIntent(id, pendingIntent)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupDayOpenIntent(id: Int, dayCode: String) {
|
private fun setupAppOpenIntent(context: Context, views: RemoteViews, id: Int) {
|
||||||
Intent(mContext, SplashActivity::class.java).apply {
|
val intent = Intent(context, SplashActivity::class.java)
|
||||||
|
val pendingIntent = PendingIntent.getActivity(context, 0, intent, 0)
|
||||||
|
views.setOnClickPendingIntent(id, pendingIntent)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun setupDayOpenIntent(context: Context, views: RemoteViews, id: Int, dayCode: String) {
|
||||||
|
Intent(context, SplashActivity::class.java).apply {
|
||||||
putExtra(DAY_CODE, dayCode)
|
putExtra(DAY_CODE, dayCode)
|
||||||
val pendingIntent = PendingIntent.getActivity(mContext, Integer.parseInt(dayCode), this, 0)
|
val pendingIntent = PendingIntent.getActivity(context, Integer.parseInt(dayCode), this, 0)
|
||||||
mRemoteViews?.setOnClickPendingIntent(id, pendingIntent)
|
views.setOnClickPendingIntent(id, pendingIntent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setupButtons() {
|
private fun getComponentName(context: Context) = ComponentName(context, MyWidgetMonthlyProvider::class.java)
|
||||||
setupIntent(PREV, R.id.top_left_arrow)
|
|
||||||
setupIntent(NEXT, R.id.top_right_arrow)
|
|
||||||
setupIntent(NEW_EVENT, R.id.top_new_event)
|
|
||||||
setupAppOpenIntent(R.id.top_value)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onReceive(context: Context, intent: Intent) {
|
override fun onReceive(context: Context, intent: Intent) {
|
||||||
if (mCalendar == null || mRemoteViews == null) {
|
when (intent.action) {
|
||||||
initVariables(context)
|
PREV -> getPrevMonth(context)
|
||||||
}
|
NEXT -> getNextMonth(context)
|
||||||
|
NEW_EVENT -> context.launchNewEventIntent()
|
||||||
val action = intent.action
|
|
||||||
when (action) {
|
|
||||||
PREV -> getPrevMonth()
|
|
||||||
NEXT -> getNextMonth()
|
|
||||||
NEW_EVENT -> mContext.launchNewEventIntent()
|
|
||||||
else -> super.onReceive(context, intent)
|
else -> super.onReceive(context, intent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getPrevMonth() {
|
private fun getPrevMonth(context: Context) {
|
||||||
mTargetDate = mTargetDate.minusMonths(1)
|
targetDate = targetDate!!.minusMonths(1)
|
||||||
mCalendar?.getMonth(mTargetDate)
|
MonthlyCalendarImpl(monthlyCalendar, context).getMonth(targetDate!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getNextMonth() {
|
private fun getNextMonth(context: Context) {
|
||||||
mTargetDate = mTargetDate.plusMonths(1)
|
targetDate = targetDate!!.plusMonths(1)
|
||||||
mCalendar?.getMonth(mTargetDate)
|
MonthlyCalendarImpl(monthlyCalendar, context).getMonth(targetDate!!)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateDays(days: List<DayMonthly>) {
|
private fun updateDays(context: Context, views: RemoteViews, days: List<DayMonthly>) {
|
||||||
if (mRemoteViews == null)
|
val displayWeekNumbers = context.config.displayWeekNumbers
|
||||||
return
|
val textColor = context.config.widgetTextColor
|
||||||
|
val smallerFontSize = context.config.getFontSize() - 3f
|
||||||
val displayWeekNumbers = mContext.config.displayWeekNumbers
|
val res = context.resources
|
||||||
val len = days.size
|
val len = days.size
|
||||||
val packageName = mContext.packageName
|
val packageName = context.packageName
|
||||||
mRemoteViews!!.apply {
|
views.apply {
|
||||||
setTextColor(R.id.week_num, mTextColor)
|
setTextColor(R.id.week_num, textColor)
|
||||||
setTextSize(R.id.week_num, mSmallerFontSize)
|
setTextSize(R.id.week_num, smallerFontSize)
|
||||||
setViewVisibility(R.id.week_num, if (displayWeekNumbers) View.VISIBLE else View.GONE)
|
setViewVisibility(R.id.week_num, if (displayWeekNumbers) View.VISIBLE else View.GONE)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i in 0..5) {
|
for (i in 0..5) {
|
||||||
val id = mRes.getIdentifier("week_num_$i", "id", packageName)
|
val id = res.getIdentifier("week_num_$i", "id", packageName)
|
||||||
mRemoteViews!!.apply {
|
views.apply {
|
||||||
setTextViewText(id, "${days[i * 7 + 3].weekOfYear}:") // fourth day of the week matters
|
setTextViewText(id, "${days[i * 7 + 3].weekOfYear}:") // fourth day of the week matters at determining week of the year
|
||||||
setTextColor(id, mTextColor)
|
setTextColor(id, textColor)
|
||||||
setTextSize(id, mSmallerFontSize)
|
setTextSize(id, smallerFontSize)
|
||||||
setViewVisibility(id, if (displayWeekNumbers) View.VISIBLE else View.GONE)
|
setViewVisibility(id, if (displayWeekNumbers) View.VISIBLE else View.GONE)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val weakTextColor = mTextColor.adjustAlpha(LOW_ALPHA)
|
val weakTextColor = textColor.adjustAlpha(LOW_ALPHA)
|
||||||
for (i in 0 until len) {
|
for (i in 0 until len) {
|
||||||
val day = days[i]
|
val day = days[i]
|
||||||
var textColor = if (day.isThisMonth) mTextColor else weakTextColor
|
var currTextColor = if (day.isThisMonth) textColor else weakTextColor
|
||||||
val primaryColor = mContext.config.primaryColor
|
val primaryColor = context.config.primaryColor
|
||||||
if (day.isToday)
|
if (day.isToday)
|
||||||
textColor = primaryColor.getContrastColor()
|
currTextColor = primaryColor.getContrastColor()
|
||||||
|
|
||||||
val id = mRes.getIdentifier("day_$i", "id", packageName)
|
val id = res.getIdentifier("day_$i", "id", packageName)
|
||||||
mRemoteViews!!.removeAllViews(id)
|
views.removeAllViews(id)
|
||||||
addDayNumber(day, packageName, textColor, id, primaryColor)
|
addDayNumber(context, views, day, currTextColor, id, primaryColor)
|
||||||
|
setupDayOpenIntent(context, views, id, day.code)
|
||||||
|
|
||||||
day.dayEvents.forEach {
|
day.dayEvents.forEach {
|
||||||
var backgroundColor = it.color
|
var backgroundColor = it.color
|
||||||
|
@ -180,68 +157,56 @@ class MyWidgetMonthlyProvider : AppWidgetProvider(), MonthlyCalendar {
|
||||||
val newRemoteView = RemoteViews(packageName, R.layout.day_monthly_event_view).apply {
|
val newRemoteView = RemoteViews(packageName, R.layout.day_monthly_event_view).apply {
|
||||||
setTextViewText(R.id.day_monthly_event_id, it.title.replace(" ", "\u00A0"))
|
setTextViewText(R.id.day_monthly_event_id, it.title.replace(" ", "\u00A0"))
|
||||||
setTextColor(R.id.day_monthly_event_id, eventTextColor)
|
setTextColor(R.id.day_monthly_event_id, eventTextColor)
|
||||||
|
setTextSize(R.id.day_monthly_event_id, smallerFontSize - 3f)
|
||||||
setBackgroundColor(R.id.day_monthly_event_id, backgroundColor)
|
setBackgroundColor(R.id.day_monthly_event_id, backgroundColor)
|
||||||
}
|
}
|
||||||
mRemoteViews!!.addView(id, newRemoteView)
|
views.addView(id, newRemoteView)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addDayNumber(day: DayMonthly, packageName: String, textColor: Int, id: Int, primaryColor: Int) {
|
private fun addDayNumber(context: Context, views: RemoteViews, day: DayMonthly, textColor: Int, id: Int, primaryColor: Int) {
|
||||||
val newRemoteView = RemoteViews(packageName, R.layout.day_monthly_number_view).apply {
|
val newRemoteView = RemoteViews(context.packageName, R.layout.day_monthly_number_view).apply {
|
||||||
setTextViewText(R.id.day_monthly_number_id, day.value.toString())
|
setTextViewText(R.id.day_monthly_number_id, day.value.toString())
|
||||||
setTextColor(R.id.day_monthly_number_id, textColor)
|
setTextColor(R.id.day_monthly_number_id, textColor)
|
||||||
|
setTextSize(R.id.day_monthly_number_id, context.config.getFontSize() - 3f)
|
||||||
|
|
||||||
if (day.isToday) {
|
if (day.isToday) {
|
||||||
setViewPadding(R.id.day_monthly_number_id, 10, 0, 10, 0)
|
setViewPadding(R.id.day_monthly_number_id, 10, 0, 10, 0)
|
||||||
setBackgroundColor(R.id.day_monthly_number_id, primaryColor)
|
setBackgroundColor(R.id.day_monthly_number_id, primaryColor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mRemoteViews!!.addView(id, newRemoteView)
|
views.addView(id, newRemoteView)
|
||||||
setupDayOpenIntent(id, day.code)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateTopViews() {
|
private val monthlyCalendar = object : MonthlyCalendar {
|
||||||
mRemoteViews?.setTextColor(R.id.top_value, mTextColor)
|
override fun updateMonthlyCalendar(context: Context, month: String, days: List<DayMonthly>) {
|
||||||
mRemoteViews?.setTextSize(R.id.top_value, mLargerFontSize)
|
val appWidgetManager = AppWidgetManager.getInstance(context)
|
||||||
|
appWidgetManager.getAppWidgetIds(getComponentName(context)).forEach {
|
||||||
var bmp = getColoredIcon(mContext, mTextColor, R.drawable.ic_pointer_left)
|
val views = RemoteViews(context.packageName, R.layout.fragment_month_widget)
|
||||||
mRemoteViews?.setImageViewBitmap(R.id.top_left_arrow, bmp)
|
views.setTextViewText(R.id.top_value, month)
|
||||||
|
updateDays(context, views, days)
|
||||||
bmp = getColoredIcon(mContext, mTextColor, R.drawable.ic_pointer_right)
|
appWidgetManager.updateAppWidget(it, views)
|
||||||
mRemoteViews?.setImageViewBitmap(R.id.top_right_arrow, bmp)
|
}
|
||||||
|
|
||||||
bmp = getColoredIcon(mContext, mTextColor, R.drawable.ic_plus)
|
|
||||||
mRemoteViews?.setImageViewBitmap(R.id.top_new_event, bmp)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun updateMonth(month: String) {
|
|
||||||
mRemoteViews?.setTextViewText(R.id.top_value, month)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun updateMonthlyCalendar(month: String, days: List<DayMonthly>) {
|
|
||||||
try {
|
|
||||||
updateMonth(month)
|
|
||||||
updateDays(days)
|
|
||||||
updateWidget()
|
|
||||||
} catch (ignored: ArrayIndexOutOfBoundsException) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateLabelColor() {
|
private fun updateDayLabels(context: Context, views: RemoteViews, textColor: Int) {
|
||||||
val mSundayFirst = mContext.config.isSundayFirst
|
val sundayFirst = context.config.isSundayFirst
|
||||||
val packageName = mContext.packageName
|
val smallerFontSize = context.config.getFontSize() - 3f
|
||||||
|
val res = context.resources
|
||||||
|
val packageName = context.packageName
|
||||||
val letters = letterIDs
|
val letters = letterIDs
|
||||||
for (i in 0..6) {
|
for (i in 0..6) {
|
||||||
val id = mRes.getIdentifier("label_$i", "id", packageName)
|
val id = res.getIdentifier("label_$i", "id", packageName)
|
||||||
mRemoteViews?.setTextColor(id, mTextColor)
|
views.setTextColor(id, textColor)
|
||||||
mRemoteViews?.setTextSize(id, mSmallerFontSize)
|
views.setTextSize(id, smallerFontSize)
|
||||||
|
|
||||||
var index = i
|
var index = i
|
||||||
if (!mSundayFirst)
|
if (!sundayFirst)
|
||||||
index = (index + 1) % letters.size
|
index = (index + 1) % letters.size
|
||||||
|
|
||||||
mRemoteViews?.setTextViewText(id, mContext.resources.getString(letters[index]))
|
views.setTextViewText(id, res.getString(letters[index]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package com.simplemobiletools.calendar.interfaces
|
package com.simplemobiletools.calendar.interfaces
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
import com.simplemobiletools.calendar.models.DayMonthly
|
import com.simplemobiletools.calendar.models.DayMonthly
|
||||||
|
|
||||||
interface MonthlyCalendar {
|
interface MonthlyCalendar {
|
||||||
fun updateMonthlyCalendar(month: String, days: List<DayMonthly>)
|
fun updateMonthlyCalendar(context: Context, month: String, days: List<DayMonthly>)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,7 @@
|
||||||
android:id="@+id/day_monthly_event_id"
|
android:id="@+id/day_monthly_event_id"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginLeft="@dimen/tiny_margin"
|
android:layout_margin="1dp"
|
||||||
android:layout_marginRight="@dimen/tiny_margin"
|
|
||||||
android:ellipsize="none"
|
android:ellipsize="none"
|
||||||
android:gravity="start"
|
android:gravity="start"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
|
@ -14,9 +13,8 @@
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:visibility="gone"
|
android:text="#"
|
||||||
tools:text="#"
|
android:visibility="gone"/>
|
||||||
tools:visibility="visible"/>
|
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyTextView
|
<com.simplemobiletools.commons.views.MyTextView
|
||||||
android:id="@+id/label_0"
|
android:id="@+id/label_0"
|
||||||
|
|
|
@ -3,81 +3,72 @@
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
android:orientation="horizontal"
|
||||||
android:layout_weight="1"
|
android:paddingBottom="@dimen/small_margin"
|
||||||
android:orientation="horizontal">
|
android:paddingTop="@dimen/small_margin">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/week_num"
|
android:id="@+id/week_num"
|
||||||
style="@style/DayView"
|
style="@style/MetaView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
tools:text="#"
|
android:text="#"/>
|
||||||
android:visibility="gone"
|
|
||||||
tools:visibility="visible"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label_0"
|
android:id="@+id/label_0"
|
||||||
style="@style/DayView"
|
style="@style/MetaView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/monday_letter"
|
android:text="@string/monday_letter"/>
|
||||||
android:textStyle="bold"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label_1"
|
android:id="@+id/label_1"
|
||||||
style="@style/DayView"
|
style="@style/MetaView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/tuesday_letter"
|
android:text="@string/tuesday_letter"/>
|
||||||
android:textStyle="bold"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label_2"
|
android:id="@+id/label_2"
|
||||||
style="@style/DayView"
|
style="@style/MetaView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/wednesday_letter"
|
android:text="@string/wednesday_letter"/>
|
||||||
android:textStyle="bold"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label_3"
|
android:id="@+id/label_3"
|
||||||
style="@style/DayView"
|
style="@style/MetaView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/thursday_letter"
|
android:text="@string/thursday_letter"/>
|
||||||
android:textStyle="bold"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label_4"
|
android:id="@+id/label_4"
|
||||||
style="@style/DayView"
|
style="@style/MetaView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/friday_letter"
|
android:text="@string/friday_letter"/>
|
||||||
android:textStyle="bold"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label_5"
|
android:id="@+id/label_5"
|
||||||
style="@style/DayView"
|
style="@style/MetaView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/saturday_letter"
|
android:text="@string/saturday_letter"/>
|
||||||
android:textStyle="bold"/>
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/label_6"
|
android:id="@+id/label_6"
|
||||||
style="@style/DayView"
|
style="@style/MetaView"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:text="@string/sunday_letter"
|
android:text="@string/sunday_letter"/>
|
||||||
android:textStyle="bold"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/calendar_holder"
|
android:id="@+id/calendar_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:padding="@dimen/medium_margin">
|
||||||
|
|
||||||
<include layout="@layout/top_navigation"/>
|
<include layout="@layout/top_navigation"/>
|
||||||
|
|
||||||
|
|
|
@ -1,26 +1,30 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/calendar_holder"
|
android:id="@+id/calendar_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:padding="@dimen/medium_margin">
|
||||||
|
|
||||||
<include layout="@layout/top_navigation_widget"/>
|
<include layout="@layout/top_navigation_widget"/>
|
||||||
|
|
||||||
|
<include
|
||||||
|
android:id="@+id/first_row_widget"
|
||||||
|
layout="@layout/first_row_widget"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_below="@+id/top_value"
|
||||||
|
tools:ignore="UnknownIdInLayout"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/table_holder"
|
android:id="@+id/table_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_below="@+id/top_value"
|
android:layout_below="@+id/first_row_widget"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<include
|
|
||||||
layout="@layout/first_row_widget"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_weight="1"/>
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/month_line_holder_1"
|
android:id="@+id/month_line_holder_1"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -30,11 +34,11 @@
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/week_num_0"
|
android:id="@+id/week_num_0"
|
||||||
style="@style/MetaView"
|
style="@style/WeekNumberStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:visibility="visible"/>
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/day_0"
|
android:id="@+id/day_0"
|
||||||
|
@ -102,11 +106,11 @@
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/week_num_1"
|
android:id="@+id/week_num_1"
|
||||||
style="@style/MetaView"
|
style="@style/WeekNumberStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:visibility="visible"/>
|
android:visibility="gone"/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/day_7"
|
android:id="@+id/day_7"
|
||||||
|
@ -174,7 +178,7 @@
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/week_num_2"
|
android:id="@+id/week_num_2"
|
||||||
style="@style/MetaView"
|
style="@style/WeekNumberStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
@ -246,7 +250,7 @@
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/week_num_3"
|
android:id="@+id/week_num_3"
|
||||||
style="@style/MetaView"
|
style="@style/WeekNumberStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
@ -318,7 +322,7 @@
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/week_num_4"
|
android:id="@+id/week_num_4"
|
||||||
style="@style/MetaView"
|
style="@style/WeekNumberStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
@ -390,7 +394,7 @@
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/week_num_5"
|
android:id="@+id/week_num_5"
|
||||||
style="@style/MetaView"
|
style="@style/WeekNumberStyle"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_alignBottom="@+id/top_value"
|
android:layout_alignBottom="@+id/top_value"
|
||||||
android:layout_alignTop="@+id/top_value"
|
android:layout_alignTop="@+id/top_value"
|
||||||
android:padding="@dimen/activity_margin"
|
android:paddingLeft="@dimen/activity_margin"
|
||||||
|
android:paddingRight="@dimen/activity_margin"
|
||||||
android:src="@drawable/ic_pointer_left"/>
|
android:src="@drawable/ic_pointer_left"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
|
@ -21,8 +22,8 @@
|
||||||
android:layout_toLeftOf="@+id/top_right_arrow"
|
android:layout_toLeftOf="@+id/top_right_arrow"
|
||||||
android:layout_toRightOf="@+id/top_left_arrow"
|
android:layout_toRightOf="@+id/top_left_arrow"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:paddingBottom="@dimen/activity_margin"
|
android:paddingBottom="@dimen/medium_margin"
|
||||||
android:paddingTop="@dimen/activity_margin"
|
android:paddingTop="@dimen/medium_margin"
|
||||||
android:textSize="@dimen/month_text_size"/>
|
android:textSize="@dimen/month_text_size"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
@ -33,7 +34,8 @@
|
||||||
android:layout_alignBottom="@+id/top_value"
|
android:layout_alignBottom="@+id/top_value"
|
||||||
android:layout_alignTop="@+id/top_value"
|
android:layout_alignTop="@+id/top_value"
|
||||||
android:layout_toLeftOf="@+id/top_new_event"
|
android:layout_toLeftOf="@+id/top_new_event"
|
||||||
android:padding="@dimen/activity_margin"
|
android:paddingLeft="@dimen/activity_margin"
|
||||||
|
android:paddingRight="@dimen/activity_margin"
|
||||||
android:src="@drawable/ic_pointer_right"/>
|
android:src="@drawable/ic_pointer_right"/>
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
|
@ -44,7 +46,8 @@
|
||||||
android:layout_alignBottom="@+id/top_value"
|
android:layout_alignBottom="@+id/top_value"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_alignTop="@+id/top_value"
|
android:layout_alignTop="@+id/top_value"
|
||||||
android:padding="@dimen/activity_margin"
|
android:paddingLeft="@dimen/activity_margin"
|
||||||
|
android:paddingRight="@dimen/activity_margin"
|
||||||
android:src="@drawable/ic_plus"/>
|
android:src="@drawable/ic_plus"/>
|
||||||
|
|
||||||
</merge>
|
</merge>
|
||||||
|
|
Loading…
Reference in New Issue