-
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.
Merge pull request #5 from stslex/dev
Dev
- Loading branch information
Showing
34 changed files
with
442 additions
and
34 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
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
21 changes: 21 additions & 0 deletions
21
app/src/main/java/com/stslex/aproselection/ui/MainActivity.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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
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 @@ | ||
plugins { | ||
id("aproselection.android.library") | ||
} | ||
|
||
android.namespace = "com.stslex.aproselection.core.datastore" | ||
|
||
dependencies { | ||
implementation(libs.androidx.datastore.preferences) | ||
implementation(libs.androidx.datastore) | ||
} |
Empty file.
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
24 changes: 24 additions & 0 deletions
24
...e/src/androidTest/java/com/stslex/aproselection/core/datastore/ExampleInstrumentedTest.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,24 @@ | ||
package com.stslex.aproselection.core.datastore | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
|
||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Instrumented test, which will execute on an Android device. | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class ExampleInstrumentedTest { | ||
@Test | ||
fun useAppContext() { | ||
// Context of the app under test. | ||
val appContext = InstrumentationRegistry.getInstrumentation().targetContext | ||
assertEquals("com.stslex.aproselection.core.datastore.test", appContext.packageName) | ||
} | ||
} |
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,2 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest /> |
13 changes: 13 additions & 0 deletions
13
core/datastore/src/main/java/com/stslex/aproselection/core/datastore/AppDataStore.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.stslex.aproselection.core.datastore | ||
|
||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface AppDataStore { | ||
|
||
val uuid: Flow<String> | ||
val token: Flow<String> | ||
|
||
suspend fun setUuid(uuid: String) | ||
|
||
suspend fun setToken(token: String) | ||
} |
48 changes: 48 additions & 0 deletions
48
core/datastore/src/main/java/com/stslex/aproselection/core/datastore/AppDataStoreImpl.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,48 @@ | ||
package com.stslex.aproselection.core.datastore | ||
|
||
import android.content.Context | ||
import androidx.datastore.core.DataStore | ||
import androidx.datastore.preferences.core.Preferences | ||
import androidx.datastore.preferences.core.stringPreferencesKey | ||
import androidx.datastore.preferences.preferencesDataStore | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.map | ||
|
||
class AppDataStoreImpl( | ||
private val context: Context | ||
) : AppDataStore { | ||
|
||
companion object { | ||
private const val DATA_STORE_KEY = "app_data_store" | ||
private val UUID_KEY = stringPreferencesKey("UUID_KEY") | ||
private val TOKEN_KEY = stringPreferencesKey("TOKEN_KEY") | ||
private val Context.dataStore: DataStore<Preferences> by preferencesDataStore(DATA_STORE_KEY) | ||
} | ||
|
||
override val uuid: Flow<String> | ||
get() = context.dataStore.data.map { prefs -> | ||
prefs[UUID_KEY].orEmpty() | ||
} | ||
|
||
override val token: Flow<String> | ||
get() = context.dataStore.data.map { prefs -> | ||
prefs[TOKEN_KEY].orEmpty() | ||
} | ||
|
||
override suspend fun setUuid(uuid: String) { | ||
context.dataStore.updateData { prefs -> | ||
prefs.toMutablePreferences().apply { | ||
set(UUID_KEY, uuid) | ||
} | ||
} | ||
} | ||
|
||
|
||
override suspend fun setToken(token: String) { | ||
context.dataStore.updateData { prefs -> | ||
prefs.toMutablePreferences().apply { | ||
set(TOKEN_KEY, token) | ||
} | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
core/datastore/src/main/java/com/stslex/aproselection/core/datastore/CoreDataStoreModule.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,9 @@ | ||
package com.stslex.aproselection.core.datastore | ||
|
||
import org.koin.core.module.dsl.bind | ||
import org.koin.core.module.dsl.singleOf | ||
import org.koin.dsl.module | ||
|
||
val coreDataStoreModule = module { | ||
singleOf(::AppDataStoreImpl) { bind<AppDataStore>() } | ||
} |
17 changes: 17 additions & 0 deletions
17
core/datastore/src/test/java/com/stslex/aproselection/core/datastore/ExampleUnitTest.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,17 @@ | ||
package com.stslex.aproselection.core.datastore | ||
|
||
import org.junit.Test | ||
|
||
import org.junit.Assert.* | ||
|
||
/** | ||
* Example local unit test, which will execute on the development machine (host). | ||
* | ||
* See [testing documentation](http://d.android.com/tools/testing). | ||
*/ | ||
class ExampleUnitTest { | ||
@Test | ||
fun addition_isCorrect() { | ||
assertEquals(4, 2 + 2) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,6 @@ interface NetworkClient { | |
val client: HttpClient | ||
|
||
val apiClient: HttpClient | ||
|
||
suspend fun regenerateToken() | ||
} |
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
7 changes: 7 additions & 0 deletions
7
...ork/src/main/java/com/stslex/aproselection/core/network/clients/auth/AuthNetworkClient.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 |
---|---|---|
@@ -1,8 +1,15 @@ | ||
package com.stslex.aproselection.core.network.clients.auth | ||
|
||
import com.stslex.aproselection.core.network.clients.auth.model.HelloRequestModel | ||
import com.stslex.aproselection.core.network.clients.auth.model.UserAuthResponseModel | ||
import com.stslex.aproselection.core.network.clients.auth.model.UserAuthSendModel | ||
import kotlinx.coroutines.flow.Flow | ||
|
||
interface AuthNetworkClient { | ||
|
||
suspend fun getHello(username: String): HelloRequestModel | ||
|
||
fun auth(user: UserAuthSendModel): Flow<UserAuthResponseModel> | ||
|
||
fun register(user: UserAuthSendModel): Flow<UserAuthResponseModel> | ||
} |
Oops, something went wrong.