Skip to content

Commit

Permalink
Merge branch 'release-1.2.0-android' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
2chang5 committed Nov 12, 2023
2 parents 72cc4d3 + afb8545 commit 258be9b
Show file tree
Hide file tree
Showing 144 changed files with 4,096 additions and 806 deletions.
27 changes: 27 additions & 0 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,30 @@ android {
localProperties.getProperty("ENCRYPTED_SHARED_PREFERENCE_MASTER_KEY_ALIAS"),
)

buildConfigField(
"String",
"OPEN_SOURCE_LICENSE_URL",
localProperties.getProperty("OPEN_SOURCE_LICENSE_URL"),
)

buildConfigField(
"String",
"PRIVACY_POLICY_URL",
localProperties.getProperty("PRIVACY_POLICY_URL"),
)

buildConfigField(
"String",
"TERMS_OF_SERVICE_URL",
localProperties.getProperty("TERMS_OF_SERVICE_URL"),
)

buildConfigField(
"String",
"TRIP_DRAW_API_VERSION",
localProperties.getProperty("TRIP_DRAW_API_VERSION"),
)

manifestPlaceholders["NATIVE_APP_KEY"] =
localProperties.getProperty("KAKAO_NATIVE_APP_KEY_NO_QUOTES")

Expand Down Expand Up @@ -222,4 +246,7 @@ dependencies {
// hilt
implementation(libs.hilt)
kapt(libs.hiltKapt)

// lottie
implementation(libs.lottie)
}
13 changes: 12 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
android:name=".ui.home.recordingPoint.RecordingPointService"
android:description="@string/recording_point_service_description"
android:exported="false"
android:foregroundServiceType="location"/>
android:foregroundServiceType="location" />
<service
android:name="com.google.android.gms.metadata.ModuleDependencies"
android:enabled="false"
Expand Down Expand Up @@ -146,6 +146,17 @@
android:name=".ui.history.HistoryActivity"
android:exported="false"
android:screenOrientation="portrait" />

<activity
android:name=".ui.filter.FilterSelectionActivity"
android:exported="false"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize" />

<activity
android:name=".ui.filter.address.AddressSelectionActivity"
android:exported="false"
android:screenOrientation="portrait" />
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.teamtripdraw.android.data.dataSource.address

interface AddressDataSource {
interface Remote {
suspend fun getAddresses(siDo: String, siGunGu: String): Result<List<String>>
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.teamtripdraw.android.data.dataSource.address

import com.teamtripdraw.android.data.httpClient.service.GetAddressesService
import javax.inject.Inject

class RemoteAddressDataSource @Inject constructor(
private val getAddressesService: GetAddressesService,
) : AddressDataSource.Remote {

override suspend fun getAddresses(siDo: String, siGunGu: String): Result<List<String>> =
getAddressesService.getAddresses(siDo, siGunGu)
.process { body, headers -> Result.success(body.areas) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.teamtripdraw.android.data.model.DataPostOfAll
import com.teamtripdraw.android.data.model.DataPrePatchPost
import com.teamtripdraw.android.data.model.DataPrePost
import java.io.File
import java.time.LocalDateTime

interface PostDataSource {

Expand All @@ -17,7 +18,20 @@ interface PostDataSource {
imageFile: File?,
): Result<Long>

suspend fun getPost(postId: Long): Result<DataPost>
suspend fun createCurrentPointPost(
tripId: Long,
title: String,
address: String,
writing: String,
latitude: Double,
longitude: Double,
recordedAt: LocalDateTime,
imageFile: File?,
): Result<Long>

suspend fun getPostByPostId(postId: Long): Result<DataPost>

suspend fun getPostByPointId(pointId: Long): Result<DataPost>

suspend fun getTripPosts(tripId: Long): Result<List<DataPost>>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,30 @@ import com.teamtripdraw.android.data.dataSource.post.PostDataSource
import com.teamtripdraw.android.data.httpClient.dto.mapper.toData
import com.teamtripdraw.android.data.httpClient.dto.mapper.toHttpRequest
import com.teamtripdraw.android.data.httpClient.dto.request.AddPostRequest
import com.teamtripdraw.android.data.httpClient.dto.request.CreateCurrentPointPostRequest
import com.teamtripdraw.android.data.httpClient.dto.request.PatchPostRequest
import com.teamtripdraw.android.data.httpClient.service.CreateCurrentPointPostService
import com.teamtripdraw.android.data.httpClient.service.GetPointPostService
import com.teamtripdraw.android.data.httpClient.service.PostService
import com.teamtripdraw.android.data.model.DataPost
import com.teamtripdraw.android.data.model.DataPostOfAll
import com.teamtripdraw.android.data.model.DataPrePatchPost
import com.teamtripdraw.android.data.model.DataPrePost
import com.teamtripdraw.android.data.model.mapper.toData
import com.teamtripdraw.android.support.framework.presentation.LocalDateTimeFormatter.isoRemoveNanoSecondFormatter
import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.MultipartBody
import okhttp3.RequestBody.Companion.asRequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import java.io.File
import java.time.LocalDateTime
import javax.inject.Inject

class RemotePostDataSourceImpl @Inject constructor(
private val moshi: Moshi,
private val postService: PostService,
private val getPointPostService: GetPointPostService,
private val createCurrentPointPostService: CreateCurrentPointPostService,
) : PostDataSource.Remote {

override suspend fun addPost(
Expand All @@ -39,12 +46,46 @@ class RemotePostDataSourceImpl @Inject constructor(
}
}

override suspend fun getPost(postId: Long): Result<DataPost> {
override suspend fun createCurrentPointPost(
tripId: Long,
title: String,
address: String,
writing: String,
latitude: Double,
longitude: Double,
recordedAt: LocalDateTime,
imageFile: File?,
): Result<Long> {
val createCurrentPointPostRequest = CreateCurrentPointPostRequest(
address = address,
latitude = latitude,
longitude = longitude,
recordedAt = recordedAt.format(isoRemoveNanoSecondFormatter),
title = title,
tripId = tripId,
writing = writing,
)

val request = moshi.adapter(CreateCurrentPointPostRequest::class.java)
.toJson(createCurrentPointPostRequest)
val dto = request.toRequestBody("application/json".toMediaTypeOrNull())
val imageBody = imageFile?.toMultipartRequestBody()
return createCurrentPointPostService.createCurrentPointPost(dto, imageBody)
.process { body, headers ->
Result.success(body.postId)
}
}

override suspend fun getPostByPostId(postId: Long): Result<DataPost> {
return postService.getPost(postId).process { body, headers ->
Result.success(body.toData())
}
}

override suspend fun getPostByPointId(pointId: Long): Result<DataPost> =
getPointPostService.getPost(pointId)
.process { body, headers -> Result.success(body.toData()) }

override suspend fun getTripPosts(tripId: Long): Result<List<DataPost>> {
return postService.getTripPosts(tripId).process { body, headers ->
Result.success(body.toData())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.teamtripdraw.android.data.httpClient.dto.mapper

import com.teamtripdraw.android.data.httpClient.dto.request.CreateRecordingPointRequest
import com.teamtripdraw.android.data.httpClient.dto.response.GetPointPostResponse
import com.teamtripdraw.android.data.model.DataPost
import com.teamtripdraw.android.data.model.DataPrePoint

fun DataPrePoint.toHttpRequest(tripId: Long): CreateRecordingPointRequest =
Expand All @@ -10,3 +12,18 @@ fun DataPrePoint.toHttpRequest(tripId: Long): CreateRecordingPointRequest =
longitude = longitude,
recordedAt = recordedAt,
)

fun GetPointPostResponse.toData(): DataPost {
return DataPost(
postId = postId,
tripId = tripId,
title = title,
writing = writing,
address = address,
point = point.toData(),
postImageUrl = postImageUrl,
routeImageUrl = routeImageUrl,
isMine = isMine,
authorNickname = authorNickname,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.teamtripdraw.android.data.httpClient.dto.request.AddPostRequest
import com.teamtripdraw.android.data.httpClient.dto.request.PatchPostRequest
import com.teamtripdraw.android.data.httpClient.dto.response.AddPostResponse
import com.teamtripdraw.android.data.httpClient.dto.response.GetAllPostsResponse
import com.teamtripdraw.android.data.httpClient.dto.response.GetPointPostResponse
import com.teamtripdraw.android.data.httpClient.dto.response.GetPointResponse
import com.teamtripdraw.android.data.httpClient.dto.response.GetPostPointResponse
import com.teamtripdraw.android.data.httpClient.dto.response.GetTripPostListResponse
Expand Down Expand Up @@ -65,6 +66,8 @@ fun GetTripPostResponse.toData(): DataPost {
point = point.toData(),
postImageUrl = postImageUrl,
routeImageUrl = routeImageUrl,
isMine = isMine,
authorNickname = authorNickname,
)
}

Expand All @@ -82,6 +85,8 @@ fun GetAllPostsResponse.toData(): List<DataPostOfAll> {
postImageUrl = it.postImageUrl,
routeImageUrl = it.routeImageUrl,
recordedAt = it.recordedAt,
isMine = it.isMine,
authorNickname = it.authorNickname,
)
}
return posts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ fun GetTripInfoResponse.toData(): DataTrip =
status = status,
imageUrl = imageUrl,
routeImageUrl = routeImageUrl,
isMine = isMine,
authorNickname = authorNickname,
)

fun GetTripInfoPoint.toData(): DataPoint =
Expand Down Expand Up @@ -54,6 +56,8 @@ fun GetAllTripsResponse.toData(): List<DataTripOfAll> {
routeImageUrl = it.routeImageUrl,
startTime = it.startTime,
endTime = it.endTime,
isMine = it.isMine,
authorNickname = it.authorNickname,
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.teamtripdraw.android.data.httpClient.dto.request

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class CreateCurrentPointPostRequest(
@Json(name = "address")
val address: String,
@Json(name = "latitude")
val latitude: Double,
@Json(name = "longitude")
val longitude: Double,
@Json(name = "recordedAt")
val recordedAt: String,
@Json(name = "title")
val title: String,
@Json(name = "tripId")
val tripId: Long,
@Json(name = "writing")
val writing: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.teamtripdraw.android.data.httpClient.dto.response

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class CreateCurrentPointPostResponse(
@Json(name = "postId")
val postId: Long,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.teamtripdraw.android.data.httpClient.dto.response

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class GetAddressesResponse(
@Json(name = "areas")
val areas: List<String>,
)
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ data class Post(
val tripId: Long,
@Json(name = "writing")
val writing: String,
@Json(name = "isMine")
val isMine: Boolean,
@Json(name = "authorNickname")
val authorNickname: String,
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ data class Trip(
val startTime: String,
@Json(name = "tripId")
val tripId: Long,
@Json(name = "isMine")
val isMine: Boolean,
@Json(name = "authorNickname")
val authorNickname: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.teamtripdraw.android.data.httpClient.dto.response

import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass

@JsonClass(generateAdapter = true)
data class GetPointPostResponse(
@Json(name = "address")
val address: String,
@Json(name = "pointResponse")
val point: GetPostPointResponse,
@Json(name = "postId")
val postId: Long,
@Json(name = "postImageUrl")
val postImageUrl: String,
@Json(name = "routeImageUrl")
val routeImageUrl: String,
@Json(name = "title")
val title: String,
@Json(name = "tripId")
val tripId: Long,
@Json(name = "writing")
val writing: String,
@Json(name = "isMine")
val isMine: Boolean,
@Json(name = "authorNickname")
val authorNickname: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ data class GetTripInfoResponse(
val imageUrl: String,
@Json(name = "routeImageUrl")
val routeImageUrl: String,
@Json(name = "isMine")
val isMine: Boolean,
@Json(name = "authorNickname")
val authorNickname: String,
)

@JsonClass(generateAdapter = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ data class GetTripPostResponse(
val tripId: Long,
@Json(name = "writing")
val writing: String,
@Json(name = "isMine")
val isMine: Boolean,
@Json(name = "authorNickname")
val authorNickname: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.teamtripdraw.android.data.httpClient.service

import com.teamtripdraw.android.data.httpClient.dto.response.CreateCurrentPointPostResponse
import com.teamtripdraw.android.data.httpClient.retrofitAdapter.responseState.ResponseState
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Multipart
import retrofit2.http.POST
import retrofit2.http.Part

interface CreateCurrentPointPostService {
@Multipart
@POST("/posts/current-location")
suspend fun createCurrentPointPost(
@Part("dto") createCurrentPointPostRequest: RequestBody,
@Part imageFile: MultipartBody.Part?,
): ResponseState<CreateCurrentPointPostResponse>
}
Loading

0 comments on commit 258be9b

Please sign in to comment.