Skip to content

Commit bf01f66

Browse files
authored
Merge pull request #8 from ENTS-H104/daffa/dev
RELEASE BETA v1.0 🤩✨
2 parents 88fb247 + 6165658 commit bf01f66

File tree

61 files changed

+861
-463
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+861
-463
lines changed

README.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
</a>
88
</div>
99

10-
<!-- You can make badge by read on official documentation at https://shields.io/badges -->
11-
12-
1310
<p align="center">
1411
<a href="#-introduction">Introduction</a> &nbsp;&bull;&nbsp;
1512
<a href="#-tech-stack">Tech Stack</a> &nbsp;&bull;&nbsp;
@@ -25,16 +22,15 @@ Key features include detailed mountain information, secure guide and partner boo
2522

2623
## 💻 Tech Stack
2724

28-
> Framework, Library, Database, Tools, etc
29-
3025
![Kotlin](https://img.shields.io/badge/Kotlin-0095D5?style=for-the-badge&logo=kotlin&logoColor=white)
3126
![Android Studio](https://img.shields.io/badge/Android%20Studio-3DDC84?style=for-the-badge&logo=android-studio&logoColor=white)
3227
![Postman](https://img.shields.io/badge/Postman-FF6C37?style=for-the-badge&logo=postman&logoColor=white)
33-
![Retrofit](https://img.shields.io/badge/Retrofit-007FFF?style=for-the-badge&logo=retrofit&logoColor=white)
34-
![ViewPager](https://img.shields.io/badge/ViewPager-FF4081?style=for-the-badge&logo=android&logoColor=white)
35-
![DataStore](https://img.shields.io/badge/DataStore-FF6F00?style=for-the-badge&logo=android&logoColor=white)
36-
![Room](https://img.shields.io/badge/Room-007FFF?style=for-the-badge&logo=room&logoColor=white)
37-
![Paging 3](https://img.shields.io/badge/Paging%203-FF6F00?style=for-the-badge&logo=android&logoColor=white)
28+
![Retrofit](https://img.shields.io/badge/Retrofit-FF4081?style=for-the-badge&logo=android&logoColor=white)
29+
![ViewPager](https://img.shields.io/badge/ViewPager-0095D5?style=for-the-badge&logo=android&logoColor=white)
30+
![DataStore](https://img.shields.io/badge/DataStore-3DDC84?style=for-the-badge&logo=android&logoColor=white)
31+
![Room Dao](https://img.shields.io/badge/Room-FF6C37?style=for-the-badge&logo=android&logoColor=white)
32+
![Paging 3](https://img.shields.io/badge/Paging%203-FF4081?style=for-the-badge&logo=android&logoColor=white)
33+
![Midtrans](https://img.shields.io/badge/Midtrans-0095D5?style=for-the-badge&logo=android&logoColor=white)
3834

3935

4036
## 📚 Reference
@@ -45,6 +41,7 @@ Key features include detailed mountain information, secure guide and partner boo
4541
- [DataStore](https://developer.android.com/topic/libraries/architecture/datastore)
4642
- [Room](https://developer.android.com/training/data-storage/room/)
4743
- [Paging 3](https://developer.android.com/topic/libraries/architecture/paging/v3-overview)
44+
- [Midtrans](https://docs.midtrans.com/reference/android-sdk)
4845

4946

5047
## 🚩 Issue

app/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ android {
2121

2222
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
2323
resValue("string", "google_maps_key", "AIzaSyDsbvczf_2-MgmpGzxjdrMRZPcatQI4bPA")
24+
resValue("string", "payment_gateway_uuid", "dc5ce8d6-e907-44fa-8d3f-106a83dd6f22")
2425
buildConfigField("String", "BASE_URL", "\"https://highking.cloud/api/\"")
26+
buildConfigField("String", "MIDTRANS_CLIENT_KEY", "\"SB-Mid-client-0euqacxFYGhkN5uu\"")
27+
buildConfigField("String", "MIDTRANS_URL", "\"https://api.sandbox.midtrans.com/\"")
2528
}
2629

2730
buildTypes {
10.1 KB
Binary file not shown.
9.99 KB
Binary file not shown.

app/release/highking_v1.0_beta.apk

20.7 MB
Binary file not shown.

app/release/output-metadata.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"version": 3,
3+
"artifactType": {
4+
"type": "APK",
5+
"kind": "Directory"
6+
},
7+
"applicationId": "com.entsh104.highking",
8+
"variantName": "release",
9+
"elements": [
10+
{
11+
"type": "SINGLE",
12+
"filters": [],
13+
"attributes": [],
14+
"versionCode": 1,
15+
"versionName": "1.0",
16+
"outputFile": "app-release.apk"
17+
}
18+
],
19+
"elementType": "File",
20+
"baselineProfiles": [
21+
{
22+
"minApi": 28,
23+
"maxApi": 30,
24+
"baselineProfiles": [
25+
"baselineProfiles/1/app-release.dm"
26+
]
27+
},
28+
{
29+
"minApi": 31,
30+
"maxApi": 2147483647,
31+
"baselineProfiles": [
32+
"baselineProfiles/0/app-release.dm"
33+
]
34+
}
35+
],
36+
"minSdkVersionForDexing": 24
37+
}

app/src/main/java/com/entsh104/highking/data/model/Response.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ data class UserResponse(
4545
val updated_at: String?
4646
)
4747

48+
@Parcelize
4849
data class MountainResponse(
4950
@SerializedName("mountain_uuid") val mountainId: String,
5051
@SerializedName("name") val name: String,
@@ -59,7 +60,7 @@ data class MountainResponse(
5960
@SerializedName("harga") val harga: Int,
6061
@SerializedName("gmaps") val gmaps: String,
6162
@SerializedName("total_trip_open") val totalTripOpen: Int
62-
)
63+
): Parcelable
6364

6465
data class MountainsResponse(
6566
@SerializedName("status") val status: Int,

app/src/main/java/com/entsh104/highking/data/repository/UserRepository.kt

Lines changed: 39 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ import com.entsh104.highking.data.model.UpdateUserRequest
1919
import com.entsh104.highking.data.model.UserResponse
2020
import com.entsh104.highking.data.model.UserUpdateApiResponse
2121
import com.entsh104.highking.data.source.local.SharedPreferencesManager
22-
import kotlinx.coroutines.CoroutineScope
2322
import kotlinx.coroutines.Dispatchers
24-
import kotlinx.coroutines.launch
2523
import kotlinx.coroutines.withContext
2624
import okhttp3.MediaType.Companion.toMediaTypeOrNull
2725
import okhttp3.MultipartBody
@@ -92,9 +90,7 @@ class UserRepository(
9290
imageUri: Uri
9391
): Result<UpdatePhotoResponse> {
9492
val token = prefs.getToken() ?: return Result.failure(Exception("Token not found"))
95-
Log.d("UploadPhoto", "Token: $token")
9693
val parcelFileDescriptor = contentResolver.openFileDescriptor(imageUri, "r", null) ?: return Result.failure(Exception("Failed to open file descriptor"))
97-
Log.d("UploadPhoto", "File Descriptor opened successfully")
9894
val inputStream = FileInputStream(parcelFileDescriptor.fileDescriptor)
9995
val file = File(cacheDir, contentResolver.getFileName(imageUri))
10096
val outputStream = FileOutputStream(file)
@@ -105,7 +101,6 @@ class UserRepository(
105101

106102
return try {
107103
val response = apiService.updatePhotoUser("Bearer $token", body)
108-
Log.d("UploadPhoto", "Response: ${response.message()}")
109104
if (response.isSuccessful) {
110105
Result.success(response.body()!!)
111106
} else {
@@ -205,16 +200,19 @@ class UserRepository(
205200
Result.failure(e)
206201
}
207202
}
208-
// suspend fun getMountains(): LiveData<PagingData<List<MountainResponse>>> {
209-
// return Pager(
210-
// config = PagingConfig(
211-
// pageSize = 5
212-
// ),
213-
// PagingSourceFactory = {
214-
// MountainPagingSource(apiService)
215-
// }
216-
// ).livedata
217-
// }
203+
204+
suspend fun getMountainsLimit(): Result<List<MountainResponse>> {
205+
return try {
206+
val response = apiService.getMountainsLimit()
207+
if (response.isSuccessful) {
208+
Result.success(response.body()?.data ?: emptyList())
209+
} else {
210+
Result.failure(Exception(response.message()))
211+
}
212+
} catch (e: Exception) {
213+
Result.failure(e)
214+
}
215+
}
218216

219217
suspend fun getMountainById(id: String): Result<MountainDetailResponse> {
220218
val token = prefs.getToken()
@@ -243,7 +241,6 @@ class UserRepository(
243241
}
244242
}
245243

246-
247244
suspend fun getOpenTripById(tripId: String): Result<OpenTripDetailResponse> {
248245
val token = prefs.getToken()
249246
return try {
@@ -300,11 +297,33 @@ class UserRepository(
300297
}
301298
}
302299

303-
fun saveToken(token: String) {
304-
prefs.saveToken(token)
300+
suspend fun getRecommendedMountains(userUid: String): Result<List<MountainResponse>> {
301+
return try {
302+
val response = apiService.getRecommendedMountains(userUid)
303+
if (response.isSuccessful) {
304+
Result.success(response.body()?.data ?: emptyList())
305+
} else {
306+
Result.failure(Throwable(response.message()))
307+
}
308+
} catch (e: Exception) {
309+
Result.failure(e)
310+
}
305311
}
306312

307-
fun getToken(): String? {
308-
return prefs.getToken()
313+
suspend fun getRecommendedTrips(userUid: String): Result<OpenTripResponse> = withContext(Dispatchers.IO) {
314+
try {
315+
val response = apiService.getRecommendedTrips(userUid)
316+
if (response.isSuccessful) {
317+
Result.success(response.body()!!)
318+
} else {
319+
Result.failure(Exception(response.message()))
320+
}
321+
} catch (e: Exception) {
322+
Result.failure(e)
323+
}
324+
}
325+
326+
fun saveToken(token: String) {
327+
prefs.saveToken(token)
309328
}
310329
}

app/src/main/java/com/entsh104/highking/data/source/local/SharedPreferencesManager.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ class SharedPreferencesManager(context: Context) {
1010
prefs.edit().putString("token", token).apply()
1111
}
1212

13+
fun saveUserUid(uid: String) {
14+
prefs.edit().putString("userUid", uid).apply()
15+
}
16+
1317
fun getToken(): String? {
1418
return prefs.getString("token", null)
1519
}

app/src/main/java/com/entsh104/highking/data/source/remote/ApiService.kt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import com.entsh104.highking.data.model.UpdateUserRequest
1919
import com.entsh104.highking.data.model.UserApiResponse
2020
import com.entsh104.highking.data.model.UserResponse
2121
import com.entsh104.highking.data.model.UserUpdateApiResponse
22+
import com.entsh104.highking.ui.model.Mountain
2223
import okhttp3.MultipartBody
2324
import okhttp3.RequestBody
2425
import retrofit2.Response
@@ -65,14 +66,23 @@ interface ApiService {
6566
@GET("mountains")
6667
suspend fun getMountains(
6768
@Query("page") page: Int = 1,
68-
@Query("limit") size: Int = 100
69+
@Query("limit") size: Int = 1000
70+
): Response<MountainsResponse>
71+
72+
@GET("mountains")
73+
suspend fun getMountainsLimit(
74+
@Query("page") page: Int = 1,
75+
@Query("limit") size: Int = 10
6976
): Response<MountainsResponse>
7077

7178
@GET("mountains/{id}")
7279
suspend fun getMountainById(@Header("Authorization") token: String, @Path("id") id: String): Response<MountainDetailResponse>
7380

7481
@GET("open-trips")
75-
suspend fun getOpenTrips(): Response<OpenTripResponse>
82+
suspend fun getOpenTrips(
83+
@Query("page") page: Int = 1,
84+
@Query("limit") size: Int = 10
85+
): Response<OpenTripResponse>
7686

7787
@GET("open-trips/{open_trip_uuid}")
7888
suspend fun getOpenTripById(@Header("Authorization") token: String, @Path("open_trip_uuid") openTripId: String): Response<OpenTripDetailResponse>
@@ -109,4 +119,10 @@ interface ApiService {
109119
@Query("page") page: Int,
110120
@Query("limit") size: Int
111121
): Response<OpenTripResponse>
122+
123+
@GET("/api/recommendation/mountain/{user_uid}")
124+
suspend fun getRecommendedMountains(@Path("user_uid") userUid: String): Response<MountainsResponse>
125+
126+
@GET("/api/recommendation/open-trip/{user_uid}")
127+
suspend fun getRecommendedTrips(@Path("user_uid") userId: String): Response<OpenTripResponse>
112128
}

0 commit comments

Comments
 (0)