Compare commits

..

No commits in common. "3593861e3950119ccee156e831d6091757fbdc8b" and "15516b0dde2fd1f598b04d3435437a1a6314c59c" have entirely different histories.

3 changed files with 15 additions and 36 deletions

View file

@ -7,7 +7,6 @@
- Removed "Fake Camera" feature as it has not been supported since R. - Removed "Fake Camera" feature as it has not been supported since R.
- Version displayed within the app has now been changed to also reflect the exact Git commit when the app is built. - Version displayed within the app has now been changed to also reflect the exact Git commit when the app is built.
- File Shuttle no longer appends ".null" or ".bin" suffixes unnecessarily. This should make it work much better with file managers such as Material Files. - File Shuttle no longer appends ".null" or ".bin" suffixes unnecessarily. This should make it work much better with file managers such as Material Files.
- File Shuttle now triggers media scanning much more robustly. Media files (pictures, videos, etc.) copied into the work profile should now show up much quicker in gallery apps.
1.8 1.8
=== ===

View file

@ -55,11 +55,6 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} }
} }
applicationVariants.all { variant ->
if (variant.name == "debug") {
variant.outputs.each { o -> o.versionCodeOverride = System.currentTimeSeconds() }
}
}
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8

View file

@ -101,24 +101,10 @@ public class FileShuttleService extends Service {
public ParcelFileDescriptor openFile(String path, String mode) { public ParcelFileDescriptor openFile(String path, String mode) {
resetSuicideTask(); resetSuicideTask();
File f = new File(resolvePath(path)); File f = new File(resolvePath(path));
int numericMode = ParcelFileDescriptor.parseMode(mode);
try { try {
if ((numericMode & ParcelFileDescriptor.MODE_WRITE_ONLY) != 0) { return ParcelFileDescriptor.open(f, ParcelFileDescriptor.parseMode(mode));
// When the file is opened in writable mode, and the file is of a media } catch (FileNotFoundException e) {
// type, we need to notify the media scanner of the update.
// Even though this is done as part of file creation as well, that scan
// might have failed because it happened before the writer was able to
// finish writing.
return ParcelFileDescriptor.open(f, numericMode, mHandler, (e) -> {
String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(
Utility.getFileExtension(f.getAbsolutePath()));
notifyMediaScannerIfNecessary(f, mime);
});
} else {
return ParcelFileDescriptor.open(f, numericMode);
}
} catch (IOException e) {
return null; return null;
} }
} }
@ -152,6 +138,8 @@ public class FileShuttleService extends Service {
DocumentsContract.Document.MIME_TYPE_DIR.equals(mimeType); DocumentsContract.Document.MIME_TYPE_DIR.equals(mimeType);
boolean shouldAppendExtension = boolean shouldAppendExtension =
mimeType != null && !isDirectory && !mimeType.equals("application/octet-stream"); mimeType != null && !isDirectory && !mimeType.equals("application/octet-stream");
boolean isMedia =
mimeType != null && (mimeType.startsWith("image/") || mimeType.startsWith("video/"));
// Append extension for files if a MIME type is specified // Append extension for files if a MIME type is specified
if (shouldAppendExtension) { if (shouldAppendExtension) {
@ -171,7 +159,13 @@ public class FileShuttleService extends Service {
return null; return null;
} }
notifyMediaScannerIfNecessary(f, mimeType); // Notify the media scanner to scan the file as needed
// This has to be done AFTER file creation
if (isMedia) {
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(f));
sendBroadcast(intent);
}
return f.getAbsolutePath(); return f.getAbsolutePath();
} }
@ -290,13 +284,14 @@ public class FileShuttleService extends Service {
return null; return null;
} }
FileOutputStream os = new FileOutputStream(pair[1].getFileDescriptor());
// Send the bitmap into the pipe in another thread, so that we can return the // Send the bitmap into the pipe in another thread, so that we can return the
// reading fd to the Documents UI before we finish sending the Bitmap. // reading fd to the Documents UI before we finish sending the Bitmap.
new Thread(() -> { new Thread(() -> {
try (FileOutputStream os = new FileOutputStream(pair[1].getFileDescriptor())) {
bmp.compress(Bitmap.CompressFormat.PNG, 100, os); bmp.compress(Bitmap.CompressFormat.PNG, 100, os);
try {
os.flush(); os.flush();
os.close();
} catch (IOException e) { } catch (IOException e) {
// ... // ...
} }
@ -305,14 +300,4 @@ public class FileShuttleService extends Service {
return pair[0]; return pair[0];
} }
private void notifyMediaScannerIfNecessary(File f, String mimeType) {
// Notify the media scanner to scan the file as needed
// This has to be done AFTER file creation
if (mimeType != null && (mimeType.startsWith("image/") || mimeType.startsWith("video/"))) {
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(f));
sendBroadcast(intent);
}
}
} }