Package zendesk.belvedere
Class Belvedere
- java.lang.Object
-
- zendesk.belvedere.Belvedere
-
public class Belvedere extends java.lang.Object
Media picker manager.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static class
Belvedere.Builder
Builder for creating a customizeBelvedere
instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description MediaIntent.CameraIntentBuilder
camera()
Request an image from a camera app.void
clearStorage()
Clear the internal Belvedere cache.MediaIntent.DocumentIntentBuilder
document()
Request media from an external app.static Belvedere
from(Context context)
Get the globalBelvedere
instance.MediaResult
getFile(java.lang.String dir, java.lang.String fileName)
Returns aFile
andUri
for the given file name.void
getFilesFromActivityOnResult(int requestCode, int resultCode, Intent data, Callback<java.util.List<MediaResult>> callback)
Parse data fromActivity#onActivityResult(int, int, Intent)
.void
getFilesFromActivityOnResult(int requestCode, int resultCode, Intent data, Callback<java.util.List<MediaResult>> callback, boolean resolveFiles)
Parse data fromActivity#onActivityResult(int, int, Intent)
.Intent
getShareIntent(Uri uri, java.lang.String contentType)
Create anIntent
for sharing anUri
.Intent
getViewIntent(Uri uri, java.lang.String contentType)
Create anIntent
for viewing anUri
.void
grantPermissionsForUri(Intent intent, Uri uri)
Grant all Apps that are resolvable through the providedIntent
Intent#FLAG_GRANT_READ_URI_PERMISSION
andIntent#FLAG_GRANT_WRITE_URI_PERMISSION
.void
resolveUris(java.util.List<Uri> uris, java.lang.String directory, Callback<java.util.List<MediaResult>> callback)
Copy the list of providedUri
into the internal cache.void
revokePermissionsForUri(Uri uri)
RevokeIntent#FLAG_GRANT_READ_URI_PERMISSION
andIntent#FLAG_GRANT_WRITE_URI_PERMISSION
that were previously granted byBelvedere.grantPermissionsForUri(Intent, Uri)
.static void
setSingletonInstance(Belvedere belvedere)
Set the globalBelvedere
instance.
-
-
-
Method Detail
-
setSingletonInstance
public static void setSingletonInstance(Belvedere belvedere)
- Parameters:
belvedere
- an instance created throughBelvedere.Builder
-
camera
public MediaIntent.CameraIntentBuilder camera()
Request an image from a camera app.Belvedere.from(context) .camera() .open(activity);
-
document
public MediaIntent.DocumentIntentBuilder document()
Request media from an external app.Belvedere.from(context) .document() ... .open(activity);
-
getViewIntent
public Intent getViewIntent(Uri uri, java.lang.String contentType)
Create anIntent
for viewing anUri
.- Parameters:
uri
-Uri
pointing to a filecontentType
- (optional) the content type of theUri
-
getShareIntent
public Intent getShareIntent(Uri uri, java.lang.String contentType)
Create anIntent
for sharing anUri
.- Parameters:
uri
-Uri
pointing to a filecontentType
- (optional) the content type of theUri
-
getFilesFromActivityOnResult
public void getFilesFromActivityOnResult(int requestCode, int resultCode, Intent data, Callback<java.util.List<MediaResult>> callback)
Parse data fromActivity#onActivityResult(int, int, Intent)
.It's important that the same instance of Belvedere is used, which was used to start the dialog or create the
MediaIntent
.- Parameters:
requestCode
- The requestCode provided byActivity#onActivityResult(int, int, Intent)
resultCode
- The resultCode provided byActivity#onActivityResult(int, int, Intent)
data
- TheIntent
provided byActivity#onActivityResult(int, int, Intent)
callback
-Callback
that will deliver a list ofMediaResult
-
getFilesFromActivityOnResult
public void getFilesFromActivityOnResult(int requestCode, int resultCode, Intent data, Callback<java.util.List<MediaResult>> callback, boolean resolveFiles)
Parse data fromActivity#onActivityResult(int, int, Intent)
.- Parameters:
requestCode
- The requestCode provided byActivity#onActivityResult(int, int, Intent)
resultCode
- The resultCode provided byActivity#onActivityResult(int, int, Intent)
data
- TheIntent
provided byActivity#onActivityResult(int, int, Intent)
callback
-Callback
that will deliver a list ofMediaResult
resolveFiles
- Set totrue
if belvedere should resolve selected files
-
getFile
public MediaResult getFile(java.lang.String dir, java.lang.String fileName)
Returns aFile
andUri
for the given file name. The returned file is located in Belvedere's internal cache and can be accessed throughBelvedereFileProvider
.Belvedere doesn't keep track of your files, you have to manage them.
- Parameters:
dir
- Directory name of the file ornull
if not needed.fileName
- The file name- Returns:
- A
MediaResult
-
resolveUris
public void resolveUris(java.util.List<Uri> uris, java.lang.String directory, Callback<java.util.List<MediaResult>> callback)
Copy the list of providedUri
into the internal cache.- Parameters:
uris
- The list ofUri
to resolvedirectory
- Name of directory for storing themcallback
-Callback
that will deliver a list ofMediaResult
-
grantPermissionsForUri
public void grantPermissionsForUri(Intent intent, Uri uri)
Grant all Apps that are resolvable through the providedIntent
Intent#FLAG_GRANT_READ_URI_PERMISSION
andIntent#FLAG_GRANT_WRITE_URI_PERMISSION
.- Parameters:
intent
- AnIntent
uri
- AnUri
-
revokePermissionsForUri
public void revokePermissionsForUri(Uri uri)
RevokeIntent#FLAG_GRANT_READ_URI_PERMISSION
andIntent#FLAG_GRANT_WRITE_URI_PERMISSION
that were previously granted byBelvedere.grantPermissionsForUri(Intent, Uri)
.- Parameters:
uri
- AnUri
-
clearStorage
public void clearStorage()
Clear the internal Belvedere cache.
-
-