Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/chore/update_gradle811' into cho…
Browse files Browse the repository at this point in the history
…re/update_gradle811

# Conflicts:
#	app/build.gradle
#	app/src/main/java/de/tum/in/tumcampusapp/component/tumui/calendar/WidgetCalendarItem.kt
#	app/src/main/java/de/tum/in/tumcampusapp/component/ui/openinghour/OpeningHoursDetailFragment.java
#	app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/BoughtTicketViewHolder.kt
#	app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/TicketAmountViewHolder.kt
#	app/src/main/java/de/tum/in/tumcampusapp/component/ui/ticket/fragment/EventDetailsFragment.kt
#	app/src/main/java/de/tum/in/tumcampusapp/component/ui/tufilm/KinoDetailsFragment.kt
#	app/src/main/res/values-de/strings.xml
#	app/src/main/res/values/strings.xml
#	build.gradle
  • Loading branch information
tobiasjungmann committed Oct 10, 2023
2 parents 5abc74d + 9af3374 commit 79134a2
Show file tree
Hide file tree
Showing 12 changed files with 537 additions and 57 deletions.
23 changes: 15 additions & 8 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ dependencies {
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2'
implementation 'android.arch.lifecycle:reactivestreams:1.1.1'
implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:2.6.2"
implementation 'android.arch.work:work-runtime-ktx:1.0.1'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.lifecycle:lifecycle-common-java8:2.6.2'
Expand Down Expand Up @@ -137,11 +137,11 @@ dependencies {

// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'androidx.core:core-ktx:1.12.0'
implementation 'androidx.fragment:fragment-ktx:1.6.1'
implementation 'androidx.core:core-ktx:1.8.0'
implementation 'androidx.fragment:fragment-ktx:1.4.1'
// Note: fix for internal androidx libraries using outdated WorkManager causing a crash
implementation "androidx.work:work-runtime-ktx:2.8.1"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
implementation "androidx.work:work-runtime-ktx:2.7.1"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1'

// RxJava
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
Expand All @@ -164,6 +164,7 @@ dependencies {
// UI
implementation 'com.github.mtotschnig:StickyListHeaders:2.8.0'
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
implementation 'me.dm7.barcodescanner:zxing:1.9.13'
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
implementation 'de.psdev.licensesdialog:licensesdialog:2.1.0'
implementation 'com.github.thellmund.Android-Week-View:core:4.1.6'
Expand All @@ -172,11 +173,17 @@ dependencies {
implementation 'com.makeramen:roundedimageview:2.3.0'

// Dagger
implementation 'com.google.dagger:dagger:2.38.1'
kapt 'com.google.dagger:dagger-compiler:2.38.1'
implementation 'com.google.dagger:dagger:2.28.3'
kapt 'com.google.dagger:dagger-compiler:2.28.3'

// LeakCanary
debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1'

// DebugDatabase
debugImplementation 'com.amitshekhar.android:debug-db:1.0.6'

// Testing
testImplementation 'androidx.test:core:1.5.0'
testImplementation 'androidx.test:core:1.4.0'
testImplementation "commons-io:commons-io:2.11.0"

testImplementation 'junit:junit:4.13.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,7 @@ class CreateEventActivity : ActivityForAccessingTumOnline<CreateEventResponse>(R
}

// We’re creating a new event, so we set the start and end time to the next full hour
start = initialDate.toDateTimeAtCurrentTime()
.plusHours(1)
.withMinuteOfHour(0)
.withSecondOfMinute(0)
.withMillisOfSecond(0)
start = initialDate.toDateTimeAtCurrentTime().plusHours(1).withMinuteOfHour(0).withSecondOfMinute(0).withMillisOfSecond(0)
end = start.plusHours(1)
repeatHelper.end = end.plusWeeks(1)
} else {
Expand Down Expand Up @@ -434,19 +430,7 @@ class CreateEventActivity : ActivityForAccessingTumOnline<CreateEventResponse>(R
// event ends after n times
if (repeatHelper.isRepeatingNTimes()) {
for (i in 1 until repeatHelper.times) {
events.add(
CalendarItem(
"",
"",
"",
baseEvent.title,
baseEvent.description,
baseEvent.dtstart.plusWeeks(i),
baseEvent.dtend.plusWeeks(i),
"",
false
)
)
events.add(CalendarItem("", "", "", baseEvent.title, baseEvent.description, baseEvent.dtstart.plusWeeks(i), baseEvent.dtend.plusWeeks(i), "", false))
}
// event ends after "last" date
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,14 @@ data class WidgetCalendarItem(val id: String, val title: String, val startTime:
override fun toWeekViewEvent(): WeekViewEvent<WidgetCalendarItem> {
val style = WeekViewEvent.Style.Builder().setBackgroundColor(color).build()

return WeekViewEvent.Builder(this)
.setId(id.toLong())
.setTitle(title)
.setStartTime(startTime.toGregorianCalendar())
.setEndTime(endTime.toGregorianCalendar())
.setLocation(location)
.setAllDay(false)
.setStyle(style)
.build()
return WeekViewEvent.Builder(this).setId(id.toLong()).setTitle(title).setStartTime(startTime.toGregorianCalendar()).setEndTime(endTime.toGregorianCalendar()).setLocation(location).setAllDay(false).setStyle(style).build()
}

companion object {

@JvmStatic
fun create(calendarItem: CalendarItem): WidgetCalendarItem {
return WidgetCalendarItem(
calendarItem.nr,
calendarItem.getFormattedTitle(),
calendarItem.eventStart,
calendarItem.eventEnd,
calendarItem.getEventLocation()
)
return WidgetCalendarItem(calendarItem.nr, calendarItem.getFormattedTitle(), calendarItem.eventStart, calendarItem.eventEnd, calendarItem.getEventLocation())
}

@JvmStatic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@ enum class CalendarItemType {
*/
@Entity(tableName = "calendar")
data class CalendarItem(
@PrimaryKey
var nr: String = "",
@PrimaryKey var nr: String = "",
var status: String = "",
var url: String = "",
var title: String = "",
var description: String = "",
var dtstart: DateTime = DateTime(),
var dtend: DateTime = DateTime(),
var location: String = "",
@Ignore
var blacklisted: Boolean = false
@Ignore var blacklisted: Boolean = false
) : WeekViewDisplayable<CalendarItem> {

@Ignore
Expand Down Expand Up @@ -83,10 +81,7 @@ data class CalendarItem(
* Formats event's location
*/
fun getEventLocation(): String {
return Pattern.compile("\\([A-Z0-9\\.]+\\)")
.matcher(location)
.replaceAll("")
.trim { it <= ' ' }
return Pattern.compile("\\([A-Z0-9\\.]+\\)").matcher(location).replaceAll("").trim { it <= ' ' }
}

fun getEventDateString(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class OpeningHoursDetailFragment extends Fragment {
static final String ARG_ITEM_ID = "item_id";
static final String ARG_ITEM_CONTENT = "item_content";
static final String TWO_PANE = "two_pane";
// private static final Pattern COMPILE = Pattern.compile("\\\\n");

private int mItemId;
private String mItemContent;
Expand All @@ -56,7 +57,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
View rootView = inflater.inflate(R.layout.fragment_item_detail, container, false);

// click on category in list
LocationDao dao = TcaDb.Companion.getInstance(requireActivity()).locationDao();
LocationDao dao = TcaDb.Companion.getInstance(requireActivity())
.locationDao();
String[] categories = {"library", "info", "cafeteria_gar", "cafeteria_grh", "cafeteria", "cafeteria_pas", "cafeteria_wst"};
List<Location> locations = dao.getAllOfCategory(categories[mItemId]);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package de.tum.`in`.tumcampusapp.component.ui.ticket

import android.view.View
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import de.tum.`in`.tumcampusapp.R
import de.tum.`in`.tumcampusapp.component.ui.ticket.model.TicketInfo
import de.tum.`in`.tumcampusapp.utils.Utils

class BoughtTicketViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

private val amountTextView: TextView by lazy { itemView.findViewById(R.id.ticket_amount) }
private val ticketTypeNameTextView: TextView by lazy { itemView.findViewById(R.id.ticket_type_name) }
private val ticketPriceTextView: TextView by lazy { itemView.findViewById(R.id.price_per_ticket) }

fun bind(ticketInfo: TicketInfo) {
amountTextView.text = itemView.context.getString(R.string.amount_x, ticketInfo.count)
ticketTypeNameTextView.text = ticketInfo.ticketType?.description
ticketPriceTextView.text = itemView.context.getString(
R.string.price_per_ticket,
Utils.formatPrice(ticketInfo.ticketType?.price ?: 0)
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package de.tum.`in`.tumcampusapp.component.ui.ticket

import android.content.res.Resources
import android.view.View
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.google.android.material.button.MaterialButton
import de.tum.`in`.tumcampusapp.R
import de.tum.`in`.tumcampusapp.component.ui.ticket.model.TicketType
import de.tum.`in`.tumcampusapp.utils.Utils

class TicketAmountViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {

interface SelectTicketInterface {
fun ticketAmountUpdated(ticketTypeId: Int, amount: Int)
}

private val minusButton: MaterialButton by lazy { itemView.findViewById(R.id.ticket_amount_minus) }
private val plusButton: MaterialButton by lazy { itemView.findViewById(R.id.ticket_amount_plus) }
private val currentAmount: TextView by lazy { itemView.findViewById(R.id.current_ticket_amount) }
private val ticketTypeName: TextView by lazy { itemView.findViewById(R.id.ticket_type_name) }
private val ticketPrice: TextView by lazy { itemView.findViewById(R.id.price_per_ticket) }

private var ticketAmount = 1
private var ticketType = TicketType()
private var ticketTypePos = 0
private var remainingTickets = 0
private var minAmount = 1
private var maxAmount = 1

fun bindToTicketType(ticketType: TicketType, position: Int) {
this.ticketType = ticketType
ticketTypePos = position

minAmount = ticketType.paymentInfo.minTickets
maxAmount = ticketType.paymentInfo.maxTickets

if (position == 0) {
ticketAmount = minAmount
notifyActivity()
} else {
ticketAmount = 0
}

// init text views
ticketTypeName.text = ticketType.description
ticketPrice.text = itemView.resources.getString(R.string.price_per_ticket, Utils.formatPrice(ticketType.price))
currentAmount.text = ticketAmount.toString()
// init buttons
plusButton.setOnClickListener { updateTicketAmount(true) }
minusButton.setOnClickListener { updateTicketAmount(false) }

// handle how many tickets are left
remainingTickets = ticketType.contingent - ticketType.sold
maxAmount = Math.min(maxAmount, remainingTickets)
if (remainingTickets < minAmount) {
ticketAmount = 0
currentAmount.text = ticketAmount.toString()
plusButton.isEnabled = false
minusButton.isEnabled = false
ticketTypeName.setTextColor(Resources.getSystem().getColor(R.color.text_light_gray, null))
}
updateButtonState()
}

/**
* Updates the current ticket amount when the plus or minus button is clicked,
* makes sure the min and max amount of tickets is adhered to (either 0 tickets or minAmount of tickets, nothing in between)
* and the user doesn't select more tickets than are available
*/
private fun updateTicketAmount(increase: Boolean) {
if (increase) {
if (ticketAmount == 0) {
ticketAmount = minAmount
} else {
ticketAmount++
}
} else {
if (ticketAmount == minAmount) {
ticketAmount = 0
} else {
ticketAmount--
}
}
currentAmount.text = ticketAmount.toString()
updateButtonState()

notifyActivity()
}

private fun notifyActivity() {
if (itemView.context is SelectTicketInterface) {
(itemView.context as SelectTicketInterface).ticketAmountUpdated(ticketTypePos, ticketAmount)
} else {
Utils.log("The context is not a SelectTicketInterface")
}
}

private fun updateButtonState() {
plusButton.isEnabled = ticketAmount != maxAmount
minusButton.isEnabled = ticketAmount != 0
}
}
Loading

0 comments on commit 79134a2

Please sign in to comment.