diff --git a/android/libraries/rib-android-compose/src/main/kotlin/com/uber/rib/core/BasicComposeRouter.kt b/android/libraries/rib-android-compose/src/main/kotlin/com/uber/rib/core/BasicComposeRouter.kt index 2574963e4..e8d50d818 100644 --- a/android/libraries/rib-android-compose/src/main/kotlin/com/uber/rib/core/BasicComposeRouter.kt +++ b/android/libraries/rib-android-compose/src/main/kotlin/com/uber/rib/core/BasicComposeRouter.kt @@ -18,10 +18,10 @@ package com.uber.rib.core import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState -open class BasicComposeRouter>( - val presenter: ComposePresenter, +public open class BasicComposeRouter>( + public val presenter: ComposePresenter, interactor: I, - val slot: MutableState<(@Composable () -> Unit)>, + public val slot: MutableState<(@Composable () -> Unit)>, ) : BasicRouter(interactor) { override fun willAttach() { slot.value = presenter.composable diff --git a/android/libraries/rib-android-compose/src/main/kotlin/com/uber/rib/core/ComposePresenter.kt b/android/libraries/rib-android-compose/src/main/kotlin/com/uber/rib/core/ComposePresenter.kt index 10654e17a..e3e71afe8 100644 --- a/android/libraries/rib-android-compose/src/main/kotlin/com/uber/rib/core/ComposePresenter.kt +++ b/android/libraries/rib-android-compose/src/main/kotlin/com/uber/rib/core/ComposePresenter.kt @@ -17,6 +17,6 @@ package com.uber.rib.core import androidx.compose.runtime.Composable -abstract class ComposePresenter : Presenter() { - abstract val composable: @Composable () -> Unit +public abstract class ComposePresenter : Presenter() { + public abstract val composable: @Composable () -> Unit } diff --git a/android/libraries/rib-android-core/src/main/kotlin/com/uber/rib/core/ActivityDelegate.kt b/android/libraries/rib-android-core/src/main/kotlin/com/uber/rib/core/ActivityDelegate.kt index c2b391621..ccc6d173f 100644 --- a/android/libraries/rib-android-core/src/main/kotlin/com/uber/rib/core/ActivityDelegate.kt +++ b/android/libraries/rib-android-core/src/main/kotlin/com/uber/rib/core/ActivityDelegate.kt @@ -25,27 +25,27 @@ import androidx.annotation.IntRange * functionality. This allows [RibActivity] and any other type of [Activity] that you need to * support to share [CoreAppCompatActivity] as a common parent. */ -interface ActivityDelegate { +public interface ActivityDelegate { /** @see [Activity.onCreate] */ - fun onCreate(savedInstanceState: Bundle?) {} + public fun onCreate(savedInstanceState: Bundle?) {} /** @see [Activity.onStart] */ - fun onStart() {} + public fun onStart() {} /** @see [Activity.onResume] */ - fun onResume() {} + public fun onResume() {} /** @see [Activity.onPause] */ - fun onPause() {} + public fun onPause() {} /** @see [Activity.onStop] */ - fun onStop() {} + public fun onStop() {} /** @see [Activity.onDestroy] */ - fun onDestroy() {} + public fun onDestroy() {} /** @see [Activity.onActivityResult] */ - fun onActivityResult( + public fun onActivityResult( activity: Activity, requestCode: Int, resultCode: Int, @@ -53,7 +53,7 @@ interface ActivityDelegate { ) {} /** @see [Activity.onRequestPermissionsResult] */ - fun onRequestPermissionsResult( + public fun onRequestPermissionsResult( activity: Activity, @IntRange(from = 0, to = 255) requestCode: Int, permissions: Array, diff --git a/android/libraries/rib-android-core/src/main/kotlin/com/uber/rib/core/CoreAppCompatActivity.kt b/android/libraries/rib-android-core/src/main/kotlin/com/uber/rib/core/CoreAppCompatActivity.kt index 2b6156706..5a5641cc3 100644 --- a/android/libraries/rib-android-core/src/main/kotlin/com/uber/rib/core/CoreAppCompatActivity.kt +++ b/android/libraries/rib-android-core/src/main/kotlin/com/uber/rib/core/CoreAppCompatActivity.kt @@ -25,7 +25,7 @@ import androidx.lifecycle.ViewTreeViewModelStoreOwner import androidx.savedstate.ViewTreeSavedStateRegistryOwner /** Core Support v7 AppCompat Activity. */ -abstract class CoreAppCompatActivity : AppCompatActivity() { +public abstract class CoreAppCompatActivity : AppCompatActivity() { private var activityDelegate: ActivityDelegate? = null diff --git a/android/libraries/rib-android-core/src/main/kotlin/com/uber/rib/core/HasActivityDelegate.kt b/android/libraries/rib-android-core/src/main/kotlin/com/uber/rib/core/HasActivityDelegate.kt index 55f42bdec..2db9d7c75 100644 --- a/android/libraries/rib-android-core/src/main/kotlin/com/uber/rib/core/HasActivityDelegate.kt +++ b/android/libraries/rib-android-core/src/main/kotlin/com/uber/rib/core/HasActivityDelegate.kt @@ -16,11 +16,11 @@ package com.uber.rib.core /** Interface to indicate an object has an [ActivityDelegate]. */ -interface HasActivityDelegate { +public interface HasActivityDelegate { /** * Get the delegate. * * @return The delegate. */ - fun activityDelegate(): ActivityDelegate + public fun activityDelegate(): ActivityDelegate } diff --git a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ActivityContext.kt b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ActivityContext.kt index 8da53a9db..84cdcde12 100644 --- a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ActivityContext.kt +++ b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ActivityContext.kt @@ -15,9 +15,7 @@ */ package com.uber.rib.core -import java.lang.annotation.Retention -import java.lang.annotation.RetentionPolicy.RUNTIME import javax.inject.Qualifier /** Injection qualifier for an Activity Context. */ -@Qualifier @Retention(RUNTIME) annotation class ActivityContext +@Qualifier @Retention public annotation class ActivityContext diff --git a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ActivityStarter.kt b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ActivityStarter.kt index 9d0caf019..55d44982d 100644 --- a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ActivityStarter.kt +++ b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ActivityStarter.kt @@ -21,13 +21,13 @@ import android.content.Intent * Start activities. A much cleaner dependency than an entire activity or context, and easier to * inject and mock in tests. */ -interface ActivityStarter { +public interface ActivityStarter { /** * Start an activity with the given intent. * * @param intent The intent to open a new activity. */ - fun startActivity(intent: Intent) + public fun startActivity(intent: Intent) /** * Start an activity with the given intent, to be notified when that activity finishes. @@ -37,5 +37,5 @@ interface ActivityStarter { * from this request. */ @Deprecated("""use plain Activity instead""") - fun startActivityForResult(intent: Intent, requestCode: Int) + public fun startActivityForResult(intent: Intent, requestCode: Int) } diff --git a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/BasicViewRouter.kt b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/BasicViewRouter.kt index bfd1ec88a..968fcc3a2 100644 --- a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/BasicViewRouter.kt +++ b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/BasicViewRouter.kt @@ -22,7 +22,5 @@ import android.view.View * * @param type of interactor. */ -abstract class BasicViewRouter>( - view: V, - interactor: I, -) : ViewRouter(view, interactor) +public abstract class BasicViewRouter>(view: V, interactor: I) : + ViewRouter(view, interactor) diff --git a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/IntentCreator.kt b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/IntentCreator.kt index 045747a67..071ef7a8e 100644 --- a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/IntentCreator.kt +++ b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/IntentCreator.kt @@ -18,7 +18,7 @@ package com.uber.rib.core import android.content.Intent /** Creates intent objects. */ -interface IntentCreator { +public interface IntentCreator { /** * Create an explicit intent targeted at a particular class, which is guaranteed to be limited to * your app's package. @@ -26,7 +26,7 @@ interface IntentCreator { * @param cls The class that you intend to receive this intent. * @return The intent. */ - fun create(cls: Class<*>): Intent + public fun create(cls: Class<*>): Intent /** * Create an implicit intent targeted at an action, which may end up resolving to your app or to @@ -37,5 +37,5 @@ interface IntentCreator { * @param action The intent action, which any app may register to receive. * @return The intent. */ - fun create(action: String): Intent + public fun create(action: String): Intent } diff --git a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/IntentCreatorImpl.kt b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/IntentCreatorImpl.kt index 10831fb91..501ecd2f0 100644 --- a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/IntentCreatorImpl.kt +++ b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/IntentCreatorImpl.kt @@ -19,8 +19,8 @@ import android.content.Context import android.content.Intent /** A default implementation of [IntentCreator]. */ -open class IntentCreatorImpl(private val context: Context) : IntentCreator { - override fun create(cls: Class<*>) = Intent(context, cls) +public open class IntentCreatorImpl(private val context: Context) : IntentCreator { + override fun create(cls: Class<*>): Intent = Intent(context, cls) - override fun create(action: String) = Intent(action) + override fun create(action: String): Intent = Intent(action) } diff --git a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/IntentFactory.kt b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/IntentFactory.kt index 4d94dc33a..7692f1246 100644 --- a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/IntentFactory.kt +++ b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/IntentFactory.kt @@ -18,12 +18,12 @@ package com.uber.rib.core import android.content.Intent /** Factory for an [Intent] that opens an activity. */ -interface IntentFactory { +public interface IntentFactory { /** * Create a view router to be displayed for an [Intent]. * * @param intentCreator to create the [Intent]. * @return the activity [Intent]. */ - fun create(intentCreator: IntentCreator): Intent + public fun create(intentCreator: IntentCreator): Intent } diff --git a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/RibDebugOverlay.kt b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/RibDebugOverlay.kt index ac7788a61..a4ac059a7 100644 --- a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/RibDebugOverlay.kt +++ b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/RibDebugOverlay.kt @@ -22,10 +22,10 @@ import android.graphics.Paint import android.graphics.PixelFormat import android.graphics.drawable.Drawable -open class RibDebugOverlay : Drawable() { +public open class RibDebugOverlay : Drawable() { private var enabled = true - open fun setEnabled(enabled: Boolean) { + public open fun setEnabled(enabled: Boolean) { this.enabled = enabled } @@ -43,9 +43,9 @@ open class RibDebugOverlay : Drawable() { override fun setColorFilter(colorFilter: ColorFilter?) {} - override fun getOpacity() = PixelFormat.TRANSLUCENT + @Deprecated("Deprecated in upstream.") override fun getOpacity(): Int = PixelFormat.TRANSLUCENT - companion object { + private companion object { private const val OVERLAY_COLOR = Color.RED private const val OVERLAY_ALPHA = 35 } diff --git a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/RxActivityEvents.kt b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/RxActivityEvents.kt index 1e83cdfd3..95b7c9bb9 100644 --- a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/RxActivityEvents.kt +++ b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/RxActivityEvents.kt @@ -20,32 +20,30 @@ import com.uber.rib.core.lifecycle.ActivityLifecycleEvent import io.reactivex.Observable /** Interface for reactive activities. */ -interface RxActivityEvents { +public interface RxActivityEvents { /** @return an observable of this activity's lifecycle events. */ - fun lifecycle(): Observable + public fun lifecycle(): Observable /** @return an observable of this activity's lifecycle events. */ - fun callbacks(): Observable + public fun callbacks(): Observable /** * @param The type of [ActivityLifecycleEvent] subclass you want. * @param clazz The [ActivityLifecycleEvent] subclass you want. * @return an observable of this activity's lifecycle events. */ - fun lifecycle(clazz: Class): Observable { - return lifecycle() + public fun lifecycle(clazz: Class): Observable = + lifecycle() .filter { activityEvent -> clazz.isAssignableFrom(activityEvent.javaClass) } .cast(clazz) - } /** * @param The type of [ActivityCallbackEvent] subclass you want. * @param clazz The [ActivityCallbackEvent] subclass you want. * @return an observable of this activity's callbacks events. */ - fun callbacks(clazz: Class): Observable { - return callbacks() + public fun callbacks(clazz: Class): Observable = + callbacks() .filter { activityEvent -> clazz.isAssignableFrom(activityEvent.javaClass) } .cast(clazz) - } } diff --git a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ViewBuilder.kt b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ViewBuilder.kt index 6c236599e..fbfd8fa40 100644 --- a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ViewBuilder.kt +++ b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ViewBuilder.kt @@ -27,7 +27,7 @@ import android.view.ViewGroup * @param type of router built by this builder. * @param dependency required to create this router. */ -abstract class ViewBuilder, DependencyT>( +public abstract class ViewBuilder, DependencyT>( dependency: DependencyT, ) : Builder(dependency) { /** @@ -36,7 +36,7 @@ abstract class ViewBuilder, DependencyT>( * @param parentViewGroup to inflate view with. * @return the view for a new router. */ - fun createView(parentViewGroup: ViewGroup): ViewType { + public fun createView(parentViewGroup: ViewGroup): ViewType { val context = parentViewGroup.context return inflateView(LayoutInflater.from(onThemeContext(context)), parentViewGroup) } @@ -59,7 +59,5 @@ abstract class ViewBuilder, DependencyT>( * overridden. * @return the possibly themed context. */ - protected open fun onThemeContext(parentContext: Context): Context { - return parentContext - } + protected open fun onThemeContext(parentContext: Context): Context = parentContext } diff --git a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ViewPresenter.kt b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ViewPresenter.kt index 8fd9d4f92..1fd5eb973 100644 --- a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ViewPresenter.kt +++ b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ViewPresenter.kt @@ -22,7 +22,7 @@ import android.view.View * * @param the view type. */ -abstract class ViewPresenter( +public abstract class ViewPresenter( /** @return the view fronted by the page. */ - val view: V, + public val view: V, ) : Presenter() diff --git a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ViewRouter.kt b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ViewRouter.kt index ec0f74657..036e679cc 100644 --- a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ViewRouter.kt +++ b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/ViewRouter.kt @@ -23,11 +23,11 @@ import android.view.View * @param type of view owned by the router. * @param type of interactor owned by the router. */ -abstract class ViewRouter> : Router { +public abstract class ViewRouter> : Router { /** @return the router's view. */ - open val view: V + public val view: V - constructor( + public constructor( view: V, interactor: I, component: InteractorBaseComponent<*>, diff --git a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/XRay.kt b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/XRay.kt index 3e545702e..efc7a38a7 100644 --- a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/XRay.kt +++ b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/XRay.kt @@ -25,9 +25,10 @@ import android.view.Gravity import android.view.View /** Utility class that shows riblets name in its background. */ -class XRay private constructor() { +public class XRay private constructor() { private var isEnabled = false private var textPaint: Paint? = null + private fun writeOnBitmap(bitmap: Bitmap, text: String) { val canvas = Canvas(bitmap) val textPaint = getTextPaint() @@ -47,7 +48,7 @@ class XRay private constructor() { return textPaint!! } - companion object { + public companion object { private val INSTANCE = XRay() private const val FRAME_WIDTH = 500 private const val FRAME_HEIGHT = 150 @@ -57,15 +58,12 @@ class XRay private constructor() { /** Toggles state of XRay. */ @JvmStatic - fun toggle() { + public fun toggle() { INSTANCE.isEnabled = !INSTANCE.isEnabled } /** @return `true` if XRay is enabled, `false` otherwise. */ - @JvmStatic - fun isEnabled(): Boolean { - return INSTANCE.isEnabled - } + @JvmStatic public fun isEnabled(): Boolean = INSTANCE.isEnabled /** * Puts [ViewBuilder]s riblet name in the background of the [View] @@ -74,7 +72,7 @@ class XRay private constructor() { * @param view a [View] to put the name behind. */ @JvmStatic - fun apply(viewRouter: ViewRouter<*, *>, view: View) { + public fun apply(viewRouter: ViewRouter<*, *>, view: View) { val oldBackground = view.background val bitmap: Bitmap = if (oldBackground != null) { @@ -110,8 +108,7 @@ class XRay private constructor() { return bitmap } - private fun getRibletName(viewRouter: ViewRouter<*, *>): String { - return viewRouter.javaClass.simpleName.replace("Router", "") - } + private fun getRibletName(viewRouter: ViewRouter<*, *>): String = + viewRouter.javaClass.simpleName.replace("Router", "") } } diff --git a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/lifecycle/ActivityCallbackEvent.kt b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/lifecycle/ActivityCallbackEvent.kt index f854bc315..aafd5bd17 100644 --- a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/lifecycle/ActivityCallbackEvent.kt +++ b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/lifecycle/ActivityCallbackEvent.kt @@ -19,14 +19,14 @@ import android.content.Intent import android.os.Bundle /** Callback events that can be emitted by Activities. */ -open class ActivityCallbackEvent +public open class ActivityCallbackEvent private constructor( /** @return this event's type. */ override val type: Type, ) : ActivityEvent { /** Types of activity events that can occur. */ - enum class Type : ActivityEvent.BaseType { + public enum class Type : ActivityEvent.BaseType { LOW_MEMORY, ACTIVITY_RESULT, SAVE_INSTANCE_STATE, @@ -37,36 +37,39 @@ private constructor( } /** An [ActivityCallbackEvent] that represents [Activity.onNewIntent] event */ - open class NewIntent(open val intent: Intent) : ActivityCallbackEvent(Type.NEW_INTENT) - open class PictureInPictureMode(open val isInPictureInPictureMode: Boolean) : + public open class NewIntent(public open val intent: Intent) : + ActivityCallbackEvent(Type.NEW_INTENT) + + public open class PictureInPictureMode(public open val isInPictureInPictureMode: Boolean) : ActivityCallbackEvent(Type.PICTURE_IN_PICTURE_MODE) /** An [ActivityCallbackEvent] that represents [Activity.onWindowFocusChanged] event */ - open class WindowFocus(open val hasFocus: Boolean) : ActivityCallbackEvent(Type.WINDOW_FOCUS) + public open class WindowFocus(public open val hasFocus: Boolean) : + ActivityCallbackEvent(Type.WINDOW_FOCUS) /** An [ActivityCallbackEvent] that represents [Activity.onTrimMemory] event */ - open class TrimMemory internal constructor(open val trimMemoryType: Int) : + public open class TrimMemory internal constructor(public open val trimMemoryType: Int) : ActivityCallbackEvent(Type.TRIM_MEMORY) /** An [ActivityCallbackEvent] that encapsulates information from [Activity.onActivityResult]. */ - open class ActivityResult( + public open class ActivityResult( /** @return this event's activity result data intent. */ - open val data: Intent?, + public open val data: Intent?, /** @return this event's request code. */ - open val requestCode: Int, + public open val requestCode: Int, /** @return this event's result code. */ - open val resultCode: Int, + public open val resultCode: Int, ) : ActivityCallbackEvent(Type.ACTIVITY_RESULT) /** * An [ActivityCallbackEvent] that encapsulates information from [Activity.onSaveInstanceState]. */ - open class SaveInstanceState( + public open class SaveInstanceState( /** @return this event's outState data. */ - open val outState: Bundle?, + public open val outState: Bundle?, ) : ActivityCallbackEvent(Type.SAVE_INSTANCE_STATE) - companion object { + public companion object { private val LOW_MEMORY_EVENT = ActivityCallbackEvent(Type.LOW_MEMORY) /** @@ -78,13 +81,11 @@ private constructor( * @return the created ActivityEvent. */ @JvmStatic - fun createOnActivityResultEvent( + public fun createOnActivityResultEvent( requestCode: Int, resultCode: Int, resultData: Intent?, - ): ActivityResult { - return ActivityResult(resultData, requestCode, resultCode) - } + ): ActivityResult = ActivityResult(resultData, requestCode, resultCode) /** * Creates an activity event for a given type. @@ -93,15 +94,14 @@ private constructor( * @return The corresponding ActivityEvent. */ @JvmStatic - fun create(type: Type): ActivityCallbackEvent { - return when (type) { + public fun create(type: Type): ActivityCallbackEvent = + when (type) { Type.LOW_MEMORY -> LOW_MEMORY_EVENT else -> throw IllegalArgumentException( "Use the createOn${type.name.toLowerCase().capitalize()}Event() method for this type!", ) } - } /** * Creates an event for onSaveInstanceState. @@ -110,9 +110,8 @@ private constructor( * @return the created ActivityEvent. */ @JvmStatic - fun createOnSaveInstanceStateEvent(outState: Bundle?): ActivityCallbackEvent { - return SaveInstanceState(outState) - } + public fun createOnSaveInstanceStateEvent(outState: Bundle?): ActivityCallbackEvent = + SaveInstanceState(outState) /** * Creates an event for [Activity.onTrimMemory] @@ -121,14 +120,11 @@ private constructor( * @return the created [TrimMemory] */ @JvmStatic - fun createTrimMemoryEvent(trimMemoryType: Int): TrimMemory { - return TrimMemory(trimMemoryType) - } + public fun createTrimMemoryEvent(trimMemoryType: Int): TrimMemory = TrimMemory(trimMemoryType) @JvmStatic - fun createPictureInPictureMode(isInPictureInPictureMode: Boolean): PictureInPictureMode { - return PictureInPictureMode(isInPictureInPictureMode) - } + public fun createPictureInPictureMode(isInPictureInPictureMode: Boolean): PictureInPictureMode = + PictureInPictureMode(isInPictureInPictureMode) /** * Creates an event for onNewIntent. @@ -136,10 +132,7 @@ private constructor( * @param intent is the new intent received * @return the created [NewIntent]. */ - @JvmStatic - fun createNewIntent(intent: Intent): NewIntent { - return NewIntent(intent) - } + @JvmStatic public fun createNewIntent(intent: Intent): NewIntent = NewIntent(intent) /** * Creates an event for onWindowFocusChanged @@ -148,8 +141,6 @@ private constructor( * @return the newly created [WindowFocus] */ @JvmStatic - fun createWindowFocusEvent(hasFocus: Boolean): WindowFocus { - return WindowFocus(hasFocus) - } + public fun createWindowFocusEvent(hasFocus: Boolean): WindowFocus = WindowFocus(hasFocus) } } diff --git a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/lifecycle/ActivityEvent.kt b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/lifecycle/ActivityEvent.kt index 23616c4c0..ecefaf777 100644 --- a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/lifecycle/ActivityEvent.kt +++ b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/lifecycle/ActivityEvent.kt @@ -19,10 +19,10 @@ package com.uber.rib.core.lifecycle * Base class for Activity events, useful for when you want a stream of both lifecycle and callback * events. */ -interface ActivityEvent { +public interface ActivityEvent { /** @return This activity event type. */ - val type: BaseType + public val type: BaseType /** Base interface of Activity event types. */ - interface BaseType + public interface BaseType } diff --git a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/lifecycle/ActivityLifecycleEvent.kt b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/lifecycle/ActivityLifecycleEvent.kt index c1cd2cf38..2951d3837 100644 --- a/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/lifecycle/ActivityLifecycleEvent.kt +++ b/android/libraries/rib-android/src/main/kotlin/com/uber/rib/core/lifecycle/ActivityLifecycleEvent.kt @@ -45,14 +45,14 @@ import android.os.Bundle * [total order](https://en.wikipedia.org/wiki/Total_order): it is reflexive, transitive, strongly * connected, but **not** antisymmetric. */ -open class ActivityLifecycleEvent +public open class ActivityLifecycleEvent private constructor( /** @return this event's type. */ override val type: Type, ) : ActivityEvent, Comparable { /** Types of activity events that can occur. */ - enum class Type : ActivityEvent.BaseType { + public enum class Type : ActivityEvent.BaseType { CREATE, START, RESUME, @@ -68,12 +68,12 @@ private constructor( * An [ActivityLifecycleEvent] that encapsulates information from * [Activity.onCreate][android.app.Activity.onCreate]. */ - open class Create( + public open class Create( /** @return this event's savedInstanceState data. */ - open val savedInstanceState: Bundle?, + public open val savedInstanceState: Bundle?, ) : ActivityLifecycleEvent(Type.CREATE) - companion object { + public companion object { private val START_EVENT = ActivityLifecycleEvent(Type.START) private val RESUME_EVENT = ActivityLifecycleEvent(Type.RESUME) private val USER_LEAVING_EVENT = ActivityLifecycleEvent(Type.USER_LEAVING) @@ -87,10 +87,7 @@ private constructor( * @param stateData the instate bundle. * @return the created ActivityEvent. */ - @JvmStatic - fun createOnCreateEvent(stateData: Bundle?): Create { - return Create(stateData) - } + @JvmStatic public fun createOnCreateEvent(stateData: Bundle?): Create = Create(stateData) /** * Creates an activity event for a given type. @@ -99,8 +96,8 @@ private constructor( * @return The corresponding ActivityEvent. */ @JvmStatic - fun create(type: Type): ActivityLifecycleEvent { - return when (type) { + public fun create(type: Type): ActivityLifecycleEvent = + when (type) { Type.START -> START_EVENT Type.RESUME -> RESUME_EVENT Type.USER_LEAVING -> USER_LEAVING_EVENT @@ -112,6 +109,5 @@ private constructor( "Use the createOn${type.name.lowercase().replaceFirstChar(Char::titlecase)}Event() method for this type!", ) } - } } } diff --git a/android/libraries/rib-screen-stack-base/src/main/kotlin/com/uber/rib/core/screenstack/ScreenStackBase.kt b/android/libraries/rib-screen-stack-base/src/main/kotlin/com/uber/rib/core/screenstack/ScreenStackBase.kt index 7bb11f8df..1e8a248d5 100644 --- a/android/libraries/rib-screen-stack-base/src/main/kotlin/com/uber/rib/core/screenstack/ScreenStackBase.kt +++ b/android/libraries/rib-screen-stack-base/src/main/kotlin/com/uber/rib/core/screenstack/ScreenStackBase.kt @@ -18,7 +18,7 @@ package com.uber.rib.core.screenstack import androidx.annotation.IntRange /** Implementation of a view based screen stack. */ -interface ScreenStackBase { +public interface ScreenStackBase { /** * Pushes a new screen into the stack. The new screen view will have its type inspected in order * to manipulate the status bar background and icon colors. @@ -27,7 +27,7 @@ interface ScreenStackBase { * * @param viewProvider to create a new view to be displayed. */ - fun pushScreen(viewProvider: ViewProvider) + public fun pushScreen(viewProvider: ViewProvider) /** * Pushes a new screen into the stack. The new screen view will have its type inspected in order @@ -37,10 +37,10 @@ interface ScreenStackBase { * @param shouldAnimate whether the addition of the screen should be animated using the default * transition. */ - fun pushScreen(viewProvider: ViewProvider, shouldAnimate: Boolean) + public fun pushScreen(viewProvider: ViewProvider, shouldAnimate: Boolean) /** Removes the current screen from the stack. This will use animations. */ - fun popScreen() + public fun popScreen() /** * Removes the current screen from the stack. Allows enabling/disabling of the animation used in @@ -48,7 +48,7 @@ interface ScreenStackBase { * * @param shouldAnimate Whether the removal of the screen should be animated. */ - fun popScreen(shouldAnimate: Boolean) + public fun popScreen(shouldAnimate: Boolean) /** * Pops back to the specified index. (Starting at 0). @@ -59,7 +59,7 @@ interface ScreenStackBase { * @param shouldAnimate If true, we should animate to the final entry that we are popping to. If * false, no animations will be used. */ - fun popBackTo(@IntRange(from = -1) index: Int, shouldAnimate: Boolean) + public fun popBackTo(@IntRange(from = -1) index: Int, shouldAnimate: Boolean) /** * Try to handle a back press. Pass the back press to children, if they exist. Or pop the top item @@ -67,7 +67,7 @@ interface ScreenStackBase { * * @return True if the back press is handled. */ - fun handleBackPress(): Boolean + public fun handleBackPress(): Boolean /** * Try to handle a back press. Pass the back press to children, if they exist. Or pop the top item @@ -76,12 +76,12 @@ interface ScreenStackBase { * @param shouldAnimate True if we should use animations. False otherwise. * @return TRUE if the back press is handled. */ - fun handleBackPress(shouldAnimate: Boolean): Boolean + public fun handleBackPress(shouldAnimate: Boolean): Boolean /** * Gets the size of the stack. * * @return Size. */ - @IntRange(from = 0) fun size(): Int + @IntRange(from = 0) public fun size(): Int } diff --git a/android/libraries/rib-screen-stack-base/src/main/kotlin/com/uber/rib/core/screenstack/ViewProvider.kt b/android/libraries/rib-screen-stack-base/src/main/kotlin/com/uber/rib/core/screenstack/ViewProvider.kt index 848bebcf3..ee0741cc4 100644 --- a/android/libraries/rib-screen-stack-base/src/main/kotlin/com/uber/rib/core/screenstack/ViewProvider.kt +++ b/android/libraries/rib-screen-stack-base/src/main/kotlin/com/uber/rib/core/screenstack/ViewProvider.kt @@ -26,12 +26,12 @@ import kotlinx.coroutines.flow.SharedFlow import kotlinx.coroutines.rx2.asObservable /** Interface to provide [View] instances to [ScreenStackBase]. */ -abstract class ViewProvider { +public abstract class ViewProvider { private val _lifecycleFlow = MutableSharedFlow(1, 0, BufferOverflow.DROP_OLDEST) - open val lifecycleFlow: SharedFlow + public open val lifecycleFlow: SharedFlow get() = _lifecycleFlow - open fun buildViewInternal(parentView: ViewGroup): View { + public open fun buildViewInternal(parentView: ViewGroup): View { _lifecycleFlow.tryEmit(ScreenStackEvent.BUILT) return buildView(parentView) } @@ -42,10 +42,10 @@ abstract class ViewProvider { * @param parentView parent [ViewGroup] that the view will be displayed in. * @return the view to be displayed. */ - abstract fun buildView(parentView: ViewGroup): View + public abstract fun buildView(parentView: ViewGroup): View /** @return an observable that emits events for this view provider's lifecycle. */ - fun lifecycle(): Observable = lifecycleFlow.asObservable() + public fun lifecycle(): Observable = lifecycleFlow.asObservable() /** * Callers can implement this in order to complete additional work when a call to @@ -54,7 +54,7 @@ abstract class ViewProvider { protected open fun doOnViewRemoved() {} /** Notifies the view provider that the view has been popped from the stack. */ - fun onViewRemoved() { + public fun onViewRemoved() { _lifecycleFlow.tryEmit(ScreenStackEvent.REMOVED) doOnViewRemoved() } @@ -64,19 +64,17 @@ abstract class ViewProvider { * * @return TRUE if the provider handled the back press. */ - open fun onBackPress(): Boolean { - return false - } + public open fun onBackPress(): Boolean = false /** Notifies the view provider that view is at the top of the stack and visible. */ @CallSuper - open fun onViewAppeared() { + public open fun onViewAppeared() { _lifecycleFlow.tryEmit(ScreenStackEvent.APPEARED) } /** Notifies the view provider that the view is no longer at the top of the stack. */ @CallSuper - open fun onViewHidden() { + public open fun onViewHidden() { _lifecycleFlow.tryEmit(ScreenStackEvent.HIDDEN) } } diff --git a/android/libraries/rib-screen-stack-base/src/main/kotlin/com/uber/rib/core/screenstack/lifecycle/ScreenStackEvent.kt b/android/libraries/rib-screen-stack-base/src/main/kotlin/com/uber/rib/core/screenstack/lifecycle/ScreenStackEvent.kt index d49dc6a3c..95ed6ae22 100644 --- a/android/libraries/rib-screen-stack-base/src/main/kotlin/com/uber/rib/core/screenstack/lifecycle/ScreenStackEvent.kt +++ b/android/libraries/rib-screen-stack-base/src/main/kotlin/com/uber/rib/core/screenstack/lifecycle/ScreenStackEvent.kt @@ -18,7 +18,7 @@ package com.uber.rib.core.screenstack.lifecycle import com.uber.rib.core.screenstack.ScreenStackBase /** Lifecycle events that can be emitted by [ScreenStackBase] view providers. */ -enum class ScreenStackEvent { +public enum class ScreenStackEvent { BUILT, APPEARED, HIDDEN, diff --git a/android/libraries/rib-workflow-test/src/main/kotlin/com/uber/rib/workflow/core/StepTester.kt b/android/libraries/rib-workflow-test/src/main/kotlin/com/uber/rib/workflow/core/StepTester.kt index 20f4f138c..75ace078b 100644 --- a/android/libraries/rib-workflow-test/src/main/kotlin/com/uber/rib/workflow/core/StepTester.kt +++ b/android/libraries/rib-workflow-test/src/main/kotlin/com/uber/rib/workflow/core/StepTester.kt @@ -31,11 +31,9 @@ public object StepTester { * @return a [Observable] that runs the steps action. */ @JvmStatic - public fun exposeObservable( + public fun exposeObservable( step: Step, - ): Observable>> { - return step.asObservable() - } + ): Observable>> = step.asObservable() /** * Exposes the [com.uber.rib.workflow.core.Step.Data] of a [Step] @@ -46,9 +44,8 @@ public object StepTester { * @return the data of the step */ @JvmStatic - public fun exposeStepData(step: Step.Data): T? { - return step.getValue() - } + public fun exposeStepData(step: Step.Data): T? = + step.getValue() /** * Asserts that no [Step] has been emitted from the [TestObserver] @@ -58,7 +55,7 @@ public object StepTester { * @param type of next actionable item for a step. */ @JvmStatic - public fun assertStepNotYetEmitted( + public fun assertStepNotYetEmitted( testSubscriber: TestObserver>>, ) { testSubscriber.run { @@ -76,7 +73,7 @@ public object StepTester { * @param type of next actionable item for a step. */ @JvmStatic - public fun assertStepEmitted( + public fun assertStepEmitted( testSubscriber: TestObserver>>, ) { testSubscriber.assertValueCount(1) diff --git a/android/libraries/rib-workflow/src/main/kotlin/com/uber/rib/workflow/core/ActionableItem.kt b/android/libraries/rib-workflow/src/main/kotlin/com/uber/rib/workflow/core/ActionableItem.kt index f7c2634d4..615528660 100644 --- a/android/libraries/rib-workflow/src/main/kotlin/com/uber/rib/workflow/core/ActionableItem.kt +++ b/android/libraries/rib-workflow/src/main/kotlin/com/uber/rib/workflow/core/ActionableItem.kt @@ -19,10 +19,10 @@ import com.uber.rib.core.lifecycle.InteractorEvent import io.reactivex.Observable /** Represents an item that [Step] operations can be performed on. */ -fun interface ActionableItem { +public fun interface ActionableItem { /** * @return a lifecycle observable that can be observed so a workflow knows when to start a step * for this actionable item. */ - fun lifecycle(): Observable + public fun lifecycle(): Observable } diff --git a/android/libraries/rib-workflow/src/main/kotlin/com/uber/rib/workflow/core/Step.kt b/android/libraries/rib-workflow/src/main/kotlin/com/uber/rib/workflow/core/Step.kt index e3a460969..cf2c570df 100644 --- a/android/libraries/rib-workflow/src/main/kotlin/com/uber/rib/workflow/core/Step.kt +++ b/android/libraries/rib-workflow/src/main/kotlin/com/uber/rib/workflow/core/Step.kt @@ -29,10 +29,8 @@ import io.reactivex.functions.BiFunction * @param type of return value (if any) for this step. * @param type of [ActionableItem] this step returns when finished. */ -open class Step -private constructor( - private val stepDataSingle: Single>>, -) { +public open class Step +private constructor(private val stepDataSingle: Single>>) { /** * Chains another step to be performed after this step completes. If the previous step results in @@ -47,10 +45,10 @@ private constructor( */ @OptIn(WorkflowFriendModuleApi::class) @SuppressWarnings("RxJavaToSingle") // Replace singleOrError() with firstOrError() - public open fun onStep( + public open fun onStep( func: BiFunction>, - ): Step { - return Step( + ): Step = + Step( asObservable() .flatMap { data: Optional> -> if (data.isPresent) { @@ -61,12 +59,10 @@ private constructor( } .singleOrError(), ) - } @OptIn(WorkflowFriendModuleApi::class) - internal open fun asResultObservable(): Observable> { - return asObservable().map { data -> Optional.fromNullable(data.orNull()?.getValue()) } - } + internal open fun asResultObservable(): Observable> = + asObservable().map { data -> Optional.fromNullable(data.orNull()?.getValue()) } @WorkflowFriendModuleApi public open fun asObservable(): Observable>> { @@ -94,14 +90,14 @@ private constructor( * @param value for this instance. * @param actionableItem for this instance. */ - public open class Data( + public open class Data( private val value: T, internal val actionableItem: A, ) { - @WorkflowFriendModuleApi public open fun getValue() = value + @WorkflowFriendModuleApi public open fun getValue(): T = value - companion object { + public companion object { /** * Convenience function to create a [Step.Data] instance that does not have a return value * type. @@ -111,21 +107,20 @@ private constructor( * @return a new [Step.Data] instance. */ @JvmStatic - public fun toActionableItem(actionableItem: A): Data { - return Data(NoValueHolder.INSTANCE, actionableItem) - } + public fun toActionableItem(actionableItem: A): Data = + Data(NoValueHolder.INSTANCE, actionableItem) } } /** Used to indicate that a step has no return value. */ - open class NoValue + public open class NoValue /** Initialization On Demand Singleton for [NoValue]. */ private object NoValueHolder { val INSTANCE = NoValue() } - companion object { + public companion object { /** * Create a new step with a single that always returns a value. * @@ -135,9 +130,8 @@ private constructor( * @return a new [Step]. */ @JvmStatic - fun from(stepDataSingle: Single>): Step { - return Step(stepDataSingle.map { Optional.of(it) }) - } + public fun from(stepDataSingle: Single>): Step = + Step(stepDataSingle.map { Optional.of(it) }) /** * Create a new step with a single that can emit an absent result. @@ -151,7 +145,7 @@ private constructor( * @return a new [Step]. */ @JvmStatic - fun fromOptional( + public fun fromOptional( stepDataSingle: Single>>, ): Step = Step(stepDataSingle) } diff --git a/android/libraries/rib-workflow/src/main/kotlin/com/uber/rib/workflow/core/Workflow.kt b/android/libraries/rib-workflow/src/main/kotlin/com/uber/rib/workflow/core/Workflow.kt index 862fdc121..18c0fc8cb 100644 --- a/android/libraries/rib-workflow/src/main/kotlin/com/uber/rib/workflow/core/Workflow.kt +++ b/android/libraries/rib-workflow/src/main/kotlin/com/uber/rib/workflow/core/Workflow.kt @@ -25,7 +25,7 @@ import io.reactivex.Single * @param initial [ActionableItem] type for this workflow. * */ -abstract class Workflow { +public abstract class Workflow { /** * Creates a single to execute a workflow. * @@ -33,9 +33,10 @@ abstract class Workflow { * @return an Rx [Single] that will return the workflow when subscribed to. */ @SuppressWarnings("RxJavaToSingle") // Replace singleOrError() with firstOrError() - open fun createSingle(rootActionableItem: TRootActionableItem): Single> { - return getSteps(rootActionableItem).asResultObservable().singleOrError() - } + public open fun createSingle( + rootActionableItem: TRootActionableItem, + ): Single> = + getSteps(rootActionableItem).asResultObservable().singleOrError() /** * @param rootActionableItem to create steps from. diff --git a/android/tooling/rib-flipper-plugin/src/main/kotlin/com/uber/rib/flipper/RibTreeMessageType.kt b/android/tooling/rib-flipper-plugin/src/main/kotlin/com/uber/rib/flipper/RibTreeMessageType.kt index 2947b2986..79d53f281 100644 --- a/android/tooling/rib-flipper-plugin/src/main/kotlin/com/uber/rib/flipper/RibTreeMessageType.kt +++ b/android/tooling/rib-flipper-plugin/src/main/kotlin/com/uber/rib/flipper/RibTreeMessageType.kt @@ -16,7 +16,7 @@ package com.uber.rib.flipper /** Types of messages used by Rib Flipper Plugin. */ -enum class RibTreeMessageType { +public enum class RibTreeMessageType { SHOW_HIGHLIGHT, HIDE_HIGHLIGHT, } diff --git a/android/tooling/rib-flipper-plugin/src/main/kotlin/com/uber/rib/flipper/RibTreePlugin.kt b/android/tooling/rib-flipper-plugin/src/main/kotlin/com/uber/rib/flipper/RibTreePlugin.kt index db990105c..c55efc059 100644 --- a/android/tooling/rib-flipper-plugin/src/main/kotlin/com/uber/rib/flipper/RibTreePlugin.kt +++ b/android/tooling/rib-flipper-plugin/src/main/kotlin/com/uber/rib/flipper/RibTreePlugin.kt @@ -34,7 +34,7 @@ import java.util.UUID import java.util.WeakHashMap /** Flipper debug tool plugin to help with RIBs developement. */ -class RibTreePlugin : FlipperPlugin { +public class RibTreePlugin : FlipperPlugin { private var connection: FlipperConnection? = null private var disposable: Disposable? = null private val events: ReplaySubject = ReplaySubject.create(EVENTS_CAPACITY) @@ -43,7 +43,7 @@ class RibTreePlugin : FlipperPlugin { HashMap>() private val routersToId: WeakHashMap, String> = WeakHashMap, String>() - companion object { + private companion object { private val TAG: String = RibTreePlugin::class.java.simpleName private const val EVENTS_CAPACITY = 1000 }