mirror of
https://github.com/szkolny-eu/szkolny-android.git
synced 2025-01-18 21:06:44 -06:00
[UI/Events] Add button tooltips in dialogs. Add showing weekday in home card. Add 'go to timetable' button in details dialog.
This commit is contained in:
parent
2bea18dc3c
commit
d7d0c6f822
@ -18,6 +18,7 @@ import pl.szczodrzynski.edziennik.*
|
||||
import pl.szczodrzynski.edziennik.data.api.szkolny.SzkolnyApi
|
||||
import pl.szczodrzynski.edziennik.data.db.full.EventFull
|
||||
import pl.szczodrzynski.edziennik.databinding.DialogEventDetailsBinding
|
||||
import pl.szczodrzynski.edziennik.ui.modules.timetable.TimetableFragment
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import kotlin.coroutines.CoroutineContext
|
||||
|
||||
@ -118,9 +119,43 @@ class EventDetailsDialog(
|
||||
)
|
||||
}
|
||||
|
||||
b.goToTimetableButton.setOnClickListener {
|
||||
dialog.dismiss()
|
||||
val dateStr = event.eventDate?.stringY_m_d ?: return@setOnClickListener
|
||||
|
||||
val intent =
|
||||
if (activity is MainActivity && activity.navTargetId == MainActivity.DRAWER_ITEM_TIMETABLE)
|
||||
Intent(TimetableFragment.ACTION_SCROLL_TO_DATE)
|
||||
else if (activity is MainActivity)
|
||||
Intent("android.intent.action.MAIN")
|
||||
else
|
||||
Intent(activity, MainActivity::class.java)
|
||||
|
||||
intent.apply {
|
||||
putExtra("fragmentId", MainActivity.DRAWER_ITEM_TIMETABLE)
|
||||
putExtra("timetableDate", dateStr)
|
||||
}
|
||||
if (activity is MainActivity)
|
||||
activity.sendBroadcast(intent)
|
||||
else
|
||||
activity.startActivity(intent)
|
||||
}
|
||||
b.saveInCalendarButton.setOnClickListener {
|
||||
openInCalendar()
|
||||
}
|
||||
|
||||
b.goToTimetableButton.setOnLongClickListener {
|
||||
Toast.makeText(activity, R.string.hint_go_to_timetable, Toast.LENGTH_SHORT).show()
|
||||
true
|
||||
}
|
||||
b.saveInCalendarButton.setOnLongClickListener {
|
||||
Toast.makeText(activity, R.string.hint_save_in_calendar, Toast.LENGTH_SHORT).show()
|
||||
true
|
||||
}
|
||||
b.editButton.setOnLongClickListener {
|
||||
Toast.makeText(activity, R.string.hint_edit_event, Toast.LENGTH_SHORT).show()
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
private fun showRemoveEventDialog() {
|
||||
|
@ -8,16 +8,19 @@ import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import pl.szczodrzynski.edziennik.*
|
||||
import pl.szczodrzynski.edziennik.data.db.full.EventFull
|
||||
import pl.szczodrzynski.edziennik.databinding.EventListItemBinding
|
||||
import pl.szczodrzynski.edziennik.utils.models.Date
|
||||
import pl.szczodrzynski.edziennik.utils.models.Week
|
||||
|
||||
class EventListAdapter(
|
||||
val context: Context,
|
||||
val simpleMode: Boolean = false,
|
||||
val showDate: Boolean = false,
|
||||
val showWeekDay: Boolean = false,
|
||||
val onItemClick: ((event: EventFull) -> Unit)? = null,
|
||||
val onEventEditClick: ((event: EventFull) -> Unit)? = null
|
||||
) : RecyclerView.Adapter<EventListAdapter.ViewHolder>() {
|
||||
@ -47,6 +50,7 @@ class EventListAdapter(
|
||||
b.topic.text = event.topic
|
||||
|
||||
b.details.text = mutableListOf<CharSequence?>(
|
||||
if (showWeekDay) Week.getFullDayName(event.eventDate.weekDay) else null,
|
||||
if (showDate) event.eventDate.getRelativeString(context, 7) ?: event.eventDate.formattedStringShort else null,
|
||||
event.typeName,
|
||||
if (simpleMode) null else event.startTime?.stringHM ?: app.getString(R.string.event_all_day),
|
||||
@ -70,11 +74,16 @@ class EventListAdapter(
|
||||
|
||||
b.typeColor.background?.setTintColor(event.getColor())
|
||||
|
||||
b.editButton.visibility = if (event.addedManually) View.VISIBLE else View.GONE
|
||||
b.editButton.visibility = if (event.addedManually && !simpleMode) View.VISIBLE else View.GONE
|
||||
b.editButton.onClick {
|
||||
onEventEditClick?.invoke(event)
|
||||
}
|
||||
|
||||
b.editButton.setOnLongClickListener {
|
||||
Toast.makeText(context, R.string.hint_edit_event, Toast.LENGTH_SHORT).show()
|
||||
true
|
||||
}
|
||||
|
||||
/*with(holder) {
|
||||
b.eventListItemRoot.background.colorFilter = when (event.type) {
|
||||
Event.TYPE_HOMEWORK -> PorterDuffColorFilter(0xffffffff.toInt(), PorterDuff.Mode.CLEAR)
|
||||
|
@ -61,6 +61,7 @@ class HomeEventsCard(
|
||||
activity,
|
||||
simpleMode = true,
|
||||
showDate = true,
|
||||
showWeekDay = true,
|
||||
onItemClick = {
|
||||
EventDetailsDialog(
|
||||
activity,
|
||||
|
@ -149,6 +149,12 @@
|
||||
android:textAppearance="@style/NavView.TextView.Medium"
|
||||
tools:text="Rozdział II: Panowanie Piastów i Jagiellonów.Przeniesiony z 11 grudnia." />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="8dp"
|
||||
android:background="@drawable/divider"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
@ -176,6 +182,17 @@
|
||||
android:text="\uFB09"
|
||||
android:textSize="20sp"
|
||||
android:fontFamily="@font/community_material_font_v3_5_95_1" />
|
||||
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/goToTimetableButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="8dp"
|
||||
android:minWidth="0dp"
|
||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||
android:text="\uFCDA"
|
||||
android:textSize="20sp"
|
||||
android:fontFamily="@font/community_material_font_v3_5_95_1" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
@ -69,8 +69,7 @@
|
||||
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
|
||||
android:text="\uFC92"
|
||||
android:textSize="20sp"
|
||||
android:fontFamily="@font/community_material_font_v3_5_95_1"
|
||||
android:visibility="@{simpleMode ? View.GONE : View.VISIBLE}"/>
|
||||
android:fontFamily="@font/community_material_font_v3_5_95_1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -1192,4 +1192,7 @@
|
||||
<string name="card_events_header_title">Najbliższe wydarzenia</string>
|
||||
<string name="events_no_nearest">Nie ma więcej wydarzeń w kalendarzu.</string>
|
||||
<string name="in_format">za %s</string>
|
||||
<string name="hint_save_in_calendar">Zapisz do kalendarza</string>
|
||||
<string name="hint_edit_event">Edytuj wydarzenie</string>
|
||||
<string name="hint_go_to_timetable">Idź do planu lekcji</string>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user