java.lang.Object | |
↳ | com.pdftron.pdf.utils.Utils |
A general utility class
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
double | INTERSECTION_EPSILON | ||||||||||
int | MAX_NUM_DUPLICATED_FILES | ||||||||||
int | URI_TYPE_DOCUMENT | The URI is a document. | |||||||||
int | URI_TYPE_FILE | The URI is a file. | |||||||||
int | URI_TYPE_TREE | The URI is a file tree. | |||||||||
int | URI_TYPE_UNKNOWN | The URI is unknown. | |||||||||
double | vertex_dist_epsilon |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
public static boolean | CHECK_ALL_FILES_ACCESS_PERMISSION | ||||||||||
public static boolean | FORCE_PRE_ANDROID_Q | ||||||||||
public static boolean | sShowAlertDialog | ||||||||||
public static boolean | sTEST_MODE |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Utils() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
static Bitmap |
adjustAlpha(Bitmap bitmap, int alpha)
Adjusts alpha channel of a bitmap
| ||||||||||
static int |
adjustAlphaColor(int color, float factor)
Adjusts alpha color.
| ||||||||||
static double | angleBetweenTwoPointsWithPivot(double point1X, double point1Y, double point2X, double point2Y, double pivotX, double pivotY) | ||||||||||
static boolean |
applyDayNight(Context context, AppCompatDelegate delegate)
Apply day night mode.
| ||||||||||
static boolean |
applyDayNight(AppCompatActivity activity)
Apply day night mode.
| ||||||||||
static void | applyPrimaryTextTintToButton(ImageView imageView) | ||||||||||
static void | applySecondaryTextTintToButton(ImageView imageView) | ||||||||||
static ExternalFileInfo |
buildExternalFile(Context context, Uri uri)
Returns an external file info from the specified URI
| ||||||||||
static RectF |
buildPageBoundBoxOnClient(PDFViewCtrl pdfViewCtrl, int pageNum)
Computes the page bounding box of PDFView in the client space.
| ||||||||||
static boolean |
cacheFileExists(Context context, String cacheFileName)
Checks whether the cache file exists.
| ||||||||||
static double | calcDistance(double x1, double y1, double x2, double y2) | ||||||||||
static Point | calcIntersection(double ax, double ay, double bx, double by, double cx, double cy, double dx, double dy) | ||||||||||
static double | calcLinePointDistance(double x1, double y1, double x2, double y2, double x, double y) | ||||||||||
static String |
capitalize(String s)
Capitalizes the first letter of the given string.
| ||||||||||
static void |
closeDocQuietly(PDFViewCtrl pdfViewCtrl)
Calls
closeDoc() quietly | ||||||||||
static void |
closeQuietly(SecondaryFileFilter filter)
Closes the file filter proper quietly
| ||||||||||
static void | closeQuietly(AutoCloseable c) | ||||||||||
static void |
closeQuietly(ParcelFileDescriptor pfd)
Closes the parcel descriptor quietly
| ||||||||||
static void |
closeQuietly(PDFDoc doc, SecondaryFileFilter filter)
Closes the PDFDoc and file filter proper quietly
| ||||||||||
static void |
closeQuietly(Closeable c)
Closes the closeable quietly
| ||||||||||
static void |
closeQuietly(PDFDoc doc)
Closes the PDF doc quietly
| ||||||||||
static void |
closeQuietly(FDFDoc doc)
Closes the FDF doc quietly
| ||||||||||
static ColorPt |
color2ColorPt(int color)
Converts an integer color to a color point
| ||||||||||
static int |
colorPt2color(ColorPt colorPt)
Converts a color point to an integer color
| ||||||||||
static float |
convDp2Pix(Context context, float dp)
Converts density independent pixels to physical pixels.
| ||||||||||
static Bitmap |
convDrawableToBitmap(Drawable drawable)
Converts a drawable to a bitmap
| ||||||||||
static File |
convExternalContentUriToFile(Context activity, Uri beamUri)
Converts external content URI to a file
| ||||||||||
static LinkedHashMap<String, String> | convJSONToMap(String jsonString) | ||||||||||
static JSONObject | convMapToJSON(LinkedHashMap<String, String> item) | ||||||||||
static float |
convPix2Dp(Context context, float pix)
Converts physical pixels to density independent pixels.
| ||||||||||
static Rect |
convertFromPageRectToScreenRect(PDFViewCtrl pdfViewCtrl, Rect rect, int pageNum)
Converts a rect in page space to screen space
| ||||||||||
static Rect |
convertFromPageRectToScrollViewerRect(PDFViewCtrl pdfViewCtrl, Rect rect, int pageNum)
Converts a rect in page space to scroll view space
| ||||||||||
static void | copy(File src, File dst) | ||||||||||
static File |
copyAssetsToTempFolder(Context context, String path, String folderName, boolean force)
Copies an assets file to cache path
| ||||||||||
static File |
copyAssetsToTempFolder(Context context, String path, boolean force)
Copies an assets file to cache path
| ||||||||||
static long |
copyLarge(RandomAccessFile inputFile, OutputStream output, byte[] buffer)
Copies a large file.
| ||||||||||
static long |
copyLarge(RandomAccessFile inputFile, OutputStream output)
Copies a large file.
| ||||||||||
static File |
copyResourceToLocal(Context context, int resId, String name, String ext)
Copies the specified resource file into the temp folder with provided name.
| ||||||||||
static String |
copyResourceToTempFolder(Context context, int resId, boolean force, String resourceName)
Copies the specified resource file into the temp folder.
| ||||||||||
static String | correctCommaBasedDecimal(EditText editText, String input) | ||||||||||
static Intent |
createGenericShareIntent(Activity activity, Uri uri)
Returns a generic share intent for the specified URI
| ||||||||||
static Intent |
createGenericShareIntents(Activity activity, ArrayList<Uri> uris)
Returns a generic share intent for the specified URIs
| ||||||||||
static StateListDrawable |
createImageDrawableSelector(Context context, int resourceId, int color, int disableOpacity)
Creates a state image drawable (enable/disable) from a resource id with specified color and
the transparency factor when disabled.
| ||||||||||
static StateListDrawable |
createImageDrawableSelector(Context context, int resourceId, int color)
Creates a state image drawable (enable/disable) from a resource id with specified color and
the transparency factor when disabled.
| ||||||||||
static Intent |
createShareIntent(Activity activity, File file)
Returns a generic share intent for the specified file
| ||||||||||
static Intent |
createShareIntentForFile(Context context, String filePath, String mimeType)
Creates a generic share intent based on given file and mimetype
| ||||||||||
static Intent |
createShareIntents(Activity activity, ArrayList<FileInfo> files)
Returns a generic share intent for the specified files
| ||||||||||
static Intent | createSystemPickerIntent(String[] fileMimeTypes) | ||||||||||
static Intent | createSystemPickerIntent(String[] fileMimeTypes, boolean multiSelect) | ||||||||||
static Intent | createSystemPickerIntent() | ||||||||||
static Intent | createSystemPickerIntentAllSource(String[] fileMimeTypes, boolean multiSelect) | ||||||||||
static String | createThumb(Context context, PDFDoc doc, int minSize) | ||||||||||
static void |
deleteCacheFile(Context context, String cacheFileName)
Deletes the cache file.
| ||||||||||
static boolean | docLockRead(boolean tryLock, PDFViewCtrl pdfViewCtrl) | ||||||||||
static
|
duplicateInDownload(Context context, ContentResolver cr, Uri uri, String title)
Returns an Single for a duplicating file in the "Downloads" folder.
| ||||||||||
static
|
duplicateInFolder(ContentResolver cr, Uri uri, String title, File outputFolder)
Returns an Single for a duplicating file in the specified folder.
| ||||||||||
static int | findMinIndex(double[] numbers) | ||||||||||
static int |
getAccentColor(Context context)
Returns the accent color defined in android attribute.
| ||||||||||
static AlertDialog.Builder |
getAlertDialogBuilder(Context context, int messageId, int titleId)
Creates an alert dialog builder.
| ||||||||||
static AlertDialog.Builder |
getAlertDialogBuilder(Context context, String message, String title)
Creates an alert dialog builder.
| ||||||||||
static AlertDialog.Builder |
getAlertDialogNoTitleBuilder(Context context, int messageId)
Creates an alert dialog builder.
| ||||||||||
static String[] | getAllGoogleDocsSupportedTypes() | ||||||||||
static Rect | getBBox(ArrayList<Point> pagePoints) | ||||||||||
static int |
getBackgroundColor(Context context)
Returns the background color defined in android attribute.
| ||||||||||
static String |
getBidiString(String str)
Converts the specified string to Bidi.
| ||||||||||
static Bitmap | getBitmapByVecDrawable(VectorDrawable vectorDrawable) | ||||||||||
static Bitmap |
getBitmapFromImageUri(Context context, Uri imageUri, String backupFilepath)
Returns real path from the specified image URI.
| ||||||||||
static String |
getByteCount(long bytes)
Returns the number of bytes in string format
| ||||||||||
static Rect | getCachedBBox(JSONObject obj) | ||||||||||
static String | getCachedContents(JSONObject obj) | ||||||||||
static String |
getColorHexString(int color)
Gets color value in hex format (#0xFFFFFF)
| ||||||||||
static ContentResolver |
getContentResolver(Context context)
A helper to get Context.getContentResolver().
| ||||||||||
static String |
getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs)
Gets the value of the data column for this Uri.
| ||||||||||
static String | getDateTimeFormatFromField(String fieldValue, boolean isDate) | ||||||||||
static String | getDeviceName() | ||||||||||
static String |
getDisplayNameFromImageUri(Context context, Uri imageUri, String backupFilepath)
Returns the display name from the image URI
| ||||||||||
static void |
getDisplaySize(Context context, Point outSize)
Gets the size of the display, in pixels.
| ||||||||||
static Drawable |
getDrawable(Context context, int drawableRes)
Helper to get a drawable from drawable resource.
| ||||||||||
static Drawable | getDrawableWithTint(Context context, int drawableId, int tintColor) | ||||||||||
static String |
getExtension(String filename)
Returns file extension in lower case, or empty string if input is null
| ||||||||||
static File | getExternalDownloadDirectory(Context context) | ||||||||||
static File |
getExternalFilesDir(Context context, String type)
A helper to get Context.getExternalFilesDir(String).
| ||||||||||
static File[] |
getExternalFilesDirs(Context context, String type)
A helper to get Context.getExternalFilesDirs(String).
| ||||||||||
static String |
getFileNameNotInUse(ExternalFileInfo folder, String original)
Returns a file path in the specified path that is not used.
| ||||||||||
static String |
getFileNameNotInUse(String original)
Returns a file path in the specified path that is not used.
| ||||||||||
static ArrayList<String> | getFileNamesFromPortfolio(Context context, Uri fileUri, String password) | ||||||||||
static ArrayList<String> |
getFileNamesFromPortfolio(File file, String password)
Given a portfolio PDF document (ie, with embedded files), returns a list
of the embedded files.
| ||||||||||
static ArrayList<String> | getFileNamesFromPortfolio(PDFDoc doc) | ||||||||||
static Bookmark |
getFirstBookmark(PDFDoc pdfDoc)
Returns the first bookmark in a certain document.
| ||||||||||
static String |
getFontFileName(String fontFilePath)
Gets font file name
| ||||||||||
static int |
getForegroundColor(Context context)
Returns the foreground color defined in android attribute.
| ||||||||||
static long |
getFreeDiskStorage()
Gets the free disk storage size
| ||||||||||
static int[] |
getImageFileDimensions(File file, int maxDimension)
getImageFileDimensions
Helper method to extract width and height of an image File
Optionally provide maxDimension to have it scale down to that lenght of it's longest dimension
(either width or height), and then maintain it's aspect ratio
e.g.
| ||||||||||
static int[] | getImageFileDimensions(File file) | ||||||||||
static String |
getLocaleDigits(String input)
Returns digits based on the Locale.
| ||||||||||
static String | getLocaleLanguageCode() | ||||||||||
static Rect | getPageRect(PDFViewCtrl pdfViewCtrl, int pageNum) | ||||||||||
static String |
getPassword(Context context, String filepath)
Returns password if it is saved in
PdfViewCtrlTabsManager . | ||||||||||
static int |
getPostProcessedColor(PDFViewCtrl pdfViewCtrl, int color)
convert color to post processed color in pdf
| ||||||||||
static int |
getPrimaryColor(Context context)
Returns the primary color defined in android attribute.
| ||||||||||
static int |
getPrimaryDarkColor(Context context)
Returns the primary dark color defined in android attribute.
| ||||||||||
static int |
getPrimaryTextColor(Context context)
Returns the primary text color defined in android attribute.
| ||||||||||
static String | getReadableByteUnit(long bytes, boolean si) | ||||||||||
static Long | getReadableByteValue(long bytes, boolean si) | ||||||||||
static String |
getRealPathFromImageURI(Context context, Uri imageUri)
Returns real path from the specified image URI.
| ||||||||||
static String |
getRealPathFromURI(Context context, Uri uri)
Gets a file path from a Uri.
| ||||||||||
static int |
getRealScreenHeight(Context context)
Returns the real screen height without subtracting any window decor or
applying any compatibility scale factors.
| ||||||||||
static int |
getRealScreenWidth(Context context)
Returns the real screen width without subtracting any window decor or
applying any compatibility scale factors.
| ||||||||||
static int |
getResourceColor(Context context, String name)
A helper to get color identifier.
| ||||||||||
static int |
getResourceDrawable(Context context, String name)
A helper to get drawable identifier.
| ||||||||||
static int |
getResourceRaw(Context context, String name)
A helper to get raw identifier.
| ||||||||||
static Resources |
getResources(Context context)
A helper to get Context.getResources().
| ||||||||||
static int |
getScreenHeight(Context context)
Returns the screen height.
| ||||||||||
static Rect | getScreenRectInPageSpace(PDFViewCtrl pdfViewCtrl, int pageNum) | ||||||||||
static int |
getScreenWidth(Context context)
Returns the screen width.
| ||||||||||
static String | getScreenshotFileName() | ||||||||||
static int |
getSecondaryTextColor(Context context)
Returns the secondary text color defined in android attribute.
| ||||||||||
static String | getTempFile(Context context, String ext) | ||||||||||
static int | getThemeAttrColor(Context context, int attr) | ||||||||||
static String |
getUriDisplayName(Context context, Uri contentUri)
Returns the display name of the specified URI
| ||||||||||
static String |
getUriDisplayName(ContentResolver contentResolver, Uri contentUri)
Returns the display name of the specified URI
| ||||||||||
static String |
getUriDocumentPath(Uri uri)
Returns the URI document path.
| ||||||||||
static String |
getUriExtension(ContentResolver contentResolver, Uri uri)
Returns the file extension of the specified URI
| ||||||||||
static
|
getUriExtensionAsync(ContentResolver contentResolver, Uri uri) | ||||||||||
static long |
getUriFileSize(ContentResolver contentResolver, Uri uri)
Returns the file size of the specified URI
| ||||||||||
static Uri |
getUriForFile(Context context, File file)
Return the URI for the specified file
| ||||||||||
static String |
getUriTreePath(Uri uri)
Returns the URI tree path.
| ||||||||||
static int |
getUriType(Uri uri)
Returns the URI type
| ||||||||||
static String |
getValidFilename(String filename)
Return a valid file name from the specified file name.
| ||||||||||
static String |
getValidTitle(Context context, Uri fileUri)
Return a valid title from the specified URI
| ||||||||||
static PointF[] | getVerticesFromPoly(PDFViewCtrl pdfViewCtrl, Polygon polygon, int pageNum) | ||||||||||
static void |
handleEmptyPopup(PDFDoc pdfDoc, Markup markup)
Handles an empty popup
| ||||||||||
static void |
handlePdfFromImageFailed(Context context, Map imageIntent)
Handles when trying to create PDF from an image fails.
| ||||||||||
static boolean | hasEnoughStorageToSave(long fileSize) | ||||||||||
static boolean | hasFileAttachments(PDFDoc doc) | ||||||||||
static boolean | hasFileAttachments(PDFViewCtrl pdfViewCtrl) | ||||||||||
static boolean | hasInternetConnection(Context context) | ||||||||||
static boolean | hasPostNotificationsPermission(Context context) | ||||||||||
static boolean | hasRecordAudioPermission(Context context) | ||||||||||
static boolean |
hasRightToLeftChar(String str)
Checks whether the specified string has any right-to-left characters.
| ||||||||||
static boolean |
hasStoragePermission(Context context)
This method is deprecated.
please follow the latest Android permission guideline instead
| ||||||||||
static void |
hideSoftKeyboard(Context context, View view)
Hides soft keyboard.
| ||||||||||
static String |
humanReadableByteCount(long bytes, boolean si)
Gets a human readable format of a byte size.
| ||||||||||
static boolean |
isAndroidQ()
Checks if this device is running Android Q or higher.
| ||||||||||
static boolean |
isAndroidR()
Checks if this device is running Android R or higher.
| ||||||||||
static boolean |
isAndroidS()
Checks if this device is running Android S or higher.
| ||||||||||
static boolean |
isAndroidT()
Checks if this device is running Android T or higher.
| ||||||||||
static boolean |
isAnnotationHandlerToolMode(ToolManager.ToolMode toolMode)
Gets whether a tool mode is one of the handler tool modes.
| ||||||||||
static boolean |
isAppInstalledOnDevice(Context context, String uri)
Checks whether the specified app is installed on the device.
| ||||||||||
static boolean |
isBackupFolderFile(Context context, File file)
Checks whether the specified file is stored in app sandbox.
| ||||||||||
static boolean | isChromebook(Context context) | ||||||||||
static boolean |
isColorDark(int color, float threshold)
Checks whether the given color is considered as dark.
| ||||||||||
static boolean |
isColorDark(int color)
Checks whether the given color is considered as dark.
| ||||||||||
static boolean | isConvertibleFormat(String filePath, String[] fileTypes) | ||||||||||
static boolean |
isConvertibleFormat(String filePath)
Checks whether the specified file is a convertible document.
| ||||||||||
static boolean | isConvertibleFormatFromExt(String ext) | ||||||||||
static boolean | isConvertibleFormatFromExt(String ext, String[] fileTypes) | ||||||||||
static boolean |
isDeviceNightMode(Context context)
Returns whether the current device UI mode is night.
| ||||||||||
static boolean |
isDoNotRequestThumbFile(ContentResolver cr, String fileUriString)
Checks whether should request thumbnail preview for a file.
| ||||||||||
static boolean |
isDoNotRequestThumbFile(String filePath)
Checks whether should request thumbnail preview for a file.
| ||||||||||
static boolean |
isDocModified(PDFDoc pdfDoc)
Checks whether the file is modified.
| ||||||||||
static boolean |
isDocModified(PDFViewCtrl pdfViewCtrl)
Checks whether the file is modified.
| ||||||||||
static boolean | isEmulator() | ||||||||||
static boolean |
isExtensionHandled(String extension)
Checks whether the specified extension is handled.
| ||||||||||
static boolean |
isHtmlDocument(String filePath)
Checks whether the specified file is an HTML document.
| ||||||||||
static boolean | isImageCopied(Context context) | ||||||||||
static boolean |
isImageFile(String filePath)
Checks whether the specified file is an image file.
| ||||||||||
static boolean |
isImageFile(ContentResolver cr, Uri fileUri)
Checks whether the specified URI is an image file.
| ||||||||||
static boolean | isImageFileFromExt(String ext) | ||||||||||
static boolean |
isItemInList(String item, String[] array)
This method ignores case
| ||||||||||
static boolean |
isJellyBeanMR1()
Checks if this device is running Jelly Bean MR1 or higher.
| ||||||||||
static boolean |
isJellyBeanMR2()
Checks if this device is running Jelly Bean MR2 or higher.
| ||||||||||
static boolean |
isKitKat()
Checks if this device is running KitKat or higher.
| ||||||||||
static boolean |
isKitKatOnly()
Checks if this device is running KitKat only.
| ||||||||||
static boolean |
isLandscape(Context context)
Checks if the device is in landscape mode.
| ||||||||||
static boolean |
isLargeScreen(Context context)
Checks if the screen size is large.
| ||||||||||
static boolean |
isLargeScreenWidth(Context context)
Checks if the screen width is large.
| ||||||||||
static boolean |
isLargeTablet(Context context)
Checks if the device is a 10 inch plus tablet.
| ||||||||||
static boolean |
isLeftToRightString(String str)
Checks whether the specified string is left-to-right.
| ||||||||||
static boolean |
isLollipop()
Checks if this device is running Lollipop or higher.
| ||||||||||
static boolean |
isLollipopMR1()
Checks if this device is running Lollipop MR1 or higher.
| ||||||||||
static boolean |
isMarshmallow()
Checks if this device is running Marshmallow or higher.
| ||||||||||
static boolean |
isMimeTypeHandled(String mimeType)
Checks whether the specified mime type is handled.
| ||||||||||
static boolean |
isNonPDFByMimeType(String mimeType)
Checks whether the specified mime type is an office mime type
| ||||||||||
static boolean |
isNotPdf(ContentResolver cr, Uri fileUri)
Checks whether the specified URI is non-PDF file.
| ||||||||||
static boolean |
isNotPdf(String filePath)
Checks whether the specified file is non-PDF file.
| ||||||||||
static boolean |
isNotPdfFromExt(String ext)
Checks whether the specified extension is non-PDF extension.
| ||||||||||
static boolean |
isNougat()
Checks if this device is running Nougat or higher.
| ||||||||||
static boolean |
isNullOrEmpty(String string)
Checks whether the string is null or empty.
| ||||||||||
static boolean |
isOfficeDocument(ContentResolver cr, Uri fileUri)
Checks whether the specified URI is an office document.
| ||||||||||
static boolean |
isOfficeDocument(String filePath)
Checks whether the specified file is an office document.
| ||||||||||
static boolean | isOfficeDocumentFromExt(String ext) | ||||||||||
static boolean |
isOreo()
Checks if this device is running Oreo or higher.
| ||||||||||
static boolean |
isPie()
Checks if this device is running Pie or higher.
| ||||||||||
static boolean |
isPortrait(Context context)
Checks if the device is in portrait mode.
| ||||||||||
static boolean |
isRightToLeftString(String str)
Checks whether the specified string is right-to-left.
| ||||||||||
static boolean |
isRtlLayout(Context context)
Checks whether the layout direction is right-to-left.
| ||||||||||
static boolean | isSamePoint(double ax, double ay, double bx, double by) | ||||||||||
static boolean | isSamsungKeyboard(String keyboard) | ||||||||||
static boolean |
isScreenTooNarrow(Context context)
Check whether the screen is too narrow.
| ||||||||||
static boolean |
isSdCardFile(Context context, File file)
Checks whether the specified file is stored in a SD card.
| ||||||||||
static boolean | isSystemLanguagePersianArabic() | ||||||||||
static boolean |
isTablet(Context context)
Checks if the device is a tablet.
| ||||||||||
static boolean |
isTextCopy(Annot annot)
Determines if the note is copied from annotated text.
| ||||||||||
static boolean |
isTwoColorSimilar(int color1, int color2, float threshold)
Checks whether two colors are close to each other by CIE76 computation
| ||||||||||
static boolean | isUriSeekable(Context context, Uri uri) | ||||||||||
static boolean | isUsingDocumentTree() | ||||||||||
static void |
manageOOM(PDFViewCtrl pdfViewCtrl)
Frees up memory when out-of-memory happens.
| ||||||||||
static void |
manageOOM(Context context, PDFViewCtrl pdfViewCtrl)
Frees up memory when out-of-memory happens.
| ||||||||||
static void |
manageOOM(Context context)
Frees up memory when out-of-memory happens.
| ||||||||||
static HashMap<String, String> | parseDefaults(Context context, int xmlRes) | ||||||||||
static float | parseFloat(String value) | ||||||||||
static float | parseFloat(String value, Locale locale) | ||||||||||
static void |
removeTextCopy(Annot annot)
Removes the text copy tag from the annotation's SDF Obj.
| ||||||||||
static Bitmap |
replace9PatchColor(Bitmap inputBmp, int fromColor, int toColor)
Replaces a color with another when the input bitmap is a 9-path.
| ||||||||||
static Bitmap |
replace9PatchColor(Bitmap inputBmp, int toColor)
Replaces all non-white colors of a 9-patch bitmap.
| ||||||||||
static void |
requestPostNotificationsPermissions(Activity activity, int requestCode)
This permission check is new for Android API 33+
| ||||||||||
static void |
requestRecordAudioPermissions(Activity activity, View layout, int requestCode)
Requests the user for the record audio permission.
| ||||||||||
static void |
requestStoragePermissions(Activity activity, View layout, int requestCode)
This method is deprecated.
please follow the latest Android permission guideline instead
| ||||||||||
static JSONObject |
retrieveToolCache(Context context, String cacheFileName)
Retrieves the tool cache.
| ||||||||||
static void |
safeNotifyDataSetChanged(RecyclerView.Adapter adapter)
A helper to safely call RecyclerView.Adapter#notifyDataSetChanged()
| ||||||||||
static void |
safeNotifyItemChanged(RecyclerView.Adapter adapter, int position)
A helper to safely call RecyclerView.Adapter#notifyItemChanged(int)
| ||||||||||
static void |
safeRemoveItemDecoration(RecyclerView recyclerView, RecyclerView.ItemDecoration itemDecoration)
A helper to safely call RecyclerView.Adapter#removeItemDecoration(RecyclerView.ItemDecoration)
| ||||||||||
static void |
safeShowAlertDialog(Context context, CharSequence message, String title)
Shows an alert dialog.
| ||||||||||
static void |
safeShowAlertDialog(Context context, int messageId, int titleId)
Shows an alert dialog.
| ||||||||||
static void |
setTextCopy(Annot annot)
Adds the text copy tag to the annotation's SDF Obj which is used to determine
if the note is copied from annotated text
| ||||||||||
static void |
shareGenericFile(Activity activity, Uri file)
Shares a URI.
| ||||||||||
static void |
shareGenericFiles(Activity activity, ArrayList<Uri> files)
Shares URIs.
| ||||||||||
static void |
sharePdfFile(Activity activity, File file)
Shares a PDF file.
| ||||||||||
static void |
sharePdfFiles(Activity activity, ArrayList<FileInfo> files)
Shares PDF files.
| ||||||||||
static void |
showAlertDialog(Activity activity, CharSequence message, String title)
Shows an alert dialog.
| ||||||||||
static void |
showAlertDialog(Activity activity, int messageId, int titleId)
Shows an alert dialog.
| ||||||||||
static void |
showAlertDialogWithLink(Context context, String message, String title)
Shows an alert dialog.
| ||||||||||
static void |
showSoftKeyboard(Context context, View view)
Shows soft keyboard.
| ||||||||||
static
|
simpleHTTPDownload(String link, File outputFile) | ||||||||||
static void |
snapPointToRect(PointF point, RectF rect)
Snaps a point to the specified rectangle
| ||||||||||
static void | throwIfNotOnMainThread() | ||||||||||
static void | throwIfOnMainThread() | ||||||||||
static Bitmap |
tint(Bitmap bitmap, int color)
Tints a bitmap to a new color.
| ||||||||||
static Drawable | tintDrawable(Context context, Drawable drawable) | ||||||||||
static int | toolbarIconMaxCount(Context context) | ||||||||||
static void |
unlockQuietly(PDFDoc doc)
Unlocks the PDF doc write lock quietly
| ||||||||||
static void |
unlockReadQuietly(PDFDoc doc)
Unlocks the PDF doc read lock quietly
| ||||||||||
static void | updateDashedLineColor(View view, int color) | ||||||||||
static boolean |
uriHasReadPermission(Context context, Uri uri, CancellationSignal cancellationSignal)
Checks whether the specified URI has read permission.
| ||||||||||
static boolean |
uriHasReadPermission(Context context, Uri uri)
Checks whether the specified URI has read permission.
| ||||||||||
static boolean |
uriHasReadWritePermission(Context context, Uri uri)
Checks whether the specified URI has read/write permission.
| ||||||||||
static boolean |
uriHasWritePermission(Context context, Uri uri)
Checks whether the specified URI has write permission.
| ||||||||||
static boolean |
validActivity(Activity activity)
Returns whether the activity is valid for displaying UI (such as dialogs).
| ||||||||||
static void | validateContentResolver(ContentResolver cr, Uri uri) |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
The URI is a document.
The URI is a file.
The URI is a file tree.
The URI is unknown.
Adjusts alpha channel of a bitmap
bitmap | The input bitmap |
---|---|
alpha | The alpha |
Adjusts alpha color.
color | The color |
---|---|
factor | The factor for adjustment |
Apply day night mode.
Apply day night mode.
Returns an external file info from the specified URI
context | The context |
---|---|
uri | The URI |
Computes the page bounding box of PDFView in the client space.
pdfViewCtrl | The PDFViewCtrl |
---|---|
pageNum | The page number |
Checks whether the cache file exists.
context | The context |
---|---|
cacheFileName | The cache file name |
Capitalizes the first letter of the given string.
s | string to capitalize. |
---|
Calls closeDoc()
quietly
pdfViewCtrl | the PDFViewCtrl |
---|
Closes the file filter proper quietly
filter | the SecondaryFileFilter |
---|
Closes the parcel descriptor quietly
pfd | The parcel descriptor |
---|
Closes the PDFDoc and file filter proper quietly
doc | the PDFDoc |
---|---|
filter | the SecondaryFileFilter |
Closes the closeable quietly
c | The closeable |
---|
Converts an integer color to a color point
color | The color as integer |
---|
ColorPt
Converts a color point to an integer color
colorPt | The color as ColorPt |
---|
Converts density independent pixels to physical pixels.
Converts a drawable to a bitmap
drawable | The drawable |
---|
Converts external content URI to a file
activity | The activity |
---|---|
beamUri | The URI |
Converts physical pixels to density independent pixels.
Converts a rect in page space to screen space
pdfViewCtrl | The PDFViewCtrl |
---|---|
rect | The rectangle in page space |
pageNum | The page number |
PDFNetException | PDFNet exception |
---|
Converts a rect in page space to scroll view space
pdfViewCtrl | The PDFViewCtrl |
---|---|
rect | The rectangle in page space |
pageNum | The page number |
PDFNetException | PDFNet exception |
---|
IOException |
---|
Copies an assets file to cache path
context | the context |
---|---|
path | the asset file path, i.e. /android_asset/test.pdf |
folderName | the folder to put the file |
force | whether to create a new copy if file exists or overwrite |
Copies an assets file to cache path
context | the context |
---|---|
path | the asset file path, i.e. /android_asset/test.pdf |
force | whether to create a new copy if file exists or overwrite |
Copies a large file.
inputFile | The input file |
---|---|
output | The output stream |
buffer | A helper buffer |
IOException | IO exception |
---|
Copies a large file.
inputFile | The input file |
---|---|
output | The output stream |
IOException | IO exception |
---|
Copies the specified resource file into the temp folder with provided name. If file already exists, it will be overridden.
context | The context |
---|---|
resId | The resource ID to be copied |
name | The name of resource and will be used as name of the output file |
ext | The extension of resource and will be used as extension of the output file |
Copies the specified resource file into the temp folder.
context | The context |
---|---|
resId | The resource ID to be copied |
force | True to overwrite the existing resource file |
resourceName | The name of resource |
PDFNetException | PDFNet exception |
---|
Returns a generic share intent for the specified URI
activity | The activity |
---|---|
uri | The URI |
Returns a generic share intent for the specified URIs
activity | The activity |
---|---|
uris | A list of URIs |
Creates a state image drawable (enable/disable) from a resource id with specified color and the transparency factor when disabled.
context | The context |
---|---|
resourceId | The input resource id |
color | The tint color |
disableOpacity | The transparency when the drawable is disabled |
Creates a state image drawable (enable/disable) from a resource id with specified color and the transparency factor when disabled.
context | The context |
---|---|
resourceId | The input resource id |
color | The tint color |
Returns a generic share intent for the specified file
activity | The activity |
---|---|
file | The file |
Creates a generic share intent based on given file and mimetype
context | The context |
---|---|
filePath | File to share |
mimeType | Files mimetype (eg image/png) |
Returns a generic share intent for the specified files
activity | The activity |
---|---|
files | A list of files |
IOException | |
---|---|
PDFNetException |
Deletes the cache file.
context | The context |
---|---|
cacheFileName | The cache file name |
Returns an Single for a duplicating file in the "Downloads" folder.
Returns an Single for a duplicating file in the specified folder.
On subscribe: Duplicates a file in the specified folder /p>
cr | Content resolver for the uri |
---|---|
uri | The URI of a file |
title | The title of the file |
outputFolder | The output folder to duplicate this file |
Returns the accent color defined in android attribute.
context | The context |
---|
Creates an alert dialog builder.
context | The context |
---|---|
messageId | The id of the message |
Creates an alert dialog builder.
context | The context |
---|---|
message | The message of the dialog |
title | The title of the dialog |
Creates an alert dialog builder.
context | The context |
---|---|
messageId | The id of the message |
Returns the background color defined in android attribute.
context | The context |
---|
Converts the specified string to Bidi.
str | The string |
---|
Returns real path from the specified image URI.
context | The context |
---|---|
imageUri | The image URI |
backupFilepath | The backup file path |
Returns the number of bytes in string format
bytes | The number of bytes |
---|
Gets color value in hex format (#0xFFFFFF)
color | color |
---|
A helper to get Context.getContentResolver().
Gets the value of the data column for this Uri. This is useful for MediaStore Uris, and other file-based ContentProviders.
context | The context. |
---|---|
uri | The Uri to query. |
selection | (Optional) Filter used in the query. |
selectionArgs | (Optional) Selection arguments used in the query. |
Returns the display name from the image URI
context | The context |
---|---|
imageUri | The URI |
backupFilepath | The backup file path |
Gets the size of the display, in pixels.
context | the Context |
---|---|
outSize | A Point object to receive the size information |
Helper to get a drawable from drawable resource.
context | The context |
---|---|
drawableRes | The drawable resource |
Returns file extension in lower case, or empty string if input is null
A helper to get Context.getExternalFilesDir(String).
A helper to get Context.getExternalFilesDirs(String).
Returns a file path in the specified path that is not used.
folder | The folder in external storage |
---|---|
original | The original file name |
Returns a file path in the specified path that is not used.
original | The original file path |
---|
Given a portfolio PDF document (ie, with embedded files), returns a list of the embedded files.
file | the PDF document |
---|---|
password | the password to open this document if secured |
Returns the first bookmark in a certain document.
pdfDoc | The PDF Doc |
---|
Gets font file name
fontFilePath | font file path |
---|
Returns the foreground color defined in android attribute.
context | The context |
---|
Gets the free disk storage size
getImageFileDimensions Helper method to extract width and height of an image File Optionally provide maxDimension to have it scale down to that lenght of it's longest dimension (either width or height), and then maintain it's aspect ratio e.g. Width: 2000, Height: 1000 If you apply maxDimension 1000 it becomes [1000,500]
file | input file |
---|---|
maxDimension | maximum dimension edge of image, it will retain aspect ratio, use 0 to disable |
Returns digits based on the Locale.
input | The digits in string format |
---|
Returns password if it is saved in PdfViewCtrlTabsManager
.
context | The Context |
---|---|
filepath | The file path |
convert color to post processed color in pdf
pdfViewCtrl | The PDFViewCtrl |
---|---|
color | The color to be post processed |
Returns the primary color defined in android attribute.
context | The context |
---|
Returns the primary dark color defined in android attribute.
context | The context |
---|
Returns the primary text color defined in android attribute.
context | The context |
---|
Returns real path from the specified image URI.
context | The context |
---|---|
imageUri | The image URI |
Gets a file path from a Uri. This will get the the path for Storage Access Framework Documents, as well as the _data field for the MediaStore and other file-based ContentProviders.
context | The context. |
---|---|
uri | The Uri to query.
reference http://stackoverflow.com/a/20559175 Note: there is also another version of this function in QuadOverImageView package (FileUtils.java) |
Returns the real screen height without subtracting any window decor or applying any compatibility scale factors.
context | The context |
---|
Returns the real screen width without subtracting any window decor or applying any compatibility scale factors.
context | The context |
---|
A helper to get color identifier.
A helper to get drawable identifier.
A helper to get raw identifier.
A helper to get Context.getResources().
Returns the screen height. Value returned by this method does not necessarily represent the actual screen height (native resolution) of the display.
context | The context |
---|
Returns the screen width. Value returned by this method does not necessarily represent the actual screen width (native resolution) of the display.
context | The context |
---|
Returns the secondary text color defined in android attribute.
context | The context |
---|
IOException |
---|
Returns the display name of the specified URI
context | The context |
---|---|
contentUri | The content URI |
Returns the display name of the specified URI
contentResolver | The content resolver |
---|---|
contentUri | The content URI |
Returns the URI document path.
uri | The URI |
---|
Returns the file extension of the specified URI
contentResolver | The content resolver |
---|---|
uri | The URI |
Returns the file size of the specified URI
contentResolver | The content resolver |
---|---|
uri | The URI |
Return the URI for the specified file
context | The context |
---|---|
file | The file |
Returns the URI tree path.
uri | The URI |
---|
Returns the URI type
uri | The URI |
---|
URI_TYPE_UNKNOWN
,
URI_TYPE_FILE
, URI_TYPE_DOCUMENT
and URI_TYPE_TREE
Return a valid file name from the specified file name.
filename | The file name |
---|
Return a valid title from the specified URI
context | The context |
---|---|
fileUri | The uri of the document |
Handles an empty popup
markup | The markup |
---|
Handles when trying to create PDF from an image fails. It remove any cached memory if any and show a toast
context | The context |
---|---|
imageIntent | The internal image intent map obtained from readImageIntent(Intent, Context, Uri)
|
Checks whether the specified string has any right-to-left characters.
str | The string |
---|
This method is deprecated.
please follow the latest Android permission guideline instead
Checks whether the app has the storage permission.
context | The context |
---|
Hides soft keyboard.
context | The context |
---|---|
view | The view |
Gets a human readable format of a byte size.
See http://stackoverflow.com/questions/3758606/how-to-convert-byte-size-into-human-readable-format-in-javabytes | the number of bytes |
---|---|
si | true for SI units or false for binary units |
Checks if this device is running Android Q or higher.
Checks if this device is running Android R or higher.
Checks if this device is running Android S or higher.
Checks if this device is running Android T or higher.
Gets whether a tool mode is one of the handler tool modes.
toolMode | the tool mode |
---|
Checks whether the specified app is installed on the device.
context | The context |
---|---|
uri | The app URI |
Checks whether the specified file is stored in app sandbox.
Checks whether the given color is considered as dark.
color | The color |
---|---|
threshold | threshold value to determine if the color is dark |
Checks whether the given color is considered as dark.
color | The color |
---|
Checks whether the specified file is a convertible document. For example .xod or .xps
filePath | The file path |
---|
Returns whether the current device UI mode is night.
context | The context |
---|
Checks whether should request thumbnail preview for a file. Binary office files are skipped for better performance.
cr | The content resolver |
---|---|
fileUriString | The URI |
Checks whether should request thumbnail preview for a file. Binary office files are skipped for better performance.
filePath | the file path |
---|
Checks whether the file is modified.
pdfDoc | The PDF doc |
---|
Checks whether the file is modified.
pdfViewCtrl | The PDFViewCtrl |
---|
Checks whether the specified extension is handled.
extension | The extension |
---|
Checks whether the specified file is an HTML document.
filePath | The file path |
---|
Checks whether the specified file is an image file.
filePath | The file path |
---|
Checks whether the specified URI is an image file.
cr | The content resolver |
---|---|
fileUri | The URI |
This method ignores case
Checks if this device is running Jelly Bean MR1 or higher.
Checks if this device is running Jelly Bean MR2 or higher.
Checks if this device is running KitKat or higher.
Checks if this device is running KitKat only.
Checks if the device is in landscape mode.
context | The context |
---|
Checks if the screen size is large.
context | The context |
---|
Checks if the screen width is large.
context | The context |
---|
Checks if the device is a 10 inch plus tablet.
context | The context |
---|
Checks whether the specified string is left-to-right.
str | The string |
---|
Checks if this device is running Lollipop or higher.
Checks if this device is running Lollipop MR1 or higher.
Checks if this device is running Marshmallow or higher.
Checks whether the specified mime type is handled.
mimeType | The mime type |
---|
Checks whether the specified mime type is an office mime type
Checks whether the specified URI is non-PDF file.
cr | The content resolver |
---|---|
fileUri | The URI |
Checks whether the specified file is non-PDF file.
filePath | The file path |
---|
Checks whether the specified extension is non-PDF extension.
ext | The file extension |
---|
Checks if this device is running Nougat or higher.
Checks whether the string is null or empty.
string | the string to be checked against |
---|
Checks whether the specified URI is an office document.
cr | The content resolver |
---|---|
fileUri | The URI |
Checks whether the specified file is an office document.
filePath | The file path |
---|
Checks if this device is running Oreo or higher.
Checks if this device is running Pie or higher.
Checks if the device is in portrait mode.
context | The context |
---|
Checks whether the specified string is right-to-left.
str | The string |
---|
Checks whether the layout direction is right-to-left.
context | The context |
---|
Check whether the screen is too narrow.
context | The context |
---|
Checks whether the specified file is stored in a SD card.
context | The context |
---|---|
file | The file |
Checks if the device is a tablet.
context | The context |
---|
Determines if the note is copied from annotated text.
annot | The annotation |
---|
Checks whether two colors are close to each other by CIE76 computation
color1 | The first color to compare |
---|---|
color2 | The second color to compare |
threshold | If the distance of two colors is lower than the threshold, then they are considered as closed color |
Frees up memory when out-of-memory happens.
pdfViewCtrl | The PDFViewCtrl |
---|
Frees up memory when out-of-memory happens.
context | The context |
---|---|
pdfViewCtrl | The PDFViewCtrl |
Frees up memory when out-of-memory happens.
context | The context |
---|
ParseException |
---|
ParseException |
---|
Removes the text copy tag from the annotation's SDF Obj. See {setTextCopy(Annot)
}.
annot | The annotation |
---|
Replaces a color with another when the input bitmap is a 9-path.
inputBmp | The input 9-patch bitmap |
---|---|
fromColor | The color to be replaced from |
toColor | The color to be replaced to |
Replaces all non-white colors of a 9-patch bitmap.
inputBmp | The input 9-patch bitmap |
---|---|
toColor | The color to replace all non-white pixels |
This permission check is new for Android API 33+
Requests the user for the record audio permission.
activity | The activity |
---|---|
requestCode | The request code |
This method is deprecated.
please follow the latest Android permission guideline instead
Requests the user for the storage permission.
activity | The activity |
---|---|
requestCode | The request code |
Retrieves the tool cache.
context | The context |
---|---|
cacheFileName | The cache file name |
A helper to safely call RecyclerView.Adapter#notifyDataSetChanged()
A helper to safely call RecyclerView.Adapter#notifyItemChanged(int)
A helper to safely call RecyclerView.Adapter#removeItemDecoration(RecyclerView.ItemDecoration)
Shows an alert dialog.
/\p>
Note: always call showAlertDialog(Activity, CharSequence, String)
instead unless you
are sure it is running on the UI thread, for example inside onPostExecute, onClick, etc
context | The context |
---|---|
message | The message |
title | The title |
Shows an alert dialog.
/\p>
Note: always call showAlertDialog(Activity, int, int)
instead unless you are sure
it is running on the UI thread, for example inside onPostExecute, onClick, etc
context | The context |
---|---|
messageId | The ID of the message |
titleId | The ID of the title |
Adds the text copy tag to the annotation's SDF Obj which is used to determine if the note is copied from annotated text
annot | The annotation |
---|
Shares a URI.
activity | The activity |
---|---|
file | The file |
Shares URIs.
activity | The activity |
---|---|
files | A list of URIs |
Shares a PDF file.
activity | The activity |
---|---|
file | The file |
Shares PDF files.
activity | The activity |
---|---|
files | A list of files |
Shows an alert dialog.
activity | The activity |
---|---|
message | The message |
title | The title |
Shows an alert dialog.
activity | The activity |
---|---|
messageId | The ID of the message |
titleId | The ID of the title |
Shows an alert dialog.
context | The context |
---|---|
message | The message |
title | The title |
Shows soft keyboard.
context | The context |
---|---|
view | The view |
Snaps a point to the specified rectangle
point | The resulted point snapped to the rectangle |
---|---|
rect | The rectangle |
IllegalStateException | if not running on main thread |
---|
IllegalStateException | if running on main thread |
---|
Tints a bitmap to a new color.
bitmap | The input bitmap |
---|---|
color | The tinting color |
Unlocks the PDF doc write lock quietly
doc | The PDF doc |
---|
Unlocks the PDF doc read lock quietly
doc | The PDF doc |
---|
Checks whether the specified URI has read permission.
context | The context |
---|---|
uri | The URI |
cancellationSignal | Used to cancel any pending calls using openFileDescriptor |
Checks whether the specified URI has read permission.
context | The context |
---|---|
uri | The URI |
Checks whether the specified URI has read/write permission.
context | The context |
---|---|
uri | The URI |
Checks whether the specified URI has write permission.
context | The context |
---|---|
uri | The URI |
Returns whether the activity is valid for displaying UI (such as dialogs).
activity | the activity to check |
---|