diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/AdapterArrayHelper.java b/app/src/main/java/de/k3b/android/androFotoFinder/AdapterArrayHelper.java index 36a1dcd5..e0c215d7 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/AdapterArrayHelper.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/AdapterArrayHelper.java @@ -26,9 +26,9 @@ import java.util.ArrayList; import de.k3b.android.androFotoFinder.queries.FotoSql; +import de.k3b.io.FileUtils; import de.k3b.io.VISIBILITY; import de.k3b.io.collections.SelectedItems; -import de.k3b.io.FileUtils; import de.k3b.media.PhotoPropertiesUtil; /** @@ -47,7 +47,7 @@ public AdapterArrayHelper(Activity context, String fullPhotoPath, String debugCo if (Global.mustRemoveNOMEDIAfromDB && (mRootDir != null) && (mFullPhotoPaths != null)) { String parentDirString = mRootDir.getAbsolutePath(); - FotoSql.execDeleteByPath(debugContext + " AdapterArrayHelper mustRemoveNOMEDIAfromDB ", context, parentDirString, VISIBILITY.PRIVATE_PUBLIC); + FotoSql.execDeleteByPath(debugContext + " AdapterArrayHelper mustRemoveNOMEDIAfromDB ", parentDirString, VISIBILITY.PRIVATE_PUBLIC); } } diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/AffUtils.java b/app/src/main/java/de/k3b/android/androFotoFinder/AffUtils.java index e68386cb..8406b0b2 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/AffUtils.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/AffUtils.java @@ -122,7 +122,7 @@ public static SelectedFiles querySelectedFiles(Context context, SelectedItems it List paths = new ArrayList(); List datesPhotoTaken = new ArrayList(); - if (FotoSql.getFileNames(context, items, ids, paths, datesPhotoTaken) != null) { + if (FotoSql.getFileNames(items, ids, paths, datesPhotoTaken) != null) { return new SelectedFiles(paths.toArray(new String[paths.size()]), ids.toArray(new Long[ids.size()]), datesPhotoTaken.toArray(new Date[datesPhotoTaken.size()])); } } diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/AndroFotoFinderApp.java b/app/src/main/java/de/k3b/android/androFotoFinder/AndroFotoFinderApp.java index 97b76eaf..65d3e901 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/AndroFotoFinderApp.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/AndroFotoFinderApp.java @@ -38,6 +38,7 @@ import de.k3b.android.androFotoFinder.imagedetail.HugeImageLoader; import de.k3b.android.androFotoFinder.queries.FotoSql; import de.k3b.android.androFotoFinder.queries.FotoSqlBase; +import de.k3b.android.androFotoFinder.queries.MediaDBContentprovider; import de.k3b.android.osmdroid.forge.MapsForgeSupport; import de.k3b.android.util.LogCat; import de.k3b.android.widget.ActivityWithCallContext; @@ -94,6 +95,9 @@ public static RefWatcher getRefWatcher(Context context) { // StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyDeath().build()); FotoSqlBase.init(); + /// #155: todo: depending on android-api version set IMediaDBApi + FotoSql.setMediaDBApi(new MediaDBContentprovider(this)); + super.onCreate(); LibGlobal.appName = getString(R.string.app_name); @@ -165,7 +169,7 @@ private File getOutpuFile() { // #60: configure some of the mapsforge settings first MapsForgeSupport.createInstance(this); - FotoSql.deleteMediaWithNullPath(this); + FotoSql.deleteMediaWithNullPath(); Log.i(Global.LOG_CONTEXT, getAppId() + " created"); } diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/PhotoAutoprocessingEditActivity.java b/app/src/main/java/de/k3b/android/androFotoFinder/PhotoAutoprocessingEditActivity.java index 06efc4c9..40fac08d 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/PhotoAutoprocessingEditActivity.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/PhotoAutoprocessingEditActivity.java @@ -591,7 +591,7 @@ private SelectedFiles getSelectedFiles(String dbgContext, Intent intent, boolean if (itemCount > 0) { if ((mustLoadIDs) && (ids == null)) { ids = new Long[itemCount]; - Map idMap = FotoSql.execGetPathIdMap(this, fileNames); + Map idMap = FotoSql.execGetPathIdMap(fileNames); for (int i = 0; i < itemCount; i++) { ids[i] = idMap.get(fileNames[i]); diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/PhotoPropertiesEditActivity.java b/app/src/main/java/de/k3b/android/androFotoFinder/PhotoPropertiesEditActivity.java index 18b176c1..d3d32f19 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/PhotoPropertiesEditActivity.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/PhotoPropertiesEditActivity.java @@ -284,7 +284,7 @@ private static SelectedFiles getSelectedFiles(String dbgContext, Context ctx, In if (itemCount > 0) { if ((mustLoadIDs) && (ids == null)) { ids = new Long[itemCount]; - Map idMap = FotoSql.execGetPathIdMap(ctx, fileNames); + Map idMap = FotoSql.execGetPathIdMap(fileNames); for (int i = 0; i < itemCount; i++) { ids[i] = idMap.get(fileNames[i]); diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/backup/Backup2ZipService.java b/app/src/main/java/de/k3b/android/androFotoFinder/backup/Backup2ZipService.java index 7de70da1..fbf2c76e 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/backup/Backup2ZipService.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/backup/Backup2ZipService.java @@ -31,7 +31,6 @@ import de.k3b.android.androFotoFinder.Global; import de.k3b.android.androFotoFinder.R; import de.k3b.android.androFotoFinder.media.PhotoPropertiesMediaDBCursor; -import de.k3b.android.androFotoFinder.queries.ContentProviderMediaExecuter; import de.k3b.android.androFotoFinder.queries.FotoSql; import de.k3b.android.androFotoFinder.tagDB.TagSql; import de.k3b.database.QueryParameter; @@ -210,8 +209,8 @@ private void execQuery(QueryParameter query, Cursor cursor = null; try { this.onProgress(0,0, "Calculate"); - cursor = ContentProviderMediaExecuter.createCursorForQuery( - null, "ZipExecute", context, + cursor = FotoSql.getMediaDBApi().createCursorForQuery( + null, "ZipExecute", query, null); int itemCount = cursor.getCount(); diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/backup/BackupActivity.java b/app/src/main/java/de/k3b/android/androFotoFinder/backup/BackupActivity.java index 70fe7acf..6197748d 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/backup/BackupActivity.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/backup/BackupActivity.java @@ -496,7 +496,7 @@ private SelectedFiles getSelectedFiles(String dbgContext, Intent intent, boolean if (itemCount > 0) { if ((mustLoadIDs) && (ids == null)) { ids = new Long[itemCount]; - Map idMap = FotoSql.execGetPathIdMap(this, fileNames); + Map idMap = FotoSql.execGetPathIdMap(fileNames); for (int i = 0; i < itemCount; i++) { ids[i] = idMap.get(fileNames[i]); @@ -702,7 +702,7 @@ private void updateHistory(QueryParameter query) { paths.add(DCIM_ROOT); - String minFolder = FotoSql.getMinFolder(getApplicationContext(), query, true); + String minFolder = FotoSql.getMinFolder(query, true); updateHistory(FileUtils.getDir(minFolder), filenames, paths, 1); String queryFolder = FotoSql.getFilePath(query, false); diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/directory/DirectoryLoaderTask.java b/app/src/main/java/de/k3b/android/androFotoFinder/directory/DirectoryLoaderTask.java index 67df3563..eff46449 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/directory/DirectoryLoaderTask.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/directory/DirectoryLoaderTask.java @@ -28,7 +28,6 @@ import java.util.List; import de.k3b.android.androFotoFinder.Global; -import de.k3b.android.androFotoFinder.queries.ContentProviderMediaExecuter; import de.k3b.android.androFotoFinder.queries.FotoSql; import de.k3b.database.QueryParameter; import de.k3b.io.Directory; @@ -102,8 +101,8 @@ protected IDirectory doInBackground(QueryParameter... queryParameter) { } try { - cursor = ContentProviderMediaExecuter.createCursorForQuery( - null, "ZipExecute", context, + cursor = FotoSql.getMediaDBApi().createCursorForQuery( + null, "ZipExecute", queryParameters, null); int itemCount = cursor.getCount(); diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/directory/DirectoryPickerFragment.java b/app/src/main/java/de/k3b/android/androFotoFinder/directory/DirectoryPickerFragment.java index 1806edc3..84f33d02 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/directory/DirectoryPickerFragment.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/directory/DirectoryPickerFragment.java @@ -62,7 +62,6 @@ import de.k3b.android.androFotoFinder.ThumbNailUtils; import de.k3b.android.androFotoFinder.backup.BackupActivity; import de.k3b.android.androFotoFinder.imagedetail.ImageDetailMetaDialogBuilder; -import de.k3b.android.androFotoFinder.queries.ContentProviderMediaExecuter; import de.k3b.android.androFotoFinder.queries.FotoSql; import de.k3b.android.androFotoFinder.queries.FotoThumbSql; import de.k3b.android.androFotoFinder.queries.FotoViewerParameter; @@ -545,7 +544,7 @@ private void onDeleteAnswer(File file, IDirectory dir) { } // delete from database - if (FotoSql.deleteMedia("delete album", getActivity(), + if (FotoSql.deleteMedia("delete album", ListUtils.toStringList(file.getAbsolutePath()),false) > 0) { deleteSuccess = true; } @@ -664,11 +663,11 @@ private boolean fixLinks(IDirectory linkDir) { if (!canonicalPath.endsWith("/")) canonicalPath+="/"; String sqlWhereLink = FotoSql.SQL_COL_PATH + " like '" + linkPath + "%'"; - SelectedFiles linkFiles = FotoSql.getSelectedfiles(context, sqlWhereLink, VISIBILITY.PRIVATE_PUBLIC); + SelectedFiles linkFiles = FotoSql.getSelectedfiles(sqlWhereLink, VISIBILITY.PRIVATE_PUBLIC); String sqlWhereCanonical = FotoSql.SQL_COL_PATH + " in (" + linkFiles.toString() + ")"; sqlWhereCanonical = sqlWhereCanonical.replace(linkPath,canonicalPath); - SelectedFiles canonicalFiles = FotoSql.getSelectedfiles(context, sqlWhereCanonical, VISIBILITY.PRIVATE_PUBLIC); + SelectedFiles canonicalFiles = FotoSql.getSelectedfiles(sqlWhereCanonical, VISIBILITY.PRIVATE_PUBLIC); HashMap link2canonical = new HashMap(); for(String cann : canonicalFiles.getFileNames()) { link2canonical.put(linkPath + cann.substring(canonicalPath.length()), cann); @@ -693,9 +692,9 @@ private boolean fixLinks(IDirectory linkDir) { if (cann == null) { // rename linkFile to canonicalFile updateValues.put(FotoSql.SQL_COL_PATH, canonicalPath + lin.substring(linkPath.length())); - ContentProviderMediaExecuter.execUpdate("fixLinks", context, linkIds[i].intValue(), updateValues); + FotoSql.getMediaDBApi().execUpdate("fixLinks", linkIds[i].intValue(), updateValues); } else { - ContentProviderMediaExecuter.deleteMedia("DirectoryPickerFragment.fixLinks", context, FotoSql.FILTER_COL_PK, new String[]{linkIds[i].toString()}, true); + FotoSql.getMediaDBApi().deleteMedia("DirectoryPickerFragment.fixLinks", FotoSql.FILTER_COL_PK, new String[]{linkIds[i].toString()}, true); } } PhotoPropertiesMediaFilesScanner.notifyChanges(context, "Fixed link/canonical duplicates"); diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/directory/ShowInMenuHandler.java b/app/src/main/java/de/k3b/android/androFotoFinder/directory/ShowInMenuHandler.java index 45a72c9a..4e0395bb 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/directory/ShowInMenuHandler.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/directory/ShowInMenuHandler.java @@ -134,7 +134,7 @@ private long getPickCount(String dbgContext, QueryParameter query = AndroidAlbumUtils.getAsAlbumOrMergedNewQuery( dbgContext, mContext, baseQuery, filter); if (query == null) return 0; - return FotoSql.getCount(mContext, query); + return FotoSql.getCount(query); } private boolean showPhoto(String dbgContext, QueryParameter baseQuery) { @@ -162,7 +162,7 @@ private boolean showMap(String dbgContext, QueryParameter baseQuery) { QueryParameter query = AndroidAlbumUtils.getAsAlbumOrMergedNewQuery( dbgContext, mContext, baseQuery, currentSelectionFilter); if (query != null) { - IGeoRectangle area = FotoSql.execGetGeoRectangle(null, mContext, query, + IGeoRectangle area = FotoSql.execGetGeoRectangle(null, query, null, "Calculate visible arean", dbgContext); MapGeoPickerActivity.showActivity(dbgContext, mContext, null, query, area, 0); diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/gallery/cursor/GalleryCursorFragment.java b/app/src/main/java/de/k3b/android/androFotoFinder/gallery/cursor/GalleryCursorFragment.java index 224b8732..0b228046 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/gallery/cursor/GalleryCursorFragment.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/gallery/cursor/GalleryCursorFragment.java @@ -71,7 +71,6 @@ import de.k3b.android.androFotoFinder.imagedetail.ImageDetailMetaDialogBuilder; import de.k3b.android.androFotoFinder.locationmap.GeoEditActivity; import de.k3b.android.androFotoFinder.locationmap.MapGeoPickerActivity; -import de.k3b.android.androFotoFinder.queries.ContentProviderMediaExecuter; import de.k3b.android.androFotoFinder.queries.FotoSql; import de.k3b.android.androFotoFinder.queries.FotoViewerParameter; import de.k3b.android.androFotoFinder.queries.Queryable; @@ -1153,7 +1152,7 @@ private Uri getUri(Activity parent, long id) { Uri resultUri = null; if (mModePickGeoElsePickImaage) { // mode pick gep - IGeoPoint initialPoint = FotoSql.execGetPosition(null, parent, + IGeoPoint initialPoint = FotoSql.execGetPosition(null, null, id, mDebugPrefix, "getSelectedUri"); if (initialPoint != null) { @@ -1417,7 +1416,7 @@ private void onDuplicatesFound(SelectedItems selectedItems, StringBuffer debugMe String sqlWhere = query.toAndroidWhere(); // + " OR " + FotoSql.SQL_COL_PATH + " is null"; try { - delCount = ContentProviderMediaExecuter.deleteMedia(mDebugPrefix + "onDuplicatesFound", activity, sqlWhere, null, true); + delCount = FotoSql.getMediaDBApi().deleteMedia(mDebugPrefix + "onDuplicatesFound", sqlWhere, null, true); } catch (Exception ex) { Log.w(Global.LOG_CONTEXT, "deleteMedia via update failed for 'where " + sqlWhere + "'."); diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImageDetailActivityViewPager.java b/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImageDetailActivityViewPager.java index e4cec378..a98bbc58 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImageDetailActivityViewPager.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImageDetailActivityViewPager.java @@ -800,7 +800,7 @@ private static int updateIncompleteMediaDatabase(String debugPrefix, Context con String dbPathSearch = null; ArrayList missing = new ArrayList(); dbPathSearch = dirToScan.getPath() + "/%"; - List known = FotoSql.execGetFotoPaths(context, dbPathSearch); + List known = FotoSql.execGetFotoPaths(dbPathSearch); File[] existing = dirToScan.listFiles(); if (existing != null) { @@ -973,7 +973,7 @@ public boolean onOptionsItemSelected(MenuItem menuItem) { case R.id.cmd_show_geo_as: { final long imageId = getCurrentImageId(); - IGeoPoint _geo = FotoSql.execGetPosition(null, this, + IGeoPoint _geo = FotoSql.execGetPosition(null, null, imageId, mDebugPrefix, "on cmd_show_geo_as"); final String currentFilePath = getCurrentFilePath(); GeoPointDto geo = new GeoPointDto(_geo.getLatitude(), _geo.getLongitude(), GeoPointDto.NO_ZOOM); diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImageDetailMetaDialogBuilder.java b/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImageDetailMetaDialogBuilder.java index 880d922d..16e54560 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImageDetailMetaDialogBuilder.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/imagedetail/ImageDetailMetaDialogBuilder.java @@ -33,7 +33,7 @@ import java.util.Date; import java.util.List; -import de.k3b.android.androFotoFinder.queries.ContentProviderMediaExecuter; +import de.k3b.android.androFotoFinder.queries.ContentProviderMediaImpl; import de.k3b.android.androFotoFinder.tagDB.TagSql; import de.k3b.android.widget.ActivityWithCallContext; import de.k3b.database.QueryParameter; @@ -138,7 +138,7 @@ private static void appendExifInfo(StringBuilder result, Activity context, Strin if (currentImageId != 0) { - ContentValues dbContent = ContentProviderMediaExecuter.getDbContent(context, currentImageId); + ContentValues dbContent = ContentProviderMediaImpl.getDbContent(context, currentImageId); if (dbContent != null) { result.append(NL).append(line).append(NL); result.append(NL).append(TagSql.SQL_TABLE_EXTERNAL_CONTENT_URI_FILE).append(NL).append(NL); diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/locationmap/LocationMapFragment.java b/app/src/main/java/de/k3b/android/androFotoFinder/locationmap/LocationMapFragment.java index 7abacfe5..d7af20f1 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/locationmap/LocationMapFragment.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/locationmap/LocationMapFragment.java @@ -1120,7 +1120,7 @@ private boolean zoomToFit(IGeoPoint geoCenterPoint, Object... dbgContext) { QueryParameter baseQuery = getQueryForPositionRectangle(geoCenterPoint); BoundingBox boundingBox = null; - IGeoRectangle fittingRectangle = FotoSql.execGetGeoRectangle(null, this.getActivity(), + IGeoRectangle fittingRectangle = FotoSql.execGetGeoRectangle(null, baseQuery, null, mDebugPrefix, "zoomToFit", dbgContext); double delta = getDelta(fittingRectangle); if ((geoCenterPoint != null) && (delta < 1e-6)) { @@ -1194,7 +1194,7 @@ private double getMarkerDelta() { private IGeoPoint getGeoPointById(int markerId, IGeoPoint notFoundValue, Object... dbgContext) { if (markerId != NO_MARKER_ID) { - IGeoPoint pos = FotoSql.execGetPosition(null, this.getActivity(), + IGeoPoint pos = FotoSql.execGetPosition(null, null, markerId, mDebugPrefix, "getGeoPointById", dbgContext); if (pos != null) { return pos; diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/locationmap/MapGeoPickerActivity.java b/app/src/main/java/de/k3b/android/androFotoFinder/locationmap/MapGeoPickerActivity.java index 72c81766..4e3d7d0a 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/locationmap/MapGeoPickerActivity.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/locationmap/MapGeoPickerActivity.java @@ -94,7 +94,7 @@ public static void showActivity(String debugContext, Activity context, SelectedF } if (AffUtils.putSelectedFiles(intent, selectedItems)) { - IGeoPoint initialPoint = FotoSql.execGetPosition(null, context, + IGeoPoint initialPoint = FotoSql.execGetPosition(null, null, selectedItems.getId(0), context, mDebugPrefix, "showActivity"); if (initialPoint != null) { GeoUri PARSER = new GeoUri(GeoUri.OPT_PARSE_INFER_MISSING); diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/locationmap/MarkerLoaderTask.java b/app/src/main/java/de/k3b/android/androFotoFinder/locationmap/MarkerLoaderTask.java index 8dae8276..7ba13187 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/locationmap/MarkerLoaderTask.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/locationmap/MarkerLoaderTask.java @@ -33,7 +33,6 @@ import de.k3b.android.androFotoFinder.Global; import de.k3b.android.androFotoFinder.R; -import de.k3b.android.androFotoFinder.queries.ContentProviderMediaExecuter; import de.k3b.android.androFotoFinder.queries.FotoSql; import de.k3b.android.osmdroid.ClickableIconOverlay; import de.k3b.android.osmdroid.IconFactory; @@ -96,8 +95,8 @@ protected OverlayManager doInBackground(QueryParameter... queryParameter) { Cursor cursor = null; try { - cursor = ContentProviderMediaExecuter.createCursorForQuery( - null, "MakerLoader", mContext, + cursor = FotoSql.getMediaDBApi().createCursorForQuery( + null, "MakerLoader", queryParameters, null); int itemCount = cursor.getCount(); diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/locationmap/PickerLocationMapFragment.java b/app/src/main/java/de/k3b/android/androFotoFinder/locationmap/PickerLocationMapFragment.java index fbb6c292..53b4bb73 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/locationmap/PickerLocationMapFragment.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/locationmap/PickerLocationMapFragment.java @@ -170,7 +170,7 @@ protected void onOk() { Activity activity = getActivity(); if (mMarkerId != NO_MARKER_ID) { - result = FotoSql.execGetPosition(null, activity, null, mMarkerId, + result = FotoSql.execGetPosition(null, null, mMarkerId, mDebugPrefix,"onOk"); } diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/media/PhotoPropertiesMediaDBCsvImportActivity.java b/app/src/main/java/de/k3b/android/androFotoFinder/media/PhotoPropertiesMediaDBCsvImportActivity.java index ed4ecff4..4fd1bf49 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/media/PhotoPropertiesMediaDBCsvImportActivity.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/media/PhotoPropertiesMediaDBCsvImportActivity.java @@ -19,12 +19,12 @@ package de.k3b.android.androFotoFinder.media; +import android.app.Activity; import android.content.ContentValues; import android.content.Intent; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; -import android.app.Activity; import android.util.Log; import android.view.View; import android.widget.TextView; @@ -206,7 +206,7 @@ private void updateDB(String dbgContext, String _path, long xmlLastFileModifyDat TagSql.setFileModifyDate(dbValues, new Date().getTime() / 1000); - mUpdateCount += TagSql.execUpdate(dbgContext, PhotoPropertiesMediaDBCsvImportActivity.this, path, xmlLastFileModifyDate, dbValues, VISIBILITY.PRIVATE_PUBLIC); + mUpdateCount += TagSql.execUpdate(dbgContext, path, xmlLastFileModifyDate, dbValues, VISIBILITY.PRIVATE_PUBLIC); mItemCount++; } } diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/queries/AndroidAlbumUtils.java b/app/src/main/java/de/k3b/android/androFotoFinder/queries/AndroidAlbumUtils.java index 9bceb428..56f8b5c8 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/queries/AndroidAlbumUtils.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/queries/AndroidAlbumUtils.java @@ -155,7 +155,7 @@ public static QueryParameter getQueryFromUriOrNull( QueryParameter query = QueryParameter.load(context.getContentResolver().openInputStream(uri)); if (query != null) { - Map found = FotoSql.execGetPathIdMap(context, path); + Map found = FotoSql.execGetPathIdMap(path); if ((found == null) || (found.size() == 0)) { AndroidAlbumUtils.albumMediaScan(dbgContext + " not found mediadb => ", context, new File(path), 1); } @@ -368,7 +368,7 @@ public static void insertToMediaDB(String dbgContext, @NonNull Context context, ContentValues values = new ContentValues(); String newAbsolutePath = PhotoPropertiesMediaFilesScanner.setFileFields(values, fileToBeScannedAndInserted); values.put(FotoSql.SQL_COL_EXT_MEDIA_TYPE, FotoSql.MEDIA_TYPE_ALBUM_FILE); - ContentProviderMediaExecuter.insertOrUpdateMediaDatabase(dbgContext, context, newAbsolutePath, values, null, 1l); + FotoSql.getMediaDBApi().insertOrUpdateMediaDatabase(dbgContext, newAbsolutePath, values, null, 1l); } } @@ -381,7 +381,7 @@ public static int albumMediaScan(String dbgContext, Context context, File _root, int result = 0; if (root != null) { List currentFiles = AlbumFile.getFilePaths(null, root, subDirLevels); - List databaseFiles = FotoSql.getAlbumFiles(context, FileUtils.tryGetCanonicalPath(root, null), subDirLevels); + List databaseFiles = FotoSql.getAlbumFiles(FileUtils.tryGetCanonicalPath(root, null), subDirLevels); List added = new ArrayList(); List removed = new ArrayList(); @@ -392,7 +392,7 @@ public static int albumMediaScan(String dbgContext, Context context, File _root, result++; } - result += FotoSql.deleteMedia(dbgMessage + "delete-obsolete", context, removed, false); + result += FotoSql.deleteMedia(dbgMessage + "delete-obsolete", removed, false); } return result; } diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/queries/ContentProviderMediaExecuter.java b/app/src/main/java/de/k3b/android/androFotoFinder/queries/ContentProviderMediaImpl.java similarity index 98% rename from app/src/main/java/de/k3b/android/androFotoFinder/queries/ContentProviderMediaExecuter.java rename to app/src/main/java/de/k3b/android/androFotoFinder/queries/ContentProviderMediaImpl.java index 7eee65be..45e6f3f7 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/queries/ContentProviderMediaExecuter.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/queries/ContentProviderMediaImpl.java @@ -35,7 +35,10 @@ import de.k3b.io.StringUtils; import de.k3b.io.VISIBILITY; -public class ContentProviderMediaExecuter { +/** + * Static Implementation of Context.getContentResolver()-ContentProvider based media api + */ +public class ContentProviderMediaImpl { public static Cursor createCursorForQuery( StringBuilder out_debugMessage, String dbgContext, final Context context, QueryParameter parameters, VISIBILITY visibility) { diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/queries/FotoSql.java b/app/src/main/java/de/k3b/android/androFotoFinder/queries/FotoSql.java index a725ba0f..6196bc98 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/queries/FotoSql.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/queries/FotoSql.java @@ -19,7 +19,6 @@ package de.k3b.android.androFotoFinder.queries; -import android.app.Activity; import android.content.ContentValues; import android.content.Context; import android.content.CursorLoader; @@ -280,6 +279,16 @@ public class FotoSql extends FotoSqlBase { */ private static final int SIZE_TRANLATION_LIMIT = SIZE_K * 10; + private static IMediaDBApi mediaDBApi; + + public static IMediaDBApi getMediaDBApi() { + return FotoSql.mediaDBApi; + } + + public static void setMediaDBApi(IMediaDBApi mediaDBApi) { + FotoSql.mediaDBApi = mediaDBApi; + } + public static final double getGroupFactor(final double _zoomLevel) { double zoomLevel = _zoomLevel; double result = GROUPFACTOR_FOR_Z0; @@ -755,10 +764,16 @@ public static boolean set(GalleryFilterParameter dest, String selectedAbsolutePa } /** converts content-Uri-with-id to full path */ - public static String execGetFotoPath(Context context, Uri uriWithID) { + public static String execGetFotoPath(Uri uriWithID) { Cursor c = null; try { - c = ContentProviderMediaExecuter.createCursorForQuery(null, "execGetFotoPath(uri)", context, uriWithID.toString(), null, null, null, FotoSql.SQL_COL_PATH); + c = mediaDBApi.createCursorForQuery( + null, + "execGetFotoPath(uri)", + uriWithID.toString(), + null, + null, null, + FotoSql.SQL_COL_PATH); if (c.moveToFirst()) { return DBUtils.getString(c,FotoSql.SQL_COL_PATH, null); } @@ -771,14 +786,20 @@ public static String execGetFotoPath(Context context, Uri uriWithID) { } /** search for all full-image-file-paths that matches pathfilter */ - public static List execGetFotoPaths(Context context, String pathFilter) { + public static List execGetFotoPaths(String pathFilter) { ArrayList result = new ArrayList(); Cursor c = null; try { - c = ContentProviderMediaExecuter.createCursorForQuery(null, "execGetFotoPaths(pathFilter)", context, SQL_TABLE_EXTERNAL_CONTENT_URI_FILE_NAME, - FotoSql.SQL_COL_PATH + " like ? and " + FILTER_EXPR_PRIVATE_PUBLIC, - new String[]{pathFilter}, FotoSql.SQL_COL_PATH, FotoSql.SQL_COL_PATH); + QueryParameter query = new QueryParameter() + .addFrom(SQL_TABLE_EXTERNAL_CONTENT_URI_FILE_NAME) + .addWhere(FotoSql.SQL_COL_PATH + " like ? and " + FILTER_EXPR_PRIVATE_PUBLIC, pathFilter) + .addColumn(FotoSql.SQL_COL_PATH) + .addOrderBy(FotoSql.SQL_COL_PATH); + c = mediaDBApi.createCursorForQuery( + null, + "execGetFotoPaths(pathFilter)", + query, null); while (c.moveToNext()) { result.add(c.getString(0)); } @@ -794,7 +815,7 @@ public static List execGetFotoPaths(Context context, String pathFilter) return result; } - public static IGeoRectangle execGetGeoRectangle(StringBuilder out_debugMessage, Context context, QueryParameter baseQuery, + public static IGeoRectangle execGetGeoRectangle(StringBuilder out_debugMessage, QueryParameter baseQuery, SelectedItems selectedItems, Object... dbgContext) { StringBuilder debugMessage = (out_debugMessage == null) ? StringUtils.createDebugMessage(Global.debugEnabledSql, dbgContext) @@ -823,7 +844,7 @@ public static IGeoRectangle execGetGeoRectangle(StringBuilder out_debugMessage, GeoRectangle result = null; Cursor c = null; try { - c = ContentProviderMediaExecuter.createCursorForQuery(debugMessage, "execGetGeoRectangle", context, query, VISIBILITY.PRIVATE_PUBLIC); + c = mediaDBApi.createCursorForQuery(debugMessage, "execGetGeoRectangle", query, VISIBILITY.PRIVATE_PUBLIC); if (c.moveToFirst()) { result = new GeoRectangle(); result.setLatitude(c.getDouble(0), c.getDouble(1)); @@ -846,7 +867,7 @@ public static IGeoRectangle execGetGeoRectangle(StringBuilder out_debugMessage, } /** gets IGeoPoint either from file if fullPath is not null else from db via id */ - public static IGeoPoint execGetPosition(StringBuilder out_debugMessage, Context context, + public static IGeoPoint execGetPosition(StringBuilder out_debugMessage, String fullPath, long id, Object... dbgContext) { StringBuilder debugMessage = (out_debugMessage == null) ? StringUtils.createDebugMessage(Global.debugEnabledSql, dbgContext) : out_debugMessage; QueryParameter query = new QueryParameter() @@ -867,7 +888,7 @@ public static IGeoPoint execGetPosition(StringBuilder out_debugMessage, Context GeoPoint result = null; Cursor c = null; try { - c = ContentProviderMediaExecuter.createCursorForQuery(debugMessage, "execGetPosition", context, query, VISIBILITY.PRIVATE_PUBLIC); + c = mediaDBApi.createCursorForQuery(debugMessage, "execGetPosition", query, VISIBILITY.PRIVATE_PUBLIC); if (c.moveToFirst()) { result = new GeoPoint(c.getDouble(0),c.getDouble(1)); return result; @@ -889,7 +910,7 @@ public static IGeoPoint execGetPosition(StringBuilder out_debugMessage, Context /** * @return returns a hashmap filename => mediaID */ - public static Map execGetPathIdMap(Context context, String... fileNames) { + public static Map execGetPathIdMap(String... fileNames) { Map result = new HashMap(); String whereFileNames = getWhereInFileNames(fileNames); @@ -902,7 +923,7 @@ public static Map execGetPathIdMap(Context context, String... file Cursor c = null; try { - c = ContentProviderMediaExecuter.createCursorForQuery(null, "execGetPathIdMap", context, query, null); + c = mediaDBApi.createCursorForQuery(null, "execGetPathIdMap", query, null); while (c.moveToNext()) { result.put(c.getString(1),c.getLong(0)); } @@ -941,7 +962,7 @@ public static String getWhereInFileNames(String... fileNames) { * "/storage/sdcard0/testFolder/image.jpg" becomes "/storage/sdcard0/renamedFolder/image.jpg" * @return number of updated items */ - public static int execRenameFolder(Context context, String pathOld, String pathNew) { + public static int execRenameFolder(String pathOld, String pathNew) { final String dbgContext = "FotoSql.execRenameFolder('" + pathOld + "' => '" + pathNew + "')"; // sql update file set path = newBegin + substing(path, begin+len) where path like newBegin+'%' @@ -961,7 +982,7 @@ public static int execRenameFolder(Context context, String pathOld, String pathN .addWhere(SQL_COL_EXT_MEDIA_TYPE + " IS NOT NULL") ; - SelectedFiles selectedFiles= getSelectedfiles(context, queryAffectedFiles, sqlColNewPathAlias, null); + SelectedFiles selectedFiles = getSelectedfiles(queryAffectedFiles, sqlColNewPathAlias, null); String[] paths = selectedFiles.getFileNames(); Long[] ids = selectedFiles.getIds(); @@ -972,7 +993,7 @@ public static int execRenameFolder(Context context, String pathOld, String pathN for (int i = 0; i < ids.length; i++) { values.put(SQL_COL_PATH, paths[i]); selectionArgs[0] = ids[i].toString(); - if (ContentProviderMediaExecuter.exexUpdateImpl(_dbgContext, context, values, FILTER_COL_PK, selectionArgs) < 0) + if (mediaDBApi.exexUpdateImpl(_dbgContext, values, FILTER_COL_PK, selectionArgs) < 0) return -1; _dbgContext = null; } @@ -995,21 +1016,21 @@ public static CursorLoader createCursorLoader(Context context, final QueryParame return loader; } - public static int execDeleteByPath(String dbgContext, Activity context, String parentDirString, VISIBILITY visibility) { - int delCount = ContentProviderMediaExecuter.deleteMedia(dbgContext, context, getFilterExprPathLikeWithVisibility(visibility), new String[]{parentDirString + "/%"}, true); + public static int execDeleteByPath(String dbgContext, String parentDirString, VISIBILITY visibility) { + int delCount = mediaDBApi.deleteMedia(dbgContext, getFilterExprPathLikeWithVisibility(visibility), new String[]{parentDirString + "/%"}, true); return delCount; } - public static int deleteMedia(String dbgContext, Context context, List pathsToBeRemoved, + public static int deleteMedia(String dbgContext, List pathsToBeRemoved, boolean preventDeleteImageFile) { if ((pathsToBeRemoved != null) && (pathsToBeRemoved.size() > 0)) { String whereDelete = SQL_COL_PATH + " in ('" + ListUtils.toString("','", pathsToBeRemoved) + "')"; - return ContentProviderMediaExecuter.deleteMedia(dbgContext, context, whereDelete, null, preventDeleteImageFile); + return mediaDBApi.deleteMedia(dbgContext, whereDelete, null, preventDeleteImageFile); } return 0; } - public static int deleteMediaWithNullPath(Context context) { + public static int deleteMediaWithNullPath() { /// delete where SQL_COL_PATH + " is null" throws null pointer exception QueryParameter wherePathIsNull = new QueryParameter(); wherePathIsNull.addWhere(SQL_COL_PATH + " is null"); @@ -1017,13 +1038,13 @@ public static int deleteMediaWithNullPath(Context context) { // return deleteMedia("delete without path (_data = null)", context, wherePathIsNull.toAndroidWhere(), null, false); - SelectedFiles filesWitoutPath = getSelectedfiles(context, wherePathIsNull, FotoSql.SQL_COL_PATH, VISIBILITY.PRIVATE_PUBLIC); + SelectedFiles filesWitoutPath = getSelectedfiles(wherePathIsNull, FotoSql.SQL_COL_PATH, VISIBILITY.PRIVATE_PUBLIC); String pksAsString = filesWitoutPath.toIdString(); if ((pksAsString != null) && (pksAsString.length() > 0)) { QueryParameter whereInIds = new QueryParameter(); FotoSql.setWhereSelectionPks(whereInIds, pksAsString); - return ContentProviderMediaExecuter.deleteMedia("delete without path (_data = null)", context, whereInIds.toAndroidWhere(), null, true); + return mediaDBApi.deleteMedia("delete without path (_data = null)", whereInIds.toAndroidWhere(), null, true); } return 0; } @@ -1058,17 +1079,17 @@ public static String getUriString(long imageID) { return SQL_TABLE_EXTERNAL_CONTENT_URI_FILE_NAME + "/" + imageID; } - public static SelectedFiles getSelectedfiles(Context context, String sqlWhere, VISIBILITY visibility) { + public static SelectedFiles getSelectedfiles(String sqlWhere, VISIBILITY visibility) { QueryParameter query = new QueryParameter(FotoSql.queryChangePath); query.addWhere(sqlWhere); query.addOrderBy(FotoSql.SQL_COL_PATH); - return getSelectedfiles(context, query, FotoSql.SQL_COL_PATH, visibility); + return getSelectedfiles(query, FotoSql.SQL_COL_PATH, visibility); } @Nullable - public static String getMinFolder(Context context, QueryParameter query, + public static String getMinFolder(QueryParameter query, boolean removeLastModifiedFromFilter) { QueryParameter queryModified = new QueryParameter(query); queryModified.clearColumns().addColumn("min(" + SQL_EXPR_FOLDER + ")"); @@ -1081,7 +1102,7 @@ public static String getMinFolder(Context context, QueryParameter query, Cursor c = null; try { - c = ContentProviderMediaExecuter.createCursorForQuery(null, "getCount", context, queryModified, null); + c = mediaDBApi.createCursorForQuery(null, "getCount", queryModified, null); if (c.moveToNext()) { return c.getString(0); } @@ -1094,13 +1115,13 @@ public static String getMinFolder(Context context, QueryParameter query, } @Nullable - public static long getCount(Context context, QueryParameter query) { + public static long getCount(QueryParameter query) { QueryParameter queryModified = new QueryParameter(query); queryModified.clearColumns().addColumn("count(*)"); Cursor c = null; try { - c = ContentProviderMediaExecuter.createCursorForQuery(null, "getCount", context, queryModified, null); + c = mediaDBApi.createCursorForQuery(null, "getCount", queryModified, null); if (c.moveToNext()) { return c.getLong(0); } @@ -1129,7 +1150,7 @@ public static CharSequence getStatisticsMessage(Context context, int prefixStrin Cursor c = null; try { - c = ContentProviderMediaExecuter.createCursorForQuery(null, "getCount", context, queryModified, null); + c = mediaDBApi.createCursorForQuery(null, "getCount", queryModified, null); if (c.moveToNext()) { final long count = c.getLong(0); long size = c.getLong(1); @@ -1160,12 +1181,12 @@ public static CharSequence getStatisticsMessage(Context context, int prefixStrin } @Nullable - private static SelectedFiles getSelectedfiles(Context context, QueryParameter query, String colnameForPath, VISIBILITY visibility) { + private static SelectedFiles getSelectedfiles(QueryParameter query, String colnameForPath, VISIBILITY visibility) { SelectedFiles result = null; Cursor c = null; try { - c = ContentProviderMediaExecuter.createCursorForQuery(null, "getSelectedfiles", context, query, visibility); + c = mediaDBApi.createCursorForQuery(null, "getSelectedfiles", query, visibility); int len = c.getCount(); Long[] ids = new Long[len]; String[] paths = new String[len]; @@ -1199,13 +1220,13 @@ public static Date getDate(Cursor cursor,int colDateTimeTaken) { } /** converts internal ID-list to string array of filenNames via media database. */ - public static List getFileNames(Context context, SelectedItems items, List ids, List paths, List datesPhotoTaken) { + public static List getFileNames(SelectedItems items, List ids, List paths, List datesPhotoTaken) { if (!items.isEmpty()) { // query ordered by DatePhotoTaken so that lower rename-numbers correspond to older images. QueryParameter parameters = new QueryParameter(queryAutoRename); setWhereSelectionPks(parameters, items); - List result = getFileNamesImpl(context, parameters, ids, paths, datesPhotoTaken); + List result = getFileNamesImpl(parameters, ids, paths, datesPhotoTaken); int size = result.size(); if (size > 0) { @@ -1217,13 +1238,13 @@ public static List getFileNames(Context context, SelectedItems items, Li } /** converts internal ID-list to string array of filenNames via media database. */ - public static String[] getFileNames(Context context, String pksAsListString , List ids, List paths, List datesPhotoTaken) { + public static String[] getFileNames(String pksAsListString, List ids, List paths, List datesPhotoTaken) { if ((pksAsListString != null) && !pksAsListString.isEmpty()) { // query ordered by DatePhotoTaken so that lower rename-numbers correspond to older images. QueryParameter parameters = new QueryParameter(queryAutoRename); setWhereSelectionPks(parameters, pksAsListString); - List result = getFileNamesImpl(context, parameters, ids, paths, datesPhotoTaken); + List result = getFileNamesImpl(parameters, ids, paths, datesPhotoTaken); int size = result.size(); if (size > 0) { @@ -1233,13 +1254,13 @@ public static String[] getFileNames(Context context, String pksAsListString , Li return null; } - private static List getFileNamesImpl(Context context, QueryParameter parameters, List ids, List paths, List datesPhotoTaken) { + private static List getFileNamesImpl(QueryParameter parameters, List ids, List paths, List datesPhotoTaken) { List result = (paths != null) ? paths : new ArrayList(); Cursor cursor = null; try { - cursor = ContentProviderMediaExecuter.createCursorForQuery(null, "getFileNames", context, parameters, VISIBILITY.PRIVATE_PUBLIC); + cursor = mediaDBApi.createCursorForQuery(null, "getFileNames", parameters, VISIBILITY.PRIVATE_PUBLIC); int colPath = cursor.getColumnIndex(SQL_COL_DISPLAY_TEXT); if (colPath == -1) colPath = cursor.getColumnIndex(SQL_COL_PATH); @@ -1294,8 +1315,8 @@ public static QueryParameter setWhereVisibility(QueryParameter parameters, VISIB return parameters; } - public static List getAlbumFiles(Context context, String path, int subDirLevels) { - SelectedFiles databaseFiles = FotoSql.getSelectedfiles(context, + public static List getAlbumFiles(String path, int subDirLevels) { + SelectedFiles databaseFiles = FotoSql.getSelectedfiles( SQL_COL_PATH +" like '" + path + "/%" + AlbumFile.SUFFIX_VALBUM + "' OR " + SQL_COL_PATH +" like '" + path + "/%" + AlbumFile.SUFFIX_QUERY + "'", null); String[] fileNames = (databaseFiles == null) ? null : databaseFiles.getFileNames(); @@ -1314,10 +1335,10 @@ public static List getAlbumFiles(Context context, String path, int subDi return paths; } - public static int execRename(Context context, String oldFullPath, String newFullPath) { + public static int execRename(String oldFullPath, String newFullPath) { ContentValues values = new ContentValues(); values.put(SQL_COL_PATH, newFullPath); - return ContentProviderMediaExecuter.execUpdate("rename file", context, oldFullPath, + return mediaDBApi.execUpdate("rename file", oldFullPath, values, null); } diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/queries/FotoThumbSql.java b/app/src/main/java/de/k3b/android/androFotoFinder/queries/FotoThumbSql.java index b9b00c78..bbf0661c 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/queries/FotoThumbSql.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/queries/FotoThumbSql.java @@ -66,7 +66,7 @@ private static String getStatistic(Context context, QueryParameter query, String Cursor c = null; try { - c = ContentProviderMediaExecuter.createCursorForQuery(null, mDebugPrefix + "getStatistic", context, query, VISIBILITY.PRIVATE_PUBLIC); + c = FotoSql.getMediaDBApi().createCursorForQuery(null, mDebugPrefix + "getStatistic", query, VISIBILITY.PRIVATE_PUBLIC); if (Global.debugEnabledSql) { Log.i(Global.LOG_CONTEXT, mDebugPrefix + "getStatistic " + c.getCount() + "\n\t" + query.toSqlString()); diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/queries/IMediaDBApi.java b/app/src/main/java/de/k3b/android/androFotoFinder/queries/IMediaDBApi.java new file mode 100644 index 00000000..87560b3b --- /dev/null +++ b/app/src/main/java/de/k3b/android/androFotoFinder/queries/IMediaDBApi.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2019 by k3b. + * + * This file is part of AndroFotoFinder / #APhotoManager. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see + */ +package de.k3b.android.androFotoFinder.queries; + +import android.content.ContentValues; +import android.database.Cursor; +import android.net.Uri; + +import de.k3b.database.QueryParameter; +import de.k3b.io.VISIBILITY; + +/** + * media database api + */ +public interface IMediaDBApi { + Cursor createCursorForQuery( + StringBuilder out_debugMessage, String dbgContext, + QueryParameter parameters, VISIBILITY visibility); + + Cursor createCursorForQuery(StringBuilder out_debugMessage, String dbgContext, final String from, final String sqlWhereStatement, + final String[] sqlWhereParameters, final String sqlSortOrder, + final String... sqlSelectColums); + + int execUpdate(String dbgContext, long id, ContentValues values); + + int execUpdate(String dbgContext, String path, ContentValues values, VISIBILITY visibility); + + int exexUpdateImpl(String dbgContext, ContentValues values, String sqlWhere, String[] selectionArgs); + + /** + * return id of inserted item + */ + Long insertOrUpdateMediaDatabase(String dbgContext, + String dbUpdateFilterJpgFullPathName, + ContentValues values, VISIBILITY visibility, + Long updateSuccessValue); + + /** + * every database insert should go through this. adds logging if enabled + */ + Uri execInsert(String dbgContext, ContentValues values); + + /** + * Deletes media items specified by where with the option to prevent cascade delete of the image. + */ + int deleteMedia(String dbgContext, String where, String[] selectionArgs, boolean preventDeleteImageFile); + + ContentValues getDbContent(long id); +} diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/queries/MediaDBContentprovider.java b/app/src/main/java/de/k3b/android/androFotoFinder/queries/MediaDBContentprovider.java new file mode 100644 index 00000000..645a6078 --- /dev/null +++ b/app/src/main/java/de/k3b/android/androFotoFinder/queries/MediaDBContentprovider.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2019 by k3b. + * + * This file is part of AndroFotoFinder / #APhotoManager. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see + */ +package de.k3b.android.androFotoFinder.queries; + +import android.content.ContentValues; +import android.content.Context; +import android.database.Cursor; +import android.net.Uri; + +import de.k3b.database.QueryParameter; +import de.k3b.io.VISIBILITY; + +/** + * Implementation of Context.getContentResolver()-ContentProvider based media api + */ +public class MediaDBContentprovider implements IMediaDBApi { + private final Context context; + + public MediaDBContentprovider(final Context context) { + this.context = context; + } + + @Override + public Cursor createCursorForQuery( + StringBuilder out_debugMessage, String dbgContext, + QueryParameter parameters, VISIBILITY visibility) { + return ContentProviderMediaImpl.createCursorForQuery( + out_debugMessage, dbgContext, context, parameters, visibility); + } + + @Override + public Cursor createCursorForQuery(StringBuilder out_debugMessage, String dbgContext, final String from, final String sqlWhereStatement, + final String[] sqlWhereParameters, final String sqlSortOrder, + final String... sqlSelectColums) { + return ContentProviderMediaImpl.createCursorForQuery( + out_debugMessage, dbgContext, context, from, sqlWhereStatement, + sqlWhereParameters, sqlSortOrder, sqlSelectColums); + } + + @Override + public int execUpdate(String dbgContext, long id, ContentValues values) { + return ContentProviderMediaImpl.execUpdate(dbgContext, context, id, values); + } + + @Override + public int execUpdate(String dbgContext, String path, ContentValues values, VISIBILITY visibility) { + return ContentProviderMediaImpl.execUpdate(dbgContext, context, path, values, visibility); + } + + @Override + public int exexUpdateImpl(String dbgContext, ContentValues values, String sqlWhere, String[] selectionArgs) { + return ContentProviderMediaImpl.exexUpdateImpl(dbgContext, context, values, sqlWhere, selectionArgs); + } + + /** + * return id of inserted item + */ + @Override + public Long insertOrUpdateMediaDatabase(String dbgContext, + String dbUpdateFilterJpgFullPathName, + ContentValues values, VISIBILITY visibility, + Long updateSuccessValue) { + return ContentProviderMediaImpl.insertOrUpdateMediaDatabase(dbgContext, context, + dbUpdateFilterJpgFullPathName, + values, visibility, + updateSuccessValue); + } + + /** + * every database insert should go through this. adds logging if enabled + */ + @Override + public Uri execInsert(String dbgContext, ContentValues values) { + return ContentProviderMediaImpl.execInsert(dbgContext, context, values); + } + + /** + * Deletes media items specified by where with the option to prevent cascade delete of the image. + */ + @Override + public int deleteMedia(String dbgContext, String where, String[] selectionArgs, boolean preventDeleteImageFile) { + return ContentProviderMediaImpl.deleteMedia(dbgContext, context, where, selectionArgs, preventDeleteImageFile); + } + + @Override + public ContentValues getDbContent(final long id) { + return ContentProviderMediaImpl.getDbContent(context, id); + } +} diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/queries/MediaImageDbReplacement.java b/app/src/main/java/de/k3b/android/androFotoFinder/queries/MediaImageDbReplacement.java index 4818a043..c059ae32 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/queries/MediaImageDbReplacement.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/queries/MediaImageDbReplacement.java @@ -187,7 +187,7 @@ public static int updateMedaiCopy(Context context, SQLiteDatabase db, Date lastU Cursor c = null; ContentValues contentValues = new ContentValues(); try { - c = ContentProviderMediaExecuter.createCursorForQuery(null, "execGetFotoPaths(pathFilter)", context, + c = ContentProviderMediaImpl.createCursorForQuery(null, "execGetFotoPaths(pathFilter)", context, query, null); while (c.moveToNext()) { getContentValues(c, contentValues); diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/queries/SqlJobTaskBase.java b/app/src/main/java/de/k3b/android/androFotoFinder/queries/SqlJobTaskBase.java index 4a580e90..515915d5 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/queries/SqlJobTaskBase.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/queries/SqlJobTaskBase.java @@ -65,8 +65,8 @@ protected SelectedItems doInBackground(QueryParameter... querys) { Cursor cursor = null; try { - cursor = ContentProviderMediaExecuter.createCursorForQuery( - null, "SqlJobTask", mContext, + cursor = FotoSql.getMediaDBApi().createCursorForQuery( + null, "SqlJobTask", query, null); int itemCount = cursor.getCount(); diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/tagDB/TagSql.java b/app/src/main/java/de/k3b/android/androFotoFinder/tagDB/TagSql.java index a9d7c4db..169329f3 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/tagDB/TagSql.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/tagDB/TagSql.java @@ -20,7 +20,6 @@ package de.k3b.android.androFotoFinder.tagDB; import android.content.ContentValues; -import android.content.Context; import android.database.Cursor; import android.provider.MediaStore; import android.util.Log; @@ -34,7 +33,6 @@ import de.k3b.android.androFotoFinder.Global; import de.k3b.android.androFotoFinder.media.PhotoPropertiesMediaDBContentValues; import de.k3b.android.androFotoFinder.queries.AndroidAlbumUtils; -import de.k3b.android.androFotoFinder.queries.ContentProviderMediaExecuter; import de.k3b.android.androFotoFinder.queries.FotoSql; import de.k3b.android.util.PhotoPropertiesMediaFilesScanner; import de.k3b.database.QueryParameter; @@ -259,7 +257,7 @@ public static void addWhereTagsIncluded(QueryParameter resultQuery, List } } - public static int fixPrivate(Context context) { + public static int fixPrivate() { // update ... set media_type=1001 where media_type=1 and tags like '%;PRIVATE;%' ContentValues values = new ContentValues(); values.put(SQL_COL_EXT_MEDIA_TYPE, MEDIA_TYPE_IMAGE_PRIVATE); @@ -273,7 +271,7 @@ public static int fixPrivate(Context context) { PhotoPropertiesUtil.IMG_TYPE_PRIVATE + "'")); } where.append(")"); - return ContentProviderMediaExecuter.exexUpdateImpl("Fix visibility private", context, + return getMediaDBApi().exexUpdateImpl("Fix visibility private", values, where.toString(), new String[] {"%;" + VISIBILITY.TAG_PRIVATE + ";%"}); } @@ -332,7 +330,7 @@ public static void setFileModifyDate(ContentValues values, long fileModifyDateSe * @param allowSetNulls if one of these columns are null, the set null is copied, too * @return number of changed db items */ - public static int updateDB(String dbgContext, Context context, String oldFullJpgFilePath, + public static int updateDB(String dbgContext, String oldFullJpgFilePath, PhotoPropertiesUpdateHandler jpg, MediaFormatter.FieldID... allowSetNulls) { if ((jpg != null) && (!PhotoPropertiesMediaFilesScanner.isNoMedia(oldFullJpgFilePath))) { ContentValues dbValues = new ContentValues(); @@ -358,7 +356,7 @@ public static int updateDB(String dbgContext, Context context, String oldFullJpg TagSql.setXmpFileModifyDate(dbValues, xmpFilelastModified); TagSql.setFileModifyDate(dbValues, newFullJpgFilePath); - return TagSql.execUpdate(dbgContext, context, oldFullJpgFilePath, + return TagSql.execUpdate(dbgContext, oldFullJpgFilePath, TagSql.EXT_LAST_EXT_SCAN_UNKNOWN, dbValues, VISIBILITY.PRIVATE_PUBLIC); } @@ -368,21 +366,21 @@ public static int updateDB(String dbgContext, Context context, String oldFullJpg } - public static int execUpdate(String dbgContext, Context context, String path, long xmpFileDate, ContentValues values, VISIBILITY visibility) { + public static int execUpdate(String dbgContext, String path, long xmpFileDate, ContentValues values, VISIBILITY visibility) { if ((!Global.Media.enableXmpNone) || (xmpFileDate == EXT_LAST_EXT_SCAN_UNKNOWN)) { - return ContentProviderMediaExecuter.execUpdate(dbgContext, context, path, values, visibility); + return getMediaDBApi().execUpdate(dbgContext, path, values, visibility); } - return ContentProviderMediaExecuter.exexUpdateImpl(dbgContext, context, values, FILTER_EXPR_PATH_LIKE_XMP_DATE, new String[]{path, Long.toString(xmpFileDate)}); + return getMediaDBApi().exexUpdateImpl(dbgContext, values, FILTER_EXPR_PATH_LIKE_XMP_DATE, new String[]{path, Long.toString(xmpFileDate)}); } /** return how many photos exist that have one or more tags from list */ - public static int getTagRefCount(Context context, List tags) { + public static int getTagRefCount(List tags) { QueryParameter query = new QueryParameter() .addColumn("count(*)").addFrom(SQL_TABLE_EXTERNAL_CONTENT_URI_FILE_NAME); if (addWhereAnyOfTags(query, tags) > 0) { Cursor c = null; try { - c = ContentProviderMediaExecuter.createCursorForQuery(null, "getTagRefCount", context, query, VISIBILITY.PRIVATE_PUBLIC); + c = getMediaDBApi().createCursorForQuery(null, "getTagRefCount", query, VISIBILITY.PRIVATE_PUBLIC); if (c.moveToFirst()) { return c.getInt(0); } @@ -412,12 +410,11 @@ public TagWorflowItem(long id, String path, List tags, long xmpLastModif /** * converts selectedItemPks and/or anyOfTags to TagWorflowItem-s - * @param context * @param selectedItemPks if not null list of comma seperated item-pks * @param anyOfTags if not null list of tag-s where at least one oft the tag must be in the photo. * @return */ - public static List loadTagWorflowItems(Context context, String selectedItemPks, List anyOfTags) { + public static List loadTagWorflowItems(String selectedItemPks, List anyOfTags) { QueryParameter query = new QueryParameter() .addColumn(TagSql.SQL_COL_PK, TagSql.SQL_COL_PATH, TagSql.SQL_COL_EXT_TAGS, TagSql.SQL_COL_EXT_XMP_LAST_MODIFIED_DATE); @@ -436,7 +433,7 @@ public static List loadTagWorflowItems(Context context, String s if (filterCount > 0) { try { - c = ContentProviderMediaExecuter.createCursorForQuery(null, "loadTagWorflowItems", context, query, VISIBILITY.PRIVATE_PUBLIC); + c = getMediaDBApi().createCursorForQuery(null, "loadTagWorflowItems", query, VISIBILITY.PRIVATE_PUBLIC); if (c.moveToFirst()) { do { result.add(new TagWorflowItem(c.getLong(0), c.getString(1), TagConverter.fromString(c.getString(2)), diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/tagDB/TagWorflow.java b/app/src/main/java/de/k3b/android/androFotoFinder/tagDB/TagWorflow.java index 20962708..5e5bd9ea 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/tagDB/TagWorflow.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/tagDB/TagWorflow.java @@ -30,12 +30,12 @@ import de.k3b.android.androFotoFinder.Global; import de.k3b.android.util.AndroidFileCommands; +import de.k3b.io.FileCommands; import de.k3b.io.IProgessListener; import de.k3b.io.collections.SelectedFiles; -import de.k3b.io.FileCommands; import de.k3b.media.MediaFormatter; -import de.k3b.media.PhotoPropertiesXmpSegment; import de.k3b.media.PhotoPropertiesUpdateHandler; +import de.k3b.media.PhotoPropertiesXmpSegment; import de.k3b.tagDB.Tag; import de.k3b.tagDB.TagConverter; import de.k3b.tagDB.TagProcessor; @@ -124,7 +124,7 @@ protected int updateTags(TagSql.TagWorflowItem tagWorflowItemFromDB, List loadTagWorflowItems(Context context, String selectedItems, List anyOfTags) { - return TagSql.loadTagWorflowItems(context, selectedItems, anyOfTags); + return TagSql.loadTagWorflowItems(selectedItems, anyOfTags); } } diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/tagDB/TagsPickerFragment.java b/app/src/main/java/de/k3b/android/androFotoFinder/tagDB/TagsPickerFragment.java index a66f9cf6..262f7c33 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/tagDB/TagsPickerFragment.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/tagDB/TagsPickerFragment.java @@ -580,14 +580,14 @@ public boolean showTagDeleteDialog(final Tag item) { List rootList = new ArrayList(); rootList.add(item); - final int rootTagReferenceCount = TagSql.getTagRefCount(getActivity(), rootList); + final int rootTagReferenceCount = TagSql.getTagRefCount(rootList); List children = item.getChildren(loadTagRepositoryItems(false), true, false); if (children != null) rootList.addAll(children); final int allTagReferenceCount = (children == null) ? rootTagReferenceCount - : TagSql.getTagRefCount(getActivity(), rootList); + : TagSql.getTagRefCount(rootList); if (children == null) { chkDeleteChildren.setVisibility(View.GONE); @@ -690,7 +690,7 @@ protected View onCreateContentView(Activity parent) { List rootList = new ArrayList(); rootList.add(tag); - final int rootTagReferenceCount = TagSql.getTagRefCount(getActivity(), rootList); + final int rootTagReferenceCount = TagSql.getTagRefCount(rootList); chkUpdatePhotos.setText(getString(R.string.tags_update_photos) + " (" + rootTagReferenceCount + ")"); diff --git a/app/src/main/java/de/k3b/android/util/AndroidFileCommands.java b/app/src/main/java/de/k3b/android/util/AndroidFileCommands.java index 72f04c3a..5ac78acb 100644 --- a/app/src/main/java/de/k3b/android/util/AndroidFileCommands.java +++ b/app/src/main/java/de/k3b/android/util/AndroidFileCommands.java @@ -42,7 +42,6 @@ import de.k3b.android.androFotoFinder.R; import de.k3b.android.androFotoFinder.directory.DirectoryPickerFragment; import de.k3b.android.androFotoFinder.media.AndroidPhotoPropertiesBulkUpdateService; -import de.k3b.android.androFotoFinder.queries.ContentProviderMediaExecuter; import de.k3b.android.androFotoFinder.queries.DatabaseHelper; import de.k3b.android.androFotoFinder.queries.FotoSql; import de.k3b.android.androFotoFinder.tagDB.TagSql; @@ -219,9 +218,9 @@ public int execRename(File srcDirFile, String newFolderName) { boolean isDir = srcDirFile.isDirectory(); if (srcDirFile.renameTo(destDirFile)) { if (isDir) { - modifyCount = FotoSql.execRenameFolder(this.mContext, srcDirFile.getAbsolutePath() + "/", destDirFile.getAbsolutePath() + "/"); + modifyCount = FotoSql.execRenameFolder(srcDirFile.getAbsolutePath() + "/", destDirFile.getAbsolutePath() + "/"); } else { - modifyCount = FotoSql.execRename(mContext, srcDirFile.getAbsolutePath(), destDirFile.getAbsolutePath()); + modifyCount = FotoSql.execRename(srcDirFile.getAbsolutePath(), destDirFile.getAbsolutePath()); } if (modifyCount < 0) { destDirFile.renameTo(srcDirFile); // error: undo change @@ -329,7 +328,7 @@ public int deleteFiles(SelectedFiles fotos, IProgessListener progessListener) { QueryParameter where = new QueryParameter(); FotoSql.setWhereSelectionPks (where, fotos.toIdString()); - ContentProviderMediaExecuter.deleteMedia("AndroidFileCommands.deleteFiles", mContext, where.toAndroidWhere(), null, true); + FotoSql.getMediaDBApi().deleteMedia("AndroidFileCommands.deleteFiles", where.toAndroidWhere(), null, true); } return deleteCount; } @@ -469,7 +468,7 @@ public int setGeo(double latitude, double longitude, SelectedFiles selectedItems } File file = files[i]; PhotoPropertiesUpdateHandler jpg = createWorkflow(null, dbgContext).saveLatLon(file, latitude, longitude); - resultFile += TagSql.updateDB(dbgContext, applicationContext, + resultFile += TagSql.updateDB(dbgContext, file.getAbsolutePath(), jpg, MediaFormatter.FieldID.latitude_longitude); itemcount++; addTransactionLog(selectedItems.getId(i), file.getAbsolutePath(), now, MediaTransactionLogEntryType.GPS, latLong); diff --git a/app/src/main/java/de/k3b/android/util/IntentUtil.java b/app/src/main/java/de/k3b/android/util/IntentUtil.java index 945a335a..9bf1ab41 100644 --- a/app/src/main/java/de/k3b/android/util/IntentUtil.java +++ b/app/src/main/java/de/k3b/android/util/IntentUtil.java @@ -65,7 +65,7 @@ public static File getExistingFileOrNull(Context context, Uri uri) { path = uri.getPath(); } else if ("content".equals(scheme)) { // try to translate via media db - path = FotoSql.execGetFotoPath(context, uri); + path = FotoSql.execGetFotoPath(uri); if (path != null) { if (Global.debugEnabled) { Log.i(Global.LOG_CONTEXT, "Translate from '" + uri + diff --git a/app/src/main/java/de/k3b/android/util/PhotoPropertiesMediaFilesScanner.java b/app/src/main/java/de/k3b/android/util/PhotoPropertiesMediaFilesScanner.java index 2388e523..5d9ac8de 100644 --- a/app/src/main/java/de/k3b/android/util/PhotoPropertiesMediaFilesScanner.java +++ b/app/src/main/java/de/k3b/android/util/PhotoPropertiesMediaFilesScanner.java @@ -44,7 +44,6 @@ import de.k3b.LibGlobal; import de.k3b.android.androFotoFinder.Global; import de.k3b.android.androFotoFinder.media.PhotoPropertiesMediaDBContentValues; -import de.k3b.android.androFotoFinder.queries.ContentProviderMediaExecuter; import de.k3b.android.androFotoFinder.queries.FotoSql; import de.k3b.android.androFotoFinder.tagDB.TagSql; import de.k3b.database.QueryParameter; @@ -150,7 +149,7 @@ public static int hideFolderMedia(Activity context, String path) { if (Global.debugEnabled) { Log.i(Global.LOG_CONTEXT, CONTEXT + " hideFolderMedia: delete from media db " + path + "/**"); } - result = FotoSql.execDeleteByPath(CONTEXT + " hideFolderMedia", context, path, VISIBILITY.PRIVATE_PUBLIC); + result = FotoSql.execDeleteByPath(CONTEXT + " hideFolderMedia", path, VISIBILITY.PRIVATE_PUBLIC); if (result > 0) { PhotoPropertiesMediaFilesScanner.notifyChanges(context, "hide " + path + "/**"); } @@ -171,7 +170,7 @@ public int updateMediaDatabase_Android42(Context context, String[] oldPathNames, } if (hasNew) { result = insertIntoMediaDatabase(context, newPathNames); } - TagSql.fixPrivate(context); + TagSql.fixPrivate(); return result; } @@ -208,7 +207,7 @@ private int insertIntoMediaDatabase(Context context, String[] newPathNames) { Log.i(Global.LOG_CONTEXT, CONTEXT + "A42 scanner starting with " + newPathNames.length + " files " + newPathNames[0] + "..."); } - Map inMediaDb = FotoSql.execGetPathIdMap(context.getApplicationContext(), newPathNames); + Map inMediaDb = FotoSql.execGetPathIdMap(newPathNames); for (String fileName : newPathNames) { if (fileName != null) { @@ -233,8 +232,8 @@ public Long insertOrUpdateMediaDatabase(String dbgContext, Context context, if ((currentJpgFile != null) && currentJpgFile.exists() && currentJpgFile.canRead()) { ContentValues values = createDefaultContentValues(); getExifFromFile(values, currentJpgFile); - Long result = ContentProviderMediaExecuter.insertOrUpdateMediaDatabase( - dbgContext, context, dbUpdateFilterJpgFullPathName, + Long result = FotoSql.getMediaDBApi().insertOrUpdateMediaDatabase( + dbgContext, dbUpdateFilterJpgFullPathName, values, VISIBILITY.PRIVATE_PUBLIC, updateSuccessValue); return result; @@ -249,7 +248,7 @@ private int deleteInMediaDatabase(Context context, String[] oldPathNames) { if ((oldPathNames != null) && (oldPathNames.length > 0)) { String sqlWhere = FotoSql.getWhereInFileNames(oldPathNames); try { - modifyCount = ContentProviderMediaExecuter.deleteMedia(CONTEXT + "deleteInMediaDatabase", context, sqlWhere, null, true); + modifyCount = FotoSql.getMediaDBApi().deleteMedia(CONTEXT + "deleteInMediaDatabase", sqlWhere, null, true); if (Global.debugEnabled) { Log.d(Global.LOG_CONTEXT, CONTEXT + "deleteInMediaDatabase(len=" + oldPathNames.length + ", files='" + oldPathNames[0] + "'...) result count=" + modifyCount); } @@ -301,7 +300,7 @@ private int renameInMediaDatabase(Context context, Map old2NewFi Cursor c = null; try { - c = ContentProviderMediaExecuter.createCursorForQuery(null, "renameInMediaDatabase", context, query, VISIBILITY.PRIVATE_PUBLIC); + c = FotoSql.getMediaDBApi().createCursorForQuery(null, "renameInMediaDatabase", query, VISIBILITY.PRIVATE_PUBLIC); int pkColNo = c.getColumnIndex(FotoSql.SQL_COL_PK); int pathColNo = c.getColumnIndex(FotoSql.SQL_COL_PATH); while (c.moveToNext()) { @@ -432,7 +431,7 @@ public int updatePathRelatedFields(Context context, Cursor cursor, String newAbs String oldAbsolutePath = cursor.getString(columnIndexPath); int id = cursor.getInt(columnIndexPk); setPathRelatedFieldsIfNeccessary(values, newAbsolutePath, oldAbsolutePath); - return ContentProviderMediaExecuter.execUpdate("updatePathRelatedFields", context, id, values); + return FotoSql.getMediaDBApi().execUpdate("updatePathRelatedFields", id, values); } /** sets the path related fields */ @@ -464,7 +463,7 @@ private int update_Android42(String dbgContext, Context context, long id, File f if ((file != null) && file.exists() && file.canRead()) { ContentValues values = createDefaultContentValues(); getExifFromFile(values, file); - return ContentProviderMediaExecuter.execUpdate(dbgContext, context, id, values); + return FotoSql.getMediaDBApi().execUpdate(dbgContext, id, values); } return 0; } @@ -488,7 +487,7 @@ private int insert_Android42(String dbgContext, Context context, File file) { FotoSql.addDateAdded(values); getExifFromFile(values, file); - return (null != ContentProviderMediaExecuter.execInsert(dbgContext, context, values)) ? 1 : 0; + return (null != FotoSql.getMediaDBApi().execInsert(dbgContext, values)) ? 1 : 0; } return 0; }