-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dependency injection and file structure rearranged
- Loading branch information
1 parent
1de9ac3
commit 0dbfcc4
Showing
38 changed files
with
430 additions
and
262 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -13,3 +13,4 @@ | |
.externalNativeBuild | ||
.cxx | ||
local.properties | ||
.idea |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
34 changes: 34 additions & 0 deletions
34
...n/java/com/ferhatozcelik/androidmvvmtemplate/common/data/preferences/PreferenceManager.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,34 @@ | ||
package com.ferhatozcelik.androidmvvmtemplate.common.data.preferences | ||
|
||
import android.content.Context | ||
import javax.inject.Inject | ||
|
||
class PreferenceManager @Inject constructor( | ||
context: Context | ||
) : SharedPreferences(context), Preferences { | ||
|
||
override fun getPrefName() = "WiseriaPrefs" | ||
|
||
override fun getAccessToken() = preferences.getString(PreferencesConstants.KEY_ACCESS_TOKEN, "") | ||
|
||
|
||
override fun setAccessToken(token: String) { | ||
preferences.edit().putString(PreferencesConstants.KEY_ACCESS_TOKEN, token).apply() | ||
} | ||
|
||
override fun deleteAccessToken() { | ||
preferences.edit().remove(PreferencesConstants.KEY_ACCESS_TOKEN).apply() | ||
} | ||
|
||
override fun getRefreshToken() = | ||
preferences.getString(PreferencesConstants.KEY_REFRESH_TOKEN, "") | ||
|
||
override fun setRefreshToken(token: String) { | ||
preferences.edit().putString(PreferencesConstants.KEY_REFRESH_TOKEN, token).apply() | ||
} | ||
|
||
override fun deleteRefreshToken() { | ||
preferences.edit().remove(PreferencesConstants.KEY_REFRESH_TOKEN).apply() | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
...rc/main/java/com/ferhatozcelik/androidmvvmtemplate/common/data/preferences/Preferences.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,16 @@ | ||
package com.ferhatozcelik.androidmvvmtemplate.common.data.preferences | ||
|
||
interface Preferences { | ||
|
||
fun getAccessToken(): String? | ||
|
||
fun setAccessToken(token: String) | ||
fun deleteAccessToken() | ||
|
||
fun getRefreshToken(): String? | ||
|
||
fun setRefreshToken(token: String) | ||
|
||
fun deleteRefreshToken() | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
...ava/com/ferhatozcelik/androidmvvmtemplate/common/data/preferences/PreferencesConstants.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.ferhatozcelik.androidmvvmtemplate.common.data.preferences | ||
|
||
object PreferencesConstants { | ||
|
||
const val KEYSTORE_NAME = "X1kp5vI3oySeyXOqftOS" | ||
const val KEY_ACCESS_TOKEN = "userAccessToken" | ||
const val KEY_REFRESH_TOKEN = "userRefreshToken" | ||
} |
14 changes: 14 additions & 0 deletions
14
...n/java/com/ferhatozcelik/androidmvvmtemplate/common/data/preferences/SharedPreferences.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,14 @@ | ||
package com.ferhatozcelik.androidmvvmtemplate.common.data.preferences | ||
|
||
import android.content.Context | ||
import android.content.Context.MODE_PRIVATE | ||
import android.content.SharedPreferences | ||
|
||
abstract class SharedPreferences(context: Context) { | ||
|
||
abstract fun getPrefName(): String | ||
|
||
protected val preferences: SharedPreferences by lazy { | ||
context.getSharedPreferences(PreferencesConstants.KEYSTORE_NAME,MODE_PRIVATE) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...c/main/java/com/ferhatozcelik/androidmvvmtemplate/common/domain/session/SessionManager.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,25 @@ | ||
package com.wiseria.common.domain.session | ||
|
||
interface SessionManager { | ||
|
||
fun getAccessToken(): String? | ||
|
||
fun setAccessToken(token: String) | ||
|
||
fun saveAccessToken() | ||
|
||
fun deleteAccessToken() | ||
|
||
fun getRefreshToken(): String? | ||
|
||
fun setRefreshToken(token: String) | ||
|
||
fun saveRefreshToken() | ||
|
||
fun deleteRefreshToken() | ||
|
||
fun logOut() | ||
|
||
fun saveTokens(accessToken: String, refreshToken: String) | ||
|
||
} |
Oops, something went wrong.