Skip to content

Commit

Permalink
Update dependency com.pinterest.ktlint:ktlint-cli to v1.3.0 (#3564)
Browse files Browse the repository at this point in the history
* Update dependency com.pinterest.ktlint:ktlint-cli to v1.3.0

* ktlint fixes

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Daniel Frett <[email protected]>
renovate[bot] and frett authored Jun 10, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent f0d6259 commit 4f581a2
Showing 57 changed files with 158 additions and 185 deletions.
2 changes: 0 additions & 2 deletions app/config/ktlint/baseline.xml
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
<baseline version="1.0">
<file name="src/main/kotlin/org/cru/godtools/ui/account/AccountLayout.kt">
<error line="61" column="9" source="compose:vm-injection-check" />
<error line="103" column="12" source="compose:unstable-collections" />
</file>
<file name="src/main/kotlin/org/cru/godtools/ui/account/globalactivity/GlobalActivityLayout.kt">
<error line="33" column="5" source="compose:modifier-missing-check" />
@@ -18,7 +17,6 @@
</file>
<file name="src/main/kotlin/org/cru/godtools/ui/dashboard/tools/ToolsLayout.kt">
<error line="40" column="9" source="compose:vm-injection-check" />
<error line="111" column="34" source="compose:unstable-collections" />
</file>
<file name="src/main/kotlin/org/cru/godtools/ui/languages/downloadable/DownloadableLanguagesLayout.kt">
<error line="59" column="5" source="compose:modifier-missing-check" />
4 changes: 3 additions & 1 deletion app/src/main/kotlin/org/cru/godtools/GodToolsApplication.kt
Original file line number Diff line number Diff line change
@@ -21,7 +21,9 @@ import org.ccci.gto.android.common.util.LocaleUtils
import timber.log.Timber

@HiltAndroidApp
open class GodToolsApplication : Application(), Configuration.Provider {
open class GodToolsApplication :
Application(),
Configuration.Provider {
@Inject
internal lateinit var eagerInitializer: EagerSingletonInitializer

Original file line number Diff line number Diff line change
@@ -5,11 +5,8 @@ import android.os.Bundle
private const val PARAM_SOURCE = "cru_source"
private const val PARAM_TOOL = "cru_tool"

internal class OpenAnalyticsActionEvent(
action: String,
private val tool: String?,
private val source: String
) : AnalyticsActionEvent(action = action, system = AnalyticsSystem.FIREBASE) {
internal class OpenAnalyticsActionEvent(action: String, private val tool: String?, private val source: String) :
AnalyticsActionEvent(action = action, system = AnalyticsSystem.FIREBASE) {
companion object {
const val ACTION_OPEN_LESSON = "open_lesson"
const val ACTION_OPEN_TOOL = "open_tool"
Original file line number Diff line number Diff line change
@@ -10,9 +10,7 @@ import org.cru.godtools.shared.user.activity.model.UserActivity
import org.cru.godtools.user.activity.UserActivityManager

@HiltViewModel
class AccountActivityViewModel @Inject constructor(
userActivityManager: UserActivityManager,
) : ViewModel() {
class AccountActivityViewModel @Inject constructor(userActivityManager: UserActivityManager) : ViewModel() {
val userActivity = userActivityManager.userActivityFlow
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), UserActivity(emptyMap()))
}
Original file line number Diff line number Diff line change
@@ -10,9 +10,7 @@ import org.cru.godtools.db.repository.GlobalActivityRepository
import org.cru.godtools.model.GlobalActivityAnalytics

@HiltViewModel
class GlobalActivityViewModel @Inject constructor(
globalActivityRepository: GlobalActivityRepository
) : ViewModel() {
class GlobalActivityViewModel @Inject constructor(globalActivityRepository: GlobalActivityRepository) : ViewModel() {
val activity = globalActivityRepository.getGlobalActivityFlow()
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), GlobalActivityAnalytics())
}
Original file line number Diff line number Diff line change
@@ -9,9 +9,10 @@ import org.cru.godtools.base.ui.dashboard.Page
internal fun Uri.isDashboardLessonsDeepLink() =
(scheme == "http" || scheme == "https") && host.equals(HOST_GODTOOLSAPP_COM, true) && path == "/lessons"

internal fun Uri.isDashboardGodToolsDeepLink() =
(scheme == "http" || scheme == "https") && host.equals(HOST_GODTOOLSAPP_COM, true) &&
pathSegments[0] == "deeplink" && pathSegments[1] == "dashboard"
internal fun Uri.isDashboardGodToolsDeepLink() = (scheme == "http" || scheme == "https") &&
host.equals(HOST_GODTOOLSAPP_COM, true) &&
pathSegments[0] == "deeplink" &&
pathSegments[1] == "dashboard"

internal fun Uri.isDashboardCustomUriSchemeDeepLink() = SCHEME_GODTOOLS.equals(scheme, true) &&
HOST_GODTOOLS_CUSTOM_URI.equals(host, true) &&
Original file line number Diff line number Diff line change
@@ -65,12 +65,8 @@ import org.cru.godtools.ui.tooldetails.ToolDetailsScreen
import org.cru.godtools.ui.tools.ToolCardEvent

internal sealed interface DashboardEvent {
open class OpenTool(
val tool: String?,
val type: Tool.Type?,
val lang1: Locale?,
val lang2: Locale? = null,
) : DashboardEvent
open class OpenTool(val tool: String?, val type: Tool.Type?, val lang1: Locale?, val lang2: Locale? = null) :
DashboardEvent
class OpenLesson(lesson: String?, lang: Locale?) : OpenTool(lesson, Tool.Type.LESSON, lang)
class OpenToolDetails(val tool: String?, val lang: Locale? = null) : DashboardEvent
}
Original file line number Diff line number Diff line change
@@ -52,12 +52,8 @@ import org.cru.godtools.ui.tools.ToolCardEvent
private val PADDING_HORIZONTAL = 16.dp

internal sealed interface DashboardHomeEvent {
open class OpenTool(
val tool: String?,
val type: Tool.Type?,
val lang1: Locale?,
val lang2: Locale? = null,
) : DashboardHomeEvent {
open class OpenTool(val tool: String?, val type: Tool.Type?, val lang1: Locale?, val lang2: Locale? = null) :
DashboardHomeEvent {
constructor(event: ToolCardEvent) : this(event.tool, event.toolType, event.lang1, event.lang2)
}
open class OpenToolDetails(val tool: String?) : DashboardHomeEvent {
Original file line number Diff line number Diff line change
@@ -14,10 +14,8 @@ import org.cru.godtools.db.repository.ToolsRepository
import org.greenrobot.eventbus.EventBus

@HiltViewModel
class LessonsViewModel @Inject constructor(
private val eventBus: EventBus,
toolsRepository: ToolsRepository,
) : ViewModel() {
class LessonsViewModel @Inject constructor(private val eventBus: EventBus, toolsRepository: ToolsRepository) :
ViewModel() {
val lessons = toolsRepository.getLessonsFlow()
.map { it.filterNot { it.isHidden }.sortedBy { it.defaultOrder }.mapNotNull { it.code } }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), emptyList())
Original file line number Diff line number Diff line change
@@ -16,9 +16,7 @@ import org.cru.godtools.ui.drawer.DrawerMenuScreen.Event
import org.cru.godtools.ui.drawer.DrawerMenuScreen.State

@Singleton
class DrawerMenuPresenter @Inject constructor(
private val accountManager: GodToolsAccountManager,
) : Presenter<State> {
class DrawerMenuPresenter @Inject constructor(private val accountManager: GodToolsAccountManager) : Presenter<State> {
@Composable
override fun present(): State {
val scope = rememberCoroutineScope()
Original file line number Diff line number Diff line change
@@ -12,9 +12,7 @@ import kotlinx.coroutines.withContext
import org.cru.godtools.account.GodToolsAccountManager

@HiltViewModel
class DrawerViewModel @Inject constructor(
private val accountManager: GodToolsAccountManager,
) : ViewModel() {
class DrawerViewModel @Inject constructor(private val accountManager: GodToolsAccountManager) : ViewModel() {
val isAuthenticatedFlow = accountManager.isAuthenticatedFlow
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000), false)

Original file line number Diff line number Diff line change
@@ -12,9 +12,8 @@ import org.cru.godtools.ui.BasePaparazziTest
import org.junit.runner.RunWith

@RunWith(TestParameterInjector::class)
class AccountActivityBadgesPaparazziTest(
@TestParameter nightMode: NightMode,
) : BasePaparazziTest(nightMode = nightMode, renderingMode = RenderingMode.SHRINK) {
class AccountActivityBadgesPaparazziTest(@TestParameter nightMode: NightMode) :
BasePaparazziTest(nightMode = nightMode, renderingMode = RenderingMode.SHRINK) {
@Test
fun `AccountActivityBadges() - All Incomplete`() {
val activity = UserActivity(emptyMap())
Original file line number Diff line number Diff line change
@@ -10,9 +10,8 @@ import org.cru.godtools.ui.BasePaparazziTest
import org.junit.runner.RunWith

@RunWith(TestParameterInjector::class)
class LanguageDownloadStatusIndicatorPaparazziTest(
@TestParameter nightMode: NightMode
) : BasePaparazziTest(nightMode = nightMode, renderingMode = RenderingMode.SHRINK) {
class LanguageDownloadStatusIndicatorPaparazziTest(@TestParameter nightMode: NightMode) :
BasePaparazziTest(nightMode = nightMode, renderingMode = RenderingMode.SHRINK) {
@Test
fun `LanguageDownloadStatusIndicator()`() = centerInSnapshot {
Row {
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ kotlin = "1.9.24"
kotlinCoroutines = "1.8.1"
kotlinKover = "0.7.6"
ksp = "1.9.24-1.0.20"
ktlint = "1.2.1"
ktlint = "1.3.0"
ktlintGradle = "12.1.1"
lottie = "6.4.1"
okhttp3 = "4.12.0"
2 changes: 1 addition & 1 deletion library/account/config/ktlint/baseline.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<baseline version="1.0">
<file name="src/main/kotlin/org/cru/godtools/account/compose/LocalGodToolsAccountManager.kt">
<error line="14" column="17" source="compose:compositionlocal-allowlist" />
<error line="13" column="17" source="compose:compositionlocal-allowlist" />
</file>
</baseline>
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.cru.godtools.account.compose

import androidx.compose.runtime.Composable
import androidx.compose.runtime.ProvidedValue
import androidx.compose.runtime.compositionLocalOf
import androidx.compose.ui.platform.LocalContext
import dagger.hilt.EntryPoint
@@ -24,9 +23,7 @@ internal object LocalGodToolsAccountManager {
/**
* Associates a [GodToolsAccountManager] key to a value in a call to [CompositionLocalProvider].
*/
infix fun provides(accountManager: GodToolsAccountManager): ProvidedValue<GodToolsAccountManager?> {
return LocalComposition.provides(accountManager)
}
infix fun provides(accountManager: GodToolsAccountManager) = LocalComposition.provides(accountManager)
}

@EntryPoint
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package org.cru.godtools.account.provider.google

class GoogleBuildConfig(
val serverClientId: String
)
class GoogleBuildConfig(val serverClientId: String)
Original file line number Diff line number Diff line change
@@ -7,11 +7,8 @@ import java.util.Locale
private const val ACTION_EXIT_LINK = "exit_link_engaged"
private const val FIREBASE_PARAM_EXIT_LINK = "cru_mobileexitlink"

class ExitLinkActionEvent(
private val tool: String?,
private val link: String,
locale: Locale? = null
) : AnalyticsActionEvent(ACTION_EXIT_LINK, locale = locale) {
class ExitLinkActionEvent(private val tool: String?, private val link: String, locale: Locale? = null) :
AnalyticsActionEvent(ACTION_EXIT_LINK, locale = locale) {
constructor(tool: String?, link: Uri, locale: Locale? = null) : this(tool, link.toString(), locale)

override fun isForSystem(system: AnalyticsSystem) = system == AnalyticsSystem.FIREBASE
Original file line number Diff line number Diff line change
@@ -3,6 +3,4 @@ package org.cru.godtools.api.model
import org.ccci.gto.android.common.jsonapi.annotation.JsonApiType

@JsonApiType("publisher-info")
class PublisherInfo(
var subscriberChannelId: String? = null
)
class PublisherInfo(var subscriberChannelId: String? = null)
Original file line number Diff line number Diff line change
@@ -11,8 +11,8 @@ import timber.log.Timber

fun Locale.getPrimaryCollator(): Collator = Collator.getInstance(this).also { it.strength = Collator.PRIMARY }

fun Locale.getDisplayName(context: Context? = null, defaultName: String? = null, inLocale: Locale? = null): String {
return getLanguageNameStringRes(context, inLocale)
fun Locale.getDisplayName(context: Context? = null, defaultName: String? = null, inLocale: Locale? = null) =
getLanguageNameStringRes(context, inLocale)
// use Locale.getDisplayName()
?: getOptionalDisplayName(inLocale)
// use the default name if specified
@@ -24,7 +24,6 @@ fun Locale.getDisplayName(context: Context? = null, defaultName: String? = null,
.e(e, "Locale(%s).getDisplayName(defaultName = %s, inLocale = %s)", this, defaultName, inLocale)
if (inLocale != null) getDisplayName(inLocale) else displayName
}
}

private fun Locale.getLanguageNameStringRes(context: Context?, inLocale: Locale?) = when (toLanguageTag()) {
"fa" -> context?.getLocalizedString(inLocale, R.string.language_name_fa)
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
package org.cru.godtools.db.room.entity.partial

internal class MigrationUserCounter(
val name: String,
val count: Int,
val decayedCount: Double
)
internal class MigrationUserCounter(val name: String, val count: Int, val decayedCount: Double)
Original file line number Diff line number Diff line change
@@ -2,10 +2,6 @@ package org.cru.godtools.db.room.entity.partial

import org.cru.godtools.model.UserCounter

internal class SyncUserCounter(
val name: String,
val count: Int,
val decayedCount: Double
) {
internal class SyncUserCounter(val name: String, val count: Int, val decayedCount: Double) {
constructor(counter: UserCounter) : this(counter.id, counter.apiCount, counter.apiDecayedCount)
}
Original file line number Diff line number Diff line change
@@ -67,10 +67,8 @@ private const val DATABASE_VERSION = 63
* 63: 2024-01-17
*/

internal class GodToolsDatabase(
private val context: Context,
private val roomDb: GodToolsRoomDatabase,
) : WalSQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) {
internal class GodToolsDatabase(private val context: Context, private val roomDb: GodToolsRoomDatabase) :
WalSQLiteOpenHelper(context, DATABASE_NAME, null, DATABASE_VERSION) {
override fun onCreate(db: SQLiteDatabase) = Unit

override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
6 changes: 4 additions & 2 deletions library/model/src/main/kotlin/org/cru/godtools/model/Tool.kt
Original file line number Diff line number Diff line change
@@ -177,8 +177,10 @@ class Tool(
@Suppress("SENSELESS_COMPARISON")
val isValid
get() = !code.isNullOrEmpty() &&
type != null && type != Type.UNKNOWN &&
apiId != null && apiId != INVALID_ID
type != null &&
type != Type.UNKNOWN &&
apiId != null &&
apiId != INVALID_ID
val totalShares get() = pendingShares + shares

override fun equals(other: Any?) = when {
Original file line number Diff line number Diff line change
@@ -2,9 +2,4 @@ package org.cru.godtools.model

import java.util.Locale

data class TrainingTip(
val tool: String,
val locale: Locale,
val tipId: String,
val isCompleted: Boolean
)
data class TrainingTip(val tool: String, val locale: Locale, val tipId: String, val isCompleted: Boolean)
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ import org.cru.godtools.db.repository.GlobalActivityRepository
import org.cru.godtools.db.repository.LastSyncTimeRepository

private const val SYNC_TIME_GLOBAL_ACTIVITY = "last_synced.global_activity"
private const val STALE_DURATION_GLOBAL_ACTIVITY = DAY_IN_MS
private const val STALE_GLOBAL_ACTIVITY = DAY_IN_MS

@Singleton
internal class AnalyticsSyncTasks @Inject internal constructor(
@@ -22,8 +22,8 @@ internal class AnalyticsSyncTasks @Inject internal constructor(

suspend fun syncGlobalActivity(force: Boolean): Boolean = globalActivityMutex.withLock {
// short-circuit if we aren't forcing a sync and the data isn't stale
if (!force && !lastSyncTimeRepository
.isLastSyncStale(SYNC_TIME_GLOBAL_ACTIVITY, staleAfter = STALE_DURATION_GLOBAL_ACTIVITY)
if (!force &&
!lastSyncTimeRepository.isLastSyncStale(SYNC_TIME_GLOBAL_ACTIVITY, staleAfter = STALE_GLOBAL_ACTIVITY)
) {
return@withLock true
}
Original file line number Diff line number Diff line change
@@ -23,9 +23,7 @@ class Resource(@field:PrimaryKey val uri: Uri) {
/**
* @return true if this resource needs to be downloaded
*/
fun needsDownload(): Boolean {
return localFileName == null || dateDownloaded == null
}
fun needsDownload() = localFileName == null || dateDownloaded == null

suspend fun getLocalFile(fs: FileSystem) = localFileName?.let { fs.file(it) }
suspend fun getInputStream(fs: FileSystem) = getLocalFile(fs)?.inputStream()
Original file line number Diff line number Diff line change
@@ -76,13 +76,17 @@ class ArticlesActivity :
}

private fun Uri.isGodToolsDeepLink() = (scheme == "http" || scheme == "https") &&
HOST_GODTOOLSAPP_COM.equals(host, true) && pathSegments.orEmpty().size >= 5 &&
HOST_GODTOOLSAPP_COM.equals(host, true) &&
pathSegments.orEmpty().size >= 5 &&
pathSegments?.getOrNull(0) == "deeplink" &&
pathSegments?.getOrNull(1) == "tool" && pathSegments?.getOrNull(2) == "article"
pathSegments?.getOrNull(1) == "tool" &&
pathSegments?.getOrNull(2) == "article"

private fun Uri.isCustomUriDeepLink() = scheme == SCHEME_GODTOOLS &&
HOST_GODTOOLS_CUSTOM_URI.equals(host, true) && pathSegments.orEmpty().size >= 4 &&
pathSegments?.getOrNull(0) == "tool" && pathSegments?.getOrNull(1) == "article"
HOST_GODTOOLS_CUSTOM_URI.equals(host, true) &&
pathSegments.orEmpty().size >= 4 &&
pathSegments?.getOrNull(0) == "tool" &&
pathSegments?.getOrNull(1) == "article"
// endregion Intent Processing

private fun updateToolbarTitle() {
Original file line number Diff line number Diff line change
@@ -13,10 +13,9 @@ import org.cru.godtools.article.aem.model.Article
import org.cru.godtools.shared.tool.parser.model.Manifest
import org.cru.godtools.tool.article.databinding.ListItemArticleBinding

class ArticlesAdapter(
lifecycleOwner: LifecycleOwner?,
private val manifest: LiveData<Manifest?>
) : SimpleDataBindingAdapter<ListItemArticleBinding>(lifecycleOwner), Observer<List<Article>?> {
class ArticlesAdapter(lifecycleOwner: LifecycleOwner?, private val manifest: LiveData<Manifest?>) :
SimpleDataBindingAdapter<ListItemArticleBinding>(lifecycleOwner),
Observer<List<Article>?> {
interface Callbacks {
fun onArticleSelected(article: Article?)
}
Original file line number Diff line number Diff line change
@@ -29,7 +29,9 @@ import org.greenrobot.eventbus.EventBus
import splitties.fragmentargs.argOrNull

@AndroidEntryPoint
class ArticlesFragment : BaseToolFragment<FragmentArticlesBinding>, ArticlesAdapter.Callbacks {
class ArticlesFragment :
BaseToolFragment<FragmentArticlesBinding>,
ArticlesAdapter.Callbacks {
constructor() : super(R.layout.fragment_articles)
constructor(
code: String,
Original file line number Diff line number Diff line change
@@ -12,7 +12,8 @@ import org.cru.godtools.shared.tool.parser.model.Category
import org.cru.godtools.tool.article.databinding.ListItemCategoryBinding

internal class CategoriesAdapter(lifecycleOwner: LifecycleOwner? = null) :
SimpleDataBindingAdapter<ListItemCategoryBinding>(lifecycleOwner), Observer<List<Category>?> {
SimpleDataBindingAdapter<ListItemCategoryBinding>(lifecycleOwner),
Observer<List<Category>?> {
init {
setHasStableIds(true)
}
Original file line number Diff line number Diff line change
@@ -18,7 +18,9 @@ import org.cru.godtools.tool.article.databinding.ArticleCategoriesFragmentBindin
import org.greenrobot.eventbus.EventBus

@AndroidEntryPoint
class CategoriesFragment : BaseToolFragment<ArticleCategoriesFragmentBinding>, CategorySelectedListener {
class CategoriesFragment :
BaseToolFragment<ArticleCategoriesFragmentBinding>,
CategorySelectedListener {
constructor() : super(R.layout.article_categories_fragment)
constructor(code: String, locale: Locale) : super(R.layout.article_categories_fragment, code, locale)

9 changes: 9 additions & 0 deletions ui/base-tool/config/ktlint/baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<baseline version="1.0">
<file name="src/main/kotlin/org/cru/godtools/base/tool/ui/share/ShareBottomSheetDialogFragment.kt">
<error line="19" column="46" source="standard:class-signature" />
</file>
<file name="src/main/kotlin/org/cru/godtools/base/tool/ui/shareable/ShareableImageBottomSheetDialogFragment.kt">
<error line="19" column="46" source="standard:class-signature" />
</file>
</baseline>
Original file line number Diff line number Diff line change
@@ -216,7 +216,8 @@ class MultiLanguageToolActivityDataModel @Inject constructor(
LoadingState.NOT_FOUND,
LoadingState.INVALID_TYPE,
LoadingState.OFFLINE -> availableLocales.firstOrNull {
loadingState[it] != LoadingState.NOT_FOUND && loadingState[it] != LoadingState.INVALID_TYPE &&
loadingState[it] != LoadingState.NOT_FOUND &&
loadingState[it] != LoadingState.INVALID_TYPE &&
loadingState[it] != LoadingState.OFFLINE
}?.let { activeLocale.value = it }
else -> Unit
Original file line number Diff line number Diff line change
@@ -6,11 +6,8 @@ import org.cru.godtools.shared.tool.parser.model.Manifest

const val SCREEN_CATEGORIES = "Categories"

open class ToolAnalyticsScreenEvent(
screen: String,
private val tool: String?,
locale: Locale? = null
) : AnalyticsScreenEvent(screen, locale) {
open class ToolAnalyticsScreenEvent(screen: String, private val tool: String?, locale: Locale? = null) :
AnalyticsScreenEvent(screen, locale) {
protected constructor(screen: String, manifest: Manifest) : this(screen, manifest.code, manifest.locale)

override val appSection get() = tool
Original file line number Diff line number Diff line change
@@ -6,11 +6,8 @@ import org.cru.godtools.shared.tool.analytics.ToolAnalyticsActionNames.ACTION_OP
import org.cru.godtools.shared.tool.parser.model.Manifest
import org.cru.godtools.shared.user.activity.UserCounterNames

class ToolOpenedAnalyticsActionEvent(
tool: String,
type: Manifest.Type? = null,
first: Boolean = false
) : ToolAnalyticsActionEvent(tool, action = if (first) ACTION_OPEN_FIRST else ACTION_OPEN) {
class ToolOpenedAnalyticsActionEvent(tool: String, type: Manifest.Type? = null, first: Boolean = false) :
ToolAnalyticsActionEvent(tool, action = if (first) ACTION_OPEN_FIRST else ACTION_OPEN) {
override fun isForSystem(system: AnalyticsSystem) = when (system) {
AnalyticsSystem.USER -> true
else -> false
Original file line number Diff line number Diff line change
@@ -7,16 +7,14 @@ import org.cru.godtools.base.tool.model.getFileBlocking
import org.cru.godtools.base.toolFileSystem
import org.cru.godtools.shared.tool.parser.model.shareable.ShareableImage

internal fun ShareableImage.buildShareIntent(context: Context): Intent? {
return resource?.let { resource ->
resource.getFileBlocking(context.toolFileSystem)?.let { file ->
val authority = "${context.packageName}.tool.fileprovider"
val uri = FileProvider.getUriForFile(context, authority, file, resource.name.orEmpty())
internal fun ShareableImage.buildShareIntent(context: Context) = resource?.let { resource ->
resource.getFileBlocking(context.toolFileSystem)?.let { file ->
val authority = "${context.packageName}.tool.fileprovider"
val uri = FileProvider.getUriForFile(context, authority, file, resource.name.orEmpty())

Intent(Intent.ACTION_SEND)
.setType("image/*")
.putExtra(Intent.EXTRA_STREAM, uri)
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
Intent(Intent.ACTION_SEND)
.setType("image/*")
.putExtra(Intent.EXTRA_STREAM, uri)
.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
}
}
Original file line number Diff line number Diff line change
@@ -19,7 +19,8 @@ class TabsController private constructor(
private val binding: ToolContentTabsBinding,
parentController: BaseController<*>,
tabControllerFactory: TabController.Factory
) : BaseController<Tabs>(Tabs::class, binding.root, parentController), OnTabSelectedListener {
) : BaseController<Tabs>(Tabs::class, binding.root, parentController),
OnTabSelectedListener {
@AssistedInject
constructor(
@Assisted parent: ViewGroup,
Original file line number Diff line number Diff line change
@@ -6,7 +6,9 @@ import android.os.Parcelable
import androidx.annotation.LayoutRes
import org.ccci.gto.android.common.Ordered

interface ShareItem : Parcelable, Ordered {
interface ShareItem :
Parcelable,
Ordered {
val shareIntent: Intent? get() = null

@get:LayoutRes
Original file line number Diff line number Diff line change
@@ -10,8 +10,7 @@ import org.ccci.gto.android.common.androidx.lifecycle.switchCombineWith
import org.cru.godtools.base.tool.service.ManifestManager

@HiltViewModel
open class LatestPublishedManifestDataModel @Inject constructor(manifestManager: ManifestManager) :
ViewModel() {
open class LatestPublishedManifestDataModel @Inject constructor(manifestManager: ManifestManager) : ViewModel() {
val toolCode = MutableLiveData<String?>()
val locale = MutableLiveData<Locale?>()

Original file line number Diff line number Diff line change
@@ -17,7 +17,8 @@ class SimpleScaledPicassoImageView @JvmOverloads constructor(
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
defStyleRes: Int = 0
) : SimplePicassoImageView(context, attrs, defStyleAttr), ScaledPicassoImageView {
) : SimplePicassoImageView(context, attrs, defStyleAttr),
ScaledPicassoImageView {
@Inject
internal lateinit var picasso: Picasso
override val helper = ScaleHelper(this, attrs, defStyleAttr, defStyleRes, picasso)
Original file line number Diff line number Diff line change
@@ -99,15 +99,13 @@ class ParentControllerTest {
assertThat(controller.childContainer.children.toList(), contains(instanceOf(Space::class.java)))
}

class ConcreteParentController(
public override val childContainer: LinearLayout,
cache: UiControllerCache
) : ParentController<Paragraph>(
Paragraph::class,
childContainer,
null,
UiControllerCache.Factory { _, _ -> cache }
)
class ConcreteParentController(public override val childContainer: LinearLayout, cache: UiControllerCache) :
ParentController<Paragraph>(
Paragraph::class,
childContainer,
null,
UiControllerCache.Factory { _, _ -> cache }
)

private inline fun <reified T : Base> testController(root: View) = object : BaseController<T>(T::class, root) {}
}
Original file line number Diff line number Diff line change
@@ -4,11 +4,9 @@ import org.cru.godtools.base.tool.analytics.model.ToolAnalyticsScreenEvent
import org.cru.godtools.shared.tool.analytics.ToolAnalyticsScreenNames
import org.cru.godtools.shared.tool.parser.model.page.Page

open class CyoaPageAnalyticsScreenEvent(
page: Page,
screen: String = ToolAnalyticsScreenNames.forCyoaPage(page)
) : ToolAnalyticsScreenEvent(
screen = screen,
tool = page.manifest.code,
locale = page.manifest.locale
)
open class CyoaPageAnalyticsScreenEvent(page: Page, screen: String = ToolAnalyticsScreenNames.forCyoaPage(page)) :
ToolAnalyticsScreenEvent(
screen = screen,
tool = page.manifest.code,
locale = page.manifest.locale
)
Original file line number Diff line number Diff line change
@@ -96,12 +96,14 @@ class CyoaActivity :
private inline val Uri.isGodToolsDeepLink
get() = (scheme.equals("http", true) || scheme.equals("https", true)) &&
HOST_GODTOOLSAPP_COM.equals(host, true) &&
pathSegments.size >= 5 && path?.startsWith("/deeplink/tool/cyoa/") == true
pathSegments.size >= 5 &&
path?.startsWith("/deeplink/tool/cyoa/") == true

private inline val Uri.isCustomUriSchemeDeepLink
get() = SCHEME_GODTOOLS.equals(scheme, true) &&
HOST_GODTOOLS_CUSTOM_URI.equals(host, true) &&
pathSegments.size >= 4 && path?.startsWith("/tool/cyoa/") == true
pathSegments.size >= 4 &&
path?.startsWith("/tool/cyoa/") == true
// endregion Intent Processing

private fun setupBinding() {
Original file line number Diff line number Diff line change
@@ -13,12 +13,11 @@ import org.cru.godtools.tool.cyoa.ui.controller.CardCollectionPageController
import org.cru.godtools.tool.cyoa.ui.controller.bindController

@AndroidEntryPoint
class CyoaCardCollectionPageFragment(
page: String? = null
) : CyoaPageFragment<CyoaPageCardCollectionBinding, CardCollectionPageController>(
R.layout.cyoa_page_card_collection,
page
) {
class CyoaCardCollectionPageFragment(page: String? = null) :
CyoaPageFragment<CyoaPageCardCollectionBinding, CardCollectionPageController>(
R.layout.cyoa_page_card_collection,
page
) {
override fun supportsPage(page: Page) = page is CardCollectionPage

// region Controller
Original file line number Diff line number Diff line change
@@ -12,9 +12,8 @@ import org.cru.godtools.tool.cyoa.ui.controller.ContentPageController
import org.cru.godtools.tool.cyoa.ui.controller.bindController

@AndroidEntryPoint
class CyoaContentPageFragment(
page: String? = null
) : CyoaPageFragment<CyoaPageContentBinding, ContentPageController>(R.layout.cyoa_page_content, page) {
class CyoaContentPageFragment(page: String? = null) :
CyoaPageFragment<CyoaPageContentBinding, ContentPageController>(R.layout.cyoa_page_content, page) {
override fun supportsPage(page: Page) = page is ContentPage

// region Controller
Original file line number Diff line number Diff line change
@@ -24,7 +24,8 @@ import org.greenrobot.eventbus.EventBus
import splitties.fragmentargs.arg

abstract class CyoaPageFragment<B : ViewDataBinding, C : BaseController<*>>(@LayoutRes layoutId: Int, page: String?) :
BaseFragment<B>(layoutId), ShowTipCallback {
BaseFragment<B>(layoutId),
ShowTipCallback {
@Inject
internal lateinit var eventBus: EventBus

6 changes: 6 additions & 0 deletions ui/lesson-renderer/config/ktlint/baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<baseline version="1.0">
<file name="src/main/kotlin/org/cru/godtools/tool/lesson/ui/feedback/LessonFeedbackDialogFragment.kt">
<error line="29" column="35" source="standard:class-signature" />
</file>
</baseline>
Original file line number Diff line number Diff line change
@@ -116,12 +116,15 @@ class LessonActivity :
}

private fun Uri.isGodToolsDeepLink() = ("http".equals(scheme, true) || "https".equals(scheme, true)) &&
HOST_GODTOOLSAPP_COM.equals(host, true) && pathSegments.orEmpty().size >= 5 &&
HOST_GODTOOLSAPP_COM.equals(host, true) &&
pathSegments.orEmpty().size >= 5 &&
path?.startsWith("/deeplink/tool/lesson/") == true

private fun Uri.isCustomUriDeepLink() = scheme == SCHEME_GODTOOLS &&
HOST_GODTOOLS_CUSTOM_URI.equals(host, true) && pathSegments.orEmpty().size >= 4 &&
pathSegments?.getOrNull(0) == "tool" && pathSegments?.getOrNull(1) == "lesson"
HOST_GODTOOLS_CUSTOM_URI.equals(host, true) &&
pathSegments.orEmpty().size >= 4 &&
pathSegments?.getOrNull(0) == "tool" &&
pathSegments?.getOrNull(1) == "lesson"
// endregion Intent Processing

// region UI
Original file line number Diff line number Diff line change
@@ -7,4 +7,5 @@ import org.cru.godtools.base.HOST_GODTOOLSAPP_COM

internal fun Uri.isLessonDeepLink() = ("http".equals(scheme, true) || "https".equals(scheme, true)) &&
host.equals(HOST_GODTOOLSAPP_COM, true) &&
pathSegments.getOrNull(0) == "lessons" && pathSegments.size >= 3
pathSegments.getOrNull(0) == "lessons" &&
pathSegments.size >= 3
Original file line number Diff line number Diff line change
@@ -39,7 +39,9 @@ import org.greenrobot.eventbus.EventBus
import splitties.fragmentargs.arg

@AndroidEntryPoint
class TipBottomSheetDialogFragment : BindingBottomSheetDialogFragment<ToolTipBinding>(R.layout.tool_tip), TipCallbacks {
class TipBottomSheetDialogFragment :
BindingBottomSheetDialogFragment<ToolTipBinding>(R.layout.tool_tip),
TipCallbacks {
companion object {
fun create(tip: Tip): TipBottomSheetDialogFragment? = TipBottomSheetDialogFragment().apply {
tool = tip.manifest.code ?: return null
Original file line number Diff line number Diff line change
@@ -18,7 +18,9 @@ internal class TipPageAdapter @AssistedInject internal constructor(
@Assisted lifecycleOwner: LifecycleOwner,
@Assisted private val toolState: State,
private val controllerFactory: TipPageController.Factory
) : SimpleDataBindingAdapter<ToolTipPageBinding>(lifecycleOwner), Observer<Tip?>, TipCallbacks {
) : SimpleDataBindingAdapter<ToolTipPageBinding>(lifecycleOwner),
Observer<Tip?>,
TipCallbacks {
@AssistedFactory
interface Factory {
fun create(lifecycleOwner: LifecycleOwner, toolState: State): TipPageAdapter
Original file line number Diff line number Diff line change
@@ -197,12 +197,15 @@ class TractActivity :
}

private fun Uri.isGodToolsDeepLink() = (scheme == "http" || scheme == "https") &&
HOST_GODTOOLSAPP_COM.equals(host, true) && pathSegments.orEmpty().size >= 5 &&
HOST_GODTOOLSAPP_COM.equals(host, true) &&
pathSegments.orEmpty().size >= 5 &&
path?.startsWith("/deeplink/tool/tract/") == true

private fun Uri.isCustomUriDeepLink() = scheme == SCHEME_GODTOOLS &&
HOST_GODTOOLS_CUSTOM_URI.equals(host, true) && pathSegments.orEmpty().size >= 4 &&
pathSegments?.getOrNull(0) == "tool" && pathSegments?.getOrNull(1) == "tract"
HOST_GODTOOLS_CUSTOM_URI.equals(host, true) &&
pathSegments.orEmpty().size >= 4 &&
pathSegments?.getOrNull(0) == "tool" &&
pathSegments?.getOrNull(1) == "tract"

@VisibleForTesting
internal val Uri.deepLinkSelectedLanguage get() = Locale.forLanguageTag(pathSegments[0])
Original file line number Diff line number Diff line change
@@ -37,7 +37,9 @@ class ManifestPagerAdapter @AssistedInject internal constructor(
@Assisted private val toolState: State,
private val pageControllerFactory: PageController.Factory,
eventBus: EventBus
) : DataBindingPagerAdapter<TractPageBinding>(lifecycleOwner), PageController.Callbacks, Observer<Manifest?> {
) : DataBindingPagerAdapter<TractPageBinding>(lifecycleOwner),
PageController.Callbacks,
Observer<Manifest?> {
@AssistedFactory
interface Factory {
fun create(
Original file line number Diff line number Diff line change
@@ -9,10 +9,8 @@ private const val DEFAULT_BOUNCES = 4
private const val DEFAULT_HEIGHT_DECAY = 0.75

@Immutable
class BounceInterpolator(
private val bounces: Int = DEFAULT_BOUNCES,
decay: Double = DEFAULT_HEIGHT_DECAY
) : Interpolator {
class BounceInterpolator(private val bounces: Int = DEFAULT_BOUNCES, decay: Double = DEFAULT_HEIGHT_DECAY) :
Interpolator {
private val heightDecay = 1 - decay
private val timeDecay = sqrt(heightDecay)
private val totalTime = (0 until bounces).map { timeDecay.pow(it) }.sum()
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.cru.godtools.tract.ui.liveshare

import android.app.Dialog
import android.os.Bundle
import android.widget.Toast
import androidx.fragment.app.DialogFragment
@@ -23,12 +22,10 @@ class LiveShareStartingDialogFragment : DialogFragment() {
startAutoDismissObservers()
}

override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
return MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.tract_live_share_starting)
.setView(R.layout.tract_live_share_dialog)
.create()
}
override fun onCreateDialog(savedInstanceState: Bundle?) = MaterialAlertDialogBuilder(requireContext())
.setTitle(R.string.tract_live_share_starting)
.setView(R.layout.tract_live_share_dialog)
.create()

private fun startAutoDismissObservers() {
// auto-dismiss dialog when we have publisherInfo
Original file line number Diff line number Diff line change
@@ -670,9 +670,6 @@ class PageContentLayout @JvmOverloads constructor(
// endregion View layout logic

@Parcelize
private class SavedState(
val activeCardPosition: Int,
val isBounceFirstCard: Boolean,
val superState: Parcelable?
) : Parcelable
private class SavedState(val activeCardPosition: Int, val isBounceFirstCard: Boolean, val superState: Parcelable?) :
Parcelable
}

0 comments on commit 4f581a2

Please sign in to comment.