|
20 | 20 | package de.k3b.android.androFotoFinder.media;
|
21 | 21 |
|
22 | 22 | import android.content.ContentValues;
|
| 23 | +import android.net.Uri; |
23 | 24 | import android.util.Log;
|
24 | 25 |
|
25 | 26 | import java.io.IOException;
|
@@ -61,6 +62,18 @@ public ExifInterfaceEx create() {
|
61 | 62 | @Override
|
62 | 63 | public void saveAttributes(IFile inFile, IFile outFile,
|
63 | 64 | boolean deleteInFileOnFinish, Boolean hasXmp) throws IOException {
|
| 65 | + if (deleteInFileOnFinish) { |
| 66 | + renameInDatabase(":saveAttributes", inFile.getCanonicalPath(), outFile.getCanonicalPath(), true); |
| 67 | + } else { |
| 68 | + if (inFile.equals(outFile)) { |
| 69 | + // !!! |
| 70 | + // renameSouraceFileBeforeReplaceOrThrow |
| 71 | + |
| 72 | + } else { |
| 73 | + insertIntoDatabase(outFile, hasXmp); |
| 74 | + } |
| 75 | + } |
| 76 | + //!!! update media database |
64 | 77 | super.saveAttributes(inFile, outFile, deleteInFileOnFinish, hasXmp);
|
65 | 78 | this.hasXmp = hasXmp;
|
66 | 79 | }
|
@@ -90,6 +103,26 @@ protected void beforeCloseSaveOutputStream() {
|
90 | 103 | super.beforeCloseSaveOutputStream();
|
91 | 104 | }
|
92 | 105 |
|
| 106 | + private void insertIntoDatabase(IFile outFile, Boolean hasXmp) { |
| 107 | + ContentValues values = new ContentValues(); |
| 108 | + PhotoPropertiesMediaDBContentValues mediaValueAdapter = new PhotoPropertiesMediaDBContentValues().set(values, null); |
| 109 | + |
| 110 | + PhotoPropertiesUtil.copyNonEmpty(mediaValueAdapter, this); |
| 111 | + |
| 112 | + Date lastModified = new Date(); |
| 113 | + TagSql.setFileModifyDate(values, lastModified); |
| 114 | + if (this.hasXmp != null) { |
| 115 | + if (this.hasXmp) { |
| 116 | + TagSql.setXmpFileModifyDate(values, lastModified); |
| 117 | + } else { |
| 118 | + TagSql.setXmpFileModifyDate(values, TagSql.EXT_LAST_EXT_SCAN_NO_XMP); |
| 119 | + } |
| 120 | + } |
| 121 | + |
| 122 | + values.put(FotoSql.SQL_COL_PATH, outFile.getCanonicalPath()); |
| 123 | + Uri result = FotoSql.getMediaDBApi().execInsert("Copy with Autoprocessing", values); |
| 124 | + } |
| 125 | + |
93 | 126 | // TODO additional database parameters (see scanner)
|
94 | 127 | // DateLastModified, xmpDate, ....
|
95 | 128 | private boolean renameInDatabase(String dbgContext, String fromPath, String toPath, boolean thransferExif) {
|
@@ -138,7 +171,7 @@ private void debugIdPaths(String dbgContext, String... paths) {
|
138 | 171 | " is not null");
|
139 | 172 | final SelectedFiles selectedfiles = FotoSql.getSelectedfiles(sqlWhere.toString(), VISIBILITY.PRIVATE_PUBLIC);
|
140 | 173 | Log.d(Global.LOG_CONTEXT, dbgContext + "\n\t["
|
141 |
| - + StringUtils.appendMessage((String[]) paths) |
| 174 | + + StringUtils.appendMessage(paths) |
142 | 175 | + "] :\n\t\t"
|
143 | 176 | + selectedfiles.toIdString() + " -> " + selectedfiles.toPathListString());
|
144 | 177 | }
|
|
0 commit comments