-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
๐ ๏ธ ๊ฐ์ ์
๋ฐ์ดํธ ๊ธฐ๋ฅ (#47)
* Add ForceUpdate Min Version API * Add DI Modules | Repository & Datasource & Service * Add ForceUpdateDialog * Add UseCase | GetForceUpdateMinVersionUseCase * Apply ForceUpdate Check
- Loading branch information
Showing
14 changed files
with
292 additions
and
1 deletion.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
ThinkerBell/data/src/main/java/com/neverland/data/datasource/VersionDataSource.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.neverland.data.datasource | ||
|
||
import com.neverland.data.remote.model.BaseResponse | ||
import com.neverland.data.remote.model.ForceUpdateMinVersionResponse | ||
import com.neverland.data.remote.model.alarm.AlarmDTO | ||
import retrofit2.Response | ||
import retrofit2.http.PATCH | ||
|
||
interface VersionDataSource { | ||
|
||
suspend fun getForceUpdateMinVersion(): Response<BaseResponse<ForceUpdateMinVersionResponse>> | ||
} |
20 changes: 20 additions & 0 deletions
20
ThinkerBell/data/src/main/java/com/neverland/data/datasourceImpl/VersionDataSourceImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.neverland.data.datasourceImpl | ||
|
||
import com.neverland.data.datasource.AlarmDataSource | ||
import com.neverland.data.datasource.VersionDataSource | ||
import com.neverland.data.remote.model.BaseResponse | ||
import com.neverland.data.remote.model.ForceUpdateMinVersionResponse | ||
import com.neverland.data.remote.model.alarm.AlarmDTO | ||
import com.neverland.data.remote.service.AlarmService | ||
import com.neverland.data.remote.service.VersionService | ||
import retrofit2.Response | ||
import javax.inject.Inject | ||
|
||
class VersionDataSourceImpl @Inject constructor( | ||
private val service: VersionService | ||
): VersionDataSource { | ||
|
||
override suspend fun getForceUpdateMinVersion(): Response<BaseResponse<ForceUpdateMinVersionResponse>> { | ||
return service.getForceUpdateMinVersion() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
...rBell/data/src/main/java/com/neverland/data/remote/model/ForceUpdateMinVersionResponse.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.neverland.data.remote.model | ||
|
||
import com.google.gson.annotations.SerializedName | ||
|
||
data class ForceUpdateMinVersionResponse( | ||
@SerializedName("versionCode") | ||
val versionCode: String, | ||
@SerializedName("versionName") | ||
val versionName: String | ||
) |
12 changes: 12 additions & 0 deletions
12
ThinkerBell/data/src/main/java/com/neverland/data/remote/service/VersionService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.neverland.data.remote.service | ||
|
||
import com.neverland.data.remote.model.BaseResponse | ||
import com.neverland.data.remote.model.ForceUpdateMinVersionResponse | ||
import retrofit2.Response | ||
import retrofit2.http.GET | ||
|
||
interface VersionService { | ||
|
||
@GET("/api/version") | ||
suspend fun getForceUpdateMinVersion(): Response<BaseResponse<ForceUpdateMinVersionResponse>> | ||
} |
23 changes: 23 additions & 0 deletions
23
ThinkerBell/data/src/main/java/com/neverland/data/repository/VersionRepositoryImpl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.neverland.data.repository | ||
|
||
import com.neverland.data.datasource.AlarmDataSource | ||
import com.neverland.data.datasource.VersionDataSource | ||
import com.neverland.data.utils.handleResponse | ||
import com.neverland.domain.model.alarm.Alarm | ||
import com.neverland.domain.repository.AlarmRepository | ||
import com.neverland.domain.repository.VersionRepository | ||
import javax.inject.Inject | ||
|
||
class VersionRepositoryImpl @Inject constructor( | ||
private val datasource: VersionDataSource | ||
) : VersionRepository { | ||
|
||
override suspend fun getForceUpdateMinVersion(): Result<String> { | ||
return handleResponse( | ||
call = { datasource.getForceUpdateMinVersion() }, | ||
onSuccess = { data -> | ||
data?.versionCode ?: "0" | ||
} | ||
) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
ThinkerBell/domain/src/main/java/com/neverland/domain/repository/VersionRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.neverland.domain.repository | ||
|
||
import com.neverland.domain.model.alarm.Alarm | ||
|
||
interface VersionRepository { | ||
|
||
suspend fun getForceUpdateMinVersion(): Result<String> | ||
} |
13 changes: 13 additions & 0 deletions
13
...ain/src/main/java/com/neverland/domain/usecase/version/GetForceUpdateMinVersionUseCase.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.neverland.domain.usecase.version | ||
|
||
import com.neverland.domain.repository.VersionRepository | ||
import javax.inject.Inject | ||
|
||
class GetForceUpdateMinVersionUseCase @Inject constructor( | ||
private val repository: VersionRepository | ||
) { | ||
|
||
suspend operator fun invoke(): Result<String> { | ||
return repository.getForceUpdateMinVersion() | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
...rBell/presentation/src/main/java/com/neverland/thinkerbell/view/home/ForceUpdateDialog.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package com.neverland.thinkerbell.view.home | ||
|
||
import android.content.ActivityNotFoundException | ||
import android.content.ClipData | ||
import android.content.ClipboardManager | ||
import android.content.Context | ||
import android.content.Intent | ||
import android.graphics.Color | ||
import android.graphics.drawable.ColorDrawable | ||
import android.net.Uri | ||
import android.os.Bundle | ||
import android.view.LayoutInflater | ||
import android.view.View | ||
import android.view.ViewGroup | ||
import android.view.ViewGroup.LayoutParams.WRAP_CONTENT | ||
import androidx.fragment.app.DialogFragment | ||
import com.neverland.domain.model.univ.DeptContact | ||
import com.neverland.thinkerbell.BuildConfig | ||
import com.neverland.thinkerbell.custom.CustomToast | ||
import com.neverland.thinkerbell.databinding.DialogContactBinding | ||
import com.neverland.thinkerbell.databinding.DialogForceUpdateBinding | ||
import com.neverland.thinkerbell.utils.DisplayUtils | ||
|
||
class ForceUpdateDialog : DialogFragment() { | ||
|
||
companion object { | ||
fun newInstance(): ForceUpdateDialog { | ||
return ForceUpdateDialog() | ||
} | ||
} | ||
|
||
private var mBinding: DialogForceUpdateBinding? = null | ||
private val binding get() = mBinding!! | ||
|
||
override fun onStart() { | ||
super.onStart() | ||
|
||
dialog?.let { | ||
it.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT)) | ||
|
||
val widthInDp = 304f | ||
|
||
val widthInPx = DisplayUtils.dpToPx(requireContext(), widthInDp).toInt() | ||
|
||
it.window?.setLayout(widthInPx, WRAP_CONTENT) | ||
} | ||
|
||
isCancelable = false | ||
} | ||
|
||
override fun onCreateView( | ||
inflater: LayoutInflater, | ||
container: ViewGroup?, | ||
savedInstanceState: Bundle? | ||
): View { | ||
mBinding = DialogForceUpdateBinding.inflate(requireActivity().layoutInflater) | ||
return binding.root | ||
} | ||
|
||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { | ||
super.onViewCreated(view, savedInstanceState) | ||
|
||
binding.btnDialogUpdate.setOnClickListener { | ||
moveToPlayStore() | ||
} | ||
} | ||
|
||
private fun moveToPlayStore() { | ||
val intent = Intent(Intent.ACTION_VIEW).apply { | ||
data = Uri.parse("https://play.google.com/store/apps/details?id=${BuildConfig.APPLICATION_ID}") | ||
setPackage("com.android.vending") | ||
} | ||
try { | ||
startActivity(intent) | ||
} catch (e: ActivityNotFoundException) { | ||
val webIntent = Intent(Intent.ACTION_VIEW).apply { | ||
data = Uri.parse("https://play.google.com/store/apps/details?id=${BuildConfig.APPLICATION_ID}") | ||
} | ||
startActivity(webIntent) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.