fix #99, add a current time indicator in weekly view

This commit is contained in:
tibbi 2017-02-07 22:15:23 +01:00
parent 1a77566eb1
commit bf55fd7318
8 changed files with 16 additions and 7 deletions

View file

@ -2,11 +2,13 @@ package com.simplemobiletools.calendar.fragments
import android.content.Intent
import android.content.res.Resources
import android.graphics.PorterDuff
import android.graphics.Rect
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.support.v4.app.Fragment
import android.view.*
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.RelativeLayout
import android.widget.TextView
@ -256,17 +258,22 @@ class WeekFragment : Fragment(), WeeklyCalendar {
checkTopHolderHeight()
}
addCurrentTimeIndicator(minuteHeight)
}
fun addCurrentTimeIndicator(minuteHeight: Float) {
if (todayColumnIndex != -1) {
val minutes = DateTime().minuteOfDay
val todayColumn = getColumnWithId(todayColumnIndex)
inflater.inflate(R.layout.week_now_marker, null, false).apply {
background = ColorDrawable(primaryColor)
(inflater.inflate(R.layout.week_now_marker, null, false) as ImageView).apply {
setColorFilter(primaryColor, PorterDuff.Mode.SRC_IN)
activity.runOnUiThread {
mView.week_events_holder.addView(this)
x = todayColumn.x
y = minutes.toFloat()
val extraWidth = (todayColumn.width * 0.3).toInt()
x = todayColumn.x - extraWidth / 2
y = minutes * minuteHeight
(layoutParams as RelativeLayout.LayoutParams).apply {
width = todayColumn.width - 1
width = todayColumn.width + extraWidth
height = resources.getDimension(R.dimen.weekly_view_now_height).toInt()
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 682 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 666 B

View file

@ -2,4 +2,6 @@
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="match_parent"
android:src="@drawable/weekly_now"
android:scaleType="fitXY"/>

View file

@ -8,7 +8,7 @@
<dimen name="weekly_view_row_height">60dp</dimen>
<dimen name="weekly_view_events_height">1440dp</dimen> <!-- weekly_view_row_height * 24 hours -->
<dimen name="weekly_view_minimal_event_height">10dp</dimen>
<dimen name="weekly_view_now_height">5dp</dimen>
<dimen name="weekly_view_now_height">10dp</dimen>
<dimen name="min_widget_width">250dp</dimen>
<dimen name="min_widget_height">250dp</dimen>