Fix bug #41  Made Naming Convention symmetrical. as 'Nia' instead of 'NiA' as that sounds more subtle and easy to follow in camel-case notation based Naming
pull/56/head
Sudhanshu 3 years ago
parent b4a2f35ed2
commit ea1114a337

@ -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.

@ -79,7 +79,7 @@ fun NiaApp(windowSizeClass: WindowSizeClass) {
contentColor = MaterialTheme.colorScheme.onBackground,
bottomBar = {
if (windowSizeClass.widthSizeClass == WindowWidthSizeClass.Compact) {
NiABottomBar(
NiaBottomBar(
onNavigateToTopLevelDestination = niaTopLevelNavigation::navigateTo,
currentDestination = currentDestination
)
@ -96,7 +96,7 @@ fun NiaApp(windowSizeClass: WindowSizeClass) {
)
) {
if (windowSizeClass.widthSizeClass != WindowWidthSizeClass.Compact) {
NiANavRail(
NiaNavRail(
onNavigateToTopLevelDestination = niaTopLevelNavigation::navigateTo,
currentDestination = currentDestination,
modifier = Modifier.safeDrawingPadding()
@ -117,7 +117,7 @@ fun NiaApp(windowSizeClass: WindowSizeClass) {
}
@Composable
private fun NiANavRail(
private fun NiaNavRail(
onNavigateToTopLevelDestination: (TopLevelDestination) -> Unit,
currentDestination: NavDestination?,
modifier: Modifier = Modifier,
@ -142,7 +142,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()
}

@ -32,9 +32,9 @@ object DatabaseModule {
@Singleton
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
@ -32,8 +32,8 @@ interface NetworkModule {
@Binds
fun bindsNiANetwork(
niANetwork: FakeNiANetwork
): NiANetwork
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,7 +17,7 @@
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.NiaNetwork
import com.google.samples.apps.nowinandroid.core.network.NiaDispatchers.IO
import com.google.samples.apps.nowinandroid.core.network.model.NetworkAuthor
import com.google.samples.apps.nowinandroid.core.network.model.NetworkChangeList
@ -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

@ -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 = com.google.samples.apps.nowinandroid.core.network.fake.FakeNiaNetwork(
ioDispatcher = testDispatcher,
networkJson = Json { ignoreUnknownKeys = true }
)
Loading…
Cancel
Save