removed now indicator from android and ios widgets
This commit is contained in:
@@ -167,14 +167,6 @@ object WidgetRenderer {
|
|||||||
horizontalPaddingDp = 7,
|
horizontalPaddingDp = 7,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
maybeAddNowIndicator(
|
|
||||||
packageName,
|
|
||||||
views,
|
|
||||||
R.id.widget_day_grid,
|
|
||||||
hourHeightDp,
|
|
||||||
anchorDate = data.anchorDate,
|
|
||||||
periods = data.periods,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
views.setOnClickPendingIntent(R.id.widget_root, openAppIntent(context))
|
views.setOnClickPendingIntent(R.id.widget_root, openAppIntent(context))
|
||||||
@@ -283,16 +275,6 @@ object WidgetRenderer {
|
|||||||
horizontalPaddingDp = 3,
|
horizontalPaddingDp = 3,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if (WidgetDateUtils.isSameDay(day, Date())) {
|
|
||||||
maybeAddNowIndicator(
|
|
||||||
packageName,
|
|
||||||
views,
|
|
||||||
columnId,
|
|
||||||
hourHeightDp,
|
|
||||||
anchorDate = day,
|
|
||||||
periods = data.periods,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
views.setOnClickPendingIntent(R.id.widget_root, openAppIntent(context))
|
views.setOnClickPendingIntent(R.id.widget_root, openAppIntent(context))
|
||||||
@@ -644,34 +626,6 @@ object WidgetRenderer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun maybeAddNowIndicator(
|
|
||||||
packageName: String,
|
|
||||||
parent: RemoteViews,
|
|
||||||
containerId: Int,
|
|
||||||
hourHeightDp: Float,
|
|
||||||
anchorDate: Date,
|
|
||||||
periods: List<WidgetPeriod>,
|
|
||||||
) {
|
|
||||||
if (!WidgetDateUtils.isSameDay(anchorDate, Date())) return
|
|
||||||
val now = Calendar.getInstance()
|
|
||||||
val nowMinutes = now.get(Calendar.HOUR_OF_DAY) * 60 + now.get(Calendar.MINUTE)
|
|
||||||
if (periods.isNotEmpty()) {
|
|
||||||
if (nowMinutes < periods.first().startMinutes ||
|
|
||||||
nowMinutes > periods.last().endMinutes
|
|
||||||
) return
|
|
||||||
}
|
|
||||||
val virtualNow = realMinutesToVirtual(nowMinutes, periods)
|
|
||||||
val topDp = virtualNow * hourHeightDp / 60.0f
|
|
||||||
val indicator = RemoteViews(packageName, R.layout.widget_now_indicator)
|
|
||||||
indicator.setViewLayoutMargin(
|
|
||||||
R.id.widget_now_indicator_root,
|
|
||||||
RemoteViews.MARGIN_TOP,
|
|
||||||
topDp,
|
|
||||||
TypedValue.COMPLEX_UNIT_DIP,
|
|
||||||
)
|
|
||||||
parent.addView(containerId, indicator)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Custom-events use the user-picked palette (orange/red/green/blue,
|
/// Custom-events use the user-picked palette (orange/red/green/blue,
|
||||||
/// mirroring CustomTimetableColors).
|
/// mirroring CustomTimetableColors).
|
||||||
private fun statusDrawable(lesson: WidgetLesson): Int {
|
private fun statusDrawable(lesson: WidgetLesson): Int {
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:shape="rectangle">
|
|
||||||
<solid android:color="#FFE53935" />
|
|
||||||
</shape>
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/widget_now_indicator_root"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="2dp"
|
|
||||||
android:layout_marginTop="0dp"
|
|
||||||
android:background="@drawable/widget_now_indicator" />
|
|
||||||
@@ -82,7 +82,6 @@ struct TimetableDayView: View {
|
|||||||
TimeGridView(
|
TimeGridView(
|
||||||
lessons: data.lessons,
|
lessons: data.lessons,
|
||||||
periods: data.periods,
|
periods: data.periods,
|
||||||
anchorDate: data.anchorDate,
|
|
||||||
hourHeight: max(
|
hourHeight: max(
|
||||||
MIN_HOUR_HEIGHT,
|
MIN_HOUR_HEIGHT,
|
||||||
min(MAX_HOUR_HEIGHT, geo.size.height / max(totalMin, 60) * 60)
|
min(MAX_HOUR_HEIGHT, geo.size.height / max(totalMin, 60) * 60)
|
||||||
@@ -135,7 +134,6 @@ struct TimetableDayView: View {
|
|||||||
struct TimeGridView: View {
|
struct TimeGridView: View {
|
||||||
let lessons: [WidgetLesson]
|
let lessons: [WidgetLesson]
|
||||||
let periods: [WidgetPeriod]
|
let periods: [WidgetPeriod]
|
||||||
let anchorDate: Date
|
|
||||||
let hourHeight: CGFloat
|
let hourHeight: CGFloat
|
||||||
let showRoom: Bool
|
let showRoom: Bool
|
||||||
let showTeacher: Bool
|
let showTeacher: Bool
|
||||||
@@ -170,9 +168,6 @@ struct TimeGridView: View {
|
|||||||
ForEach(lessons.indices, id: \.self) { idx in
|
ForEach(lessons.indices, id: \.self) { idx in
|
||||||
lessonBlock(lessons[idx])
|
lessonBlock(lessons[idx])
|
||||||
}
|
}
|
||||||
if Calendar.current.isDate(anchorDate, inSameDayAs: Date()) {
|
|
||||||
nowIndicator
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
.frame(maxWidth: .infinity, minHeight: totalHeight, alignment: .top)
|
.frame(maxWidth: .infinity, minHeight: totalHeight, alignment: .top)
|
||||||
}
|
}
|
||||||
@@ -344,27 +339,6 @@ struct TimeGridView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var nowIndicator: some View {
|
|
||||||
let cal = Calendar.current
|
|
||||||
let comps = cal.dateComponents([.hour, .minute], from: Date())
|
|
||||||
let nowMinutes = (comps.hour ?? 0) * 60 + (comps.minute ?? 0)
|
|
||||||
let inside: Bool
|
|
||||||
if let first = periods.first, let last = periods.last {
|
|
||||||
inside = nowMinutes >= first.startMinutes && nowMinutes <= last.endMinutes
|
|
||||||
} else {
|
|
||||||
inside = true
|
|
||||||
}
|
|
||||||
let top = realMinutesToVirtual(nowMinutes, periods: periods) * hourHeight / 60.0
|
|
||||||
return Group {
|
|
||||||
if inside {
|
|
||||||
Rectangle()
|
|
||||||
.fill(Color.red)
|
|
||||||
.frame(height: 2)
|
|
||||||
.offset(y: top)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private func subjectLabel(_ lesson: WidgetLesson) -> String {
|
private func subjectLabel(_ lesson: WidgetLesson) -> String {
|
||||||
!lesson.subjectShort.isEmpty
|
!lesson.subjectShort.isEmpty
|
||||||
? lesson.subjectShort
|
? lesson.subjectShort
|
||||||
|
|||||||
@@ -131,7 +131,6 @@ struct TimetableWeekView: View {
|
|||||||
return TimeGridView(
|
return TimeGridView(
|
||||||
lessons: lessonsForDay,
|
lessons: lessonsForDay,
|
||||||
periods: data.periods,
|
periods: data.periods,
|
||||||
anchorDate: day,
|
|
||||||
hourHeight: hourHeight,
|
hourHeight: hourHeight,
|
||||||
showRoom: !subjectOnly,
|
showRoom: !subjectOnly,
|
||||||
showTeacher: !subjectOnly,
|
showTeacher: !subjectOnly,
|
||||||
|
|||||||
Reference in New Issue
Block a user