okhttp-idling-resource icon indicating copy to clipboard operation
okhttp-idling-resource copied to clipboard

Android X support

Open markchristopherng opened this issue 5 years ago • 13 comments

Hi I ran the following plugin and it reports that this library requires jetifier and doesn't support Android X. Will you be releasing an Android X version soon.

https://github.com/plnice/can-i-drop-jetifier/tree/master/canidropjetifier/src/main/kotlin/com.github.plnice/canidropjetifier

markchristopherng avatar Mar 28 '19 02:03 markchristopherng

Out of curiosity and for prioritization, how many other libraries do you use that do not offer AndroidX versions?

JakeWharton avatar Mar 28 '19 02:03 JakeWharton

Quite a few, firebase and playservices being the main ones which Google will update one day.

Jetifier adds to the build time but I imagine we will be using Jefitier for most of this year!

  • com.jakewharton.espresso:okhttp3-idling-resource:1.0.0
  • com.squareup.rx.idler:rx2-idler:0.9.1
  • com.squareup.leakcanary:leakcanary-android:1.6.1
  • com.google.android.gms:play-services-auth:16.0.1
  • com.google.android.gms:play-services-maps:16.1.0
  • com.google.android.gms:play-services-location:16.0.0
  • com.google.android.gms:play-services-awareness:16.0.0
  • com.google.android.gms:play-services-auth-api-phone:16.0.0
  • com.google.firebase:firebase-messaging:17.4.0
  • com.google.firebase:firebase-ml-vision:19.0.2
  • com.google.firebase:firebase-core:16.0.7
  • me.dm7.barcodescanner:zxing:1.9.8
  • com.github.JakeWharton:ViewPagerIndicator:2.4.1
  • com.github.barteksc:android-pdf-viewer:2.8.2
  • com.google.firebase:firebase-messaging:17.4.0
  • com.google.android.support:wearable:2.4.0
  • com.google.android.gms:play-services-wearable:16.0.1

markchristopherng avatar Mar 28 '19 02:03 markchristopherng

The build time is only paid once per machine, per version though since the output is cached and re-used. There's no actual build-to-build overhead. There's still downsides, though.

JakeWharton avatar Mar 28 '19 02:03 JakeWharton

This is far, far, down my backlog. So if someone wants to take a crack at it, PR welcome.

On Wed, Mar 27, 2019 at 10:50 PM markchristopherng [email protected] wrote:

Quite a few, firebase and playservices being the main ones which Google will update one day.

Jetifier adds to the build time but I imagine we will be using Jefitier for most of this year!

  • com.jakewharton.espresso:okhttp3-idling-resource:1.0.0
  • com.squareup.rx.idler:rx2-idler:0.9.1
  • com.squareup.leakcanary:leakcanary-android:1.6.1
  • com.google.android.gms:play-services-auth:16.0.1
  • com.google.android.gms:play-services-maps:16.1.0
  • com.google.android.gms:play-services-location:16.0.0
  • com.google.android.gms:play-services-awareness:16.0.0
  • com.google.android.gms:play-services-auth-api-phone:16.0.0
  • com.google.firebase:firebase-messaging:17.4.0
  • com.google.firebase:firebase-ml-vision:19.0.2
  • com.google.firebase:firebase-core:16.0.7
  • me.dm7.barcodescanner:zxing:1.9.8
  • com.github.JakeWharton:ViewPagerIndicator:2.4.1
  • com.github.barteksc:android-pdf-viewer:2.8.2
  • com.google.firebase:firebase-messaging:17.4.0
  • com.google.android.support:wearable:2.4.0
  • com.google.android.gms:play-services-wearable:16.0.1

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/JakeWharton/okhttp-idling-resource/issues/19#issuecomment-477425263, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEUNwHC3tHNtM8LlRiPntZpDPURyNks5vbC4BgaJpZM4cPKgq .

JakeWharton avatar Apr 08 '19 15:04 JakeWharton

nice, can this be released in a new version? :)

wbervoets avatar Jun 07 '19 07:06 wbervoets

We actually want to avoid using Jetifier because of the following issue: https://stackoverflow.com/questions/57363475/how-can-i-lazily-depend-on-an-aar-that-created-by-a-task

This is one of the last libraries we use that has not been upgraded to AndroidX, so if the PR could be accepted, it would be 👍

ZakTaccardi avatar Aug 05 '19 19:08 ZakTaccardi

One workaround is to use both the support lib and AndroidX in the same module without jetifier.

import com.jakewharton.espresso.OkHttp3IdlingResource
import android.support.test.espresso.IdlingResource as SupportIdlingResource
import android.support.test.espresso.IdlingResource.ResourceCallback as SupportResourceCallback
import androidx.test.espresso.IdlingResource as AndroidXIdlingResource
import androidx.test.espresso.IdlingResource.ResourceCallback as AndroidXResourceCallback

/**
 * Allows [SupportIdlingResource] and [AndroidXIdlingResource] to exist in the same module.
 *
 * This will be needed until [OkHttp3IdlingResource] is migrated to AndroidX.
 * https://github.com/JakeWharton/okhttp-idling-resource/issues/19#issuecomment-518369287
 */
internal fun SupportIdlingResource.asAndroidX(): AndroidXIdlingResource = AndroidXIdlingResource(this)

class AndroidXIdlingResource(private val delegate: SupportIdlingResource) : AndroidXIdlingResource {

    override fun getName(): String = delegate.name

    override fun isIdleNow(): Boolean = delegate.isIdleNow

    override fun registerIdleTransitionCallback(callback: AndroidXResourceCallback) = delegate
        .registerIdleTransitionCallback(callback.asSupport())
}

class SupportResourceCallback(private val delegate: AndroidXResourceCallback) : SupportResourceCallback {
    override fun onTransitionToIdle() = delegate.onTransitionToIdle()

}

internal fun AndroidXResourceCallback.asSupport(): SupportResourceCallback = SupportResourceCallback(this)

Then:

 OkHttp3IdlingResource.create(
                "OkHttp", okHttpClient
            )
                .asAndroidX()

ZakTaccardi avatar Aug 09 '19 15:08 ZakTaccardi

Big effort by @ZakTaccardi Here is java version of @ZakTaccardi 's workaround if anyone interested.

import androidx.test.espresso.IdlingResource;

public class AndroidXIdlingResource implements IdlingResource {

    private android.support.test.espresso.IdlingResource mDelegate;

    private AndroidXIdlingResource(android.support.test.espresso.IdlingResource supportIdlingResource) {
        mDelegate = supportIdlingResource;
    }

    @Override
    public String getName() {
        return mDelegate.getName();
    }

    @Override
    public boolean isIdleNow() {
        return mDelegate.isIdleNow();
    }

    @Override
    public void registerIdleTransitionCallback(ResourceCallback callback) {
        mDelegate.registerIdleTransitionCallback(new SupportResourceCallback(callback));
    }

    public static AndroidXIdlingResource asAndroidX(android.support.test.espresso.IdlingResource supportIdlingResource) {
        return new AndroidXIdlingResource(supportIdlingResource);
    }


    public class SupportResourceCallback implements android.support.test.espresso.IdlingResource.ResourceCallback {

        private ResourceCallback mDelegate;

        SupportResourceCallback(ResourceCallback androidXResourceCallback) {
            mDelegate = androidXResourceCallback;
        }

        @Override
        public void onTransitionToIdle() {
            mDelegate.onTransitionToIdle();
        }
    }
}

Usage:

@Before
public void setup() {
        OkHttpClient client = //
        IdlingResource idlingResource = OkHttp3IdlingResource.create("OkHttp", client);
        Espresso.registerIdlingResources(AndroidXIdlingResource.asAndroidX(idlingResource));
    }

yasiralijaved avatar Sep 25 '19 07:09 yasiralijaved

@JakeWharton Do you have a recommendation on this library and/or a release coming? I feel like it should be "safe" and a good choice to use still right?

neiljaywarner avatar Nov 18 '19 18:11 neiljaywarner

@JakeWharton what about #20 ?

It would be nice to get this thing merged. Even if you don't have time for it: Merging #20 without any testing and without any release seems better than abandoning this library.

fkirc avatar Jan 13 '20 12:01 fkirc

@JakeWharton now that all version above Espresso 3.1.0 is based on AndroidX, could you review your prioritization please ?

AurelienKun avatar Nov 05 '20 15:11 AurelienKun

I have no plans to work on this library. Feel free to fork it.

On Thu, Nov 5, 2020, at 10:23 AM, Auré-Chan wrote:

@JakeWharton https://github.com/JakeWharton now that all version above Espresso 3.1.0 is based on AndroidX, could you review your prioritization please ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/JakeWharton/okhttp-idling-resource/issues/19#issuecomment-722446451, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAQIEPUAX24ULEIOBV4AALSOK7PPANCNFSM4HB4VAVA.

JakeWharton avatar Nov 05 '20 15:11 JakeWharton

@JakeWharton it would be nice to add a "Deprecated" message in the readme. Thanks for your work btw :)

nokite avatar May 01 '24 18:05 nokite