Skip to content

Commit

Permalink
Merge pull request #250 from BCSDLab/release
Browse files Browse the repository at this point in the history
Update v3.4.0
  • Loading branch information
ThirFir authored May 2, 2024
2 parents 542674c + 6dcfac0 commit e260ef1
Show file tree
Hide file tree
Showing 45 changed files with 1,283 additions and 635 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ buildscript {
compileSdkVersion = 34
minSdkVersion = 21
targetSdkVersion = 34
versionName = "3.3.1"
minVersionCode = 30301
versionName = "3.4.0"
minVersionCode = 30400
}

dependencies {
Expand Down
48 changes: 48 additions & 0 deletions core/src/main/java/in/koreatech/koin/core/analytics/EventLogger.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package `in`.koreatech.koin.core.analytics

import com.google.firebase.analytics.ktx.analytics
import com.google.firebase.analytics.ktx.logEvent
import com.google.firebase.ktx.Firebase
import `in`.koreatech.koin.core.BuildConfig
import `in`.koreatech.koin.core.constant.AnalyticsConstant

object EventLogger {

private const val EVENT_CATEGORY = "event_category"
private const val EVENT_LABEL = "event_label"
private const val VALUE = "value"

/**
* @param action: 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
* @param label: 이벤트 소분류
* @param value: 이벤트 값
*/
fun logClickEvent(action: String, label: String, value: String) {
logEvent(action, AnalyticsConstant.Category.CLICK, label, value)
}

/**
* @param action: 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
* @param label: 이벤트 소분류
* @param value: 이벤트 값
*/
fun logScrollEvent(action: String, label: String, value: String) {
logEvent(action, AnalyticsConstant.Category.SCROLL, label, value)
}

/**
* @param action: 이벤트 발생 도메인(BUSINESS, CAMPUS, USER)
* @param category: 이벤트 종류(click, scroll, ...)
* @param label: 이벤트 소분류
* @param value: 이벤트 값
* @sample logEvent("BUSINESS", "click", "main_shop_categories", "전체보기")
*/
private fun logEvent(action: String, category: String, label: String, value: String) {
if (BuildConfig.IS_DEBUG) return
Firebase.analytics.logEvent(action) {
param(EVENT_CATEGORY, category)
param(EVENT_LABEL, label)
param(VALUE, value)
}
}
}
15 changes: 12 additions & 3 deletions core/src/main/java/in/koreatech/koin/core/appbar/AppBarBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@


import in.koreatech.koin.core.R;
import in.koreatech.koin.core.analytics.EventLogger;
import in.koreatech.koin.core.constant.AnalyticsConstant;


public class AppBarBase extends AppBarLayout {
Expand Down Expand Up @@ -50,7 +52,14 @@ public void setOnClickListener(OnClickListener onClickListener) {
this.onClickListener = onClickListener;
background.setOnClickListener(onClickListener);
leftButton.setOnClickListener(onClickListener);
rightButton.setOnClickListener(onClickListener);
rightButton.setOnClickListener( v -> {
onClickListener.onClick(v);
EventLogger.INSTANCE.logClickEvent(
AnalyticsConstant.Domain.USER,
AnalyticsConstant.Label.HAMBURGER,
getContext().getString(R.string.hamburger)
);
});
title.setOnClickListener(onClickListener);
}

Expand Down Expand Up @@ -107,7 +116,7 @@ private void setTypeArray(TypedArray typedArray) {
leftButton.setBackground(leftButtonBackground);
leftButton.setText(leftButtonString);
leftButton.setVisibility(leftButtonVisibility);
if(leftButtonHeight!= -1 || leftButtonWidth != -1){
if (leftButtonHeight != -1 || leftButtonWidth != -1) {
leftButton.setHeight(leftButtonHeight);
leftButton.setWidth(leftButtonWidth);
}
Expand All @@ -116,7 +125,7 @@ private void setTypeArray(TypedArray typedArray) {
rightButton.setBackground(rightButtonBackground);
rightButton.setText(rightButtonString);
rightButton.setVisibility(rightButtonVisibility);
if(leftButtonHeight!= -1 || leftButtonWidth != -1){
if (leftButtonHeight != -1 || leftButtonWidth != -1) {
rightButton.setHeight(rightButtonHeight);
rightButton.setWidth(rightButtonWidth);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package `in`.koreatech.koin.core.constant

object AnalyticsConstant {

object Domain {
const val BUSINESS = "BUSINESS"
const val CAMPUS = "CAMPUS"
const val USER = "USER"
}

object Category {
const val CLICK = "click"
const val SCROLL = "scroll"
}

object Label {
const val MAIN_SHOP_CATEGORIES = "main_shop_categories"
const val SHOP_CATEGORIES = "shop_categories"
const val SHOP_CATEGORIES_SEARCH = "shop_categories_search"
const val HAMBURGER = "hamburger"
const val HAMBURGER_SHOP = "${HAMBURGER}_shop"
const val HAMBURGER_DINING = "${HAMBURGER}_dining"
const val HAMBURGER_MY_INFO_WITHOUT_LOGIN = "${HAMBURGER}_my_info_without_login"
const val HAMBURGER_MY_INFO_WITH_LOGIN = "${HAMBURGER}_my_info_with_login"
const val HAMBURGER_BUS = "${HAMBURGER}_bus"
const val USER_ONLY_OK = "user_only_ok"
const val MAIN_MENU_MOVEDETAILVIEW = "main_menu_moveDetailView"
const val MAIN_MENU_CORNER = "main_menu_corner"
const val MENU_TIME = "menu_time"
const val MAIN_BUS = "main_bus"
const val MAIN_BUS_CHANGETOFROM = "main_bus_changeToFrom"
const val MAIN_BUS_SCROLL = "main_bus_scroll"
const val BUS_DEPARTURE = "bus_departure"
const val BUS_ARRIVAL = "bus_arrival"
const val BUS_TIMETABLE = "bus_timetable"
const val BUS_TIMETABLE_AREA = "bus_timetable_area"
const val BUS_TIMETABLE_TIME = "bus_timetable_time"
const val BUS_TIMETABLE_EXPRESS = "bus_timetable_express"
const val MENU_IMAGE = "menu_image"
const val LOGIN = "login"
const val START_SIGN_UP = "start_sign_up"
const val COMPLETE_SIGN_UP = "complete_sign_up"
const val SHOP_PICTURE = "shop_picture"
const val SHOP_CALL = "shop_call"
const val SHOP_CLICK = "shop_click"
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ class SingleLiveEvent<T> : MutableLiveData<T>() {

override fun observe(owner: LifecycleOwner, observer: Observer<in T>) {
if (hasActiveObservers()) {
Log.w(TAG,"Multiple observers registered but only one will be notified of changes.")
Log.w(TAG, "Multiple observers registered but only one will be notified of changes.")
}

// Observe the internal MutableLiveData
super.observe(owner) { t ->
super.observe(owner) {
if (pending.compareAndSet(true, false)) {
observer.onChanged(t)
observer.onChanged(it)
}
}
}
Expand All @@ -32,11 +32,12 @@ class SingleLiveEvent<T> : MutableLiveData<T>() {
}

/**
* Used for cases where T is Void, to make calls cleaner.
* Used for cases where T is Unit, to make calls cleaner.
*/
@MainThread
fun call() {
value = null
assert(value is Unit || value is Unit?)
value = Unit as T
}

companion object {
Expand Down
1 change: 1 addition & 0 deletions core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@
<string name="navigation_drawer_right_button_ask">문의하기</string>
<string name="navigation_drawer_right_hello_message">님, 안녕하세요!</string>
<string name="navigation_drawer_right_myinfo">내 정보</string>
<string name="hamburger">햄버거</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ data class ShuttleBusRouteResponse(
)

data class ShuttleBusNodeInfoResponse(
@SerializedName("node_name") val nodeName: String,
@SerializedName("arrival_time") val arrivalTime: String
@SerializedName("nodeName") val nodeName: String,
@SerializedName("arrivalTime") val arrivalTime: String
)

data class ExpressBusRouteResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package `in`.koreatech.koin.data.response.bus
import com.google.gson.annotations.SerializedName

data class ShuttleBusTimetableResponse(
@SerializedName("bus_timetables") val routes: List<ShuttleBusRouteResponse>,
@SerializedName("bus_timetable") val routes: List<ShuttleBusRouteResponse>,
@SerializedName("updated_at") val updatedAt: String
)

data class ExpressBusTimetableResponse(
@SerializedName("bus_timetables") val routes: List<ExpressBusRouteResponse>,
@SerializedName("bus_timetable") val routes: List<ExpressBusRouteResponse>,
@SerializedName("updated_at") val updatedAt: String
)
7 changes: 6 additions & 1 deletion data/src/main/java/in/koreatech/koin/data/util/DiningUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,10 @@ fun DiningType.localized(context: Context) = when(this) {
DiningType.Breakfast -> context.getString(R.string.dining_breakfast)
DiningType.Lunch -> context.getString(R.string.dining_lunch)
DiningType.Dinner -> context.getString(R.string.dining_dinner)
DiningType.NextBreakfast -> context.getString(R.string.dining_next_breakfast)
else -> context.getString(R.string.dining_breakfast)
}

fun DiningType.todayOrTomorrow(context: Context) = when(this) {
DiningType.NextBreakfast -> context.getString(R.string.dining_tomorrow)
else -> context.getString(R.string.dining_today)
}
4 changes: 3 additions & 1 deletion data/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<string name="bus_name_commuting">통학버스</string>
<string name="bus_name_express">대성고속</string>
<string name="bus_name_shuttle">셔틀버스</string>
<string name="bus_name_school_shuttle">학교셔틀</string>
<string name="city_bus_number_format">%1$d번 버스</string>
<!-- dept -->
<string name="dept_mechanical_engineering">기계공학부</string>
Expand All @@ -61,5 +62,6 @@
<string name="dining_breakfast">아침</string>
<string name="dining_lunch">점심</string>
<string name="dining_dinner">저녁</string>
<string name="dining_next_breakfast">내일 아침</string>
<string name="dining_today">오늘</string>
<string name="dining_tomorrow">내일</string>
</resources>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package `in`.koreatech.koin.domain.model.dining

enum class DiningPlace(
val place: String
) {
CornerA("A코너"),
CornerB("B코너"),
CornerC("C코너"),
Nungsu("능수관")
}
10 changes: 10 additions & 0 deletions domain/src/main/java/in/koreatech/koin/domain/util/DiningUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,14 @@ object DiningUtil {
}
return null
}

fun getKoreanName(type: String): String {
return when (type) {
DiningType.Breakfast.typeEnglish -> DiningType.Breakfast.typeKorean
DiningType.Lunch.typeEnglish -> DiningType.Lunch.typeKorean
DiningType.Dinner.typeEnglish -> DiningType.Dinner.typeKorean
DiningType.NextBreakfast.typeEnglish -> DiningType.NextBreakfast.typeKorean
else -> "Unknown type"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package `in`.koreatech.koin.domain.util.ext

import `in`.koreatech.koin.domain.model.dining.Dining
import `in`.koreatech.koin.domain.model.dining.DiningPlace
import `in`.koreatech.koin.domain.model.dining.DiningType

fun List<Dining>.typeFilter(type: DiningType) = this.filter {
Expand All @@ -9,11 +10,26 @@ fun List<Dining>.typeFilter(type: DiningType) = this.filter {


fun List<Dining>.arrange() = this.let {
val diningList = mutableListOf<Dining>()
val campus2 = this.filter { it.place == "2캠퍼스" }
val campus1 = this.filter { it.place != "2캠퍼스" }
campus1.sortedBy { it.place }
diningList.addAll(campus1)
diningList.addAll(campus2)
diningList.toList()
val allPlaces = DiningPlace.entries.map { it.place }

allPlaces.map { place ->
campus1.find { it.place == place } ?: Dining(
id = 0,
date = "",
type = "",
place = place,
priceCard = "",
priceCash = "",
kcal = "",
menu = listOf(),
imageUrl = "",
createdAt = "",
updatedAt = "",
soldoutAt = "",
changedAt = "",
error = ""
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.LinearLayoutManager
import dagger.hilt.android.AndroidEntryPoint
import `in`.koreatech.koin.core.analytics.EventLogger
import `in`.koreatech.koin.core.constant.AnalyticsConstant
import `in`.koreatech.koin.core.util.dataBinding

@AndroidEntryPoint
Expand All @@ -44,11 +46,36 @@ class BusMainFragment : Fragment(R.layout.bus_main_fragment) {
private fun initView() = with(binding) {
busDepartureSpinner.setSelection(BusNode.Koreatech.spinnerSelection)
busArrivalSpinner.setSelection(BusNode.Terminal.spinnerSelection)
busDepartureSpinner.setOnTouchListener { _, _ ->
viewModel.isUserSelection = true
busDepartureSpinner.performClick()
}
busDepartureSpinner.setOnItemSelectedListener { _, _, position, _ ->
viewModel.setDeparture(position.busNodeSelection)
if(viewModel.isUserSelection) {
EventLogger.logClickEvent(
AnalyticsConstant.Domain.CAMPUS,
AnalyticsConstant.Label.BUS_DEPARTURE,
resources.getStringArray(R.array.bus_place)[position]
)
viewModel.isUserSelection = false
}
}

busArrivalSpinner.setOnTouchListener { _, _ ->
viewModel.isUserSelection = true
busArrivalSpinner.performClick()
}
busArrivalSpinner.setOnItemSelectedListener { _, _, position, _ ->
viewModel.setArrival(position.busNodeSelection)
if(viewModel.isUserSelection) {
EventLogger.logClickEvent(
AnalyticsConstant.Domain.CAMPUS,
AnalyticsConstant.Label.BUS_ARRIVAL,
resources.getStringArray(R.array.bus_place)[position]
)
viewModel.isUserSelection = false
}
}
recyclerView.apply {
layoutManager = LinearLayoutManager(requireContext())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import android.view.View
import androidx.fragment.app.commit
import androidx.fragment.app.viewModels
import dagger.hilt.android.AndroidEntryPoint
import `in`.koreatech.koin.core.analytics.EventLogger
import `in`.koreatech.koin.core.constant.AnalyticsConstant

@AndroidEntryPoint
class BusTimetableFragment : DataBindingFragment<BusTimetableFragmentBinding>() {
Expand Down Expand Up @@ -39,12 +41,27 @@ class BusTimetableFragment : DataBindingFragment<BusTimetableFragmentBinding>()

binding.busTimetableBustypeShuttle.setOnClickListener {
busTimetableViewModel.setBusType(BusType.Shuttle)
EventLogger.logClickEvent(
AnalyticsConstant.Domain.CAMPUS,
AnalyticsConstant.Label.BUS_TIMETABLE,
getString(R.string.bus_name_school_shuttle)
)
}
binding.busTimetableBustypeDaesung.setOnClickListener {
busTimetableViewModel.setBusType(BusType.Express)
EventLogger.logClickEvent(
AnalyticsConstant.Domain.CAMPUS,
AnalyticsConstant.Label.BUS_TIMETABLE,
getString(R.string.bus_name_express)
)
}
binding.busTimetableBustypeCity.setOnClickListener {
busTimetableViewModel.setBusType(BusType.City)
EventLogger.logClickEvent(
AnalyticsConstant.Domain.CAMPUS,
AnalyticsConstant.Label.BUS_TIMETABLE,
getString(R.string.bus_name_city)
)
}
}

Expand Down
Loading

0 comments on commit e260ef1

Please sign in to comment.