Skip to content

Commit

Permalink
Merge pull request EventFahrplan#574 from EventFahrplan/engelsystem-s…
Browse files Browse the repository at this point in the history
…hift-type-api

Use new Engelsystem shift type API
  • Loading branch information
johnjohndoe authored Nov 22, 2023
2 parents 0071b5c + c6edd7f commit 4fd2afe
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ fun Shift.toSessionAppModel(
room = virtualRoomName
speakers = emptyList()
startTime = minuteOfDay // minutes since day start
title = name
subtitle = talkTitle
title = talkTitle
subtitle = locationName
// Shift.timeZoneName is not mapped here. Using Meta.timeZoneName instead.
track = virtualRoomName
track = typeName
url = talkUrl
}

Expand All @@ -60,15 +60,18 @@ private val Shift.dateUtcMs
val Shift.descriptionText: String
get() {
var text = ""
if (locationName.isNotEmpty()) {
text += locationName
}
if (locationUrl.isNotEmpty()) {
if (text.isNotEmpty()) {
text += "\n"
}
text += "<a href=\"$locationUrl\">$locationUrl</a>"
}
if (typeDescription.isNotEmpty()) {
if (text.isNotEmpty()) {
text += "\n\n"
}
text += typeDescription
}
if (locationDescription.isNotEmpty()) {
if (text.isNotEmpty()) {
text += "\n\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.viewModels
import info.metadude.android.eventfahrplan.commons.flow.observe
import io.noties.markwon.AbstractMarkwonPlugin
import io.noties.markwon.Markwon
import io.noties.markwon.core.MarkwonTheme
import io.noties.markwon.linkify.LinkifyPlugin
import nerd.tuxmobil.fahrplan.congress.BuildConfig
import nerd.tuxmobil.fahrplan.congress.R
Expand Down Expand Up @@ -59,6 +61,15 @@ class SessionDetailsFragment : Fragment() {
private const val SCHEDULE_FEEDBACK_URL = BuildConfig.SCHEDULE_FEEDBACK_URL
private val SHOW_FEEDBACK_MENU_ITEM = !TextUtils.isEmpty(SCHEDULE_FEEDBACK_URL)

// Custom heading text size multipliers for each heading level.
// Docs: https://noties.io/Markwon/docs/v4/core/theme.html#typeface
private val HEADING_TEXT_SIZE_MULTIPLIERS = floatArrayOf(1.25f, 1.18f, 1.07F, 1.0f, .83F, .67F)
private val HEADINGS_PLUGIN = object : AbstractMarkwonPlugin() {
override fun configureTheme(builder: MarkwonTheme.Builder) {
builder.headingTextSizeMultipliers(HEADING_TEXT_SIZE_MULTIPLIERS)
}
}

@JvmStatic
fun replaceAtBackStack(fragmentManager: FragmentManager, @IdRes containerViewId: Int, sidePane: Boolean) {
val fragment = SessionDetailsFragment().withArguments(
Expand Down Expand Up @@ -114,6 +125,7 @@ class SessionDetailsFragment : Fragment() {
alarmServices = AlarmServices.newInstance(context, appRepository)
notificationHelper = NotificationHelper(context)
markwon = Markwon.builder(requireContext())
.usePlugin(HEADINGS_PLUGIN)
.usePlugin(LinkifyPlugin.create())
.build()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ShiftExtensionsTest {

@Test
fun descriptionTextWithShiftWithLocationName() {
assertThat(Shift(locationName = "Room 23").descriptionText).isEqualTo("Room 23")
assertThat(Shift(locationName = "Room 23").descriptionText).isEqualTo("")
}

@Test
Expand All @@ -71,7 +71,7 @@ class ShiftExtensionsTest {
locationDescription = "The small orange room.",
userComment = "Take a bottle of water with you"
)
val text = "Room 42\n<a href=\"https://conference.org\">https://conference.org</a>\n\nThe small orange room.\n\n_Take a bottle of water with you_"
val text = "<a href=\"https://conference.org\">https://conference.org</a>\n\nThe small orange room.\n\n_Take a bottle of water with you_"
assertThat(shift.descriptionText).isEqualTo(text)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ object Libs {
const val coreKtx = "1.9.0"
const val coreTesting = "2.2.0"
const val emailIntentBuilder = "2.0.0"
const val engelsystem = "7.3.0"
const val engelsystem = "8.0.0"
const val espresso = "3.5.1"
const val junit = "4.13.2"
const val kotlinCoroutines = "1.7.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class EngelsystemNetworkRepositoryTest {
const val VALID_ONE_ITEM_SHIFTS_JSON = """
[
{
"Comment": "This is a very secret comment.",
"user_comment": "This is a very secret comment.",
"Name": "Kirmes",
"RID": 12,
"SID": 579,
Expand All @@ -46,8 +46,9 @@ class EngelsystemNetworkRepositoryTest {
"event_timezone": "Europe/Berlin",
"freeloaded": 0,
"id": 37,
"name": "Collect stickers",
"shifttype_id": 6,
"shifttype_name": "Name of the shift type",
"shifttype_description": "# Description of the shift type as markdown\n",
"start_date": "2019-08-21T13:00:00+02:00",
"title": "Tag 1: Decorate fridge"
}
Expand All @@ -65,12 +66,13 @@ class EngelsystemNetworkRepositoryTest {
endsAtDate = ENDS_AT,
locationDescription = "Kirmes are fun.",
locationName = "Kirmes",
name = "Collect stickers",
sID = 579,
startsAtDate = STARTS_AT,
talkTitle = "Tag 1: Decorate fridge",
timeZoneName = "Europe/Berlin",
typeId = 6
typeId = 6,
typeName = "Name of the shift type",
typeDescription = "# Description of the shift type as markdown\n",
))
const val URL = "https://example.com/test/shifts-json-export/file.json?key=111111"

Expand Down

0 comments on commit 4fd2afe

Please sign in to comment.