Skip to content

Commit

Permalink
chore: update sample app implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
wax911 committed May 29, 2024
1 parent cc5f9cf commit 8cba8b1
Show file tree
Hide file tree
Showing 76 changed files with 984 additions and 1,138 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,9 @@ fabric.properties
app/.config/secrets.properties

app/schema.graphql

.idea/deploymentTargetSelector.xml

.idea/appInsightsSettings.xml

app/lint-baseline.xml
18 changes: 0 additions & 18 deletions .idea/appInsightsSettings.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/deploymentTargetSelector.xml

This file was deleted.

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

56 changes: 0 additions & 56 deletions .idea/misc.xml

This file was deleted.

3 changes: 3 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ android {
buildFeatures {
buildConfig = true
}
lint {
baseline = file("lint-baseline.xml")
}
}

dependencies {
Expand Down
7 changes: 1 addition & 6 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />

<application
android:name=".App"
Expand Down Expand Up @@ -50,12 +51,6 @@
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/support_file_provider_paths"/>
</provider>

<provider
android:name="androidx.work.impl.WorkManagerInitializer"
android:authorities="${applicationId}.workmanager-init"
tools:node="remove"
android:exported="false" />
</application>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ import io.wax911.emojify.EmojiManager

abstract class SampleApp : Application() {

/**
* Emoji manager instance
*/
internal abstract val emojiManager: EmojiManager

/**
* Uncaught exception handler
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package co.anitrend.retrofit.graphql.core.koin

import co.anitrend.arch.extension.dispatchers.SupportDispatchers
import co.anitrend.arch.extension.dispatchers.SupportDispatcher
import co.anitrend.arch.extension.dispatchers.contract.ISupportDispatcher
import co.anitrend.retrofit.graphql.core.settings.Settings
import coil.ImageLoader
import coil.ImageLoaderFactory
Expand All @@ -20,8 +21,8 @@ private val coreModule = module {
androidContext()
)
} binds(Settings.BINDINGS)
single {
SupportDispatchers()
single<ISupportDispatcher> {
SupportDispatcher()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ data class FragmentItem<T: Fragment>(
val parameter: Bundle? = null,
val fragment: Class<out T>
) {
fun tag() = fragment.simpleName
fun tag(): String = fragment.simpleName
}
Original file line number Diff line number Diff line change
@@ -1,36 +1,39 @@
package co.anitrend.retrofit.graphql.core.settings

import android.content.Context
import co.anitrend.arch.extension.preference.BooleanPreference
import co.anitrend.arch.extension.preference.IntPreference
import co.anitrend.arch.extension.preference.StringPreference
import co.anitrend.arch.extension.preference.SupportSettings
import co.anitrend.arch.extension.preference.SupportPreference
import co.anitrend.arch.extension.settings.BooleanSetting
import co.anitrend.arch.extension.settings.IntSetting
import co.anitrend.arch.extension.settings.StringSetting
import co.anitrend.retrofit.graphql.data.authentication.settings.IAuthenticationSettings
import co.anitrend.retrofit.graphql.sample.R

class Settings(context: Context) : SupportSettings(context), IAuthenticationSettings {
class Settings(context: Context) : SupportPreference(context), IAuthenticationSettings {

override var authenticatedUserId by StringPreference(
R.string.setting_authenticated_user_id,
IAuthenticationSettings.INVALID_USER_ID,
context.resources
override val authenticatedUserId = StringSetting(
key = R.string.setting_authenticated_user_id,
default = IAuthenticationSettings.INVALID_USER_ID,
resources = context.resources,
preference = this,
)

override var isNewInstallation by BooleanPreference(
R.string.setting_is_new_installation,
true,
context.resources
override val isNewInstallation = BooleanSetting(
key = R.string.setting_is_new_installation,
default = true,
resources = context.resources,
preference = this,
)

override var versionCode by IntPreference(
R.string.setting_version_code,
1,
context.resources
override val versionCode = IntSetting(
key = R.string.setting_version_code,
default = 1,
resources = context.resources,
preference = this,
)

companion object {
val BINDINGS = arrayOf(
Settings::class, SupportSettings::class, IAuthenticationSettings::class
Settings::class, SupportPreference::class, IAuthenticationSettings::class
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,39 @@ package co.anitrend.retrofit.graphql.core.view
import android.os.Build
import android.view.View
import androidx.appcompat.app.AppCompatDelegate
import co.anitrend.arch.core.model.ISupportViewModelState
import co.anitrend.arch.extension.ext.getCompatColor
import co.anitrend.arch.ui.R
import co.anitrend.arch.ui.activity.SupportActivity
import org.koin.android.scope.AndroidScopeComponent
import org.koin.androidx.fragment.android.setupKoinFragmentFactory
import org.koin.androidx.scope.lifecycleScope as koinLifecycleScope
import org.koin.androidx.scope.activityRetainedScope
import org.koin.core.component.KoinScopeComponent
import timber.log.Timber

abstract class SampleActivity : SupportActivity() {
abstract class SampleActivity : SupportActivity(), AndroidScopeComponent, KoinScopeComponent {

override val scope by activityRetainedScope()

/**
* Can be used to configure custom theme styling as desired
*/
override fun configureActivity() {
setupKoinFragmentFactory()
runCatching {
Timber.v("Setting up fragment factory using scope: $scope")
setupKoinFragmentFactory(scope)
}.onFailure {
setupKoinFragmentFactory()
Timber.v(it, "Reverting to scope-less based fragment factory")
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val systemUiOptions = window.decorView.systemUiVisibility
when (AppCompatDelegate.getDefaultNightMode()) {
AppCompatDelegate.MODE_NIGHT_NO -> {
window.navigationBarColor = getCompatColor(R.color.colorPrimary)
window.navigationBarColor = getCompatColor(co.anitrend.arch.theme.R.color.colorPrimary)
window.decorView.systemUiVisibility = systemUiOptions or View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
}
AppCompatDelegate.MODE_NIGHT_YES -> {
window.navigationBarColor = getCompatColor(R.color.colorPrimary)
window.navigationBarColor = getCompatColor(co.anitrend.arch.theme.R.color.colorPrimary)
window.decorView.systemUiVisibility = systemUiOptions and View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
window.decorView.systemUiVisibility = systemUiOptions and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
}
Expand All @@ -34,4 +45,9 @@ abstract class SampleActivity : SupportActivity() {
}
}
}

/**
* Proxy for a view model state if one exists
*/
override fun viewModelState(): ISupportViewModelState<*>? = null
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package co.anitrend.retrofit.graphql.core.view

import androidx.lifecycle.Observer
import co.anitrend.arch.domain.entities.NetworkState
import co.anitrend.arch.core.model.ISupportViewModelState
import co.anitrend.arch.ui.fragment.list.SupportFragmentList
import org.koin.android.scope.AndroidScopeComponent
import org.koin.androidx.scope.fragmentScope
import org.koin.core.component.KoinScopeComponent

abstract class SampleListFragment<M : Any> : SupportFragmentList<M>() {
override val onRefreshObserver = Observer<NetworkState> {
// workaround for support-arch:ui on refresh overrides network state
}
abstract class SampleListFragment<M : Any> : SupportFragmentList<M>(),
AndroidScopeComponent, KoinScopeComponent {

override val scope by fragmentScope()

/**
* Proxy for a view model state if one exists
*/
override fun viewModelState(): ISupportViewModelState<*>? = null
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import timber.log.Timber
*/
internal object RetrofitProvider {

private val moduleTag = javaClass.simpleName
private val retrofitCache = LruCache<EndpointType, Retrofit>(3)

private fun provideOkHttpClient(endpointType: EndpointType, scope: Scope) : OkHttpClient {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package co.anitrend.retrofit.graphql.data.arch.common

import co.anitrend.arch.data.mapper.contract.ISupportMapperHelper
import co.anitrend.arch.data.mapper.SupportResponseMapper
import co.anitrend.retrofit.graphql.domain.common.EntityId

/**
* @param E entity
* @param M model
*/
internal abstract class SampleMapper<E: EntityId, M: Any> {
protected abstract fun from(): ISupportMapperHelper<E, M>
protected abstract fun to(): ISupportMapperHelper<M, E>
protected abstract fun from(): SupportResponseMapper<E, M>
protected abstract fun to(): SupportResponseMapper<M, E>
}
Loading

0 comments on commit 8cba8b1

Please sign in to comment.