When tapping the event time, it is more reasonable to open the calendar rather than the event details (tap the event title for the details).
This commit is contained in:
parent
b3e2d8d843
commit
218dae8cc2
@ -89,11 +89,11 @@ object IntentHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getCalendarIntent(context: Context): Intent {
|
fun getCalendarIntent(context: Context, time: Long? = null): Intent {
|
||||||
val calendarUri = CalendarContract.CONTENT_URI
|
val calendarUri = CalendarContract.CONTENT_URI
|
||||||
.buildUpon()
|
.buildUpon()
|
||||||
.appendPath("time")
|
.appendPath("time")
|
||||||
.appendPath(Calendar.getInstance().timeInMillis.toString())
|
.appendPath((time ?: Calendar.getInstance().timeInMillis).toString())
|
||||||
.build()
|
.build()
|
||||||
return when (Preferences.calendarAppPackage) {
|
return when (Preferences.calendarAppPackage) {
|
||||||
DEFAULT_OPTION -> {
|
DEFAULT_OPTION -> {
|
||||||
@ -177,7 +177,7 @@ object IntentHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
false -> {
|
false -> {
|
||||||
getCalendarIntent(context)
|
getCalendarIntent(context, e.startDate)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -227,11 +227,7 @@ class AlignedWidget(val context: Context, val rightAligned: Boolean = false) {
|
|||||||
val pIntentDetail = PendingIntent.getActivity(
|
val pIntentDetail = PendingIntent.getActivity(
|
||||||
context,
|
context,
|
||||||
widgetID,
|
widgetID,
|
||||||
IntentHelper.getEventIntent(
|
IntentHelper.getCalendarIntent(context, nextEvent.startDate),
|
||||||
context,
|
|
||||||
nextEvent,
|
|
||||||
forceEventDetails = true
|
|
||||||
),
|
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT
|
PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
)
|
)
|
||||||
views.setOnClickPendingIntent(R.id.sub_line_rect, pIntentDetail)
|
views.setOnClickPendingIntent(R.id.sub_line_rect, pIntentDetail)
|
||||||
@ -563,18 +559,16 @@ class AlignedWidget(val context: Context, val rightAligned: Boolean = false) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
val flags: Int =
|
|
||||||
DateUtils.FORMAT_SHOW_DATE or DateUtils.FORMAT_NO_YEAR or DateUtils.FORMAT_ABBREV_MONTH
|
|
||||||
val start = Calendar.getInstance().apply { timeInMillis = nextEvent.startDate }
|
val start = Calendar.getInstance().apply { timeInMillis = nextEvent.startDate }
|
||||||
|
|
||||||
bindingView.subLineText.text = if (now.get(Calendar.DAY_OF_YEAR) == start.get(
|
bindingView.subLineText.text = if (now.get(Calendar.DAY_OF_YEAR) == start.get(
|
||||||
Calendar.DAY_OF_YEAR)) {
|
Calendar.DAY_OF_YEAR)) {
|
||||||
DateUtils.formatDateTime(context, nextEvent.startDate, flags)
|
DateHelper.getDateText(context, start)
|
||||||
} else if (now.get(Calendar.DAY_OF_YEAR) > start.get(Calendar.DAY_OF_YEAR) || now.get(
|
} else if (now.get(Calendar.DAY_OF_YEAR) > start.get(Calendar.DAY_OF_YEAR) || now.get(
|
||||||
Calendar.YEAR) > start.get(Calendar.YEAR)) {
|
Calendar.YEAR) > start.get(Calendar.YEAR)) {
|
||||||
DateUtils.formatDateTime(context, now.timeInMillis, flags)
|
DateHelper.getDateText(context, now)
|
||||||
} else {
|
} else {
|
||||||
DateUtils.formatDateTime(context, nextEvent.startDate, flags)
|
DateHelper.getDateText(context, start)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -253,11 +253,7 @@ class StandardWidget(val context: Context) {
|
|||||||
val pIntentDetail = PendingIntent.getActivity(
|
val pIntentDetail = PendingIntent.getActivity(
|
||||||
context,
|
context,
|
||||||
widgetID,
|
widgetID,
|
||||||
IntentHelper.getEventIntent(
|
IntentHelper.getCalendarIntent(context, nextEvent.startDate),
|
||||||
context,
|
|
||||||
nextEvent,
|
|
||||||
forceEventDetails = true
|
|
||||||
),
|
|
||||||
PendingIntent.FLAG_UPDATE_CURRENT
|
PendingIntent.FLAG_UPDATE_CURRENT
|
||||||
)
|
)
|
||||||
views.setOnClickPendingIntent(R.id.sub_line_rect, pIntentDetail)
|
views.setOnClickPendingIntent(R.id.sub_line_rect, pIntentDetail)
|
||||||
@ -592,18 +588,16 @@ class StandardWidget(val context: Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
val flags: Int =
|
|
||||||
DateUtils.FORMAT_SHOW_DATE or DateUtils.FORMAT_NO_YEAR or DateUtils.FORMAT_ABBREV_MONTH
|
|
||||||
val start = Calendar.getInstance().apply { timeInMillis = nextEvent.startDate }
|
val start = Calendar.getInstance().apply { timeInMillis = nextEvent.startDate }
|
||||||
|
|
||||||
bindingView.subLineText.text = if (now.get(Calendar.DAY_OF_YEAR) == start.get(
|
bindingView.subLineText.text = if (now.get(Calendar.DAY_OF_YEAR) == start.get(
|
||||||
Calendar.DAY_OF_YEAR)) {
|
Calendar.DAY_OF_YEAR)) {
|
||||||
DateUtils.formatDateTime(context, nextEvent.startDate, flags)
|
DateHelper.getDateText(context, start)
|
||||||
} else if (now.get(Calendar.DAY_OF_YEAR) > start.get(Calendar.DAY_OF_YEAR) || now.get(
|
} else if (now.get(Calendar.DAY_OF_YEAR) > start.get(Calendar.DAY_OF_YEAR) || now.get(
|
||||||
Calendar.YEAR) > start.get(Calendar.YEAR)) {
|
Calendar.YEAR) > start.get(Calendar.YEAR)) {
|
||||||
DateUtils.formatDateTime(context, now.timeInMillis, flags)
|
DateHelper.getDateText(context, now)
|
||||||
} else {
|
} else {
|
||||||
DateUtils.formatDateTime(context, nextEvent.startDate, flags)
|
DateHelper.getDateText(context, start)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user