Skip to content

Commit 0c0c8cc

Browse files
author
Thibault Deckers
committed
Merge branch 'develop'
2 parents 9d689b7 + 51952f7 commit 0c0c8cc

File tree

9 files changed

+175
-111
lines changed

9 files changed

+175
-111
lines changed

.github/workflows/main.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,30 @@ jobs:
6060
with:
6161
artifacts: "build/app/outputs/apk/release/*.apk,build/app/outputs/bundle/release/*.aab"
6262
token: ${{ secrets.RELEASE_WORKFLOW_TOKEN }}
63+
64+
- name: Upload app bundle
65+
uses: actions/upload-artifact@v2
66+
with:
67+
name: appbundle
68+
path: build/app/outputs/bundle/release/app-release.aab
69+
70+
release:
71+
name: Create beta release on Play Store.
72+
needs: [ build ]
73+
runs-on: ubuntu-latest
74+
steps:
75+
- uses: actions/checkout@v2
76+
77+
- name: Get appbundle from artifacts.
78+
uses: actions/download-artifact@v2
79+
with:
80+
name: appbundle
81+
82+
- name: Release app to beta channel.
83+
uses: r0adkll/upload-google-play@v1
84+
with:
85+
serviceAccountJsonPlainText: ${{ secrets.PLAYSTORE_ACCOUNT_KEY }}
86+
packageName: deckers.thibault.aves
87+
releaseFile: app-release.aab
88+
track: beta
89+
whatsNewDirectory: whatsnew

android/app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
<!-- to access media with unredacted metadata with scoped storage (Android Q+) -->
3131
<uses-permission android:name="android.permission.ACCESS_MEDIA_LOCATION" />
3232

33-
<!-- TODO remove this permission once this issue is fixed:
33+
<!-- TODO TLAD remove this permission once this issue is fixed:
3434
https://github.com/flutter/flutter/issues/42349
3535
https://github.com/flutter/flutter/issues/42451
3636
-->

android/app/src/main/java/deckers/thibault/aves/channel/streams/ImageOpStreamHandler.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import android.os.Looper;
77
import android.util.Log;
88

9+
import java.io.File;
910
import java.util.ArrayList;
1011
import java.util.HashMap;
1112
import java.util.List;
@@ -94,6 +95,10 @@ private void move() {
9495
String destinationDir = (String) argMap.get("destinationPath");
9596
if (copy == null || destinationDir == null) return;
9697

98+
if (!destinationDir.endsWith(File.separator)) {
99+
destinationDir += File.separator;
100+
}
101+
97102
List<AvesImageEntry> entries = entryMapList.stream().map(AvesImageEntry::new).collect(Collectors.toList());
98103
provider.moveMultiple(activity, copy, destinationDir, entries, new ImageProvider.ImageOpCallback() {
99104
@Override

android/app/src/main/java/deckers/thibault/aves/model/provider/ImageProvider.java

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public ListenableFuture<Object> delete(final Activity activity, final String pat
5656
return Futures.immediateFailedFuture(new UnsupportedOperationException());
5757
}
5858

59-
public void moveMultiple(final Activity activity, Boolean copy, String destinationDir, List<AvesImageEntry> entries, @NonNull ImageOpCallback callback) {
59+
public void moveMultiple(final Activity activity, final Boolean copy, final String destinationDir, final List<AvesImageEntry> entries, @NonNull final ImageOpCallback callback) {
6060
callback.onFailure(new UnsupportedOperationException());
6161
}
6262

@@ -66,12 +66,11 @@ public void rename(final Activity activity, final String oldPath, final Uri oldM
6666
return;
6767
}
6868

69-
Map<String, Object> newFields = new HashMap<>();
7069
File oldFile = new File(oldPath);
7170
File newFile = new File(oldFile.getParent(), newFilename);
7271
if (oldFile.equals(newFile)) {
7372
Log.w(LOG_TAG, "new name and old name are the same, path=" + oldPath);
74-
callback.onSuccess(newFields);
73+
callback.onSuccess(new HashMap<>());
7574
return;
7675
}
7776

@@ -94,40 +93,7 @@ public void rename(final Activity activity, final String oldPath, final Uri oldM
9493
}
9594

9695
MediaScannerConnection.scanFile(activity, new String[]{oldPath}, new String[]{mimeType}, null);
97-
MediaScannerConnection.scanFile(activity, new String[]{newFile.getPath()}, new String[]{mimeType}, (newPath, newUri) -> {
98-
Log.d(LOG_TAG, "onScanCompleted with newPath=" + newPath + ", newUri=" + newUri);
99-
if (newUri != null) {
100-
// newURI is a file media URI (e.g. "content://media/12a9-8b42/file/62872")
101-
// but we need an image/video media URI (e.g. "content://media/external/images/media/62872")
102-
long contentId = ContentUris.parseId(newUri);
103-
Uri contentUri = null;
104-
if (mimeType.startsWith(MimeTypes.IMAGE)) {
105-
contentUri = ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentId);
106-
} else if (mimeType.startsWith(MimeTypes.VIDEO)) {
107-
contentUri = ContentUris.withAppendedId(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, contentId);
108-
}
109-
if (contentUri != null) {
110-
// we retrieve updated fields as the renamed file became a new entry in the Media Store
111-
String[] projection = {MediaStore.MediaColumns.DATA, MediaStore.MediaColumns.TITLE};
112-
try {
113-
Cursor cursor = activity.getContentResolver().query(contentUri, projection, null, null, null);
114-
if (cursor != null) {
115-
if (cursor.moveToNext()) {
116-
newFields.put("uri", contentUri.toString());
117-
newFields.put("contentId", contentId);
118-
newFields.put("path", cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.DATA)));
119-
newFields.put("title", cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.TITLE)));
120-
}
121-
cursor.close();
122-
}
123-
} catch (Exception e) {
124-
callback.onFailure(e);
125-
return;
126-
}
127-
}
128-
}
129-
callback.onSuccess(newFields);
130-
});
96+
scanNewPath(activity, newFile.getPath(), mimeType, callback);
13197
}
13298

13399
public void rotate(final Activity activity, final String path, final Uri uri, final String mimeType, final boolean clockwise, final ImageOpCallback callback) {
@@ -291,6 +257,54 @@ private void rotatePng(final Activity activity, final String path, final Uri uri
291257
// }
292258
}
293259

260+
protected void scanNewPath(final Activity activity, final String path, final String mimeType, final ImageOpCallback callback) {
261+
MediaScannerConnection.scanFile(activity, new String[]{path}, new String[]{mimeType}, (newPath, newUri) -> {
262+
Log.d(LOG_TAG, "scanNewPath onScanCompleted with newPath=" + newPath + ", newUri=" + newUri);
263+
264+
long contentId = 0;
265+
Uri contentUri = null;
266+
if (newUri != null) {
267+
// newURI is possibly a file media URI (e.g. "content://media/12a9-8b42/file/62872")
268+
// but we need an image/video media URI (e.g. "content://media/external/images/media/62872")
269+
contentId = ContentUris.parseId(newUri);
270+
if (mimeType.startsWith(MimeTypes.IMAGE)) {
271+
contentUri = ContentUris.withAppendedId(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentId);
272+
} else if (mimeType.startsWith(MimeTypes.VIDEO)) {
273+
contentUri = ContentUris.withAppendedId(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, contentId);
274+
}
275+
}
276+
if (contentUri == null) {
277+
callback.onFailure(new Exception("failed to get content URI of item at path=" + path));
278+
return;
279+
}
280+
281+
Map<String, Object> newFields = new HashMap<>();
282+
// we retrieve updated fields as the renamed file became a new entry in the Media Store
283+
String[] projection = {MediaStore.MediaColumns.TITLE};
284+
try {
285+
Cursor cursor = activity.getContentResolver().query(contentUri, projection, null, null, null);
286+
if (cursor != null) {
287+
if (cursor.moveToNext()) {
288+
newFields.put("uri", contentUri.toString());
289+
newFields.put("contentId", contentId);
290+
newFields.put("path", path);
291+
newFields.put("title", cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.MediaColumns.TITLE)));
292+
}
293+
cursor.close();
294+
}
295+
} catch (Exception e) {
296+
callback.onFailure(e);
297+
return;
298+
}
299+
300+
if (newFields.isEmpty()) {
301+
callback.onFailure(new Exception("failed to get item details from provider at contentUri=" + contentUri));
302+
} else {
303+
callback.onSuccess(newFields);
304+
}
305+
});
306+
}
307+
294308
public interface ImageOpCallback {
295309
void onSuccess(Map<String, Object> fields);
296310

0 commit comments

Comments
 (0)