Skip to content

Commit

Permalink
[refactor] 모든 모듈 android ktlint 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
murjune committed Feb 6, 2024
1 parent e51ce9f commit d6c4cf8
Show file tree
Hide file tree
Showing 53 changed files with 896 additions and 972 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ android {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro",
"proguard-rules.pro"
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/moya/funch/FunchApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FunchApplication : Application() {
override fun createStackElementTag(element: StackTraceElement): String {
return "${element.fileName} : ${element.lineNumber} - ${element.methodName}"
}
},
}
)
}
}
Expand Down
11 changes: 4 additions & 7 deletions app/src/main/java/com/moya/funch/navigation/FunchNavHost.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@ import androidx.navigation.compose.NavHost
import androidx.navigation.compose.rememberNavController

@Composable
fun FunchNavHost(
hasProfile: Boolean,
navController: NavHostController = rememberNavController(),
) {
fun FunchNavHost(hasProfile: Boolean, navController: NavHostController = rememberNavController()) {
NavHost(
navController = navController,
startDestination = determineStartDestination(hasProfile),
startDestination = determineStartDestination(hasProfile)
) {
profileGraph(
onNavigateToHome = navController::navigateToHome,
onCloseMyProfile = navController::closeMyProfile,
onCloseMyProfile = navController::closeMyProfile
)
homeScreen(
onNavigateToMatching = { /* @Gun Hyung TODO : 매칭 라우터 연결 */ },
onNavigateToMyProfile = navController::navigateToMyProfile,
onNavigateToMyProfile = navController::navigateToMyProfile
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/moya/funch/ui/FunchApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ fun FunchApp() {

Surface(
modifier = Modifier.fillMaxSize(),
color = backgroundColor,
color = backgroundColor
) {
FunchNavHost(
hasProfile = false,
hasProfile = false
)
}
}
33 changes: 15 additions & 18 deletions core/data/src/main/java/com/moya/funch/mapper/DummyMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,36 @@ package com.moya.funch.mapper
// network response
data class DummyDto(
val id: Int,
val name: String,
val name: String
)

// database entity
data class DummyEntity(
val id: Int,
val name: String,
val name: String
)

// domain model
data class DummyDomain(
val id: Int,
val name: String,
val name: String
)

// toDomain() 함수
fun DummyDto.toDomain(): DummyDomain =
DummyDomain(
id = this.id,
name = name,
)
fun DummyDto.toDomain(): DummyDomain = DummyDomain(
id = this.id,
name = name
)

// toDto() 함수
fun DummyDomain.toDto(): DummyDto =
DummyDto(
id = this.id,
name = name,
)
fun DummyDomain.toDto(): DummyDto = DummyDto(
id = this.id,
name = name
)

// toEntity() 함수

fun DummyDto.toEntity(): DummyEntity =
DummyEntity(
id = this.id,
name = name,
)
fun DummyDto.toEntity(): DummyEntity = DummyEntity(
id = this.id,
name = name
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,60 +12,60 @@ import javax.inject.Singleton
@SuppressLint("HardwareIds")
@Singleton
class DefaultUserCodeDataStore
@Inject
constructor(
private val preferences: SharedPreferences,
@ApplicationContext private val context: Context,
) : UserCodeDataStore {
override var deviceId: String
get() {
initDeviceId()
return preferences.getString(DEVICE_ID, "").orEmpty()
}
set(value) {
preferences.edit(commit = true) {
putString(DEVICE_ID, value)
}
}

private fun initDeviceId() {
if (preferences.contains(DEVICE_ID).not()) {
userId = Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID)
}
@Inject
constructor(
private val preferences: SharedPreferences,
@ApplicationContext private val context: Context
) : UserCodeDataStore {
override var deviceId: String
get() {
initDeviceId()
return preferences.getString(DEVICE_ID, "").orEmpty()
}

override var userCode: String
get() = preferences.getString(USER_CODE, "").orEmpty()
set(value) {
preferences.edit(commit = true) {
putString(USER_CODE, value)
}
}
override var userId: String
get() = preferences.getString(USER_ID, "").orEmpty()
set(value) {
preferences.edit(commit = true) {
putString(USER_ID, value)
}
set(value) {
preferences.edit(commit = true) {
putString(DEVICE_ID, value)
}

override fun hasUserCode(): Boolean {
return preferences.contains(USER_CODE)
}

override fun hasUserId(): Boolean {
return preferences.contains(USER_ID)
private fun initDeviceId() {
if (preferences.contains(DEVICE_ID).not()) {
userId = Settings.Secure.getString(context.contentResolver, Settings.Secure.ANDROID_ID)
}
}

override fun clear() {
override var userCode: String
get() = preferences.getString(USER_CODE, "").orEmpty()
set(value) {
preferences.edit(commit = true) {
clear()
putString(USER_CODE, value)
}
}
override var userId: String
get() = preferences.getString(USER_ID, "").orEmpty()
set(value) {
preferences.edit(commit = true) {
putString(USER_ID, value)
}
}

override fun hasUserCode(): Boolean {
return preferences.contains(USER_CODE)
}

private companion object {
const val DEVICE_ID = "DEVICE_ID"
const val USER_CODE = "USER_CODE"
const val USER_ID = "USER_ID"
override fun hasUserId(): Boolean {
return preferences.contains(USER_ID)
}

override fun clear() {
preferences.edit(commit = true) {
clear()
}
}

private companion object {
const val DEVICE_ID = "DEVICE_ID"
const val USER_CODE = "USER_CODE"
const val USER_ID = "USER_ID"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,56 +11,50 @@ import java.security.KeyStore
import javax.inject.Inject

class PreferenceFactory
@Inject
constructor(
@ApplicationContext private val context: Context,
) {
fun create(): SharedPreferences {
return if (BuildConfig.DEBUG) {
context.getSharedPreferences(DEBUG_DATASTORE_KEY, Context.MODE_PRIVATE)
} else {
try {
createEncryptedSharedPreferences(DATASTORE_KEY, context)
} catch (e: GeneralSecurityException) {
deleteMasterKeyEntry()
deletePreference(DATASTORE_KEY, context)
createEncryptedSharedPreferences(DATASTORE_KEY, context)
}
@Inject
constructor(
@ApplicationContext private val context: Context
) {
fun create(): SharedPreferences {
return if (BuildConfig.DEBUG) {
context.getSharedPreferences(DEBUG_DATASTORE_KEY, Context.MODE_PRIVATE)
} else {
try {
createEncryptedSharedPreferences(DATASTORE_KEY, context)
} catch (e: GeneralSecurityException) {
deleteMasterKeyEntry()
deletePreference(DATASTORE_KEY, context)
createEncryptedSharedPreferences(DATASTORE_KEY, context)
}
}
}

private fun createEncryptedSharedPreferences(
fileName: String,
context: Context,
): SharedPreferences {
return EncryptedSharedPreferences.create(
context,
fileName,
MasterKey.Builder(context, MasterKey.DEFAULT_MASTER_KEY_ALIAS)
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
.build(),
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM,
)
}
private fun createEncryptedSharedPreferences(fileName: String, context: Context): SharedPreferences {
return EncryptedSharedPreferences.create(
context,
fileName,
MasterKey.Builder(context, MasterKey.DEFAULT_MASTER_KEY_ALIAS)
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
.build(),
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
)
}

private fun deletePreference(
fileName: String,
context: Context,
) {
context.deleteSharedPreferences(fileName)
}
private fun deletePreference(fileName: String, context: Context) {
context.deleteSharedPreferences(fileName)
}

private fun deleteMasterKeyEntry() {
KeyStore.getInstance(ANDROID_KEY_STORE).apply {
load(null)
deleteEntry(MasterKey.DEFAULT_MASTER_KEY_ALIAS)
}
private fun deleteMasterKeyEntry() {
KeyStore.getInstance(ANDROID_KEY_STORE).apply {
load(null)
deleteEntry(MasterKey.DEFAULT_MASTER_KEY_ALIAS)
}
}

companion object {
private const val DEBUG_DATASTORE_KEY = "DEBUG_DATASTORE_KEY"
private const val DATASTORE_KEY = "DATASTORE_KEY"
private const val ANDROID_KEY_STORE = "AndroidKeyStore"
}
companion object {
private const val DEBUG_DATASTORE_KEY = "DEBUG_DATASTORE_KEY"
private const val DATASTORE_KEY = "DATASTORE_KEY"
private const val ANDROID_KEY_STORE = "AndroidKeyStore"
}
}
Loading

0 comments on commit d6c4cf8

Please sign in to comment.