1
0
Fork 0
mirror of https://github.com/gsantner/dandelion synced 2025-09-10 10:49:42 +02:00

Rework screenshot saving and sharing; add new share options:

* Share option: Launcher shortcut (fixes #170)
* Share option: Copy link of current page to clipboard
* Share otpion: Export as PDF / print
This commit is contained in:
Gregor Santner 2018-04-08 17:52:04 +02:00
parent d53128e5cb
commit 51093e0c3d
No known key found for this signature in database
GPG key ID: 7E83A7834AECB009
35 changed files with 1222 additions and 138 deletions

View file

@ -31,6 +31,7 @@ import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.VectorDrawable;
import android.media.MediaScannerConnection;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
@ -446,6 +447,25 @@ public class ContextUtils {
return dp * _context.getResources().getDisplayMetrics().density;
}
/**
* Request the givens paths to be scanned by MediaScanner
*
* @param files Files and folders to scan
*/
public void mediaScannerScanFile(File... files) {
if (android.os.Build.VERSION.SDK_INT > 19) {
String[] paths = new String[files.length];
for (int i = 0; i < files.length; i++) {
paths[i] = files[i].getAbsolutePath();
}
MediaScannerConnection.scanFile(_context, paths, null, null);
} else {
for (File file : files) {
_context.sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.fromFile(file)));
}
}
}
/**
* Load an image into a {@link ImageView} and apply a color filter
*/
@ -459,7 +479,10 @@ public class ContextUtils {
*/
public Bitmap drawableToBitmap(Drawable drawable) {
Bitmap bitmap = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && (drawable instanceof VectorDrawable || drawable instanceof VectorDrawableCompat || drawable instanceof AdaptiveIconDrawable)) {
if (drawable instanceof VectorDrawableCompat
|| (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && drawable instanceof VectorDrawable)
|| ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && drawable instanceof AdaptiveIconDrawable))) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
drawable = (DrawableCompat.wrap(drawable)).mutate();
}