File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed
core/common/src/main/kotlin/com/ninecraft/booket/core/common Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ package com.ninecraft.booket.core.common.extensions
2+
3+ import android.content.Context
4+ import android.content.Intent
5+ import androidx.core.net.toUri
6+ import com.ninecraft.booket.core.common.BuildConfig
7+
8+ fun Context.openPlayStore () {
9+ val intent = Intent (Intent .ACTION_VIEW , " market://details?id=${BuildConfig .PACKAGE_NAME } " .toUri())
10+ startActivity(intent)
11+ }
Original file line number Diff line number Diff line change 1+ package com.ninecraft.booket.core.common.util
2+
3+ import com.orhanobut.logger.Logger
4+
5+ /* *
6+ * 두 버전을 비교하는 함수
7+ *
8+ * @param version1 첫 번째 버전 (예: "1.2.3")
9+ * @param version2 두 번째 버전 (예: "1.1.0")
10+ * @return 양수면 version1 > version2, 음수면 version1 < version2, 0이면 같음
11+ *
12+ * 버전 형식: "메이저.마이너.패치" (예: 1.2.3)
13+ * 비교 순서: 메이저 → 마이너 → 패치 버전 순으로 비교
14+ */
15+ fun compareVersions (version1 : String , version2 : String ): Int {
16+ Logger .d(" compareVersions: version1: $version1 , version2: $version2 " )
17+
18+ if (! Regex (""" ^\d+\.\d+\.\d+$""" ).matches(version1)) return 0
19+ if (! Regex (""" ^\d+\.\d+\.\d+$""" ).matches(version2)) return 0
20+
21+ val v1 = version1.split(' .' ).map { it.toInt() }
22+ val v2 = version2.split(' .' ).map { it.toInt() }
23+
24+ // 메이저 버전 비교
25+ if (v1[0 ] != v2[0 ]) return v1[0 ] - v2[0 ]
26+
27+ // 마이너 버전 비교
28+ if (v1[1 ] != v2[1 ]) return v1[1 ] - v2[1 ]
29+
30+ // 패치 버전 비교
31+ return v1[2 ] - v2[2 ]
32+ }
33+
34+ /* *
35+ * 현재 앱 버전이 최소 요구 버전보다 낮은지 확인하는 함수
36+ *
37+ * @param currentVersion 현재 앱의 버전 (예: "1.0.0")
38+ * @param minVersion 최소 요구 버전 (Firebase Remote Config에서 가져온 값)
39+ * @return true면 강제 업데이트 필요 (현재 버전 < 최소 요구 버전), false면 업데이트 불필요
40+ */
41+ fun isUpdateRequired (currentVersion : String , minVersion : String ): Boolean {
42+ return compareVersions(currentVersion, minVersion) < 0
43+ }
You can’t perform that action at this time.
0 commit comments