Skip to content

Commit

Permalink
Add explicit visibility to Android libraries.
Browse files Browse the repository at this point in the history
  • Loading branch information
psteiger committed Oct 14, 2024
1 parent d2711d8 commit 335574e
Show file tree
Hide file tree
Showing 29 changed files with 160 additions and 194 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ package com.uber.rib.core
import androidx.compose.runtime.Composable
import androidx.compose.runtime.MutableState

open class BasicComposeRouter<I : BasicInteractor<*, *>>(
val presenter: ComposePresenter,
public open class BasicComposeRouter<I : BasicInteractor<*, *>>(
public val presenter: ComposePresenter,
interactor: I,
val slot: MutableState<(@Composable () -> Unit)>,
public val slot: MutableState<(@Composable () -> Unit)>,
) : BasicRouter<I>(interactor) {
override fun willAttach() {
slot.value = presenter.composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,35 @@ 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,
data: Intent?,
) {}

/** @see [Activity.onRequestPermissionsResult] */
fun onRequestPermissionsResult(
public fun onRequestPermissionsResult(
activity: Activity,
@IntRange(from = 0, to = 255) requestCode: Int,
permissions: Array<String>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,5 @@ import android.view.View
*
* @param <I> type of interactor.
*/
abstract class BasicViewRouter<V : View, I : Interactor<*, *>>(
view: V,
interactor: I,
) : ViewRouter<V, I>(view, interactor)
public abstract class BasicViewRouter<V : View, I : Interactor<*, *>>(view: V, interactor: I) :
ViewRouter<V, I>(view, interactor)
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ 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.
*
* @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
Expand All @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ActivityLifecycleEvent>
public fun lifecycle(): Observable<ActivityLifecycleEvent>

/** @return an observable of this activity's lifecycle events. */
fun callbacks(): Observable<ActivityCallbackEvent>
public fun callbacks(): Observable<ActivityCallbackEvent>

/**
* @param <T> The type of [ActivityLifecycleEvent] subclass you want.
* @param clazz The [ActivityLifecycleEvent] subclass you want.
* @return an observable of this activity's lifecycle events.
*/
fun <T : ActivityLifecycleEvent> lifecycle(clazz: Class<T>): Observable<T> {
return lifecycle()
public fun <T : ActivityLifecycleEvent> lifecycle(clazz: Class<T>): Observable<T> =
lifecycle()
.filter { activityEvent -> clazz.isAssignableFrom(activityEvent.javaClass) }
.cast(clazz)
}

/**
* @param <T> The type of [ActivityCallbackEvent] subclass you want.
* @param clazz The [ActivityCallbackEvent] subclass you want.
* @return an observable of this activity's callbacks events.
*/
fun <T : ActivityCallbackEvent> callbacks(clazz: Class<T>): Observable<T> {
return callbacks()
public fun <T : ActivityCallbackEvent> callbacks(clazz: Class<T>): Observable<T> =
callbacks()
.filter { activityEvent -> clazz.isAssignableFrom(activityEvent.javaClass) }
.cast(clazz)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ import android.view.ViewGroup
* @param <RouterT> type of router built by this builder.
* @param <DependencyT> dependency required to create this router.
*/
abstract class ViewBuilder<ViewType : View, RouterT : Router<*>, DependencyT>(
dependency: DependencyT,
public abstract class ViewBuilder<ViewType : View, RouterT : Router<*>, DependencyT>(
dependency: DependencyT
) : Builder<RouterT, DependencyT>(dependency) {
/**
* Utility method to create the view for this router.
*
* @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)
}
Expand All @@ -59,7 +59,5 @@ abstract class ViewBuilder<ViewType : View, RouterT : Router<*>, DependencyT>(
* overridden.
* @return the possibly themed context.
*/
protected open fun onThemeContext(parentContext: Context): Context {
return parentContext
}
protected open fun onThemeContext(parentContext: Context): Context = parentContext
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import android.view.View
*
* @param <V> the view type.
*/
abstract class ViewPresenter<V : View>(
public abstract class ViewPresenter<V : View>(
/** @return the view fronted by the page. */
val view: V,
public val view: V
) : Presenter()
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import android.view.View
* @param <V> type of view owned by the router.
* @param <I> type of interactor owned by the router.
*/
abstract class ViewRouter<V : View, I : Interactor<*, *>> : Router<I> {
public abstract class ViewRouter<V : View, I : Interactor<*, *>> : Router<I> {
/** @return the router's view. */
open val view: V
public val view: V

constructor(
public constructor(
view: V,
interactor: I,
component: InteractorBaseComponent<*>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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]
Expand All @@ -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) {
Expand Down Expand Up @@ -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", "")
}
}
Loading

0 comments on commit 335574e

Please sign in to comment.