Merge pull request #56 from sud007/fix/nia-naming-convention

Fix Bug #41 | Nia Naming conventions
pull/66/head
Alex Vanyo 3 years ago committed by GitHub
commit b602abc263
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,12 +23,12 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.NiACatalog">
android:theme="@style/Theme.NiaCatalog">
<activity
android:name="com.google.samples.apps.niacatalog.NiaCatalogActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.NiACatalog">
android:theme="@style/Theme.NiaCatalog">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

@ -15,5 +15,5 @@
limitations under the License.
-->
<resources>
<style name="Theme.NiACatalog" parent="android:Theme.Material.Light.NoActionBar" />
<style name="Theme.NiaCatalog" parent="android:Theme.Material.Light.NoActionBar" />
</resources>

@ -21,7 +21,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".NiAApp"
android:name=".NiaApp"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"

@ -27,7 +27,7 @@ import dagger.hilt.android.HiltAndroidApp
* [Application] class for NiA
*/
@HiltAndroidApp
class NiAApp : Application(), ImageLoaderFactory {
class NiaApp : Application(), ImageLoaderFactory {
override fun onCreate() {
super.onCreate()
// Initialize Sync; the system responsible for keeping data in the app up to date.

@ -76,7 +76,7 @@ fun NiaApp(windowSizeClass: WindowSizeClass) {
contentColor = MaterialTheme.colorScheme.onBackground,
bottomBar = {
if (windowSizeClass.widthSizeClass == WindowWidthSizeClass.Compact) {
NiABottomBar(
NiaBottomBar(
onNavigateToTopLevelDestination = niaTopLevelNavigation::navigateTo,
currentDestination = currentDestination
)
@ -93,7 +93,7 @@ fun NiaApp(windowSizeClass: WindowSizeClass) {
)
) {
if (windowSizeClass.widthSizeClass != WindowWidthSizeClass.Compact) {
NiANavRail(
NiaNavRail(
onNavigateToTopLevelDestination = niaTopLevelNavigation::navigateTo,
currentDestination = currentDestination,
modifier = Modifier.safeDrawingPadding()
@ -114,7 +114,7 @@ fun NiaApp(windowSizeClass: WindowSizeClass) {
}
@Composable
private fun NiANavRail(
private fun NiaNavRail(
onNavigateToTopLevelDestination: (TopLevelDestination) -> Unit,
currentDestination: NavDestination?,
modifier: Modifier = Modifier,
@ -139,7 +139,7 @@ private fun NiANavRail(
}
@Composable
private fun NiABottomBar(
private fun NiaBottomBar(
onNavigateToTopLevelDestination: (TopLevelDestination) -> Unit,
currentDestination: NavDestination?
) {

@ -25,7 +25,7 @@ import com.google.samples.apps.nowinandroid.core.database.model.asExternalModel
import com.google.samples.apps.nowinandroid.core.datastore.ChangeListVersions
import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferences
import com.google.samples.apps.nowinandroid.core.model.data.Author
import com.google.samples.apps.nowinandroid.core.network.NiANetwork
import com.google.samples.apps.nowinandroid.core.network.NiaNetwork
import com.google.samples.apps.nowinandroid.core.network.model.NetworkAuthor
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
@ -37,7 +37,7 @@ import kotlinx.coroutines.flow.map
*/
class OfflineFirstAuthorsRepository @Inject constructor(
private val authorDao: AuthorDao,
private val network: NiANetwork,
private val network: NiaNetwork,
private val niaPreferences: NiaPreferences,
) : AuthorsRepository {

@ -35,7 +35,7 @@ import com.google.samples.apps.nowinandroid.core.database.model.TopicEntity
import com.google.samples.apps.nowinandroid.core.database.model.asExternalModel
import com.google.samples.apps.nowinandroid.core.datastore.ChangeListVersions
import com.google.samples.apps.nowinandroid.core.model.data.NewsResource
import com.google.samples.apps.nowinandroid.core.network.NiANetwork
import com.google.samples.apps.nowinandroid.core.network.NiaNetwork
import com.google.samples.apps.nowinandroid.core.network.model.NetworkNewsResource
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
@ -50,7 +50,7 @@ class OfflineFirstNewsRepository @Inject constructor(
private val episodeDao: EpisodeDao,
private val authorDao: AuthorDao,
private val topicDao: TopicDao,
private val network: NiANetwork,
private val network: NiaNetwork,
) : NewsRepository {
override fun getNewsResourcesStream(): Flow<List<NewsResource>> =

@ -25,7 +25,7 @@ import com.google.samples.apps.nowinandroid.core.database.model.asExternalModel
import com.google.samples.apps.nowinandroid.core.datastore.ChangeListVersions
import com.google.samples.apps.nowinandroid.core.datastore.NiaPreferences
import com.google.samples.apps.nowinandroid.core.model.data.Topic
import com.google.samples.apps.nowinandroid.core.network.NiANetwork
import com.google.samples.apps.nowinandroid.core.network.NiaNetwork
import com.google.samples.apps.nowinandroid.core.network.model.NetworkTopic
import javax.inject.Inject
import kotlinx.coroutines.flow.Flow
@ -37,7 +37,7 @@ import kotlinx.coroutines.flow.map
*/
class OfflineFirstTopicsRepository @Inject constructor(
private val topicDao: TopicDao,
private val network: NiANetwork,
private val network: NiaNetwork,
private val niaPreferences: NiaPreferences,
) : TopicsRepository {

@ -16,7 +16,7 @@
package com.google.samples.apps.nowinandroid.core.data.testdoubles
import com.google.samples.apps.nowinandroid.core.network.NiANetwork
import com.google.samples.apps.nowinandroid.core.network.NiaNetwork
import com.google.samples.apps.nowinandroid.core.network.fake.FakeDataSource
import com.google.samples.apps.nowinandroid.core.network.model.NetworkAuthor
import com.google.samples.apps.nowinandroid.core.network.model.NetworkChangeList
@ -33,9 +33,9 @@ enum class CollectionType {
}
/**
* Test double for [NiANetwork]
* Test double for [NiaNetwork]
*/
class TestNiaNetwork : NiANetwork {
class TestNiaNetwork : NiaNetwork {
private val networkJson = Json

@ -19,7 +19,7 @@ package com.google.samples.apps.nowinandroid.core.database.dao
import android.content.Context
import androidx.room.Room
import androidx.test.core.app.ApplicationProvider
import com.google.samples.apps.nowinandroid.core.database.NiADatabase
import com.google.samples.apps.nowinandroid.core.database.NiaDatabase
import com.google.samples.apps.nowinandroid.core.database.model.AuthorEntity
import com.google.samples.apps.nowinandroid.core.database.model.EpisodeEntity
import com.google.samples.apps.nowinandroid.core.database.model.NewsResourceAuthorCrossRef
@ -41,14 +41,14 @@ class NewsResourceDaoTest {
private lateinit var episodeDao: EpisodeDao
private lateinit var topicDao: TopicDao
private lateinit var authorDao: AuthorDao
private lateinit var db: NiADatabase
private lateinit var db: NiaDatabase
@Before
fun createDb() {
val context = ApplicationProvider.getApplicationContext<Context>()
db = Room.inMemoryDatabaseBuilder(
context,
NiADatabase::class.java
NiaDatabase::class.java
).build()
newsResourceDao = db.newsResourceDao()
episodeDao = db.episodeDao()

@ -30,21 +30,21 @@ import dagger.hilt.components.SingletonComponent
object DaosModule {
@Provides
fun providesAuthorDao(
database: NiADatabase,
database: NiaDatabase,
): AuthorDao = database.authorDao()
@Provides
fun providesTopicsDao(
database: NiADatabase,
database: NiaDatabase,
): TopicDao = database.topicDao()
@Provides
fun providesEpisodeDao(
database: NiADatabase,
database: NiaDatabase,
): EpisodeDao = database.episodeDao()
@Provides
fun providesNewsResourceDao(
database: NiADatabase,
database: NiaDatabase,
): NewsResourceDao = database.newsResourceDao()
}

@ -30,11 +30,11 @@ import javax.inject.Singleton
object DatabaseModule {
@Provides
@Singleton
fun providesNiADatabase(
fun providesNiaDatabase(
@ApplicationContext context: Context,
): NiADatabase = Room.databaseBuilder(
): NiaDatabase = Room.databaseBuilder(
context,
NiADatabase::class.java,
NiaDatabase::class.java,
"nia-database"
).build()
}

@ -61,7 +61,7 @@ import com.google.samples.apps.nowinandroid.core.database.util.NewsResourceTypeC
InstantConverter::class,
NewsResourceTypeConverter::class,
)
abstract class NiADatabase : RoomDatabase() {
abstract class NiaDatabase : RoomDatabase() {
abstract fun topicDao(): TopicDao
abstract fun authorDao(): AuthorDao
abstract fun episodeDao(): EpisodeDao

@ -16,8 +16,8 @@
package com.google.samples.apps.nowinandroid.core.network.di
import com.google.samples.apps.nowinandroid.core.network.NiANetwork
import com.google.samples.apps.nowinandroid.core.network.fake.FakeNiANetwork
import com.google.samples.apps.nowinandroid.core.network.NiaNetwork
import com.google.samples.apps.nowinandroid.core.network.fake.FakeNiaNetwork
import dagger.Binds
import dagger.Module
import dagger.Provides
@ -31,9 +31,9 @@ import kotlinx.serialization.json.Json
interface NetworkModule {
@Binds
fun bindsNiANetwork(
niANetwork: FakeNiANetwork
): NiANetwork
fun bindsNiaNetwork(
niANetwork: FakeNiaNetwork
): NiaNetwork
companion object {
@Provides

@ -24,7 +24,7 @@ import com.google.samples.apps.nowinandroid.core.network.model.NetworkTopic
/**
* Interface representing network calls to the NIA backend
*/
interface NiANetwork {
interface NiaNetwork {
suspend fun getTopics(ids: List<String>? = null): List<NetworkTopic>
suspend fun getAuthors(ids: List<String>? = null): List<NetworkAuthor>

@ -17,8 +17,8 @@
package com.google.samples.apps.nowinandroid.core.network.fake
import com.google.samples.apps.nowinandroid.core.network.Dispatcher
import com.google.samples.apps.nowinandroid.core.network.NiANetwork
import com.google.samples.apps.nowinandroid.core.network.NiaDispatchers.IO
import com.google.samples.apps.nowinandroid.core.network.NiaNetwork
import com.google.samples.apps.nowinandroid.core.network.model.NetworkAuthor
import com.google.samples.apps.nowinandroid.core.network.model.NetworkChangeList
import com.google.samples.apps.nowinandroid.core.network.model.NetworkNewsResource
@ -30,12 +30,12 @@ import kotlinx.serialization.decodeFromString
import kotlinx.serialization.json.Json
/**
* [NiANetwork] implementation that provides static news resources to aid development
* [NiaNetwork] implementation that provides static news resources to aid development
*/
class FakeNiANetwork @Inject constructor(
class FakeNiaNetwork @Inject constructor(
@Dispatcher(IO) private val ioDispatcher: CoroutineDispatcher,
private val networkJson: Json
) : NiANetwork {
) : NiaNetwork {
override suspend fun getTopics(ids: List<String>?): List<NetworkTopic> =
withContext(ioDispatcher) {
networkJson.decodeFromString(FakeDataSource.topicsData)

@ -17,7 +17,7 @@
package com.google.samples.apps.nowinandroid.core.network.retrofit
import com.google.samples.apps.nowinandroid.core.network.BuildConfig
import com.google.samples.apps.nowinandroid.core.network.NiANetwork
import com.google.samples.apps.nowinandroid.core.network.NiaNetwork
import com.google.samples.apps.nowinandroid.core.network.model.NetworkAuthor
import com.google.samples.apps.nowinandroid.core.network.model.NetworkChangeList
import com.google.samples.apps.nowinandroid.core.network.model.NetworkNewsResource
@ -37,7 +37,7 @@ import retrofit2.http.Query
/**
* Retrofit API declaration for NIA Network API
*/
private interface RetrofitNiANetworkApi {
private interface RetrofitNiaNetworkApi {
@GET(value = "topics")
suspend fun getTopics(
@Query("id") ids: List<String>?,
@ -69,10 +69,10 @@ private interface RetrofitNiANetworkApi {
): List<NetworkChangeList>
}
private const val NiABaseUrl = BuildConfig.BACKEND_URL
private const val NiaBaseUrl = BuildConfig.BACKEND_URL
/**
* Wrapper for data provided from the [NiABaseUrl]
* Wrapper for data provided from the [NiaBaseUrl]
*/
@Serializable
private data class NetworkResponse<T>(
@ -80,15 +80,15 @@ private data class NetworkResponse<T>(
)
/**
* [Retrofit] backed [NiANetwork]
* [Retrofit] backed [NiaNetwork]
*/
@Singleton
class RetrofitNiANetwork @Inject constructor(
class RetrofitNiaNetwork @Inject constructor(
networkJson: Json
) : NiANetwork {
) : NiaNetwork {
private val networkApi = Retrofit.Builder()
.baseUrl(NiABaseUrl)
.baseUrl(NiaBaseUrl)
.client(
OkHttpClient.Builder()
.addInterceptor(
@ -101,7 +101,7 @@ class RetrofitNiANetwork @Inject constructor(
)
.addConverterFactory(networkJson.asConverterFactory("application/json".toMediaType()))
.build()
.create(RetrofitNiANetworkApi::class.java)
.create(RetrofitNiaNetworkApi::class.java)
override suspend fun getTopics(ids: List<String>?): List<NetworkTopic> =
networkApi.getTopics(ids = ids).data

@ -16,8 +16,8 @@
package com.google.samples.apps.nowinandroid.core.network.di
import com.google.samples.apps.nowinandroid.core.network.NiANetwork
import com.google.samples.apps.nowinandroid.core.network.retrofit.RetrofitNiANetwork
import com.google.samples.apps.nowinandroid.core.network.NiaNetwork
import com.google.samples.apps.nowinandroid.core.network.retrofit.RetrofitNiaNetwork
import dagger.Binds
import dagger.Module
import dagger.Provides
@ -31,9 +31,9 @@ import kotlinx.serialization.json.Json
interface NetworkModule {
@Binds
fun bindsNiANetwork(
niANetwork: RetrofitNiANetwork
): NiANetwork
fun bindsNiaNetwork(
niANetwork: RetrofitNiaNetwork
): NiaNetwork
companion object {
@Provides

@ -23,15 +23,15 @@ import org.junit.Assert.assertEquals
import org.junit.Before
import org.junit.Test
class FakeNiANetworkTest {
class FakeNiaNetworkTest {
private lateinit var subject: FakeNiANetwork
private lateinit var subject: FakeNiaNetwork
private val testDispatcher = StandardTestDispatcher()
@Before
fun setUp() {
subject = com.google.samples.apps.nowinandroid.core.network.fake.FakeNiANetwork(
subject = FakeNiaNetwork(
ioDispatcher = testDispatcher,
networkJson = Json { ignoreUnknownKeys = true }
)

@ -212,7 +212,7 @@ A repository may depend on one or more data sources. For example, the `OfflineFi
</td>
</tr>
<tr>
<td>NiANetwork
<td>NiaNetwork
</td>
<td>Remote API accessed using Retrofit
</td>

Loading…
Cancel
Save