Skip to content

Commit

Permalink
Merge pull request EventFahrplan#723 from EventFahrplan/random-housek…
Browse files Browse the repository at this point in the history
…eeping

Random housekeeping (Favorites padding, session details name, add interfaces, room state unit tests).
  • Loading branch information
johnjohndoe authored Feb 19, 2025
2 parents 48c6061 + e39af86 commit 48bba69
Show file tree
Hide file tree
Showing 35 changed files with 374 additions and 161 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<activity
android:name=".details.SessionDetailsActivity"
android:configChanges="keyboardHidden|orientation"
android:label="@string/fahrplan"
android:label="@string/session_details_screen_name"
android:uiOptions="splitActionBarWhenNarrow"
android:resizeableActivity="true"
android:parentActivityName="nerd.tuxmobil.fahrplan.congress.schedule.MainActivity">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import nerd.tuxmobil.fahrplan.congress.models.Session
import nerd.tuxmobil.fahrplan.congress.utils.MarkdownConversion
import nerd.tuxmobil.fahrplan.congress.utils.MarkdownConverter
import nerd.tuxmobil.fahrplan.congress.utils.SessionPropertiesFormatter
import nerd.tuxmobil.fahrplan.congress.utils.SessionPropertiesFormatting
import nerd.tuxmobil.fahrplan.congress.utils.SessionUrlComposer
import nerd.tuxmobil.fahrplan.congress.utils.SessionUrlComposition
import nerd.tuxmobil.fahrplan.congress.wiki.containsWikiLink
Expand All @@ -16,7 +17,7 @@ import nerd.tuxmobil.fahrplan.congress.wiki.containsWikiLink
class CalendarDescriptionComposer(

private val sessionOnlineText: String,
private val sessionPropertiesFormatter: SessionPropertiesFormatter = SessionPropertiesFormatter(),
private val sessionPropertiesFormatting: SessionPropertiesFormatting = SessionPropertiesFormatter(),
private val markdownConversion: MarkdownConversion = MarkdownConverter,
private val sessionUrlComposition: SessionUrlComposition = SessionUrlComposer()

Expand Down Expand Up @@ -46,7 +47,7 @@ class CalendarDescriptionComposer(
}

private fun StringBuilder.appendSpeakers(session: Session) {
appendParagraphIfNotEmpty(sessionPropertiesFormatter.getFormattedSpeakers(session))
appendParagraphIfNotEmpty(sessionPropertiesFormatting.getFormattedSpeakers(session))
}

private fun StringBuilder.appendAbstract(session: Session) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package nerd.tuxmobil.fahrplan.congress.changes

import android.app.Activity
import android.content.Intent
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import androidx.appcompat.widget.Toolbar
import androidx.core.content.ContextCompat
Expand All @@ -11,6 +10,7 @@ import nerd.tuxmobil.fahrplan.congress.base.AbstractListFragment.OnSessionListCl
import nerd.tuxmobil.fahrplan.congress.base.BaseActivity
import nerd.tuxmobil.fahrplan.congress.details.SessionDetailsActivity
import nerd.tuxmobil.fahrplan.congress.repositories.AppRepository
import androidx.core.graphics.drawable.toDrawable

class ChangeListActivity :
BaseActivity(),
Expand Down Expand Up @@ -39,7 +39,7 @@ class ChangeListActivity :
val toolbar = requireViewByIdCompat<Toolbar>(R.id.toolbar)
setSupportActionBar(toolbar)
val actionBarColor = ContextCompat.getColor(this, R.color.colorActionBar)
supportActionBar!!.setBackgroundDrawable(ColorDrawable(actionBarColor))
supportActionBar!!.setBackgroundDrawable(actionBarColor.toDrawable())
}

override fun onSessionListClick(sessionId: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import info.metadude.android.eventfahrplan.commons.temporal.DateFormatter
import nerd.tuxmobil.fahrplan.congress.commons.ResourceResolving
import nerd.tuxmobil.fahrplan.congress.repositories.AppExecutionContext
import nerd.tuxmobil.fahrplan.congress.repositories.AppRepository
import nerd.tuxmobil.fahrplan.congress.utils.ContentDescriptionFormatter
import nerd.tuxmobil.fahrplan.congress.utils.SessionPropertiesFormatter
import nerd.tuxmobil.fahrplan.congress.utils.ContentDescriptionFormatting
import nerd.tuxmobil.fahrplan.congress.utils.SessionPropertiesFormatting

class ChangeListViewModelFactory(
private val appRepository: AppRepository,
private val resourceResolving: ResourceResolving,
private val sessionPropertiesFormatter: SessionPropertiesFormatter,
private val contentDescriptionFormatter: ContentDescriptionFormatter,
private val sessionPropertiesFormatting: SessionPropertiesFormatting,
private val contentDescriptionFormatting: ContentDescriptionFormatting,
) : Factory {

override fun <T : ViewModel> create(modelClass: Class<T>): T {
Expand All @@ -23,8 +23,8 @@ class ChangeListViewModelFactory(
executionContext = AppExecutionContext,
sessionChangeParametersFactory = SessionChangeParametersFactory(
resourceResolving = resourceResolving,
sessionPropertiesFormatter = sessionPropertiesFormatter,
contentDescriptionFormatter = contentDescriptionFormatter,
sessionPropertiesFormatting = sessionPropertiesFormatting,
contentDescriptionFormatting = contentDescriptionFormatting,
onDateFormatter = { useDeviceTimeZone -> DateFormatter.newInstance(useDeviceTimeZone) }
)
) as T
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import nerd.tuxmobil.fahrplan.congress.commons.VideoRecordingState.Drawable.Avai
import nerd.tuxmobil.fahrplan.congress.commons.VideoRecordingState.Drawable.Unavailable
import nerd.tuxmobil.fahrplan.congress.commons.VideoRecordingState.None
import nerd.tuxmobil.fahrplan.congress.models.Session
import nerd.tuxmobil.fahrplan.congress.utils.ContentDescriptionFormatter
import nerd.tuxmobil.fahrplan.congress.utils.SessionPropertiesFormatter
import nerd.tuxmobil.fahrplan.congress.utils.ContentDescriptionFormatting
import nerd.tuxmobil.fahrplan.congress.utils.SessionPropertiesFormatting

class SessionChangeParametersFactory(
private val resourceResolving: ResourceResolving,
private val sessionPropertiesFormatter: SessionPropertiesFormatter,
private val contentDescriptionFormatter: ContentDescriptionFormatter,
private val sessionPropertiesFormatting: SessionPropertiesFormatting,
private val contentDescriptionFormatting: ContentDescriptionFormatting,
private val onDateFormatter: (useDeviceTimeZone: Boolean) -> DateFormatter,
) {

Expand Down Expand Up @@ -50,7 +50,7 @@ class SessionChangeParametersFactory(
private fun sessionChangeOf(session: Session, dayText: String, dash: String, useDeviceTimeZone: Boolean): SessionChange {
val startsAt = onDateFormatter(useDeviceTimeZone).getFormattedTime(session.dateUTC, session.timeZoneOffset)
val duration = resourceResolving.getString(R.string.session_list_item_duration_text, session.duration)
val languages = sessionPropertiesFormatter.getLanguageText(session)
val languages = sessionPropertiesFormatting.getLanguageText(session)
val videoState = when {
session.changedRecordingOptOut -> when {
session.recordingOptOut -> Unavailable
Expand All @@ -59,7 +59,7 @@ class SessionChangeParametersFactory(

else -> None
}
val speakerNames = sessionPropertiesFormatter.getFormattedSpeakers(session)
val speakerNames = sessionPropertiesFormatting.getFormattedSpeakers(session)
val title = if (session.changedTitle && session.title.isEmpty()) dash else session.title

return SessionChange(
Expand All @@ -71,7 +71,7 @@ class SessionChangeParametersFactory(
),
subtitle = SessionChangeProperty(
value = if (session.changedSubtitle && session.subtitle.isEmpty()) dash else session.subtitle,
contentDescription = contentDescriptionFormatter
contentDescription = contentDescriptionFormatting
.getSubtitleContentDescription(session.subtitle),
changeState = changeStateOf(session, session.changedSubtitle),
),
Expand All @@ -82,7 +82,7 @@ class SessionChangeParametersFactory(
),
speakerNames = SessionChangeProperty(
value = if (session.changedSpeakers && session.speakers.isEmpty()) dash else speakerNames,
contentDescription = contentDescriptionFormatter
contentDescription = contentDescriptionFormatting
.getSpeakersContentDescription(session.speakers.size, speakerNames),
changeState = changeStateOf(session, session.changedSpeakers),
),
Expand All @@ -93,19 +93,19 @@ class SessionChangeParametersFactory(
),
startsAt = SessionChangeProperty(
value = startsAt,
contentDescription = contentDescriptionFormatter
contentDescription = contentDescriptionFormatting
.getStartTimeContentDescription(startsAt),
changeState = changeStateOf(session, session.changedStartTime),
),
duration = SessionChangeProperty(
value = duration,
contentDescription = contentDescriptionFormatter
contentDescription = contentDescriptionFormatting
.getDurationContentDescription(session.duration),
changeState = changeStateOf(session, session.changedDuration),
),
roomName = SessionChangeProperty(
value = session.roomName,
contentDescription = contentDescriptionFormatter
contentDescription = contentDescriptionFormatting
.getRoomNameContentDescription(session.roomName),
changeState = changeStateOf(session, session.changedRoomName),
),
Expand All @@ -114,7 +114,7 @@ class SessionChangeParametersFactory(
contentDescription = if (session.changedLanguage && session.language.isEmpty()) {
resourceResolving.getString(R.string.session_list_item_language_removed_content_description)
} else {
contentDescriptionFormatter.getLanguageContentDescription(languages)
contentDescriptionFormatting.getLanguageContentDescription(languages)
},
changeState = changeStateOf(session, session.changedLanguage),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ object DateFormatterDelegate : FormattingDelegate {

override fun getFormattedDateTimeShort(
useDeviceTimeZone: Boolean,
alarmTime: Long,
dateUtc: Long,
timeZoneOffset: ZoneOffset?,
) = DateFormatter
.newInstance(useDeviceTimeZone)
.getFormattedDateTimeShort(alarmTime, timeZoneOffset)
.getFormattedDateTimeShort(dateUtc, timeZoneOffset)

override fun getFormattedDateTimeLong(
useDeviceTimeZone: Boolean,
dateUtc: Long,
sessionTimeZoneOffset: ZoneOffset?,
timeZoneOffset: ZoneOffset?,
) = DateFormatter
.newInstance(useDeviceTimeZone)
.getFormattedDateTimeLong(dateUtc, sessionTimeZoneOffset)
.getFormattedDateTimeLong(dateUtc, timeZoneOffset)

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ interface FormattingDelegate {

fun getFormattedDateTimeShort(
useDeviceTimeZone: Boolean,
alarmTime: Long,
dateUtc: Long,
timeZoneOffset: ZoneOffset?,
): String

fun getFormattedDateTimeLong(
useDeviceTimeZone: Boolean,
dateUtc: Long,
sessionTimeZoneOffset: ZoneOffset?,
timeZoneOffset: ZoneOffset?,
): String

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package nerd.tuxmobil.fahrplan.congress.details

import android.app.Activity
import android.content.Intent
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.View
import androidx.core.content.ContextCompat
import nerd.tuxmobil.fahrplan.congress.R
import nerd.tuxmobil.fahrplan.congress.base.BaseActivity
import nerd.tuxmobil.fahrplan.congress.extensions.isLandscape
import nerd.tuxmobil.fahrplan.congress.utils.showWhenLockedCompat
import androidx.core.graphics.drawable.toDrawable

class SessionDetailsActivity : BaseActivity(R.layout.detail_frame) {

Expand Down Expand Up @@ -36,9 +37,10 @@ class SessionDetailsActivity : BaseActivity(R.layout.detail_frame) {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
supportActionBar!!.title = if (isLandscape()) getString(R.string.session_details_screen_name) else ""
supportActionBar!!.setDisplayHomeAsUpEnabled(true)
val actionBarColor = ContextCompat.getColor(this, R.color.colorActionBar)
supportActionBar!!.setBackgroundDrawable(ColorDrawable(actionBarColor))
supportActionBar!!.setBackgroundDrawable(actionBarColor.toDrawable())

val intent = this.intent
if (intent == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import nerd.tuxmobil.fahrplan.congress.repositories.AppRepository
import nerd.tuxmobil.fahrplan.congress.sharing.SessionSharer
import nerd.tuxmobil.fahrplan.congress.sidepane.OnSidePaneCloseListener
import nerd.tuxmobil.fahrplan.congress.utils.ContentDescriptionFormatter
import nerd.tuxmobil.fahrplan.congress.utils.ContentDescriptionFormatting
import nerd.tuxmobil.fahrplan.congress.utils.LinkMovementMethodCompat
import nerd.tuxmobil.fahrplan.congress.utils.ServerBackendType
import nerd.tuxmobil.fahrplan.congress.utils.TypefaceFactory
Expand Down Expand Up @@ -121,7 +122,7 @@ class SessionDetailsFragment : Fragment(), MenuProvider {
)
}
private lateinit var model: SelectedSessionParameter
private lateinit var contentDescriptionFormatter: ContentDescriptionFormatter
private lateinit var contentDescriptionFormatting: ContentDescriptionFormatting
private lateinit var markwon: Markwon
private var sidePane = false
private var hasArguments = false
Expand All @@ -147,7 +148,7 @@ class SessionDetailsFragment : Fragment(), MenuProvider {
appRepository = AppRepository
alarmServices = AlarmServices.newInstance(context, appRepository)
notificationHelper = NotificationHelper(context)
contentDescriptionFormatter = ContentDescriptionFormatter(ResourceResolver(context))
contentDescriptionFormatting = ContentDescriptionFormatter(ResourceResolver(context))
markwon = Markwon.builder(context)
.usePlugin(HEADINGS_PLUGIN)
.usePlugin(createListItemsPlugin(context))
Expand Down Expand Up @@ -290,13 +291,13 @@ class SessionDetailsFragment : Fragment(), MenuProvider {
var textView: TextView = view.requireViewByIdCompat(R.id.session_detailbar_date_time_view)
textView.text = if (model.hasDateUtc) model.formattedZonedDateTimeShort else ""
if (model.hasDateUtc) {
textView.contentDescription = contentDescriptionFormatter
textView.contentDescription = contentDescriptionFormatting
.getStartTimeContentDescription(model.formattedZonedDateTimeLong)
}

textView = view.requireViewByIdCompat(R.id.session_detailbar_location_view)
textView.text = model.roomName
textView.contentDescription = contentDescriptionFormatter
textView.contentDescription = contentDescriptionFormatting
.getRoomNameContentDescription(model.roomName)
textView = view.requireViewByIdCompat(R.id.session_detailbar_session_id_view)
textView.text = if (model.sessionId.isEmpty()) "" else textView.context.getString(R.string.session_details_session_id, model.sessionId)
Expand All @@ -312,7 +313,7 @@ class SessionDetailsFragment : Fragment(), MenuProvider {
textView.isVisible = false
} else {
typeface = typefaceFactory.getTypeface(viewModel.subtitleFont)
textView.applyText(typeface, model.subtitle, contentDescriptionFormatter
textView.applyText(typeface, model.subtitle, contentDescriptionFormatting
.getSubtitleContentDescription(model.subtitle))
}

Expand All @@ -322,7 +323,7 @@ class SessionDetailsFragment : Fragment(), MenuProvider {
textView.isVisible = false
} else {
typeface = typefaceFactory.getTypeface(viewModel.speakersFont)
val speakerNamesContentDescription = contentDescriptionFormatter
val speakerNamesContentDescription = contentDescriptionFormatting
.getSpeakersContentDescription(model.speakersCount, model.speakerNames)
textView.applyText(typeface, model.speakerNames, speakerNamesContentDescription)
}
Expand Down
Loading

0 comments on commit 48bba69

Please sign in to comment.