Skip to content
Permalink
Browse files

Remove deprecated ProviderContract.Artwork methods

Developers should use ProviderContract.getContentUri() and ProviderContract.getProviderClient() and its methods.
  • Loading branch information...
ianhanniballake committed Sep 8, 2019
1 parent 5bd9056 commit d04724389e6d5f7cc7d3de8b11bd72cd9f20ef0f
@@ -292,194 +292,5 @@ public Uri setArtwork(@NonNull final com.google.android.apps.muzei.api.provider.
* <P>Type: INTEGER (long)</P>
*/
public static final String DATE_MODIFIED = "date_modified";

/**
* Retrieve the content URI for the given {@link MuzeiArtProvider}, allowing you to build
* custom queries, inserts, updates, and deletes using a {@link ContentResolver}.
* <p>
* This will throw an {@link IllegalArgumentException} if the provider is not valid or the
* provider is disabled.
*
* @param context Context used to retrieve the content URI.
* @param provider The {@link MuzeiArtProvider} you need a content URI for
* @return The content URI for the {@link MuzeiArtProvider}
* @see MuzeiArtProvider#getContentUri()
* @deprecated Use {@link #getProviderClient(Context, Class)} and
* {@link ProviderClient#getContentUri()}.
*/
@Deprecated
@NonNull
public static Uri getContentUri(
@NonNull Context context,
@NonNull Class<? extends MuzeiArtProvider> provider
) {
ComponentName componentName = new ComponentName(context, provider);
PackageManager pm = context.getPackageManager();
String authority;
try {
@SuppressLint("InlinedApi")
ProviderInfo info = pm.getProviderInfo(componentName, 0);
authority = info.authority;
} catch (PackageManager.NameNotFoundException e) {
throw new IllegalArgumentException("Invalid MuzeiArtProvider: " + componentName
+ ", is your provider disabled?", e);
}
return ProviderContract.getContentUri(authority);
}

/**
* Retrieve the content URI for the given {@link MuzeiArtProvider}, allowing you to build
* custom queries, inserts, updates, and deletes using a {@link ContentResolver}.
* <p>
* This <strong>does not</strong> check for the validity of the MuzeiArtProvider. You can
* use {@link PackageManager#resolveContentProvider(String, int)} passing in the
* authority if you need to confirm the authority is valid.
*
* @param authority The {@link MuzeiArtProvider} you need a content URI for
* @return The content URI for the {@link MuzeiArtProvider}
* @see MuzeiArtProvider#getContentUri()
* @deprecated Use {@link ProviderContract#getContentUri(String)}.
*/
@Deprecated
@NonNull
public static Uri getContentUri(@NonNull String authority) {
return ProviderContract.getContentUri(authority);
}

/**
* Retrieve the last added artwork for the given {@link MuzeiArtProvider}.
*
* @param context Context used to retrieve the artwork
* @param provider The {@link MuzeiArtProvider} to query
* @return The last added Artwork, or null if no artwork has been added
* @see MuzeiArtProvider#getLastAddedArtwork()
* @deprecated Use {@link #getProviderClient(Context, Class)} and
* {@link ProviderClient#getLastAddedArtwork()}.
*/
@Deprecated
@RequiresApi(Build.VERSION_CODES.KITKAT)
@Nullable
public static com.google.android.apps.muzei.api.provider.Artwork getLastAddedArtwork(
@NonNull Context context,
@NonNull Class<? extends MuzeiArtProvider> provider
) {
return getProviderClient(context, provider).getLastAddedArtwork();
}

/**
* Retrieve the last added artwork for the given {@link MuzeiArtProvider}.
*
* @param context Context used to retrieve the artwork
* @param authority The {@link MuzeiArtProvider} to query
* @return The last added Artwork, or null if no artwork has been added
* @see MuzeiArtProvider#getLastAddedArtwork()
* @deprecated Use {@link #getProviderClient(Context, String)} and
* {@link ProviderClient#getLastAddedArtwork()}.
*/
@Deprecated
@RequiresApi(Build.VERSION_CODES.KITKAT)
@Nullable
public static com.google.android.apps.muzei.api.provider.Artwork getLastAddedArtwork(
@NonNull Context context,
@NonNull String authority
) {
return getProviderClient(context, authority).getLastAddedArtwork();
}

/**
* Add a new piece of artwork to the given {@link MuzeiArtProvider}.
*
* @param context Context used to add the artwork
* @param provider The {@link MuzeiArtProvider} to update
* @param artwork The artwork to add
* @return The URI of the newly added artwork or null if the insert failed
* @see MuzeiArtProvider#addArtwork(com.google.android.apps.muzei.api.provider.Artwork)
* @deprecated Use {@link #getProviderClient(Context, Class)} and
* {@link ProviderClient#addArtwork(com.google.android.apps.muzei.api.provider.Artwork)}.
*/
@Deprecated
@RequiresApi(Build.VERSION_CODES.KITKAT)
@Nullable
public static Uri addArtwork(
@NonNull Context context,
@NonNull Class<? extends MuzeiArtProvider> provider,
@NonNull com.google.android.apps.muzei.api.provider.Artwork artwork
) {
return getProviderClient(context, provider).addArtwork(artwork);
}

/**
* Add a new piece of artwork to the given {@link MuzeiArtProvider}.
*
* @param context Context used to add the artwork
* @param authority The {@link MuzeiArtProvider} to update
* @param artwork The artwork to add
* @return The URI of the newly added artwork or null if the insert failed
* @see MuzeiArtProvider#addArtwork(com.google.android.apps.muzei.api.provider.Artwork)
* @deprecated Use {@link #getProviderClient(Context, String)} and
* {@link ProviderClient#addArtwork(com.google.android.apps.muzei.api.provider.Artwork)}.
*/
@Deprecated
@RequiresApi(Build.VERSION_CODES.KITKAT)
@Nullable
public static Uri addArtwork(
@NonNull Context context,
@NonNull String authority,
@NonNull com.google.android.apps.muzei.api.provider.Artwork artwork
) {
return getProviderClient(context, authority).addArtwork(artwork);
}

/**
* Set the given {@link MuzeiArtProvider} to only show the given artwork, deleting any
* other artwork previously added.
* <p>
* Only in the cases where the artwork is successfully inserted will the other artwork be
* removed.
*
* @param context Context used to set the artwork
* @param provider The {@link MuzeiArtProvider} to update
* @param artwork The artwork to set
* @return The URI of the newly set artwork or null if the insert failed
* @see MuzeiArtProvider#setArtwork(com.google.android.apps.muzei.api.provider.Artwork)
* @deprecated Use {@link #getProviderClient(Context, Class)} and
* {@link ProviderClient#setArtwork(com.google.android.apps.muzei.api.provider.Artwork)}.
*/
@Deprecated
@RequiresApi(Build.VERSION_CODES.KITKAT)
@Nullable
public static Uri setArtwork(
@NonNull Context context,
@NonNull Class<? extends MuzeiArtProvider> provider,
@NonNull com.google.android.apps.muzei.api.provider.Artwork artwork
) {
return getProviderClient(context, provider).setArtwork(artwork);
}

/**
* Set the given {@link MuzeiArtProvider} to only show the given artwork, deleting any
* other artwork previously added.
* <p>
* Only in the cases where the artwork is successfully inserted will the other artwork be
* removed.
*
* @param context Context used to set the artwork
* @param authority The {@link MuzeiArtProvider} to update
* @param artwork The artwork to set
* @return The URI of the newly set artwork or null if the insert failed
* @see MuzeiArtProvider#setArtwork(com.google.android.apps.muzei.api.provider.Artwork)
* @deprecated Use {@link #getProviderClient(Context, String)} and
* {@link ProviderClient#setArtwork(com.google.android.apps.muzei.api.provider.Artwork)}.
*/
@Deprecated
@RequiresApi(Build.VERSION_CODES.KITKAT)
@Nullable
public static Uri setArtwork(
@NonNull Context context,
@NonNull String authority,
@NonNull com.google.android.apps.muzei.api.provider.Artwork artwork
) {
return getProviderClient(context, authority).setArtwork(artwork);
}
}
}

0 comments on commit d047243

Please sign in to comment.
You can’t perform that action at this time.