28.08.2023 calendare
parent
403fa40ece
commit
eaac38ae3c
|
@ -0,0 +1,39 @@
|
|||
package com.example.calendarev2
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.example.calendarev2.databinding.Example5EventItemViewv2Binding
|
||||
|
||||
|
||||
class CalendareAdapter :
|
||||
RecyclerView.Adapter<CalendareAdapter.Example5FlightsViewHolder>() {
|
||||
|
||||
val flights = mutableListOf<Flight>()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Example5FlightsViewHolder {
|
||||
return Example5FlightsViewHolder(
|
||||
Example5EventItemViewv2Binding.inflate(parent.context.layoutInflater, parent, false),
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(viewHolder: Example5FlightsViewHolder, position: Int) {
|
||||
viewHolder.bind(flights[position])
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = flights.size
|
||||
|
||||
inner class Example5FlightsViewHolder(val binding: Example5EventItemViewv2Binding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
fun bind(flight: Flight) {
|
||||
binding.itemFlightDateText.apply {
|
||||
text = flightDateTimeFormatter.format(flight.time)
|
||||
setBackgroundColor(itemView.context.getColorCompat(flight.color))
|
||||
}
|
||||
|
||||
binding.txtItem.text = flight.item
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
package com.example.rehabilitation.Calendare
|
||||
|
||||
class MonthCalendarViewHolder {
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package com.example.calendarev2
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.util.TypedValue
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.inputmethod.InputMethodManager
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.ColorRes
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.lifecycle.findViewTreeLifecycleOwner
|
||||
import com.example.calendarev2.sample.shared.StatusBarColorLifecycleObserver
|
||||
|
||||
fun View.makeVisible() {
|
||||
visibility = View.VISIBLE
|
||||
}
|
||||
|
||||
fun View.makeInVisible() {
|
||||
visibility = View.INVISIBLE
|
||||
}
|
||||
|
||||
fun View.makeGone() {
|
||||
visibility = View.GONE
|
||||
}
|
||||
|
||||
fun dpToPx(dp: Int, context: Context): Int =
|
||||
TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_DIP,
|
||||
dp.toFloat(),
|
||||
context.resources.displayMetrics,
|
||||
).toInt()
|
||||
|
||||
internal val Context.layoutInflater: LayoutInflater
|
||||
get() = LayoutInflater.from(this)
|
||||
|
||||
internal val Context.inputMethodManager
|
||||
get() = this.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|
||||
|
||||
internal fun Context.getDrawableCompat(@DrawableRes drawable: Int): Drawable =
|
||||
requireNotNull(ContextCompat.getDrawable(this, drawable))
|
||||
|
||||
internal fun Context.getColorCompat(@ColorRes color: Int) =
|
||||
ContextCompat.getColor(this, color)
|
||||
|
||||
internal fun TextView.setTextColorRes(@ColorRes color: Int) =
|
||||
setTextColor(context.getColorCompat(color))
|
||||
|
||||
fun Fragment.addStatusBarColorUpdate(@ColorRes colorRes: Int) {
|
||||
view?.findViewTreeLifecycleOwner()?.lifecycle?.addObserver(
|
||||
StatusBarColorLifecycleObserver(
|
||||
requireActivity(),
|
||||
requireContext().getColorCompat(colorRes),
|
||||
),
|
||||
)
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
package com.example.calendarev2
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.annotation.ColorRes
|
||||
import com.example.calendarev2.R
|
||||
import java.time.LocalDateTime
|
||||
import java.time.YearMonth
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
|
||||
|
||||
data class Flight(
|
||||
val time: LocalDateTime,
|
||||
val item: String,
|
||||
@ColorRes val color: Int,
|
||||
) {
|
||||
data class Airport(val city: String, val code: String)
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
fun generateFlights(): List<Flight> = buildList {
|
||||
val currentMonth = YearMonth.now()
|
||||
|
||||
currentMonth.atDay(17).also { date ->
|
||||
add(
|
||||
Flight(
|
||||
date.atTime(14, 0),
|
||||
"Lagos",
|
||||
R.color.blue_800,
|
||||
),
|
||||
)
|
||||
add(
|
||||
Flight(
|
||||
date.atTime(21, 30),
|
||||
"Enugu",
|
||||
R.color.red_800,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
currentMonth.atDay(22).also { date ->
|
||||
add(
|
||||
Flight(
|
||||
date.atTime(13, 20),
|
||||
"Ibadan",
|
||||
R.color.brown_700,
|
||||
),
|
||||
)
|
||||
add(
|
||||
Flight(
|
||||
date.atTime(17, 40),
|
||||
"Sokoto",
|
||||
R.color.blue_grey_700,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
currentMonth.atDay(3).also { date ->
|
||||
add(
|
||||
Flight(
|
||||
date.atTime(20, 0),
|
||||
"Makurdi",
|
||||
R.color.teal_700,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
currentMonth.atDay(12).also { date ->
|
||||
add(
|
||||
Flight(
|
||||
date.atTime(18, 15),
|
||||
"Kaduna",
|
||||
R.color.cyan_700,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
currentMonth.plusMonths(1).atDay(13).also { date ->
|
||||
add(
|
||||
Flight(
|
||||
date.atTime(7, 30),
|
||||
"Kano",
|
||||
R.color.pink_700,
|
||||
),
|
||||
)
|
||||
add(
|
||||
Flight(
|
||||
date.atTime(10, 50),
|
||||
"Minna",
|
||||
R.color.green_700,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
currentMonth.minusMonths(1).atDay(9).also { date ->
|
||||
add(
|
||||
Flight(
|
||||
date.atTime(20, 15),
|
||||
"Asaba",
|
||||
R.color.orange_800,
|
||||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
val flightDateTimeFormatter: DateTimeFormatter =
|
||||
DateTimeFormatter.ofPattern("EEE'\n'dd MMM'\n'HH:mm")
|
|
@ -0,0 +1,43 @@
|
|||
package com.example.calendarev2.sample.shared
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.graphics.Color
|
||||
import android.os.Build
|
||||
import android.view.View
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import androidx.lifecycle.DefaultLifecycleObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import com.example.calendarev2.R
|
||||
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
class StatusBarColorLifecycleObserver(
|
||||
activity: Activity,
|
||||
@ColorInt private val color: Int,
|
||||
) : DefaultLifecycleObserver {
|
||||
private val isLightColor = ColorUtils.calculateLuminance(color) > 0.5
|
||||
private val defaultStatusBarColor = R.color.colorPrimaryDark
|
||||
private val activity = WeakReference(activity)
|
||||
|
||||
override fun onStart(owner: LifecycleOwner) {
|
||||
activity.get()?.window?.apply {
|
||||
statusBarColor = color
|
||||
if (isLightColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
decorView.systemUiVisibility = View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("ResourceAsColor")
|
||||
override fun onStop(owner: LifecycleOwner) {
|
||||
activity.get()?.window?.apply {
|
||||
statusBarColor = defaultStatusBarColor
|
||||
if (isLightColor) decorView.systemUiVisibility = 0
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy(owner: LifecycleOwner) = activity.clear()
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package com.example.calendarev2.sample.shared
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.ContextWrapper
|
||||
import com.kizitonwose.calendar.core.Week
|
||||
import com.kizitonwose.calendar.core.yearMonth
|
||||
import java.time.DayOfWeek
|
||||
import java.time.Month
|
||||
import java.time.YearMonth
|
||||
import java.time.format.TextStyle
|
||||
import java.util.*
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
fun YearMonth.displayText(short: Boolean = false): String {
|
||||
return "${this.month.displayText(short = short)} ${this.year}"
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
fun Month.displayText(short: Boolean = true): String {
|
||||
val style = if (short) TextStyle.SHORT else TextStyle.FULL
|
||||
return getDisplayName(style, Locale.ENGLISH)
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
fun DayOfWeek.displayText(uppercase: Boolean = false): String {
|
||||
return getDisplayName(TextStyle.SHORT, Locale.ENGLISH).let { value ->
|
||||
if (uppercase) value.uppercase(Locale.ENGLISH) else value
|
||||
}
|
||||
}
|
||||
|
||||
fun Context.findActivity(): Activity {
|
||||
var context = this
|
||||
while (context is ContextWrapper) {
|
||||
if (context is Activity) return context
|
||||
context = context.baseContext
|
||||
}
|
||||
throw IllegalStateException("no activity")
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
fun getWeekPageTitle(week: Week): String {
|
||||
val firstDate = week.days.first().date
|
||||
val lastDate = week.days.last().date
|
||||
return when {
|
||||
firstDate.yearMonth == lastDate.yearMonth -> {
|
||||
firstDate.yearMonth.displayText()
|
||||
}
|
||||
firstDate.year == lastDate.year -> {
|
||||
"${firstDate.month.displayText(short = false)} - ${lastDate.yearMonth.displayText()}"
|
||||
}
|
||||
else -> {
|
||||
"${firstDate.yearMonth.displayText()} - ${lastDate.yearMonth.displayText()}"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
package com.example.rehabilitation.User.fragmentUser
|
||||
|
||||
class DayViewContainer {
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.example.calendarev2
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.example.calendarev2.databinding.Example5EventItemViewv2Binding
|
||||
|
||||
|
||||
class CalendareAdapter :
|
||||
RecyclerView.Adapter<CalendareAdapter.Example5FlightsViewHolder>() {
|
||||
|
||||
val flights = mutableListOf<Flight>()
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): Example5FlightsViewHolder {
|
||||
return Example5FlightsViewHolder(
|
||||
Example5EventItemViewv2Binding.inflate(parent.context.layoutInflater, parent, false),
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(viewHolder: Example5FlightsViewHolder, position: Int) {
|
||||
viewHolder.bind(flights[position])
|
||||
}
|
||||
|
||||
override fun getItemCount(): Int = flights.size
|
||||
|
||||
inner class Example5FlightsViewHolder(val binding: Example5EventItemViewv2Binding) :
|
||||
RecyclerView.ViewHolder(binding.root) {
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
fun bind(flight: Flight) {
|
||||
binding.itemFlightDateText.apply {
|
||||
text = flightDateTimeFormatter.format(flight.time)
|
||||
setBackgroundColor(itemView.context.getColorCompat(flight.color))
|
||||
}
|
||||
|
||||
binding.txtItem.text = flight.item
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:weightSum="7"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<include layout="@layout/calendar_day_legend_text" />
|
||||
|
||||
<include layout="@layout/calendar_day_legend_text" />
|
||||
|
||||
<include layout="@layout/calendar_day_legend_text" />
|
||||
|
||||
<include layout="@layout/calendar_day_legend_text" />
|
||||
|
||||
<include layout="@layout/calendar_day_legend_text" />
|
||||
|
||||
<include layout="@layout/calendar_day_legend_text" />
|
||||
|
||||
<include layout="@layout/calendar_day_legend_text" />
|
||||
|
||||
</LinearLayout>
|
|
@ -0,0 +1,10 @@
|
|||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/legendText1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp"
|
||||
tools:text="SUN" />
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/homeRootLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".view.CalendarViewActivity">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/activityToolbar"
|
||||
android:layout_width="match_parent"
|
||||
app:title="@string/activity_title_view"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/homeContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/examplesRecyclerview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</FrameLayout>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="12dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/itemOptionTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="20sp"
|
||||
tools:text="This is a title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/itemOptionSubtitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="4dp"
|
||||
android:textSize="16sp"
|
||||
tools:text="This is a subtitle" />
|
||||
|
||||
|
||||
</LinearLayout>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
|
||||
android:shape="rectangle">
|
||||
|
||||
<stroke
|
||||
android:width="1dp"
|
||||
android:color="@color/example_5_text_grey" />
|
||||
</shape>
|
Binary file not shown.
Before Width: | Height: | Size: 200 B |
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M19,13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/>
|
||||
</vector>
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@color/example_5_text_grey"
|
||||
android:pathData="M2.5,19H21.5V21H2.5V19M9.68,13.27L14.03,14.43L19.34,15.85C20.14,16.06 20.96,15.59 21.18,14.79C21.39,14 20.92,13.17 20.12,12.95L14.81,11.53L12.05,2.5L10.12,2V10.28L5.15,8.95L4.22,6.63L2.77,6.24V11.41L4.37,11.84L9.68,13.27Z" />
|
||||
</vector>
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
<path
|
||||
android:fillColor="@color/example_5_text_grey"
|
||||
android:pathData="M2.5,19H21.5V21H2.5V19M22.07,9.64C21.86,8.84 21.03,8.36 20.23,8.58L14.92,10L8,3.57L6.09,4.08L10.23,11.25L5.26,12.58L3.29,11.04L1.84,11.43L3.66,14.59L4.43,15.92L6.03,15.5L11.34,14.07L15.69,12.91L21,11.5C21.81,11.26 22.28,10.44 22.07,9.64Z" />
|
||||
</vector>
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M9,16.17L4.83,12l-1.42,1.41L9,19 21,7l-1.41,-1.41z"/>
|
||||
</vector>
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M15.41,7.41L14,6l-6,6 6,6 1.41,-1.41L10.83,12z"/>
|
||||
</vector>
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M10,6L8.59,7.41 13.17,12l-4.58,4.59L10,18l6,-6z"/>
|
||||
</vector>
|
|
@ -0,0 +1,9 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24.0"
|
||||
android:viewportHeight="24.0">
|
||||
<path
|
||||
android:fillColor="#FF000000"
|
||||
android:pathData="M19,6.41L17.59,5 12,10.59 6.41,5 5,6.41 10.59,12 5,17.59 6.41,19 12,13.41 17.59,19 19,17.59 13.41,12z"/>
|
||||
</vector>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,21 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:weightSum="7"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<include layout="@layout/calendar_day_legend_text" />
|
||||
|
||||
<include layout="@layout/calendar_day_legend_text" />
|
||||
|
||||
<include layout="@layout/calendar_day_legend_text" />
|
||||
|
||||
<include layout="@layout/calendar_day_legend_text" />
|
||||
|
||||
<include layout="@layout/calendar_day_legend_text" />
|
||||
|
||||
<include layout="@layout/calendar_day_legend_text" />
|
||||
|
||||
<include layout="@layout/calendar_day_legend_text" />
|
||||
|
||||
</LinearLayout>
|
|
@ -0,0 +1,10 @@
|
|||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/legendText1"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp"
|
||||
tools:text="SUN" />
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/homeRootLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".view.CalendarViewActivity">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay">
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/activityToolbar"
|
||||
android:layout_width="match_parent"
|
||||
app:title="@string/activity_title_view"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
app:popupTheme="@style/AppTheme.PopupOverlay" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/homeContainer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/examplesRecyclerview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
</FrameLayout>
|
||||
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="12dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/itemOptionTitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fontFamily="sans-serif-medium"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="20sp"
|
||||
tools:text="This is a title" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/itemOptionSubtitle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_marginTop="4dp"
|
||||
android:textSize="16sp"
|
||||
tools:text="This is a subtitle" />
|
||||
|
||||
|
||||
</LinearLayout>
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/exFiveDayLayout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="1dp"
|
||||
android:background="@color/example_5_item_view_bg_color">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/exFiveDayText"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top|end"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp"
|
||||
tools:text="24" />
|
||||
|
||||
<View
|
||||
android:id="@+id/exFiveDayFlightTop"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="5dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginBottom="18dp"
|
||||
android:background="@color/blue_grey_700" />
|
||||
|
||||
<View
|
||||
android:id="@+id/exFiveDayFlightBottom"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="5dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@color/brown_700" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<include
|
||||
android:id="@+id/legendLayout"
|
||||
layout="@layout/calendar_day_legend_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center" />
|
||||
|
||||
</FrameLayout>
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="1dp"
|
||||
android:background="#C6FFFFFF">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/itemFlightDateText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:background="#5D4037"
|
||||
android:gravity="center"
|
||||
android:lineSpacingExtra="2.5dp"
|
||||
android:textAllCaps="true"
|
||||
android:textColor="@color/example_5_text_grey"
|
||||
android:textSize="12sp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="H,1:1"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintWidth_default="percent"
|
||||
app:layout_constraintWidth_percent="0.143"
|
||||
tools:text="THU\nJUN 30\n14:00" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/txtItem"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginEnd="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:gravity="center"
|
||||
android:text="TextView"
|
||||
android:textColor="#000000"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toEndOf="@+id/itemFlightDateText"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<!--Colored view divider-->
|
||||
|
||||
<!--Departure/Destination dividers-->
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -0,0 +1,83 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<!-- The xml resource that is inflated and used as the day cell view, must be provided. -->
|
||||
<attr name="cv_dayViewResource" format="reference" />
|
||||
|
||||
<!-- The scrolling behavior of the calendar. If `true`, the calendar will
|
||||
snap to the nearest month or week (in the WeekCalendarView) after a scroll
|
||||
or swipe action. If `false`, the calendar scrolls normally. -->
|
||||
<attr name="cv_scrollPaged" format="boolean" />
|
||||
|
||||
<!-- Determines how the size of each day on the calendar is calculated. -->
|
||||
<attr name="cv_daySize" format="enum">
|
||||
<!-- Each day will have both width and height matching
|
||||
the width of the calendar divided by 7. -->
|
||||
<enum name="square" value="0" />
|
||||
<!-- Each day will have its width matching the width of the calendar
|
||||
divided by 7, and its height matching the height of the calendar divided
|
||||
by the number of weeks in the index - could be 4, 5 or 6 for the month
|
||||
calendar and 1 for the week calendar. Use this if you want each month or
|
||||
week to fill the parent's width and height. -->
|
||||
<enum name="rectangle" value="1" />
|
||||
<!-- Each day will have its width matching the width of the calendar
|
||||
divided by 7. The day is allowed to determine its height by
|
||||
setting a specific value or using [ViewGroup.LayoutParams.WRAP_CONTENT]. -->
|
||||
<enum name="seventhWidth" value="2" />
|
||||
<!-- This day is allowed to determine its width and height by
|
||||
setting specific values or using [ViewGroup.LayoutParams.WRAP_CONTENT]. -->
|
||||
<enum name="freeForm" value="3" />
|
||||
</attr>
|
||||
|
||||
<declare-styleable name="CalendarView">
|
||||
<attr name="cv_dayViewResource" />
|
||||
|
||||
<!-- The xml resource that is inflated and used as a header for every month. -->
|
||||
<attr name="cv_monthHeaderResource" format="reference" />
|
||||
|
||||
<!-- The xml resource that is inflated and used as a footer for every month. -->
|
||||
<attr name="cv_monthFooterResource" format="reference" />
|
||||
|
||||
<!-- Determines how outDates are generated for each month on the calendar. -->
|
||||
<attr name="cv_outDateStyle" format="enum">
|
||||
<!-- The calendar will generate outDates until it reaches the end
|
||||
of the month row. This means that if a month has 5 rows, it will
|
||||
display 5 rows and if a month has 6 rows, it will display 6 rows. -->
|
||||
<enum name="endOfRow" value="0" />
|
||||
<!-- The calendar will generate outDates until it reaches the end
|
||||
of a 6 x 7 grid on each month. This means that all months will have 6 rows. -->
|
||||
<enum name="endOfGrid" value="1" />
|
||||
</attr>
|
||||
|
||||
<!-- A ViewGroup which is instantiated and used as the container for each month.
|
||||
This class must have a constructor which takes only a Context. You should
|
||||
exclude the name and constructor of this class from code obfuscation if enabled. -->
|
||||
<attr name="cv_monthViewClass" format="string" />
|
||||
|
||||
<!--This determines the scroll direction of the the calendar. -->
|
||||
<attr name="cv_orientation" format="enum">
|
||||
<enum name="horizontal" value="0" />
|
||||
<enum name="vertical" value="1" />
|
||||
</attr>
|
||||
|
||||
<attr name="cv_scrollPaged" />
|
||||
<attr name="cv_daySize" />
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="WeekCalendarView">
|
||||
<attr name="cv_dayViewResource" />
|
||||
|
||||
<!-- The xml resource that is inflated and used as a header for every week. -->
|
||||
<attr name="cv_weekHeaderResource" format="reference" />
|
||||
|
||||
<!-- The xml resource that is inflated and used as a footer for every week. -->
|
||||
<attr name="cv_weekFooterResource" format="reference" />
|
||||
|
||||
<!-- A ViewGroup which is instantiated and used as the container for each week.
|
||||
This class must have a constructor which takes only a Context. You should
|
||||
exclude the name and constructor of this class from code obfuscation if enabled. -->
|
||||
<attr name="cv_weekViewClass" format="string" />
|
||||
|
||||
<attr name="cv_scrollPaged" />
|
||||
<attr name="cv_daySize" />
|
||||
</declare-styleable>
|
||||
</resources>
|
Loading…
Reference in New Issue