mirror of
https://github.com/gsantner/dandelion
synced 2024-11-22 12:22:08 +01:00
Better sharing from app
This commit is contained in:
parent
4c5911804a
commit
d8ca356d6c
1 changed files with 13 additions and 8 deletions
|
@ -631,14 +631,17 @@ public class MainActivity extends AppCompatActivity
|
||||||
|
|
||||||
Date dateNow = new Date();
|
Date dateNow = new Date();
|
||||||
DateFormat dateFormat = new SimpleDateFormat("yy_MM_dd--HH_mm_ss", Locale.getDefault());
|
DateFormat dateFormat = new SimpleDateFormat("yy_MM_dd--HH_mm_ss", Locale.getDefault());
|
||||||
File fileSaveDirectory = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/Diaspora");
|
File fileSaveDirectory = new File(hasToShareScreenshot ? getCacheDir().getAbsolutePath()
|
||||||
|
: Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES) + "/Diaspora");
|
||||||
|
|
||||||
String fileSaveName = String.format("DfA_%s.jpg", dateFormat.format(dateNow));
|
String fileSaveName = String.format("DfA_%s.jpg", hasToShareScreenshot ? "share" : dateFormat.format(dateNow));
|
||||||
if (!fileSaveDirectory.exists()) {
|
if (!fileSaveDirectory.exists()) {
|
||||||
fileSaveDirectory.mkdirs();
|
fileSaveDirectory.mkdirs();
|
||||||
}
|
}
|
||||||
|
|
||||||
Snackbar.make(swipeRefreshLayout, getString(R.string.toast_screenshot) + " " + fileSaveName, Snackbar.LENGTH_LONG).show();
|
if (!hasToShareScreenshot) {
|
||||||
|
Snackbar.make(swipeRefreshLayout, getString(R.string.toast_screenshot) + " " + fileSaveName, Snackbar.LENGTH_LONG).show();
|
||||||
|
}
|
||||||
|
|
||||||
Bitmap bitmap = null;
|
Bitmap bitmap = null;
|
||||||
webView.setDrawingCacheEnabled(true);
|
webView.setDrawingCacheEnabled(true);
|
||||||
|
@ -672,11 +675,13 @@ public class MainActivity extends AppCompatActivity
|
||||||
sharingIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
|
sharingIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
|
||||||
startActivity(Intent.createChooser(sharingIntent, getString(R.string.share_dotdodot)));
|
startActivity(Intent.createChooser(sharingIntent, getString(R.string.share_dotdodot)));
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
File file = new File(fileSaveDirectory, fileSaveName);
|
// Broadcast that this file is indexable
|
||||||
Uri uri = Uri.fromFile(file);
|
File file = new File(fileSaveDirectory, fileSaveName);
|
||||||
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri);
|
Uri uri = Uri.fromFile(file);
|
||||||
sendBroadcast(intent);
|
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, uri);
|
||||||
|
sendBroadcast(intent);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue