add some grid lines at weekly view

This commit is contained in:
tibbi 2017-02-04 16:49:28 +01:00
parent cc407072ee
commit cfed46f4a1
6 changed files with 115 additions and 17 deletions

View File

@ -11,7 +11,6 @@ import android.support.v4.view.ViewPager
import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import com.simplemobiletools.calendar.BuildConfig
import com.simplemobiletools.calendar.R
@ -265,7 +264,7 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener {
}
fun updateHoursTopMargin(margin: Int) {
(week_view_hours_scrollview.layoutParams as LinearLayout.LayoutParams).setMargins(0, margin, 0, 0)
week_view_hours_divider.layoutParams.height = margin
week_view_hours_scrollview.requestLayout()
}

View File

@ -41,6 +41,7 @@ class WeekFragment : Fragment(), WeeklyCalendar {
private var isFragmentVisible = false
private var wasFragmentInit = false
private var wasExtraHeightAdded = false
private var oneDP = 1
lateinit var mView: View
lateinit var mCalendar: WeeklyCalendarImpl
@ -51,6 +52,8 @@ class WeekFragment : Fragment(), WeeklyCalendar {
minScrollY = mRowHeight * context.config.startWeeklyAt
mWeekTimestamp = arguments.getInt(WEEK_START_TIMESTAMP)
primaryColor = context.config.primaryColor
mRes = resources
oneDP = mRes.displayMetrics.density.toInt()
mView = inflater.inflate(R.layout.fragment_week, container, false).apply {
week_events_scrollview.setOnScrollviewListener(object : MyScrollView.ScrollViewListener {
@ -74,7 +77,6 @@ class WeekFragment : Fragment(), WeeklyCalendar {
}
}
mRes = resources
mCalendar = WeeklyCalendarImpl(this, context)
wasFragmentInit = true
return mView
@ -164,7 +166,6 @@ class WeekFragment : Fragment(), WeeklyCalendar {
val fullHeight = mRes.getDimension(R.dimen.weekly_view_events_height)
val minuteHeight = fullHeight / (24 * 60)
val minimalHeight = mRes.getDimension(R.dimen.weekly_view_minimal_event_height).toInt()
val sideMargin = mRes.displayMetrics.density.toInt()
(0..6).map { getColumnWithId(it) }
.forEach { activity.runOnUiThread { it.removeAllViews() } }
@ -189,10 +190,10 @@ class WeekFragment : Fragment(), WeeklyCalendar {
activity.runOnUiThread {
layout.addView(this)
(layoutParams as RelativeLayout.LayoutParams).apply {
rightMargin = sideMargin
rightMargin = oneDP
topMargin = (startMinutes * minuteHeight).toInt()
width = layout.width
minHeight = if (event.startTS == event.endTS) minimalHeight else (duration * minuteHeight).toInt() - sideMargin
minHeight = if (event.startTS == event.endTS) minimalHeight else (duration * minuteHeight).toInt() - oneDP
}
}
setOnClickListener {
@ -225,9 +226,9 @@ class WeekFragment : Fragment(), WeeklyCalendar {
mView.week_all_day_holder.addView(this)
(layoutParams as LinearLayout.LayoutParams).apply {
topMargin = mRes.getDimension(R.dimen.tiny_margin).toInt()
bottomMargin = mRes.getDimension(R.dimen.tiny_margin).toInt()
bottomMargin = oneDP
leftMargin = firstDayIndex % 7 * dayColumnWidth
width = (daysCnt + 1) * dayColumnWidth - mRes.displayMetrics.density.toInt()
width = (daysCnt + 1) * dayColumnWidth - oneDP
}
mView.week_top_holder.viewTreeObserver.addOnGlobalLayoutListener(object : ViewTreeObserver.OnGlobalLayoutListener {

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="0dp"
android:left="-2dp"
android:right="-2dp"
android:top="-2dp">
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent"/>
<stroke
android:width="1dp"
android:color="@color/divider_grey"/>
</shape>
</item>
</layer-list>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:bottom="-2dp"
android:left="-2dp"
android:right="0dp"
android:top="-2dp">
<shape android:shape="rectangle">
<solid android:color="@android:color/transparent"/>
<stroke
android:width="1dp"
android:color="@color/divider_grey"/>
</shape>
</item>
</layer-list>

View File

@ -13,16 +13,24 @@
android:fillViewport="true"
android:visibility="gone">
<LinearLayout
<RelativeLayout
android:id="@+id/week_view_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/week_view_hours_divider"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignRight="@+id/week_view_hours_scrollview"
android:background="@drawable/stroke_bottom"/>
<com.simplemobiletools.calendar.views.MyScrollView
android:id="@+id/week_view_hours_scrollview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/week_view_hours_divider"
android:overScrollMode="never"
android:paddingTop="@dimen/medium_margin"
android:scrollbars="none">
@ -38,9 +46,16 @@
<com.simplemobiletools.commons.views.MyViewPager
android:id="@+id/week_view_view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
android:layout_height="match_parent"
android:layout_toRightOf="@+id/week_view_hours_scrollview"/>
</LinearLayout>
<ImageView
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_toRightOf="@+id/week_view_hours_scrollview"
android:foreground="@drawable/stroke_right"/>
</RelativeLayout>
</LinearLayout>
<com.simplemobiletools.commons.views.MyViewPager

View File

@ -6,18 +6,19 @@
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
<RelativeLayout
android:id="@+id/week_top_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical">
android:foreground="@drawable/stroke_bottom"
android:gravity="center_vertical">
<LinearLayout
android:id="@+id/week_letters_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingBottom="@dimen/small_margin"
android:orientation="horizontal">
<com.simplemobiletools.commons.views.MyTextView
@ -85,13 +86,63 @@
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignBottom="@+id/week_all_day_holder">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/stroke_right"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/stroke_right"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/stroke_right"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/stroke_right"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/stroke_right"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/stroke_right"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@drawable/stroke_right"/>
</LinearLayout>
<LinearLayout
android:id="@+id/week_all_day_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/week_letters_holder"
android:orientation="vertical"/>
</LinearLayout>
</RelativeLayout>
<com.simplemobiletools.calendar.views.MyScrollView
android:id="@+id/week_events_scrollview"
@ -104,14 +155,14 @@
<RelativeLayout
android:id="@+id/week_events_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
android:layout_height="wrap_content">
<GridView
android:id="@+id/week_events_grid"
android:layout_width="match_parent"
android:layout_height="@dimen/weekly_view_events_height"
android:background="@color/divider_grey"
android:foreground="@drawable/stroke_right"
android:horizontalSpacing="1dp"
android:numColumns="7"
android:verticalSpacing="1dp"/>