React-native-navigation: Less wildcards imports for Easier Androidx support

Created on 7 Mar 2019  路  7Comments  路  Source: wix/react-native-navigation

Issue Description

First off a big thanks for all the blood, sweat and tears.

I am using androidx in my project and I rewrite all the imports to the new androidx imports on postinstall. Which is fine and works as a temporary solution. However packages arent one-to-one as you can see from this example below.

Old | New
-- | --
android.support.v4.content.AsyncTaskLoader | androidx.loader.content.AsyncTaskLoader
android.support.v4.content.ContentResolverCompat | androidx.core.content.ContentResolverCompat
android.support.v4.content.ContextCompat | androidx.core.content.ContextCompat
android.support.v4.content.CursorLoader | androidx.loader.content.CursorLoader
android.support.v4.content.FileProvider | androidx.core.content.FileProvider
android.support.v4.content.IntentCompat | androidx.core.content.IntentCompat
android.support.v4.content.Loader | androidx.loader.content.Loader
android.support.v4.content.LocalBroadcastManager | androidx.localbroadcastmanager.content.LocalBroadcastManager
android.support.v4.content.MimeTypeFilter | androidx.core.content.MimeTypeFilter
android.support.v4.content.ModernAsyncTask | androidx.loader.content.ModernAsyncTask
android.support.v4.content.PermissionChecker | androidx.core.content.PermissionChecker
android.support.v4.content.pm.ActivityInfoCompat | androidx.core.content.pm.ActivityInfoCompat
android.support.v4.content.pm.PackageInfoCompat | androidx.core.content.pm.PackageInfoCompat
android.support.v4.content.pm.PermissionInfoCompat | androidx.core.content.pm.PermissionInfoCompat
android.support.v4.content.pm.ShortcutInfoCompat | androidx.core.content.pm.ShortcutInfoCompat
android.support.v4.content.pm.ShortcutManagerCompat | androidx.core.content.pm.ShortcutManagerCompat
android.support.v4.content.res.ColorStateListInflaterCompat | androidx.core.content.res.ColorStateListInflaterCompat
android.support.v4.content.res.ComplexColorCompat | androidx.core.content.res.ComplexColorCompat
android.support.v4.content.res.ConfigurationHelper | androidx.core.content.res.ConfigurationHelper
android.support.v4.content.res.FontResourcesParserCompat | androidx.core.content.res.FontResourcesParserCompat
android.support.v4.content.res.GradientColorInflaterCompat | androidx.core.content.res.GradientColorInflaterCompat
android.support.v4.content.res.GrowingArrayUtils | androidx.core.content.res.GrowingArrayUtils
android.support.v4.content.res.ResourcesCompat | androidx.core.content.res.ResourcesCompat
android.support.v4.content.res.TypedArrayUtils | androidx.core.content.res.TypedArrayUtils
android.support.v4.content.SharedPreferencesCompat | androidx.core.content.SharedPreferencesCompat
android.support.v4.content.WakefulBroadcastReceiver | androidx.legacy.content.WakefulBroadcastReceiver

source: https://developer.android.com/jetpack/androidx/migrate

I was hoping to suggest removing wildcard imports for two reasons. 1 being more explicit is generally better. 2 it will help people like me support androidx until it comes baked in.

Currently there is only 1 file which is the culprit BottomTabPresenter.java

https://github.com/wix/react-native-navigation/blob/master/lib/android/app/src/main/java/com/reactnativenavigation/presentation/BottomTabPresenter.java

Each one of the below imports only using a single item from the import

Current

import android.content.*;
import android.graphics.drawable.*;
import android.support.annotation.*;
import android.support.v4.content.*;

Proposed

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;

After Androidx rewriting

import android.content.Context;
import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;

I know this is an unsual request, but i think its good practise as well as personally handy for me

Thanks guys, and keep up the good work

Environment

  • React Native Navigation version: 2.13.1
  • React Native version: 0.58.6
  • Platform(s) (iOS, Android, or both?):Android
  • Device info (Simulator/Device? OS version? Debug/Release?): Both
Android accepteenhancement

Most helpful comment

@guyca PR submitted :)

All 7 comments

Actually I am having similar issues with SideMenu.java

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.

This is a quick one, probably just needs a simple "Yes" or "No"

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.

The issue has been closed for inactivity.

Hey @brenwell
Very sorry, completely missed you're issue - I'm all in favor of this one. Feel free to submit a PR

@guyca PR submitted :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zhanguangao picture zhanguangao  路  3Comments

yayanartha picture yayanartha  路  3Comments

yedidyak picture yedidyak  路  3Comments

switchtrue picture switchtrue  路  3Comments

birkir picture birkir  路  3Comments