From 513f2a1cd13a335358e6c5618e4163534a06a6cb Mon Sep 17 00:00:00 2001 From: k3b <1374583+k3b@users.noreply.github.com> Date: Fri, 2 Nov 2018 11:55:12 +0100 Subject: [PATCH 01/35] Prepare for addig lib com.github.k3b.ToGoZip:libK3bZip:L2.0.15 --- app/src/main/res/values/donottranslate.xml | 2 +- fotolib2/build.gradle | 5 +++++ fotolib2/src/main/java/de/k3b/io/DateUtil.java | 9 +++++---- fotolib2/src/main/java/de/k3b/io/ListUtils.java | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/main/res/values/donottranslate.xml b/app/src/main/res/values/donottranslate.xml index 875bad4d..b71e7e6e 100644 --- a/app/src/main/res/values/donottranslate.xml +++ b/app/src/main/res/values/donottranslate.xml @@ -113,7 +113,7 @@ this program. If not, see osmdroid library to display online maps from Open Street Map
  • - Andrid Stringlate app to allow the app + Android Stringlate app to allow the app user to thranslate this app to other gui-languages
  • mapsforge library to display offline maps
  • diff --git a/fotolib2/build.gradle b/fotolib2/build.gradle index 222ab021..a55aada7 100644 --- a/fotolib2/build.gradle +++ b/fotolib2/build.gradle @@ -23,6 +23,11 @@ dependencies { // https://github.com/drewnoakes/metadata-extractor/wiki/GettingStarted licence: http://www.apache.org/licenses/LICENSE-2.0 // 2.10.1 includes more recent xmpcore that generates java-8 bytecode not supported by android yet compile ('com.drewnoakes:metadata-extractor:2.10.1') { transitive = false; } // 2.8.1 + + // https://jitpack.io/com/github/k3b/ToGoZip/L2.0.15/build.log + // https://jitpack.io/com/github/k3b/ToGoZip/libK3bZip/L2.0.15/ + // implementation('com.github.k3b.ToGoZip:libK3bZip:L2.0.15') { transitive = false; } + } // workaround because android-studio does not make the test resources available diff --git a/fotolib2/src/main/java/de/k3b/io/DateUtil.java b/fotolib2/src/main/java/de/k3b/io/DateUtil.java index fc7af937..624883d0 100644 --- a/fotolib2/src/main/java/de/k3b/io/DateUtil.java +++ b/fotolib2/src/main/java/de/k3b/io/DateUtil.java @@ -1,7 +1,7 @@ /* * Copyright (c) 2016-2018 by k3b. * - * This file is part of AndroFotoFinder / #APhotoManager. + * This file is part of AndroFotoFinder / #APhotoManager and toGoZip. * * 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 @@ -33,9 +33,10 @@ */ public class DateUtil { - public static final DateFormat IsoDateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ROOT); - public static final DateFormat IsoDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.ROOT); - public static final DateFormat IsoDateFormat2 = new SimpleDateFormat("yyyyMMdd", Locale.ROOT); + // cannot use Locale.ROOT because it requires api-9. this is api-7 + public static final DateFormat IsoDateTimeFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.US); + public static final DateFormat IsoDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.US); + public static final DateFormat IsoDateFormat2 = new SimpleDateFormat("yyyyMMdd", Locale.US); public static final TimeZone UTC = TimeZone.getTimeZone("UTC"); diff --git a/fotolib2/src/main/java/de/k3b/io/ListUtils.java b/fotolib2/src/main/java/de/k3b/io/ListUtils.java index b7fb4009..d9b93bf6 100644 --- a/fotolib2/src/main/java/de/k3b/io/ListUtils.java +++ b/fotolib2/src/main/java/de/k3b/io/ListUtils.java @@ -1,7 +1,7 @@ /* * Copyright (c) 2017-2018 by k3b. * - * This file is part of AndroFotoFinder / #APhotoManager. + * This file is part of AndroFotoFinder / #APhotoManager and toGoZip. * * 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 From e3d43e2499e53c1748afec332a51c8da04dc41bc Mon Sep 17 00:00:00 2001 From: k3b <1374583+k3b@users.noreply.github.com> Date: Fri, 2 Nov 2018 16:00:40 +0100 Subject: [PATCH 02/35] refactored: renamed FotoLibGlobal to LibGlobal to have common code with toGoZip project --- .../androFotoFinder/AndroFotoFinderApp.java | 9 +++-- .../androFotoFinder/ExifEditActivity.java | 6 ++-- .../androFotoFinder/FotoGalleryActivity.java | 4 +-- .../GalleryFilterActivity.java | 6 ++-- .../androFotoFinder/SettingsActivity.java | 36 +++++++++---------- .../StringFormatResourceTests.java | 4 +-- .../directory/DirectoryPickerFragment.java | 4 +-- .../gallery/cursor/GalleryCursorFragment.java | 4 +-- .../androFotoFinder/queries/FotoSql.java | 12 +++---- .../android/androFotoFinder/tagDB/TagSql.java | 6 ++-- .../de/k3b/android/util/MediaScanner.java | 4 +-- .../k3b/android/widget/BaseQueryActivity.java | 4 +-- .../{FotoLibGlobal.java => LibGlobal.java} | 2 +- .../src/main/java/de/k3b/io/DateUtil.java | 3 +- .../java/de/k3b/io/DirectoryFormatter.java | 7 ++-- .../src/main/java/de/k3b/io/FileCommands.java | 30 ++++++++-------- .../src/main/java/de/k3b/io/FileUtils.java | 15 ++++---- .../de/k3b/io/GalleryFilterParameter.java | 4 +-- .../src/main/java/de/k3b/io/ListUtils.java | 3 +- .../src/main/java/de/k3b/io/OSDirectory.java | 6 ++-- .../main/java/de/k3b/io/PhotoWorkFlowDto.java | 12 +++---- .../java/de/k3b/io/RuleFileNameProcessor.java | 4 +-- .../src/main/java/de/k3b/io/StringUtils.java | 7 ++-- .../src/main/java/de/k3b/io/VISIBILITY.java | 4 +-- .../java/de/k3b/media/ExifInterfaceEx.java | 16 ++++----- .../java/de/k3b/media/ImageMetaReader.java | 8 ++--- .../java/de/k3b/media/JpgMetaWorkflow.java | 12 +++---- .../java/de/k3b/media/MediaXmpSegment.java | 12 +++---- .../java/de/k3b/media/MetaWriterExifXml.java | 22 ++++++------ .../main/java/de/k3b/media/XmpNamespace.java | 4 +-- .../main/java/de/k3b/media/XmpSegment.java | 4 +-- .../main/java/de/k3b/tagDB/TagRepository.java | 12 +++---- .../transactionlog/TransactionLogParser.java | 6 ++-- .../transactionlog/TransactionLoggerBase.java | 10 +++--- .../io/FileCommandAutoIntegrationTests.java | 8 ++--- .../ExifInterfaceExIntegrationTests.java | 6 ++-- .../media/ExifInterfaceIntegrationTests.java | 6 ++-- .../ImageMetaReaderIntegrationTests.java | 6 ++-- .../JpgMetaWorkflowIntegratoinTests.java | 12 +++---- .../MediaXmpSegmentIntegrationTests.java | 6 ++-- .../test/java/de/k3b/media/MediaXmpTests.java | 6 ++-- .../MetaWriterExifXmlIntegrationTests.java | 6 ++-- .../TransactionLogParserTests.java | 6 ++-- .../translations/TranslationStatistics.java | 3 +- .../TranslationStatisticsTests.java | 5 +-- 45 files changed, 187 insertions(+), 185 deletions(-) rename fotolib2/src/main/java/de/k3b/{FotoLibGlobal.java => LibGlobal.java} (99%) 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 d1258624..5c85f272 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/AndroFotoFinderApp.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/AndroFotoFinderApp.java @@ -25,13 +25,12 @@ import android.util.Log; import org.osmdroid.api.IMapView; -import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; import java.util.ArrayList; import java.util.Collections; import java.util.Date; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.android.GuiUtil; import de.k3b.android.androFotoFinder.imagedetail.HugeImageLoader; import de.k3b.android.androFotoFinder.queries.FotoSql; @@ -75,8 +74,8 @@ public static RefWatcher getRefWatcher(Context context) { super.onCreate(); - FotoLibGlobal.appName = getString(R.string.app_name); - FotoLibGlobal.appVersion = GuiUtil.getAppVersionName(this); + LibGlobal.appName = getString(R.string.app_name); + LibGlobal.appVersion = GuiUtil.getAppVersionName(this); Global.pickHistoryFile = getDatabasePath("pickHistory.geouri.txt"); SettingsActivity.prefs2Global(this); @@ -91,7 +90,7 @@ public static RefWatcher getRefWatcher(Context context) { Collections.addAll(QueryParameter.sParserDefaultSelect, FotoSql.DEFAULT_GALLERY_COLUMNS); mCrashSaveToFile = new LogCat(this, Global.LOG_CONTEXT, HugeImageLoader.LOG_TAG, PhotoViewAttacher.LOG_TAG, CupcakeGestureDetector.LOG_TAG, - FotoLibGlobal.LOG_TAG, ThumbNailUtils.LOG_TAG, IMapView.LOGTAG, + LibGlobal.LOG_TAG, ThumbNailUtils.LOG_TAG, IMapView.LOGTAG, ExifInterface.LOG_TAG, ImageMetaReader.LOG_TAG); ThumbNailUtils.init(this, null); diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/ExifEditActivity.java b/app/src/main/java/de/k3b/android/androFotoFinder/ExifEditActivity.java index 82687f01..9c4eb353 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/ExifEditActivity.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/ExifEditActivity.java @@ -53,7 +53,7 @@ import java.util.Map; import java.util.TimeZone; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.android.androFotoFinder.queries.FotoSql; import de.k3b.android.androFotoFinder.tagDB.TagsPickerFragment; import de.k3b.android.util.AndroidFileCommands; @@ -315,10 +315,10 @@ private void saveGuiToExif(String function) { // used to analyse error #91:. private void debugChanges(String function) { - if (FotoLibGlobal.debugEnabledJpgMetaIo){ + if (LibGlobal.debugEnabledJpgMetaIo){ MediaDiffCopy diff = new MediaDiffCopy(true, true); diff.setDiff(mInitialData, mCurrentData); - Log.d(FotoLibGlobal.LOG_TAG, mDebugPrefix + " " + Log.d(LibGlobal.LOG_TAG, mDebugPrefix + " " + function + "\n\t" + diff + "\n\t" + SETTINGS_KEY_INITIAL + "=" + mInitialData.toString() + ";\n\t" diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/FotoGalleryActivity.java b/app/src/main/java/de/k3b/android/androFotoFinder/FotoGalleryActivity.java index 59a1f848..41ca82d3 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/FotoGalleryActivity.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/FotoGalleryActivity.java @@ -31,7 +31,7 @@ import android.view.MenuInflater; import android.view.MenuItem; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.android.androFotoFinder.directory.DirectoryGui; import de.k3b.android.androFotoFinder.gallery.cursor.GalleryCursorFragment; import de.k3b.android.androFotoFinder.imagedetail.ImageDetailActivityViewPager; @@ -96,7 +96,7 @@ protected void onCreate(Bundle savedInstanceState) { if (BuildConfig.DEBUG) { // not implemented yet - FotoLibGlobal.itpcWriteSupport = false; + LibGlobal.itpcWriteSupport = false; } if (Global.debugEnabled && (intent != null)) { Log.d(Global.LOG_CONTEXT, mDebugPrefix + "onCreate " + intent.toUri(Intent.URI_INTENT_SCHEME)); diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/GalleryFilterActivity.java b/app/src/main/java/de/k3b/android/androFotoFinder/GalleryFilterActivity.java index b636310a..5a0e00dd 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/GalleryFilterActivity.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/GalleryFilterActivity.java @@ -44,7 +44,7 @@ import java.util.List; import java.util.Locale; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.android.androFotoFinder.directory.DirectoryLoaderTask; import de.k3b.android.androFotoFinder.directory.DirectoryPickerFragment; import de.k3b.android.androFotoFinder.imagedetail.ImageDetailMetaDialogBuilder; @@ -210,7 +210,7 @@ public void onClick(View v) { showDirectoryPickerForFilterParamValue( mDebugPrefix + " date picker " + path, FotoSql.queryGroupByDate, false, - FotoLibGlobal.datePickerUseDecade, path); + LibGlobal.datePickerUseDecade, path); } }); cmd = (Button) findViewById(R.id.cmd_select_lat_lon); @@ -466,7 +466,7 @@ public void onClick(View v) { protected void showVisibility(VISIBILITY visibility) { VISIBILITY actualVisibility = visibility; if (actualVisibility == VISIBILITY.DEFAULT) { - actualVisibility = (FotoLibGlobal.visibilityShowPrivateByDefault) ? VISIBILITY.PRIVATE_PUBLIC : VISIBILITY.PUBLIC; + actualVisibility = (LibGlobal.visibilityShowPrivateByDefault) ? VISIBILITY.PRIVATE_PUBLIC : VISIBILITY.PUBLIC; } switch (actualVisibility) { diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/SettingsActivity.java b/app/src/main/java/de/k3b/android/androFotoFinder/SettingsActivity.java index bcd59931..2ebc125e 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/SettingsActivity.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/SettingsActivity.java @@ -36,11 +36,9 @@ import android.view.Display; import android.widget.Toast; -import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants; - import java.io.File; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.android.androFotoFinder.imagedetail.HugeImageLoader; import de.k3b.android.util.MediaScanner; import de.k3b.android.util.MediaScannerExifInterface; @@ -98,12 +96,12 @@ public boolean onPreferenceChange(Preference preference, Object newValue) { mediaUpdateStrategyPreference.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { - FotoLibGlobal.mediaUpdateStrategy = (String) newValue; - setPref(FotoLibGlobal.mediaUpdateStrategy, mediaUpdateStrategyPreference, R.array.pref_media_update_strategy_names); + LibGlobal.mediaUpdateStrategy = (String) newValue; + setPref(LibGlobal.mediaUpdateStrategy, mediaUpdateStrategyPreference, R.array.pref_media_update_strategy_names); return true; } }); - setPref(FotoLibGlobal.mediaUpdateStrategy, mediaUpdateStrategyPreference, R.array.pref_media_update_strategy_names); + setPref(LibGlobal.mediaUpdateStrategy, mediaUpdateStrategyPreference, R.array.pref_media_update_strategy_names); findPreference("debugClearLog").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override @@ -151,13 +149,13 @@ public static void global2Prefs(Context context) { prefs.putBoolean("debugEnabledMemory", Global.debugEnabledMemory); - prefs.putBoolean("datePickerUseDecade", FotoLibGlobal.datePickerUseDecade); + prefs.putBoolean("datePickerUseDecade", LibGlobal.datePickerUseDecade); - prefs.putBoolean("debugEnabledJpgMetaIo", FotoLibGlobal.debugEnabledJpgMetaIo); - prefs.putBoolean("debugEnabledJpg", FotoLibGlobal.debugEnabledJpg); + prefs.putBoolean("debugEnabledJpgMetaIo", LibGlobal.debugEnabledJpgMetaIo); + prefs.putBoolean("debugEnabledJpg", LibGlobal.debugEnabledJpg); /** #100: true: private images get the extension ".jpg-p" which hides them from other gallery-apps and image pickers. */ - prefs.putBoolean("renamePrivateJpg", FotoLibGlobal.renamePrivateJpg); + prefs.putBoolean("renamePrivateJpg", LibGlobal.renamePrivateJpg); // #26 prefs.putBoolean("initialImageDetailResolutionHigh", Global.initialImageDetailResolutionHigh); @@ -165,7 +163,7 @@ public static void global2Prefs(Context context) { prefs.putBoolean("debugEnableLibs", PhotoViewAttacher.DEBUG); prefs.putBoolean("clearSelectionAfterCommand", Global.clearSelectionAfterCommand); - prefs.putBoolean("xmp_file_schema_long", FotoLibGlobal.preferLongXmpFormat); + prefs.putBoolean("xmp_file_schema_long", LibGlobal.preferLongXmpFormat); prefs.putBoolean("mapsForgeEnabled", Global.mapsForgeEnabled); @@ -185,7 +183,7 @@ public static void global2Prefs(Context context) { prefs.putString("pickHistoryFile", (Global.pickHistoryFile != null) ? Global.pickHistoryFile.getAbsolutePath() : null); - prefs.putString("mediaUpdateStrategy", FotoLibGlobal.mediaUpdateStrategy); + prefs.putString("mediaUpdateStrategy", LibGlobal.mediaUpdateStrategy); prefs.apply(); @@ -198,7 +196,7 @@ public static void prefs2Global(Context context) { final SharedPreferences prefs = PreferenceManager .getDefaultSharedPreferences(context.getApplicationContext()); Global.debugEnabled = getPref(prefs, "debugEnabled", Global.debugEnabled); - FotoLibGlobal.debugEnabled = Global.debugEnabled; + LibGlobal.debugEnabled = Global.debugEnabled; Global.debugEnabledViewItem = getPref(prefs, "debugEnabledViewItem", Global.debugEnabledViewItem); Global.debugEnabledSql = getPref(prefs, "debugEnabledSql", Global.debugEnabledSql); @@ -207,16 +205,16 @@ public static void prefs2Global(Context context) { Global.debugEnabledMemory = getPref(prefs, "debugEnabledMemory", Global.debugEnabledMemory); - FotoLibGlobal.datePickerUseDecade = getPref(prefs, "datePickerUseDecade", FotoLibGlobal.datePickerUseDecade); + LibGlobal.datePickerUseDecade = getPref(prefs, "datePickerUseDecade", LibGlobal.datePickerUseDecade); Global.locked = getPref(prefs, "locked", Global.locked); Global.passwordHash = getPref(prefs, "passwordHash", Global.passwordHash); - FotoLibGlobal.debugEnabledJpg = getPref(prefs, "debugEnabledJpg", FotoLibGlobal.debugEnabledJpg); - FotoLibGlobal.debugEnabledJpgMetaIo = getPref(prefs, "debugEnabledJpgMetaIo", FotoLibGlobal.debugEnabledJpgMetaIo); + LibGlobal.debugEnabledJpg = getPref(prefs, "debugEnabledJpg", LibGlobal.debugEnabledJpg); + LibGlobal.debugEnabledJpgMetaIo = getPref(prefs, "debugEnabledJpgMetaIo", LibGlobal.debugEnabledJpgMetaIo); /** #100: true: private images get the extension ".jpg-p" which hides them from other gallery-apps and image pickers. */ - FotoLibGlobal.renamePrivateJpg = getPref(prefs, "renamePrivateJpg", FotoLibGlobal.renamePrivateJpg); + LibGlobal.renamePrivateJpg = getPref(prefs, "renamePrivateJpg", LibGlobal.renamePrivateJpg); // one setting for several 3d party debug-flags boolean debug3rdParty = getPref(prefs, "debugEnableLibs", PhotoViewAttacher.DEBUG); @@ -236,7 +234,7 @@ public static void prefs2Global(Context context) { Global.initialImageDetailResolutionHigh = getPref(prefs, "initialImageDetailResolutionHigh", Global.initialImageDetailResolutionHigh); Global.clearSelectionAfterCommand = getPref(prefs, "clearSelectionAfterCommand", Global.clearSelectionAfterCommand); - FotoLibGlobal.preferLongXmpFormat = getPref(prefs, "xmp_file_schema_long", FotoLibGlobal.preferLongXmpFormat); + LibGlobal.preferLongXmpFormat = getPref(prefs, "xmp_file_schema_long", LibGlobal.preferLongXmpFormat); Global.mapsForgeEnabled = getPref(prefs, "mapsForgeEnabled", Global.mapsForgeEnabled); @@ -257,7 +255,7 @@ public static void prefs2Global(Context context) { Global.pickHistoryFile = getPref(prefs, "pickHistoryFile", Global.pickHistoryFile); - FotoLibGlobal.mediaUpdateStrategy = getPref(prefs, "mediaUpdateStrategy", FotoLibGlobal.mediaUpdateStrategy); + LibGlobal.mediaUpdateStrategy = getPref(prefs, "mediaUpdateStrategy", LibGlobal.mediaUpdateStrategy); /* // bool diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/StringFormatResourceTests.java b/app/src/main/java/de/k3b/android/androFotoFinder/StringFormatResourceTests.java index 09189be1..eb222d7b 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/StringFormatResourceTests.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/StringFormatResourceTests.java @@ -3,7 +3,7 @@ import android.content.Context; import android.util.Log; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.android.util.AndroidFileCommands; import de.k3b.io.ListUtils; @@ -14,7 +14,7 @@ */ public class StringFormatResourceTests { public static void test(Context context) { - if (Global.debugEnabled && FotoLibGlobal.debugEnabled) + if (Global.debugEnabled && LibGlobal.debugEnabled) Log.i(Global.LOG_CONTEXT,ListUtils.toString("\n\t" ,"testing some translations with parameters" ,AndroFotoFinderApp.getBookMarkComment(context) 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 263d5521..3f14361b 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 @@ -50,7 +50,7 @@ import android.widget.TextView; import android.widget.Toast; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.android.androFotoFinder.FotoGalleryActivity; import de.k3b.android.androFotoFinder.PhotoAutoprocessingEditActivity; import de.k3b.android.androFotoFinder.ThumbNailUtils; @@ -368,7 +368,7 @@ private PopupMenu onCreatePopupMenu(View anchor, IDirectory selection) { setMenuVisibility(menu, R.id.cmd_fix_link, FileUtils.isSymlinkDir(new File(absoluteSelectedPath), false)); setMenuVisibility(menu, R.id.cmd_folder_hide_images, !isAlbumFile && MediaScanner.canHideFolderMedia(absoluteSelectedPath)); - setMenuVisibility(menu, R.id.cmd_apm_edit, !isAlbumFile && FotoLibGlobal.apmEnabled); + setMenuVisibility(menu, R.id.cmd_apm_edit, !isAlbumFile && LibGlobal.apmEnabled); setMenuVisibility(menu, R.id.cmd_filemanager, !isAlbumFile && FileManagerUtil.hasShowInFilemanager(getActivity(), absoluteSelectedPath)); setMenuVisibility(menu, R.id.cmd_delete, isAlbumFile); 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 913259ec..f0dd3da3 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 @@ -53,7 +53,7 @@ import java.util.ArrayList; import java.util.List; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.android.androFotoFinder.AffUtils; import de.k3b.android.androFotoFinder.Common; import de.k3b.android.androFotoFinder.ExifEditActivity; @@ -1420,7 +1420,7 @@ private boolean multiSelectionHandleClick(GalleryCursorAdapter.GridCellViewHolde } private void fix() { - if (((mRequeryInstanceCount > 2) && (FotoLibGlobal.itpcWriteSupport))) { + if (((mRequeryInstanceCount > 2) && (LibGlobal.itpcWriteSupport))) { View iptc = ResourceUtils.findLast(this.mGalleryView.getRootView(), "ads"); if (iptc != null) { ((ViewGroup) iptc.getParent()).removeView(iptc); 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 bb88513d..ee853eaa 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 @@ -42,7 +42,7 @@ import java.util.List; import java.util.Map; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.android.androFotoFinder.Global; import de.k3b.android.androFotoFinder.R; import de.k3b.android.util.DBUtils; @@ -983,7 +983,7 @@ protected static int exexUpdateImpl(String dbgContext, Context context, ContentV } catch (Exception ex) { excpetion = ex; } finally { - if ((excpetion != null) || ((dbgContext != null) && (Global.debugEnabledSql || FotoLibGlobal.debugEnabledJpg))) { + if ((excpetion != null) || ((dbgContext != null) && (Global.debugEnabledSql || LibGlobal.debugEnabledJpg))) { Log.i(Global.LOG_CONTEXT, dbgContext + ":FotoSql.exexUpdate " + excpetion + "\n" + QueryParameter.toString(null, values.toString(), SQL_TABLE_EXTERNAL_CONTENT_URI_FILE_NAME, sqlWhere, selectionArgs, null, result), excpetion); @@ -1033,7 +1033,7 @@ public static Uri execInsert(String dbgContext, Context context, ContentValues v } catch (Exception ex) { excpetion = ex; } finally { - if ((excpetion != null) || Global.debugEnabledSql || FotoLibGlobal.debugEnabledJpg) { + if ((excpetion != null) || Global.debugEnabledSql || LibGlobal.debugEnabledJpg) { Log.i(Global.LOG_CONTEXT, dbgContext + ":FotoSql.execInsert " + excpetion + " " + values.toString() + " => " + result + " " + excpetion, excpetion); } @@ -1101,7 +1101,7 @@ public static int deleteMedia(String dbgContext, Context context, String where, lastSelectionArgs = null; delCount = context.getContentResolver() .delete(SQL_TABLE_EXTERNAL_CONTENT_URI_FILE, lastUsedWhereClause, lastSelectionArgs); - if (Global.debugEnabledSql || FotoLibGlobal.debugEnabledJpg) { + if (Global.debugEnabledSql || LibGlobal.debugEnabledJpg) { Log.i(Global.LOG_CONTEXT, dbgContext + "-b: FotoSql.deleteMedia delete\n" + QueryParameter.toString(null, null, SQL_TABLE_EXTERNAL_CONTENT_URI_FILE_NAME, lastUsedWhereClause, lastSelectionArgs, null, delCount)); @@ -1109,7 +1109,7 @@ public static int deleteMedia(String dbgContext, Context context, String where, } else { delCount = context.getContentResolver() .delete(SQL_TABLE_EXTERNAL_CONTENT_URI_FILE, lastUsedWhereClause, lastSelectionArgs); - if (Global.debugEnabledSql || FotoLibGlobal.debugEnabledJpg) { + if (Global.debugEnabledSql || LibGlobal.debugEnabledJpg) { Log.i(Global.LOG_CONTEXT, dbgContext +": FotoSql.deleteMedia\ndelete " + QueryParameter.toString(null, null, SQL_TABLE_EXTERNAL_CONTENT_URI_FILE_NAME, @@ -1289,7 +1289,7 @@ protected static String getFilterExpressionVisibility(VISIBILITY _visibility) { VISIBILITY visibility = _visibility; // add visibility column only if not included yet if (visibility == VISIBILITY.DEFAULT) { - visibility = (FotoLibGlobal.visibilityShowPrivateByDefault) + visibility = (LibGlobal.visibilityShowPrivateByDefault) ? VISIBILITY.PRIVATE_PUBLIC : VISIBILITY.PUBLIC; } 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 b15fd3c4..18daf866 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 @@ -32,7 +32,7 @@ import java.util.Date; import java.util.List; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.android.androFotoFinder.Global; import de.k3b.android.androFotoFinder.media.MediaContentValues; import de.k3b.android.androFotoFinder.queries.AndroidAlbumUtils; @@ -269,7 +269,7 @@ public static int fixPrivate(Context context) { .append(TagSql.FILTER_EXPR_PUBLIC) .append(" AND (") .append(TagSql.FILTER_EXPR_TAGS_INCLUDED); - if (FotoLibGlobal.renamePrivateJpg) { + if (LibGlobal.renamePrivateJpg) { where.append(" OR ").append(TagSql.FILTER_EXPR_PATH_LIKE.replace("?","'%" + MediaUtil.IMG_TYPE_PRIVATE + "'")); } @@ -362,7 +362,7 @@ public static int updateDB(String dbgContext, Context context, String oldFullJpg final int modifiedColumCout = MediaUtil.copyNonEmpty(mediaValueAdapter.set(dbValues, null), jpg, allowSetNulls); if (modifiedColumCout >= 1) { String newFullJpgFilePath = null; - if (FotoLibGlobal.renamePrivateJpg) { + if (LibGlobal.renamePrivateJpg) { newFullJpgFilePath = MediaUtil.getModifiedPath(jpg); } diff --git a/app/src/main/java/de/k3b/android/util/MediaScanner.java b/app/src/main/java/de/k3b/android/util/MediaScanner.java index 002f97f4..06f19bb3 100644 --- a/app/src/main/java/de/k3b/android/util/MediaScanner.java +++ b/app/src/main/java/de/k3b/android/util/MediaScanner.java @@ -41,7 +41,7 @@ import java.util.List; import java.util.Map; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.android.androFotoFinder.Global; import de.k3b.android.androFotoFinder.media.MediaContentValues; import de.k3b.android.androFotoFinder.queries.FotoSql; @@ -360,7 +360,7 @@ protected MediaContentValues getExifFromFile(ContentValues values, File jpgFile) src = xmpContent; } else { // (!writeExif) prefer read from xmp value before exif value - src = (FotoLibGlobal.mediaUpdateStrategy.contains("J")) + src = (LibGlobal.mediaUpdateStrategy.contains("J")) ? exif : new MetaApiChainReader(xmpContent, exif); } diff --git a/app/src/main/java/de/k3b/android/widget/BaseQueryActivity.java b/app/src/main/java/de/k3b/android/widget/BaseQueryActivity.java index 1d383deb..d3e387a7 100644 --- a/app/src/main/java/de/k3b/android/widget/BaseQueryActivity.java +++ b/app/src/main/java/de/k3b/android/widget/BaseQueryActivity.java @@ -40,7 +40,7 @@ import java.util.Date; import java.util.List; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.android.androFotoFinder.Common; import de.k3b.android.androFotoFinder.GalleryFilterActivity; import de.k3b.android.androFotoFinder.GalleryFilterPathState; @@ -566,7 +566,7 @@ private void openPicker(final int filterMode, int _dirQueryID) { this.mMustShowNavigator = true; mergedBaseQuery.setID(dirQueryID); - DirectoryLoaderTask loader = new DirectoryLoaderTask(context, loadDate ? FotoLibGlobal.datePickerUseDecade : false, + DirectoryLoaderTask loader = new DirectoryLoaderTask(context, loadDate ? LibGlobal.datePickerUseDecade : false, mDebugPrefix + " from openPicker(loadDate=" + loadDate + ")") { @Override diff --git a/fotolib2/src/main/java/de/k3b/FotoLibGlobal.java b/fotolib2/src/main/java/de/k3b/LibGlobal.java similarity index 99% rename from fotolib2/src/main/java/de/k3b/FotoLibGlobal.java rename to fotolib2/src/main/java/de/k3b/LibGlobal.java index ab81f6ac..96115f37 100644 --- a/fotolib2/src/main/java/de/k3b/FotoLibGlobal.java +++ b/fotolib2/src/main/java/de/k3b/LibGlobal.java @@ -23,7 +23,7 @@ * Public Global stuff for the lib. * Created by k3b on 03.03.2016. */ -public class FotoLibGlobal { +public class LibGlobal { /** LOG_CONTEXT is used as logging source for filtering logging messages that belong to this */ public static final String LOG_TAG = "k3bFotoLib2"; diff --git a/fotolib2/src/main/java/de/k3b/io/DateUtil.java b/fotolib2/src/main/java/de/k3b/io/DateUtil.java index 624883d0..0b1269e6 100644 --- a/fotolib2/src/main/java/de/k3b/io/DateUtil.java +++ b/fotolib2/src/main/java/de/k3b/io/DateUtil.java @@ -1,7 +1,8 @@ /* * Copyright (c) 2016-2018 by k3b. * - * This file is part of AndroFotoFinder / #APhotoManager and toGoZip. + * This file is part of #APhotoManager (https://github.com/k3b/APhotoManager/) + * and #toGoZip (https://github.com/k3b/ToGoZip/). * * 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 diff --git a/fotolib2/src/main/java/de/k3b/io/DirectoryFormatter.java b/fotolib2/src/main/java/de/k3b/io/DirectoryFormatter.java index 375815b3..bd26cfd3 100644 --- a/fotolib2/src/main/java/de/k3b/io/DirectoryFormatter.java +++ b/fotolib2/src/main/java/de/k3b/io/DirectoryFormatter.java @@ -25,9 +25,8 @@ import java.util.Date; import java.util.GregorianCalendar; import java.util.Locale; -import java.util.TimeZone; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; /** * Created by k3b on 12.07.2015. @@ -44,7 +43,7 @@ public static void getDates(String selectedAbsolutePath, Date from, Date to) { Integer year = null; Integer month = null; Integer day = null; - Integer decade = (FotoLibGlobal.datePickerUseDecade) ? null : Integer.MIN_VALUE; + Integer decade = (LibGlobal.datePickerUseDecade) ? null : Integer.MIN_VALUE; String parts[] = selectedAbsolutePath.split(Directory.PATH_DELIMITER); @@ -66,7 +65,7 @@ public static void getDates(String selectedAbsolutePath, Date from, Date to) { } int yearFrom = 0; - if ((FotoLibGlobal.datePickerUseDecade) && (decade != null)) yearFrom = decade.intValue(); + if ((LibGlobal.datePickerUseDecade) && (decade != null)) yearFrom = decade.intValue(); if (year != null) yearFrom = year.intValue(); if (yearFrom != 0) { diff --git a/fotolib2/src/main/java/de/k3b/io/FileCommands.java b/fotolib2/src/main/java/de/k3b/io/FileCommands.java index 9a71ce08..86b34c54 100644 --- a/fotolib2/src/main/java/de/k3b/io/FileCommands.java +++ b/fotolib2/src/main/java/de/k3b/io/FileCommands.java @@ -31,7 +31,7 @@ import java.util.ArrayList; import java.util.Date; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.io.collections.DestDirFileNameProcessor; import de.k3b.io.collections.SelectedFiles; import de.k3b.media.IMetaApi; @@ -52,7 +52,7 @@ * Created by k3b on 03.08.2015. */ public class FileCommands extends FileProcessor implements Cloneable, IProgessListener { - private static final Logger logger = LoggerFactory.getLogger(FotoLibGlobal.LOG_TAG); + private static final Logger logger = LoggerFactory.getLogger(LibGlobal.LOG_TAG); public static final int OP_COPY = 1; public static final int OP_MOVE = 2; @@ -79,14 +79,14 @@ public int deleteFiles(SelectedFiles fotos, IProgessListener progessListener) { this.progessListener = progessListener; try { long startTimestamp = 0; - if (FotoLibGlobal.debugEnabledJpgMetaIo) { + if (LibGlobal.debugEnabledJpgMetaIo) { startTimestamp = new Date().getTime(); } String[] fileNames = fotos.getFileNames(); long now = new Date().getTime(); - int itemsPerProgress = FotoLibGlobal.itemsPerProgress; + int itemsPerProgress = LibGlobal.itemsPerProgress; int itemcount = 0; int countdown = 0; int maxCount = fotos.size(); @@ -107,7 +107,7 @@ public int deleteFiles(SelectedFiles fotos, IProgessListener progessListener) { } } onPostProcess(dbgContext, OP_DELETE, fotos, deleteCount, fileNames.length, fileNames, null); - if (FotoLibGlobal.debugEnabledJpg || FotoLibGlobal.debugEnabledJpgMetaIo) { + if (LibGlobal.debugEnabledJpg || LibGlobal.debugEnabledJpgMetaIo) { long dbgLoadEndTimestamp = new Date().getTime(); FileCommands.logger.debug(dbgContext + " process items:" + deleteCount @@ -177,7 +177,7 @@ public int applyExifChanges(boolean move, MediaDiffCopy exifChanges, SelectedFil * @param destDirFolder where files are moved/copied to * @param progessListener */ public int moveOrCopyFilesTo(boolean move, SelectedFiles selectedFiles, File destDirFolder, IProgessListener progessListener) { - PhotoWorkFlowDto autoProccessData = (!FotoLibGlobal.apmEnabled) ? null : getPhotoWorkFlowDto(destDirFolder); + PhotoWorkFlowDto autoProccessData = (!LibGlobal.apmEnabled) ? null : getPhotoWorkFlowDto(destDirFolder); return moveOrCopyFilesTo(move, selectedFiles, destDirFolder, autoProccessData, progessListener); } @@ -243,7 +243,7 @@ protected int moveOrCopyFiles(final boolean move, String what, MediaDiffCopy exi SelectedFiles fotos, File[] destFiles, IProgessListener progessListener) { long startTimestamp = 0; - if (FotoLibGlobal.debugEnabledJpgMetaIo) { + if (LibGlobal.debugEnabledJpgMetaIo) { startTimestamp = new Date().getTime(); } @@ -263,7 +263,7 @@ protected int moveOrCopyFiles(final boolean move, String what, MediaDiffCopy exi mModifiedSrcFiles = (move) ? new ArrayList() : null; mModifiedDestFiles = new ArrayList(); - int itemsPerProgress = FotoLibGlobal.itemsPerProgress; + int itemsPerProgress = LibGlobal.itemsPerProgress; int itemcount = 0; int countdown = 0; int maxCount = fotos.size(); @@ -353,7 +353,7 @@ protected int moveOrCopyFiles(final boolean move, String what, MediaDiffCopy exi String[] modifiedDestFiles = (modifyCount > 0) ? mModifiedDestFiles.toArray(new String[modifyCount]) : null; onPostProcess(what, opCode, fotos, itemCount, sourceFiles.length, modifiedSourceFiles, modifiedDestFiles); - if (FotoLibGlobal.debugEnabledJpgMetaIo) { + if (LibGlobal.debugEnabledJpgMetaIo) { long dbgLoadEndTimestamp = new Date().getTime(); FileCommands.logger.debug(what + " process items:" + itemCount @@ -444,7 +444,7 @@ private void addProcessedFiles(boolean move, File dest, File source) { protected boolean osFileMove(File dest, File source) { if (source.renameTo(dest)) { // move within same mountpoint - if (FotoLibGlobal.debugEnabledJpg) { + if (LibGlobal.debugEnabledJpg) { logger.info("osFileMove(rename) '" + source + "' => '" + dest + "'"); } @@ -457,14 +457,14 @@ protected boolean osFileMove(File dest, File source) { && !osFileExists(dest) && osFileCopy(dest, source)) { if (osDeleteFile(source)) { - if (FotoLibGlobal.debugEnabledJpg) { + if (LibGlobal.debugEnabledJpg) { logger.info("osFileMove(copy+delete) '" + source + "' => '" + dest + "'"); } return true; // move: copy + delete(source) : success } else { // cannot delete souce: undo copy - if (FotoLibGlobal.debugEnabledJpg) { + if (LibGlobal.debugEnabledJpg) { logger.info("osFileMove failed for '" + source + "' => '" + dest + "'"); } @@ -512,7 +512,7 @@ private static boolean _osFileCopy(File targetFullPath, File sourceFullPath, Fil FileUtils.close(in,"_osFileCopy-close"); FileUtils.close(out,"_osFileCopy-close"); } - if (FotoLibGlobal.debugEnabledJpg) { + if (LibGlobal.debugEnabledJpg) { logger.info("osFileCopy '" + sourceFullPath + "' => '" + targetFullPath + "' success=" + result); } @@ -522,7 +522,7 @@ private static boolean _osFileCopy(File targetFullPath, File sourceFullPath, Fil /** to be replaced by mock/stub in unittests */ protected boolean osDeleteFile(File file) { final boolean result = file.delete(); - if (FotoLibGlobal.debugEnabledJpg) logger.info("osDeleteFile '" + file + "' success=" + result); + if (LibGlobal.debugEnabledJpg) logger.info("osDeleteFile '" + file + "' success=" + result); return result; } @@ -550,7 +550,7 @@ public void addTransactionLog( MediaTransactionLogEntryDto dto = new MediaTransactionLogEntryDto(currentMediaID, fileFullPath, modificationDate, mediaTransactionLogEntryType, commandData); - if (FotoLibGlobal.debugEnabledJpg) { + if (LibGlobal.debugEnabledJpg) { logger.info(getClass().getSimpleName() + ".addTransactionLog(" + dto.toString() + ")"); } this.log(mediaTransactionLogEntryType.getCommand(fileFullPath, commandData)); diff --git a/fotolib2/src/main/java/de/k3b/io/FileUtils.java b/fotolib2/src/main/java/de/k3b/io/FileUtils.java index 8f2b2103..85511ba0 100644 --- a/fotolib2/src/main/java/de/k3b/io/FileUtils.java +++ b/fotolib2/src/main/java/de/k3b/io/FileUtils.java @@ -1,7 +1,8 @@ /* * Copyright (c) 2015-2018 by k3b. * - * This file is part of AndroFotoFinder / #APhotoManager. + * This file is part of #APhotoManager (https://github.com/k3b/APhotoManager/) + * and #toGoZip (https://github.com/k3b/ToGoZip/). * * 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 @@ -36,14 +37,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; /** * Created by k3b on 06.10.2015. */ public class FileUtils { - private static final Logger logger = LoggerFactory.getLogger(FotoLibGlobal.LOG_TAG); + private static final Logger logger = LoggerFactory.getLogger(LibGlobal.LOG_TAG); private static final String DBG_CONTEXT = "FileUtils:"; public static final String MEDIA_IGNORE_FILENAME = ".nomedia"; // MediaStore.MEDIA_IGNORE_FILENAME; @@ -123,7 +124,7 @@ public static String tryGetCanonicalPath(File file, String errorValue) { /** @return true if directory is an alias of an other (symlink-dir). */ public static boolean isSymlinkDir(File directory, boolean errorValue) { - if (FotoLibGlobal.ignoreSymLinks || (directory == null)) { + if (LibGlobal.ignoreSymLinks || (directory == null)) { return false; } @@ -131,7 +132,7 @@ public static boolean isSymlinkDir(File directory, boolean errorValue) { String canonicalPath = tryGetCanonicalPath(directory, null); if (canonicalPath != null) { boolean result = !directory.getAbsolutePath().equals(canonicalPath); - if (result && FotoLibGlobal.debugEnabled) { + if (result && LibGlobal.debugEnabled) { logger.debug(DBG_CONTEXT + "isSymlinkDir('" + directory.getAbsolutePath() + "') => true because CanonicalPath='" + canonicalPath + "'"); } @@ -238,7 +239,7 @@ public static void delete(File file, final String fileExt) { String path = file.getAbsolutePath(); if(fileExt == null || path.endsWith(fileExt)) { boolean result = file.delete(); - if (FotoLibGlobal.debugEnabled) { + if (LibGlobal.debugEnabled) { // test if delete of file is success or not if (result) { logger.info(DBG_CONTEXT + "File {} deleted", file.getAbsolutePath()); @@ -249,7 +250,7 @@ public static void delete(File file, final String fileExt) { } } } else { - if (FotoLibGlobal.debugEnabled) logger.info(DBG_CONTEXT + "File {} doesn't exist", file.getAbsolutePath()); + if (LibGlobal.debugEnabled) logger.info(DBG_CONTEXT + "File {} doesn't exist", file.getAbsolutePath()); } } diff --git a/fotolib2/src/main/java/de/k3b/io/GalleryFilterParameter.java b/fotolib2/src/main/java/de/k3b/io/GalleryFilterParameter.java index 22104b72..896bd2e7 100644 --- a/fotolib2/src/main/java/de/k3b/io/GalleryFilterParameter.java +++ b/fotolib2/src/main/java/de/k3b/io/GalleryFilterParameter.java @@ -26,7 +26,7 @@ import java.util.Arrays; import java.util.List; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.io.collections.SelectedItems; /** @@ -399,6 +399,6 @@ public int getRatingMin() { /** get Date Min/Max in date picker compatible format */ public String getDatePath() { - return DirectoryFormatter.getDatePath(FotoLibGlobal.datePickerUseDecade, getDateMin(), getDateMax()); + return DirectoryFormatter.getDatePath(LibGlobal.datePickerUseDecade, getDateMin(), getDateMax()); } } diff --git a/fotolib2/src/main/java/de/k3b/io/ListUtils.java b/fotolib2/src/main/java/de/k3b/io/ListUtils.java index d9b93bf6..7a083330 100644 --- a/fotolib2/src/main/java/de/k3b/io/ListUtils.java +++ b/fotolib2/src/main/java/de/k3b/io/ListUtils.java @@ -1,7 +1,8 @@ /* * Copyright (c) 2017-2018 by k3b. * - * This file is part of AndroFotoFinder / #APhotoManager and toGoZip. + * This file is part of #APhotoManager (https://github.com/k3b/APhotoManager/) + * and #toGoZip (https://github.com/k3b/ToGoZip/). * * 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 diff --git a/fotolib2/src/main/java/de/k3b/io/OSDirectory.java b/fotolib2/src/main/java/de/k3b/io/OSDirectory.java index 5c19ed3f..9b001f3c 100644 --- a/fotolib2/src/main/java/de/k3b/io/OSDirectory.java +++ b/fotolib2/src/main/java/de/k3b/io/OSDirectory.java @@ -26,7 +26,7 @@ import java.util.ArrayList; import java.util.List; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; /** * Operating System Directory with load on demand @@ -34,7 +34,7 @@ * Created by k3b on 04.08.2015. */ public class OSDirectory implements IDirectory { - private static final Logger logger = LoggerFactory.getLogger(FotoLibGlobal.LOG_TAG); + private static final Logger logger = LoggerFactory.getLogger(LibGlobal.LOG_TAG); private File mCurrent = null; private List mChilden = null; @@ -138,7 +138,7 @@ public List getChildren() { if (isDirectory(file)) { mChilden.add(createOsDirectory(file, this, null)); } -// } else if (FotoLibGlobal.debugEnabled) { +// } else if (LibGlobal.debugEnabled) { // logger.debug(FileUtils.getDebugString("OSDirectory.getChildren() rejected ", file)); } } diff --git a/fotolib2/src/main/java/de/k3b/io/PhotoWorkFlowDto.java b/fotolib2/src/main/java/de/k3b/io/PhotoWorkFlowDto.java index 1889e91b..6574866e 100644 --- a/fotolib2/src/main/java/de/k3b/io/PhotoWorkFlowDto.java +++ b/fotolib2/src/main/java/de/k3b/io/PhotoWorkFlowDto.java @@ -29,7 +29,7 @@ import java.io.Serializable; import java.util.Properties; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.media.IMetaApi; import de.k3b.media.MediaAsString; @@ -40,7 +40,7 @@ */ public class PhotoWorkFlowDto { - private static final Logger logger = LoggerFactory.getLogger(FotoLibGlobal.LOG_TAG); + private static final Logger logger = LoggerFactory.getLogger(LibGlobal.LOG_TAG); /** added to every serialized item if != null. Example "Generated on 2015-10-19 with myApp Version 0815." */ public static String sFileComment = ""; @@ -72,7 +72,7 @@ public PhotoWorkFlowDto load(File outDir) throws IOException { try { inputStream = new FileInputStream(apm); properties.load(inputStream); - if (FotoLibGlobal.debugEnabled) { + if (LibGlobal.debugEnabled) { logger.debug(this.getClass().getSimpleName() + ": loaded from " + apm + ":" + this); } return this; @@ -117,13 +117,13 @@ public void save() throws IOException { File apm = getApmFile(); FileOutputStream stream = null; if (isEmpty()) { - if (FotoLibGlobal.debugEnabled) { + if (LibGlobal.debugEnabled) { logger.debug(this.getClass().getSimpleName() + ": save delete empty " + apm + ":" + this); } apm.delete(); } else { try { - if (FotoLibGlobal.debugEnabled) { + if (LibGlobal.debugEnabled) { logger.debug(this.getClass().getSimpleName() + ": save to " + apm + ":" + this); } stream = new FileOutputStream(apm); @@ -142,7 +142,7 @@ public static PhotoWorkFlowDto load(Serializable content) { String outDir = properties.getProperty(KEY_OUT_DIR); photoWorkFlowDto = new PhotoWorkFlowDto((outDir != null) ? new File(outDir) : null, properties); } - if (FotoLibGlobal.debugEnabled) { + if (LibGlobal.debugEnabled) { logger.debug(PhotoWorkFlowDto.class.getSimpleName() + ": load De-Serialize:" + photoWorkFlowDto); } return photoWorkFlowDto; diff --git a/fotolib2/src/main/java/de/k3b/io/RuleFileNameProcessor.java b/fotolib2/src/main/java/de/k3b/io/RuleFileNameProcessor.java index bebd258d..f160089f 100644 --- a/fotolib2/src/main/java/de/k3b/io/RuleFileNameProcessor.java +++ b/fotolib2/src/main/java/de/k3b/io/RuleFileNameProcessor.java @@ -27,7 +27,7 @@ import java.text.SimpleDateFormat; import java.util.Date; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; /** * #93: rule based file renaming for same target directory. @@ -37,7 +37,7 @@ */ public class RuleFileNameProcessor extends FileProcessor implements IFileNameProcessor { - private static final Logger logger = LoggerFactory.getLogger(FotoLibGlobal.LOG_TAG); + private static final Logger logger = LoggerFactory.getLogger(LibGlobal.LOG_TAG); public static final String APM_FILE_NAME = ".apm"; /** i.e "yyMM" for year and month each with 2 digits */ diff --git a/fotolib2/src/main/java/de/k3b/io/StringUtils.java b/fotolib2/src/main/java/de/k3b/io/StringUtils.java index 1bff81aa..b9af6dbd 100644 --- a/fotolib2/src/main/java/de/k3b/io/StringUtils.java +++ b/fotolib2/src/main/java/de/k3b/io/StringUtils.java @@ -1,7 +1,8 @@ /* - * Copyright (c) 2017-2018 by k3b. + * Copyright (c) 2018 by k3b. * - * This file is part of AndroFotoFinder / #APhotoManager. + * This file is part of #APhotoManager (https://github.com/k3b/APhotoManager/) + * and #toGoZip (https://github.com/k3b/ToGoZip/). * * 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 @@ -11,8 +12,8 @@ * 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. * + * for more details. * You should have received a copy of the GNU General Public License along with * this program. If not, see */ diff --git a/fotolib2/src/main/java/de/k3b/io/VISIBILITY.java b/fotolib2/src/main/java/de/k3b/io/VISIBILITY.java index 39e57db2..f62529bc 100644 --- a/fotolib2/src/main/java/de/k3b/io/VISIBILITY.java +++ b/fotolib2/src/main/java/de/k3b/io/VISIBILITY.java @@ -25,7 +25,7 @@ import java.util.ArrayList; import java.util.List; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; public enum VISIBILITY { /** take from current settings */ @@ -39,7 +39,7 @@ public enum VISIBILITY { // #100: if photo has this tag it has visibility PRIVATE public static final String TAG_PRIVATE = "PRIVATE"; - private static final Logger logger = LoggerFactory.getLogger(FotoLibGlobal.LOG_TAG); + private static final Logger logger = LoggerFactory.getLogger(LibGlobal.LOG_TAG); public static final VISIBILITY MAX = PRIVATE_PUBLIC; public final int value; diff --git a/fotolib2/src/main/java/de/k3b/media/ExifInterfaceEx.java b/fotolib2/src/main/java/de/k3b/media/ExifInterfaceEx.java index cd080098..03f5f8e1 100644 --- a/fotolib2/src/main/java/de/k3b/media/ExifInterfaceEx.java +++ b/fotolib2/src/main/java/de/k3b/media/ExifInterfaceEx.java @@ -34,7 +34,7 @@ import java.util.List; import java.util.TimeZone; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.io.ListUtils; import de.k3b.io.VISIBILITY; @@ -79,7 +79,7 @@ public ExifInterfaceEx(String absoluteJpgPath, InputStream in, IMetaApi xmpExter this.xmpExtern = xmpExtern; this.mDbg_context = dbg_context + "->ExifInterfaceEx(" + absoluteJpgPath+ ") "; - if (FotoLibGlobal.debugEnabledJpgMetaIo) { + if (LibGlobal.debugEnabledJpgMetaIo) { logger.debug(this.mDbg_context + " load: " + MediaUtil.toString(this, false, null, MediaUtil.FieldID.path, MediaUtil.FieldID.clasz)); } @@ -100,7 +100,7 @@ public void saveAttributes(File inFile, File outFile, boolean deleteInFileOnFini @Override public void saveJpegAttributes(InputStream inputStream, OutputStream outputStream, byte[] thumbnail) throws IOException { - if (FotoLibGlobal.debugEnabledJpg || FotoLibGlobal.debugEnabledJpgMetaIo) { + if (LibGlobal.debugEnabledJpg || LibGlobal.debugEnabledJpgMetaIo) { logger.debug(mDbg_context + " saveJpegAttributes: " + getPath()); } super.saveJpegAttributes(inputStream, outputStream, thumbnail); @@ -109,7 +109,7 @@ public void saveJpegAttributes(InputStream inputStream, OutputStream outputStrea @Override protected boolean deleteFile(File file) { boolean result = super.deleteFile(file); - if (result && FotoLibGlobal.debugEnabledJpg || FotoLibGlobal.debugEnabledJpgMetaIo) { + if (result && LibGlobal.debugEnabledJpg || LibGlobal.debugEnabledJpgMetaIo) { logger.debug(mDbg_context + " deleteFile: " + file); } return result; @@ -130,12 +130,12 @@ private void fixDateTakenIfNeccessary(File inFile) { protected void fixAttributes() { fixDateTakenIfNeccessary(mExifFile); - if ((FotoLibGlobal.appName != null) && (null == getAttribute(ExifInterfaceEx.TAG_MAKE))) { - setAttribute(ExifInterfaceEx.TAG_MAKE, FotoLibGlobal.appName); + if ((LibGlobal.appName != null) && (null == getAttribute(ExifInterfaceEx.TAG_MAKE))) { + setAttribute(ExifInterfaceEx.TAG_MAKE, LibGlobal.appName); } - if ((FotoLibGlobal.appVersion != null) && (null == getAttribute(ExifInterfaceEx.TAG_MODEL))) { - setAttribute(ExifInterfaceEx.TAG_MODEL, FotoLibGlobal.appVersion); + if ((LibGlobal.appVersion != null) && (null == getAttribute(ExifInterfaceEx.TAG_MODEL))) { + setAttribute(ExifInterfaceEx.TAG_MODEL, LibGlobal.appVersion); } super.fixAttributes(); } diff --git a/fotolib2/src/main/java/de/k3b/media/ImageMetaReader.java b/fotolib2/src/main/java/de/k3b/media/ImageMetaReader.java index 013ec574..1527a5fe 100644 --- a/fotolib2/src/main/java/de/k3b/media/ImageMetaReader.java +++ b/fotolib2/src/main/java/de/k3b/media/ImageMetaReader.java @@ -42,7 +42,7 @@ import java.util.Date; import java.util.List; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.io.DateUtil; import de.k3b.io.ListUtils; import de.k3b.io.StringUtils; @@ -82,7 +82,7 @@ public class ImageMetaReader implements IMetaApi, Closeable { private boolean mInitExecuted = false; static { - FotoLibGlobal.itpcWriteSupport = hasItpcWriteSupport(); + LibGlobal.itpcWriteSupport = hasItpcWriteSupport(); } private static boolean hasItpcWriteSupport() { @@ -128,14 +128,14 @@ public ImageMetaReader load(String filename, InputStream inputStream, IMetaApi e mMetadata = metadata; if (metadata == null) { - if (FotoLibGlobal.debugEnabledJpgMetaIo) { + if (LibGlobal.debugEnabledJpgMetaIo) { logger.debug(dbg_context + "load: file not found "); } return null; } - if (FotoLibGlobal.debugEnabledJpgMetaIo) { + if (LibGlobal.debugEnabledJpgMetaIo) { logger.debug(dbg_context + "loaded: " + MediaUtil.toString(this, false, null, MediaUtil.FieldID.path, MediaUtil.FieldID.clasz)); } diff --git a/fotolib2/src/main/java/de/k3b/media/JpgMetaWorkflow.java b/fotolib2/src/main/java/de/k3b/media/JpgMetaWorkflow.java index f2280e4c..5a0d185b 100644 --- a/fotolib2/src/main/java/de/k3b/media/JpgMetaWorkflow.java +++ b/fotolib2/src/main/java/de/k3b/media/JpgMetaWorkflow.java @@ -27,7 +27,7 @@ import java.util.EnumSet; import java.util.List; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.io.FileProcessor; import de.k3b.io.VISIBILITY; import de.k3b.transactionlog.TransactionLoggerBase; @@ -38,7 +38,7 @@ * Created by k3b on 25.08.2015. */ public class JpgMetaWorkflow { - private static final Logger logger = LoggerFactory.getLogger(FotoLibGlobal.LOG_TAG); + private static final Logger logger = LoggerFactory.getLogger(LibGlobal.LOG_TAG); private final TransactionLoggerBase transactionLogger; private StringBuilder debugExif(StringBuilder sb, String context, MetaWriterExifXml exif, File filePath) { @@ -74,7 +74,7 @@ public MetaWriterExifXml saveLatLon(File filePath, Double latitude, Double longi * Returns new values or null if no change. */ public MetaWriterExifXml applyChanges(File inFilePath, String outFilePath, long id, boolean deleteOriginalWhenFinished, MediaDiffCopy metaDiffCopy) { - StringBuilder sb = (FotoLibGlobal.debugEnabled) + StringBuilder sb = (LibGlobal.debugEnabled) ? createDebugStringBuilder(inFilePath) : null; File outFile = (outFilePath != null) ? new File(outFilePath) : inFilePath; @@ -105,7 +105,7 @@ public MetaWriterExifXml applyChanges(File inFilePath, String outFilePath, exif.save("MetaWriterExifXml save"); - if (FotoLibGlobal.preserveJpgFileModificationDate) { + if (LibGlobal.preserveJpgFileModificationDate) { // preseve file modification date inFilePath.setLastModified(lastModified); } @@ -173,7 +173,7 @@ public MetaWriterExifXml applyChanges(File inFilePath, String outFilePath, protected void deleteFile(File delete) { if ((delete != null) && delete.exists()) { delete.delete(); - if (FotoLibGlobal.debugEnabledJpg) { + if (LibGlobal.debugEnabledJpg) { logger.info("JpgMetaWorkflow deleteFile " + delete); } } @@ -181,7 +181,7 @@ protected void deleteFile(File delete) { /** return modified out file or null if filename must not change due to visibility rule */ protected File handleVisibility(VISIBILITY newVisibility, File outFile, MetaWriterExifXml exif) { - if (FotoLibGlobal.renamePrivateJpg) { + if (LibGlobal.renamePrivateJpg) { final String oldAbsoluteOutPath = (outFile == null) ? null : outFile.getAbsolutePath(); String newAbsoluteOutPath = MediaUtil.getModifiedPath(oldAbsoluteOutPath, newVisibility); diff --git a/fotolib2/src/main/java/de/k3b/media/MediaXmpSegment.java b/fotolib2/src/main/java/de/k3b/media/MediaXmpSegment.java index ab1cda44..78aa942a 100644 --- a/fotolib2/src/main/java/de/k3b/media/MediaXmpSegment.java +++ b/fotolib2/src/main/java/de/k3b/media/MediaXmpSegment.java @@ -32,7 +32,7 @@ import java.util.Date; import java.util.List; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.io.DateUtil; import de.k3b.io.FileCommands; import de.k3b.io.GeoUtil; @@ -46,7 +46,7 @@ public class MediaXmpSegment extends XmpSegment implements IMetaApi { private static final String dbg_context = "MediaXmpSegment: "; - private static final Logger logger = LoggerFactory.getLogger(FotoLibGlobal.LOG_TAG); + private static final Logger logger = LoggerFactory.getLogger(LibGlobal.LOG_TAG); /** the full path of the image where this xmp-file belongs to */ private String path = null; @@ -190,7 +190,7 @@ public IMetaApi setVisibility(VISIBILITY value) { @Override public XmpSegment setXmpMeta(XMPMeta xmpMeta, String dbg_context) { super.setXmpMeta(xmpMeta, dbg_context); - if (FotoLibGlobal.debugEnabledJpgMetaIo) { + if (LibGlobal.debugEnabledJpgMetaIo) { logger.info(dbg_context + " setXmpMeta " + MediaUtil.toString(this, false, null, MediaUtil.FieldID.path, MediaUtil.FieldID.clasz)); } @@ -208,7 +208,7 @@ private void fixAttributes(File file) { setProperty(file.getName(), MediaXmpFieldDefinition.OriginalFileName); } if (getPropertyAsString(" fixAttributes AppVersion", MediaXmpFieldDefinition.AppVersion) == null) { - setProperty(FotoLibGlobal.appName + "-" + FotoLibGlobal.appVersion, MediaXmpFieldDefinition.AppVersion); + setProperty(LibGlobal.appName + "-" + LibGlobal.appVersion, MediaXmpFieldDefinition.AppVersion); } } @@ -216,7 +216,7 @@ private void fixAttributes(File file) { @Override public XmpSegment save(OutputStream os, boolean humanReadable, String dbg_context) { super.save(os, humanReadable, dbg_context); - if (FotoLibGlobal.debugEnabledJpgMetaIo) { + if (LibGlobal.debugEnabledJpgMetaIo) { logger.info(dbg_context + " save " + MediaUtil.toString(this, false, null, MediaUtil.FieldID.path, MediaUtil.FieldID.clasz)); } @@ -238,7 +238,7 @@ public static MediaXmpSegment loadXmpSidecarContentOrNull(String absoluteJpgPath xmpContent = null; } - } else if (FotoLibGlobal.debugEnabledJpgMetaIo) { + } else if (LibGlobal.debugEnabledJpgMetaIo) { logger.error(dbg_context + "file not found"); } diff --git a/fotolib2/src/main/java/de/k3b/media/MetaWriterExifXml.java b/fotolib2/src/main/java/de/k3b/media/MetaWriterExifXml.java index 8f1fa239..4f4d513e 100644 --- a/fotolib2/src/main/java/de/k3b/media/MetaWriterExifXml.java +++ b/fotolib2/src/main/java/de/k3b/media/MetaWriterExifXml.java @@ -26,7 +26,7 @@ import java.io.IOException; import java.util.Date; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.io.FileCommands; import de.k3b.io.FileProcessor; import de.k3b.io.FileUtils; @@ -45,7 +45,7 @@ */ public class MetaWriterExifXml extends MetaApiWrapper implements IMetaApi { - private static final Logger logger = LoggerFactory.getLogger(FotoLibGlobal.LOG_TAG); + private static final Logger logger = LoggerFactory.getLogger(LibGlobal.LOG_TAG); private ExifInterfaceEx exif; // not null if exif changes are written to jpg file private MediaXmpSegment xmp; // not null if exif changes are written to xmp sidecar file. @@ -70,9 +70,9 @@ public static MetaWriterExifXml create(String absoluteJpgInPath, String absolute boolean deleteOriginalAfterFinish, String dbg_context) throws IOException { return create(absoluteJpgInPath, absoluteJpgOutPath, deleteOriginalAfterFinish, dbg_context, - FotoLibGlobal.mediaUpdateStrategy.contains("J"), // write jpg file - FotoLibGlobal.mediaUpdateStrategy.contains("X"), // write xmp file - FotoLibGlobal.mediaUpdateStrategy.contains("C") // create xmp if it does not exist + LibGlobal.mediaUpdateStrategy.contains("J"), // write jpg file + LibGlobal.mediaUpdateStrategy.contains("X"), // write xmp file + LibGlobal.mediaUpdateStrategy.contains("C") // create xmp if it does not exist ); } @@ -95,7 +95,7 @@ public static MetaWriterExifXml create(String absoluteJpgInPath, String absolute boolean writeJpg, boolean writeXmp, boolean createXmpIfNotExist) throws IOException { long startTimestamp = 0; - if (FotoLibGlobal.debugEnabledJpgMetaIo) { + if (LibGlobal.debugEnabledJpgMetaIo) { startTimestamp = new Date().getTime(); } MediaXmpSegment xmp = MediaXmpSegment.loadXmpSidecarContentOrNull(absoluteJpgInPath, dbg_context); @@ -153,7 +153,7 @@ public static MetaWriterExifXml create(String absoluteJpgInPath, String absolute result.absoluteJpgOutPath = (absoluteJpgOutPath != null) ? absoluteJpgOutPath : absoluteJpgInPath; result.absoluteJpgInPath = absoluteJpgInPath; result.deleteOriginalAfterFinish = deleteOriginalAfterFinish; - if (FotoLibGlobal.debugEnabledJpgMetaIo) { + if (LibGlobal.debugEnabledJpgMetaIo) { result.dbgLoadEndTimestamp = new Date().getTime(); logger.debug(dbg_context + " load[msec]:" + (result.dbgLoadEndTimestamp - startTimestamp)); } @@ -178,14 +178,14 @@ public String getAbsoluteJpgOutPath() { public int save(String dbg_context) throws IOException { long startTimestamp = 0; - if (FotoLibGlobal.debugEnabledJpgMetaIo) { + if (LibGlobal.debugEnabledJpgMetaIo) { startTimestamp = new Date().getTime(); } final int result = transferExif(dbg_context) + transferXmp(dbg_context); - if (FotoLibGlobal.debugEnabledJpgMetaIo) { + if (LibGlobal.debugEnabledJpgMetaIo) { long endTimestamp = new Date().getTime(); logger.debug(dbg_context + " process[msec]:" + (startTimestamp - this.dbgLoadEndTimestamp) @@ -209,7 +209,7 @@ private int transferXmp(String dbg_context) throws IOException { Boolean xmpLongFormat = xmp.isLongFormat(); boolean isLongFormat = (xmpLongFormat != null) ? xmpLongFormat.booleanValue() - : FotoLibGlobal.preferLongXmpFormat; + : LibGlobal.preferLongXmpFormat; changedFiles += saveXmp(xmp, outJpgFullPath, isLongFormat, dbg_context); @@ -248,7 +248,7 @@ private int saveXmp(MediaXmpSegment xmp, String outFullJpgPath, boolean isLongFileName, String dbg_context) throws IOException { File xmpOutFile = FileCommands.getSidecar(outFullJpgPath, isLongFileName); - xmp.save(xmpOutFile, FotoLibGlobal.debugEnabledJpgMetaIo, dbg_context); + xmp.save(xmpOutFile, LibGlobal.debugEnabledJpgMetaIo, dbg_context); return 1; } diff --git a/fotolib2/src/main/java/de/k3b/media/XmpNamespace.java b/fotolib2/src/main/java/de/k3b/media/XmpNamespace.java index 826e9085..f7c397de 100644 --- a/fotolib2/src/main/java/de/k3b/media/XmpNamespace.java +++ b/fotolib2/src/main/java/de/k3b/media/XmpNamespace.java @@ -26,7 +26,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; /** * Created by k3b on 10.10.2016. @@ -44,7 +44,7 @@ public enum XmpNamespace { ; private static final String dbg_context = XmpNamespace.class.getSimpleName(); - private static final Logger logger = LoggerFactory.getLogger(FotoLibGlobal.LOG_TAG); + private static final Logger logger = LoggerFactory.getLogger(LibGlobal.LOG_TAG); private final String prefix; private final String uri; diff --git a/fotolib2/src/main/java/de/k3b/media/XmpSegment.java b/fotolib2/src/main/java/de/k3b/media/XmpSegment.java index 953ce7f7..92819236 100644 --- a/fotolib2/src/main/java/de/k3b/media/XmpSegment.java +++ b/fotolib2/src/main/java/de/k3b/media/XmpSegment.java @@ -44,7 +44,7 @@ import java.util.Date; import java.util.List; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.io.FileUtils; import de.k3b.tagDB.TagConverter; @@ -56,7 +56,7 @@ public class XmpSegment { public static final String DBG_PREFIX = "XmpSegment: "; private static String dbg_context = DBG_PREFIX; - private static final Logger logger = LoggerFactory.getLogger(FotoLibGlobal.LOG_TAG); + private static final Logger logger = LoggerFactory.getLogger(LibGlobal.LOG_TAG); // public: can be changed in settings dialog public static boolean DEBUG = false; diff --git a/fotolib2/src/main/java/de/k3b/tagDB/TagRepository.java b/fotolib2/src/main/java/de/k3b/tagDB/TagRepository.java index 60627810..66f36e13 100644 --- a/fotolib2/src/main/java/de/k3b/tagDB/TagRepository.java +++ b/fotolib2/src/main/java/de/k3b/tagDB/TagRepository.java @@ -33,7 +33,7 @@ import java.util.Collections; import java.util.List; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; /** * Persistence for all known tags. @@ -44,7 +44,7 @@ public class TagRepository { // android - log compatible private static final String dbg_context = "TagRepository: "; - private static final Logger logger = LoggerFactory.getLogger(FotoLibGlobal.LOG_TAG); + private static final Logger logger = LoggerFactory.getLogger(LibGlobal.LOG_TAG); /** Lines starting with char are comments. These lines are not interpreted */ public static final java.lang.String COMMENT = "#"; @@ -216,7 +216,7 @@ public List load() { logger.debug(dbg_context + "load(): " + mItemList.size() + " items from " + this.mFile); - } else if (FotoLibGlobal.debugEnabled) { + } else if (LibGlobal.debugEnabled) { // logger.debug(dbg_context + "load() cached value : " + mItemList.size() + " items from " + this.mFile); } return mItemList; @@ -274,7 +274,7 @@ public TagRepository save() { } catch (IOException e) { e.printStackTrace(); } - if (FotoLibGlobal.debugEnabled) { + if (LibGlobal.debugEnabled) { logger.debug(dbg_context + "save(): no items for " + this.mFile); } return this; @@ -293,7 +293,7 @@ public void load(List result, Reader reader) throws IOException { Tag item = loadItem(line); final boolean valid = isValid(item); /* // to much log output - if (FotoLibGlobal.debugEnabled) { + if (LibGlobal.debugEnabled) { logger.debug(dbg_context + "load(" + line + "): " + ((valid) ? "loaded" : "ignored")); } */ @@ -389,7 +389,7 @@ protected boolean saveItem(Writer writer, Tag item, String indent) throws IOExce writer.write("\n"); } /* // to much log output - if (FotoLibGlobal.debugEnabled) { + if (LibGlobal.debugEnabled) { logger.debug(dbg_context + "save(" + line + "): " + ((valid) ? "saved" : "ignored" )); } */ diff --git a/fotolib2/src/main/java/de/k3b/transactionlog/TransactionLogParser.java b/fotolib2/src/main/java/de/k3b/transactionlog/TransactionLogParser.java index 711f2560..57ab0940 100644 --- a/fotolib2/src/main/java/de/k3b/transactionlog/TransactionLogParser.java +++ b/fotolib2/src/main/java/de/k3b/transactionlog/TransactionLogParser.java @@ -1,7 +1,7 @@ /* - * Copyright (c) 2017 by k3b. + * Copyright (c) 2018 by k3b. * - * This file is part of AndroFotoFinder / #APhotoManager. + * This file is part of #APhotoManager (https://github.com/k3b/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 @@ -11,8 +11,8 @@ * 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. * + * for more details. * You should have received a copy of the GNU General Public License along with * this program. If not, see */ diff --git a/fotolib2/src/main/java/de/k3b/transactionlog/TransactionLoggerBase.java b/fotolib2/src/main/java/de/k3b/transactionlog/TransactionLoggerBase.java index 8b1d31a6..4e6c0d9c 100644 --- a/fotolib2/src/main/java/de/k3b/transactionlog/TransactionLoggerBase.java +++ b/fotolib2/src/main/java/de/k3b/transactionlog/TransactionLoggerBase.java @@ -1,7 +1,7 @@ /* - * Copyright (c) 2017-2018 by k3b. + * Copyright (c) 2018 by k3b. * - * This file is part of AndroFotoFinder / #APhotoManager. + * This file is part of #APhotoManager (https://github.com/k3b/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 @@ -11,8 +11,8 @@ * 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. * + * for more details. * You should have received a copy of the GNU General Public License along with * this program. If not, see */ @@ -26,7 +26,7 @@ import java.util.EnumSet; import java.util.List; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.io.DateUtil; import de.k3b.io.DirectoryFormatter; import de.k3b.io.FileProcessor; @@ -124,7 +124,7 @@ public void addChangesCopyMove(boolean move, String newFullPath, String debugCon } public void addComment(Object... comment) { - if (FotoLibGlobal.debugEnabledJpgMetaIo) { + if (LibGlobal.debugEnabledJpgMetaIo) { addChanges(MediaTransactionLogEntryType.COMMENT, ListUtils.toString(" ", comment), true); } } diff --git a/fotolib2/src/test/java/de/k3b/io/FileCommandAutoIntegrationTests.java b/fotolib2/src/test/java/de/k3b/io/FileCommandAutoIntegrationTests.java index 85d1a1df..88b8164f 100644 --- a/fotolib2/src/test/java/de/k3b/io/FileCommandAutoIntegrationTests.java +++ b/fotolib2/src/test/java/de/k3b/io/FileCommandAutoIntegrationTests.java @@ -31,7 +31,7 @@ import java.util.Date; import java.util.Properties; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.TestUtil; import de.k3b.io.collections.SelectedFiles; import de.k3b.media.ExifInterface; @@ -75,11 +75,11 @@ public static void setUpClass() throws IOException { } @Before public void setUp() throws IOException { - FotoLibGlobal.appName = "JUnit"; - FotoLibGlobal.appVersion = TEST_CLASS_NAME; + LibGlobal.appName = "JUnit"; + LibGlobal.appVersion = TEST_CLASS_NAME; ExifInterface.DEBUG = true; - FotoLibGlobal.debugEnabledJpgMetaIo = true; + LibGlobal.debugEnabledJpgMetaIo = true; } /// TODO: move to seperate class FileCommandsIntegrationTests diff --git a/fotolib2/src/test/java/de/k3b/media/ExifInterfaceExIntegrationTests.java b/fotolib2/src/test/java/de/k3b/media/ExifInterfaceExIntegrationTests.java index 57d76a4c..94fbc22a 100644 --- a/fotolib2/src/test/java/de/k3b/media/ExifInterfaceExIntegrationTests.java +++ b/fotolib2/src/test/java/de/k3b/media/ExifInterfaceExIntegrationTests.java @@ -29,7 +29,7 @@ import java.io.IOException; import java.io.InputStream; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.TestUtil; import de.k3b.io.DateUtil; import de.k3b.io.ListUtils; @@ -46,8 +46,8 @@ public class ExifInterfaceExIntegrationTests { @BeforeClass public static void initDirectories() { - FotoLibGlobal.appName = "JUnit"; - FotoLibGlobal.appVersion = "ExifInterfaceExIntegrationTests"; + LibGlobal.appName = "JUnit"; + LibGlobal.appVersion = "ExifInterfaceExIntegrationTests"; } @Before diff --git a/fotolib2/src/test/java/de/k3b/media/ExifInterfaceIntegrationTests.java b/fotolib2/src/test/java/de/k3b/media/ExifInterfaceIntegrationTests.java index 1bab36f6..6ed366f1 100644 --- a/fotolib2/src/test/java/de/k3b/media/ExifInterfaceIntegrationTests.java +++ b/fotolib2/src/test/java/de/k3b/media/ExifInterfaceIntegrationTests.java @@ -33,7 +33,7 @@ import java.io.OutputStream; import java.util.HashMap; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.TestUtil; import de.k3b.io.FileUtils; @@ -56,8 +56,8 @@ public class ExifInterfaceIntegrationTests { "Русский (Russian)" ; @BeforeClass public static void initDirectories() { - FotoLibGlobal.appName = "JUnit"; - FotoLibGlobal.appVersion = "ExifInterfaceIntegrationTests"; + LibGlobal.appName = "JUnit"; + LibGlobal.appVersion = "ExifInterfaceIntegrationTests"; FileUtils.delete(OUTDIR, null); OUTDIR.mkdirs(); diff --git a/fotolib2/src/test/java/de/k3b/media/ImageMetaReaderIntegrationTests.java b/fotolib2/src/test/java/de/k3b/media/ImageMetaReaderIntegrationTests.java index de0c74e0..2f2211dd 100644 --- a/fotolib2/src/test/java/de/k3b/media/ImageMetaReaderIntegrationTests.java +++ b/fotolib2/src/test/java/de/k3b/media/ImageMetaReaderIntegrationTests.java @@ -33,7 +33,7 @@ import java.io.InputStream; import java.util.List; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.TestUtil; import de.k3b.io.DateUtil; import de.k3b.io.ListUtils; @@ -48,8 +48,8 @@ public class ImageMetaReaderIntegrationTests { private ImageMetaReader sut = null; @BeforeClass public static void initDirectories() { - FotoLibGlobal.appName = "JUnit"; - FotoLibGlobal.appVersion = "ImageMetaReaderIntegrationTests"; + LibGlobal.appName = "JUnit"; + LibGlobal.appVersion = "ImageMetaReaderIntegrationTests"; } @Before diff --git a/fotolib2/src/test/java/de/k3b/media/JpgMetaWorkflowIntegratoinTests.java b/fotolib2/src/test/java/de/k3b/media/JpgMetaWorkflowIntegratoinTests.java index 3ea0f706..39241c9f 100644 --- a/fotolib2/src/test/java/de/k3b/media/JpgMetaWorkflowIntegratoinTests.java +++ b/fotolib2/src/test/java/de/k3b/media/JpgMetaWorkflowIntegratoinTests.java @@ -9,7 +9,7 @@ import java.io.IOException; import java.util.EnumSet; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.TestUtil; import de.k3b.io.FileUtils; @@ -46,24 +46,24 @@ public class JpgMetaWorkflowIntegratoinTests { @BeforeClass public static void initDirectories() { - FotoLibGlobal.appName = "JUnit"; - FotoLibGlobal.appVersion = SUT_CLASS_NAME; + LibGlobal.appName = "JUnit"; + LibGlobal.appVersion = SUT_CLASS_NAME; FileUtils.delete(OUTDIR, null); OUTDIR.mkdirs(); ExifInterface.DEBUG = true; - FotoLibGlobal.debugEnabled = true; + LibGlobal.debugEnabled = true; // so you can see that the file was modified - FotoLibGlobal.preserveJpgFileModificationDate = false; + LibGlobal.preserveJpgFileModificationDate = false; } @Test public void shouldUpdateExistingExifWithCreateXmp() throws IOException { - FotoLibGlobal.mediaUpdateStrategy = "JXC"; + LibGlobal.mediaUpdateStrategy = "JXC"; String fileNameSrc = "test-WitExtraData.jpg"; String fileNameDest = "shouldUpdateExistingExifWithCreateXmp.jpg"; diff --git a/fotolib2/src/test/java/de/k3b/media/MediaXmpSegmentIntegrationTests.java b/fotolib2/src/test/java/de/k3b/media/MediaXmpSegmentIntegrationTests.java index 00d496e8..db78d451 100644 --- a/fotolib2/src/test/java/de/k3b/media/MediaXmpSegmentIntegrationTests.java +++ b/fotolib2/src/test/java/de/k3b/media/MediaXmpSegmentIntegrationTests.java @@ -30,7 +30,7 @@ import java.io.InputStream; import java.util.TimeZone; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.TestUtil; import de.k3b.io.DateUtil; import de.k3b.io.ListUtils; @@ -45,8 +45,8 @@ public class MediaXmpSegmentIntegrationTests { private IMetaApi sut = null; @BeforeClass public static void initDirectories() { - FotoLibGlobal.appName = "JUnit"; - FotoLibGlobal.appVersion = "MediaXmpSegmentIntegrationTests"; + LibGlobal.appName = "JUnit"; + LibGlobal.appVersion = "MediaXmpSegmentIntegrationTests"; } @Before diff --git a/fotolib2/src/test/java/de/k3b/media/MediaXmpTests.java b/fotolib2/src/test/java/de/k3b/media/MediaXmpTests.java index 29ba7334..84d10271 100644 --- a/fotolib2/src/test/java/de/k3b/media/MediaXmpTests.java +++ b/fotolib2/src/test/java/de/k3b/media/MediaXmpTests.java @@ -31,7 +31,7 @@ import java.io.InputStream; import java.util.TimeZone; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.TestUtil; /** @@ -46,8 +46,8 @@ public class MediaXmpTests { @BeforeClass public static void initDirectories() { - FotoLibGlobal.appName = "JUnit"; - FotoLibGlobal.appVersion = "MediaXmpTests"; + LibGlobal.appName = "JUnit"; + LibGlobal.appVersion = "MediaXmpTests"; } @Test diff --git a/fotolib2/src/test/java/de/k3b/media/MetaWriterExifXmlIntegrationTests.java b/fotolib2/src/test/java/de/k3b/media/MetaWriterExifXmlIntegrationTests.java index 0ca732e8..b822b394 100644 --- a/fotolib2/src/test/java/de/k3b/media/MetaWriterExifXmlIntegrationTests.java +++ b/fotolib2/src/test/java/de/k3b/media/MetaWriterExifXmlIntegrationTests.java @@ -30,7 +30,7 @@ import java.io.IOException; import java.io.Writer; -import de.k3b.FotoLibGlobal; +import de.k3b.LibGlobal; import de.k3b.TestUtil; import de.k3b.io.FileCommands; import de.k3b.io.FileUtils; @@ -46,8 +46,8 @@ public class MetaWriterExifXmlIntegrationTests { @BeforeClass public static void initDirectories() { - FotoLibGlobal.appName = "JUnit"; - FotoLibGlobal.appVersion = "MetaWriterExifXmlIntegrationTests"; + LibGlobal.appName = "JUnit"; + LibGlobal.appVersion = "MetaWriterExifXmlIntegrationTests"; OUTDIR.mkdirs(); } diff --git a/fotolib2/src/test/java/de/k3b/transactionlog/TransactionLogParserTests.java b/fotolib2/src/test/java/de/k3b/transactionlog/TransactionLogParserTests.java index f526d556..3e70b47e 100644 --- a/fotolib2/src/test/java/de/k3b/transactionlog/TransactionLogParserTests.java +++ b/fotolib2/src/test/java/de/k3b/transactionlog/TransactionLogParserTests.java @@ -1,7 +1,7 @@ /* - * Copyright (c) 2017 by k3b. + * Copyright (c) 2018 by k3b. * - * This file is part of AndroFotoFinder / #APhotoManager. + * This file is part of #APhotoManager (https://github.com/k3b/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 @@ -11,8 +11,8 @@ * 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. * + * for more details. * You should have received a copy of the GNU General Public License along with * this program. If not, see */ diff --git a/fotolib2/src/test/java/de/k3b/translations/TranslationStatistics.java b/fotolib2/src/test/java/de/k3b/translations/TranslationStatistics.java index ec22341c..71ad86b4 100644 --- a/fotolib2/src/test/java/de/k3b/translations/TranslationStatistics.java +++ b/fotolib2/src/test/java/de/k3b/translations/TranslationStatistics.java @@ -1,7 +1,8 @@ /* * Copyright (c) 2018 by k3b. * - * This file is part of AndroFotoFinder / #APhotoManager. + * This file is part of #APhotoManager (https://github.com/k3b/APhotoManager/) + * and #toGoZip (https://github.com/k3b/ToGoZip/). * * 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 diff --git a/fotolib2/src/test/java/de/k3b/translations/TranslationStatisticsTests.java b/fotolib2/src/test/java/de/k3b/translations/TranslationStatisticsTests.java index 2d9dfd21..d59ad809 100644 --- a/fotolib2/src/test/java/de/k3b/translations/TranslationStatisticsTests.java +++ b/fotolib2/src/test/java/de/k3b/translations/TranslationStatisticsTests.java @@ -1,7 +1,8 @@ /* * Copyright (c) 2018 by k3b. * - * This file is part of AndroFotoFinder / #APhotoManager. + * This file is part of #APhotoManager (https://github.com/k3b/APhotoManager/) + * and #toGoZip (https://github.com/k3b/ToGoZip/). * * 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 @@ -11,8 +12,8 @@ * 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. * + * for more details. * You should have received a copy of the GNU General Public License along with * this program. If not, see */ From 48243dbdddefbdb66d03f8c775f9010357d882cc Mon Sep 17 00:00:00 2001 From: k3b <1374583+k3b@users.noreply.github.com> Date: Sun, 4 Nov 2018 14:07:12 +0100 Subject: [PATCH 03/35] #132: Long press on Exif-Picker butten in Autoprocessing-Editor: get lat/lon/description/tags from selected photos --- .../androFotoFinder/AndroFotoFinderApp.java | 4 +- .../PhotoAutoprocessingEditActivity.java | 135 ++++++++++-------- .../k3b/android/util/AndroidFileCommands.java | 2 +- .../src/main/java/de/k3b/io/FileCommands.java | 16 +-- fotolib2/src/main/java/de/k3b/io/GeoUtil.java | 12 +- .../src/main/java/de/k3b/io/ListUtils.java | 28 +++- ...owDto.java => PhotoAutoprocessingDto.java} | 51 ++++--- .../java/de/k3b/io/RuleFileNameProcessor.java | 6 + .../de/k3b/io/collections/SelectedFiles.java | 4 + .../src/main/java/de/k3b/media/MediaUtil.java | 59 ++++++++ fotolib2/src/test/java/de/k3b/TestUtil.java | 19 ++- .../io/FileCommandAutoIntegrationTests.java | 32 ++--- .../ExifInterfaceExIntegrationTests.java | 2 +- .../media/ExifInterfaceIntegrationTests.java | 6 +- .../ImageMetaReaderIntegrationTests.java | 2 +- .../JpgMetaWorkflowIntegratoinTests.java | 2 +- .../java/de/k3b/media/MediaUtilTests.java | 19 +++ .../MediaXmpSegmentIntegrationTests.java | 2 +- .../test/java/de/k3b/media/MediaXmpTests.java | 2 +- .../MetaWriterExifXmlIntegrationTests.java | 12 +- 20 files changed, 290 insertions(+), 125 deletions(-) rename fotolib2/src/main/java/de/k3b/io/{PhotoWorkFlowDto.java => PhotoAutoprocessingDto.java} (79%) 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 5c85f272..f6c503c4 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/AndroFotoFinderApp.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/AndroFotoFinderApp.java @@ -38,7 +38,7 @@ import de.k3b.android.osmdroid.forge.MapsForgeSupport; import de.k3b.android.util.LogCat; import de.k3b.database.QueryParameter; -import de.k3b.io.PhotoWorkFlowDto; +import de.k3b.io.PhotoAutoprocessingDto; import de.k3b.media.ExifInterface; import de.k3b.media.ImageMetaReader; import uk.co.senab.photoview.PhotoViewAttacher; @@ -82,7 +82,7 @@ public static RefWatcher getRefWatcher(Context context) { // create sensible defaults for andorid-independant files from android string resources QueryParameter.sFileComment = getBookMarkComment(this); - PhotoWorkFlowDto.sFileComment = getBookMarkComment(this); + PhotoAutoprocessingDto.sFileComment = getBookMarkComment(this); QueryParameter.sParserDefaultFrom = FotoSql.SQL_TABLE_EXTERNAL_CONTENT_URI_FILE.toString(); QueryParameter.sParserDefaultQueryTypeId = FotoSql.QUERY_TYPE_DEFAULT; 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 cfd48782..b2564bea 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/PhotoAutoprocessingEditActivity.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/PhotoAutoprocessingEditActivity.java @@ -56,21 +56,21 @@ import de.k3b.android.androFotoFinder.queries.FotoSql; import de.k3b.android.util.ClipboardUtil; import de.k3b.android.util.IntentUtil; -import de.k3b.android.util.MediaScanner; import de.k3b.android.widget.AboutDialogPreference; import de.k3b.android.widget.ActivityWithAutoCloseDialogs; import de.k3b.io.ListUtils; +import de.k3b.io.PhotoAutoprocessingDto; import de.k3b.io.collections.SelectedFiles; import de.k3b.io.DateUtil; import de.k3b.io.RuleFileNameProcessor; -import de.k3b.io.PhotoWorkFlowDto; import de.k3b.io.StringUtils; import de.k3b.media.IMetaApi; import de.k3b.media.MediaAsString; +import de.k3b.media.MediaDTO; import de.k3b.media.MediaUtil; /** - * Editor for a WorkflowItem ".apm" files that define + * #93: Editor for a WorkflowItem ".apm" files that define * rules to process one or more photos * * filename schemata for copied/moved files * * default properties that every photot should receive. @@ -86,7 +86,7 @@ public class PhotoAutoprocessingEditActivity extends ActivityWithAutoCloseDialog * current modified value of the first selected file */ private File mCurrentOutDir = null; - private PhotoWorkFlowDto mCurrentData; + private PhotoAutoprocessingDto mCurrentAutoprocessingData; private SelectedFiles mSelectedFiles; private RuleFileNameProcessor mProcessor; @@ -99,7 +99,7 @@ public class PhotoAutoprocessingEditActivity extends ActivityWithAutoCloseDialog private File exampleSrcfile; private Date exampleDate; - public static void showActivity(String debugContext, Activity context, PhotoWorkFlowDto workflow, + public static void showActivity(String debugContext, Activity context, PhotoAutoprocessingDto workflow, String directoryOrApmFileUrl , SelectedFiles selectedFiles, int requestCode) { final Intent intent = new Intent().setClass(context, @@ -139,17 +139,17 @@ protected void onCreate(Bundle savedInstanceState) { if (mCurrentOutDir.isFile()) mCurrentOutDir = mCurrentOutDir.getParentFile(); } - mCurrentData = null; + mCurrentAutoprocessingData = null; if (savedInstanceState != null) { final Serializable settingsAsSerializable = savedInstanceState.getSerializable(SETTINGS_KEY); - mCurrentData = PhotoWorkFlowDto.load(settingsAsSerializable); + mCurrentAutoprocessingData = PhotoAutoprocessingDto.load(settingsAsSerializable); } - if ((mCurrentData == null) && (mCurrentOutDir != null)) { + if ((mCurrentAutoprocessingData == null) && (mCurrentOutDir != null)) { try { - mCurrentData = new PhotoWorkFlowDto(); - mCurrentData.load(mCurrentOutDir); + mCurrentAutoprocessingData = new PhotoAutoprocessingDto(); + mCurrentAutoprocessingData.load(mCurrentOutDir); } catch (IOException e) { - onFatalError(mDebugPrefix + "Cannot load .apm from " + mCurrentData, e); + onFatalError(mDebugPrefix + "Cannot load .apm from " + mCurrentAutoprocessingData, e); return; } } @@ -160,34 +160,22 @@ protected void onCreate(Bundle savedInstanceState) { "onCreate",intent.toUri(Intent.URI_INTENT_SCHEME), nl,mCurrentOutDir, nl,"savedInstanceState",savedInstanceState, - nl,mCurrentData)); + nl, mCurrentAutoprocessingData)); } - if ((mCurrentOutDir == null) || (mCurrentData == null)) { + if ((mCurrentOutDir == null) || (mCurrentAutoprocessingData == null)) { onFatalError(mDebugPrefix + "Missing Intent.data parameter. intent=" + intent.toUri(Intent.URI_INTENT_SCHEME), null); return; } - mCurrentData.setOutDir(mCurrentOutDir); + mCurrentAutoprocessingData.setOutDir(mCurrentOutDir); mProcessor = new RuleFileNameProcessor(mCurrentOutDir); - if (mCurrentData.getMediaDefaults() == null) { - File first = mSelectedFiles.getFile(0); - - MediaAsString exampleExif = new MediaAsString(); - if ((first != null) && (first.exists())) { - IMetaApi example = MediaScanner.getInstance(this).getExifFromFile(first); - if (example != null) { - exampleExif.setData(example); - } - } - - // do not predefine these - exampleExif.setDateTimeTaken(null); - exampleExif.setPath(null); - exampleExif.setTitle(null); - mCurrentData.setMediaDefaults(exampleExif); + // if there are no MediaDefaults yet infer them from selected files + if (mCurrentAutoprocessingData.getMediaDefaults() == null) { + MediaAsString exampleExif = MediaUtil.inferAutoprocessingExifDefaults(new MediaAsString(), mSelectedFiles.getFiles()); + mCurrentAutoprocessingData.setMediaDefaults(exampleExif); } this.exampleSrcfile = mProcessor.getFile(mSelectedFiles.getFile(0)); @@ -228,9 +216,9 @@ public String toString() { } private void fromGui() { - mCurrentData.setName(mEditName.getText().toString()); - mCurrentData.setDateFormat(getSelectedPattern(mSpinnerDatePattern)); - mCurrentData.setNumberFormat(getSelectedPattern(mSpinnerNumberPattern)); + mCurrentAutoprocessingData.setName(mEditName.getText().toString()); + mCurrentAutoprocessingData.setDateFormat(getSelectedPattern(mSpinnerDatePattern)); + mCurrentAutoprocessingData.setNumberFormat(getSelectedPattern(mSpinnerNumberPattern)); } /** to avoid endless recursion toGui() ... TextView.setText ... afterTextChanged ... toGui() */ @@ -238,9 +226,9 @@ private void fromGui() { private void toGui() { - String numberFormat = mCurrentData.getNumberFormat(); - final String namePart = mCurrentData.getName(); - final String dateFormat = mCurrentData.getDateFormat(); + String numberFormat = mCurrentAutoprocessingData.getNumberFormat(); + final String namePart = mCurrentAutoprocessingData.getName(); + final String dateFormat = mCurrentAutoprocessingData.getDateFormat(); inToGuiCount++; try { @@ -265,9 +253,9 @@ private void toGui() { mSelectedFiles.size(), (exampleSrcfile == null) ? null : exampleSrcfile.getName(), DateUtil.toIsoDateString(exampleDate), - mCurrentData.getOutDir(), exampleResultFileName)); + mCurrentAutoprocessingData.getOutDir(), exampleResultFileName)); - IMetaApi mediaChanges = mCurrentData.getMediaDefaults(); + IMetaApi mediaChanges = mCurrentAutoprocessingData.getMediaDefaults(); String exifChange = null; if (mediaChanges != null) { exifChange = MediaUtil.toString(mediaChanges, false, mLabelGenerator, MediaUtil.FieldID.clasz); @@ -307,7 +295,7 @@ private String getSelectedPattern(Spinner spinner) { @Override public void onSaveInstanceState(Bundle savedInstanceState) { fromGui(); - savedInstanceState.putSerializable(SETTINGS_KEY, mCurrentData.toSerializable()); + savedInstanceState.putSerializable(SETTINGS_KEY, mCurrentAutoprocessingData.toSerializable()); if (Global.debugEnabled) { Log.d(Global.LOG_CONTEXT, mDebugPrefix + " onSaveInstanceState " + savedInstanceState); @@ -328,7 +316,7 @@ private void defineGui() { mSpinnerDatePattern.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { - mCurrentData.setDateFormat(getSelectedPattern(mSpinnerDatePattern)); + mCurrentAutoprocessingData.setDateFormat(getSelectedPattern(mSpinnerDatePattern)); toGui(); } @@ -355,11 +343,11 @@ public void afterTextChanged(Editable s) { // to avoid endless recursion toGui() ... TextView.setText ... afterTextChanged ... toGui() if (inToGuiCount == 0) { String newValue = s.toString(); - if (0 != StringUtils.compare(newValue, mCurrentData.getName())) { + if (0 != StringUtils.compare(newValue, mCurrentAutoprocessingData.getName())) { int start = mEditName.getSelectionStart(); int end = mEditName.getSelectionEnd(); // prevent stackoverflow - mCurrentData.setName(newValue); + mCurrentAutoprocessingData.setName(newValue); toGui(); mEditName.setSelection(start, end); // prevent cursor from jumping } @@ -372,7 +360,7 @@ public void afterTextChanged(Editable s) { mSpinnerNumberPattern.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView parent, View view, int position, long id) { - mCurrentData.setNumberFormat(getSelectedPattern(mSpinnerNumberPattern)); + mCurrentAutoprocessingData.setNumberFormat(getSelectedPattern(mSpinnerNumberPattern)); toGui(); } @@ -390,6 +378,12 @@ public void onClick(View v) { onPickExif(); } }); + cmd.setOnLongClickListener(new View.OnLongClickListener() { + @Override + public boolean onLongClick(View v) { + return onReInferExifAndPick(); + } + }); ((ImageButton) findViewById(R.id.cmd_file_name_pattern_history)).setOnClickListener(new View.OnClickListener() { @Override @@ -414,8 +408,8 @@ private List createDatePatterns() { private Date getExampleDate(File exampleSrcfile) { Date exampleValue = null; - if ((mCurrentData != null) && (mCurrentData.getMediaDefaults() != null)) { - exampleValue = mCurrentData.getMediaDefaults().getDateTimeTaken(); + if ((mCurrentAutoprocessingData != null) && (mCurrentAutoprocessingData.getMediaDefaults() != null)) { + exampleValue = mCurrentAutoprocessingData.getMediaDefaults().getDateTimeTaken(); } if (exampleValue == null) { long lastModified = (exampleSrcfile == null) ? 0 : exampleSrcfile.lastModified(); @@ -428,8 +422,8 @@ private List createNumberPatterns() { long exampleValue = 1; /* - if ((mCurrentData != null) && (mCurrentData.getOutDir() != null)) { - exampleValue = mCurrentData.getMediaDefaults().getDateTimeTaken(); + if ((mCurrentAutoprocessingData != null) && (mCurrentAutoprocessingData.getOutDir() != null)) { + exampleValue = mCurrentAutoprocessingData.getMediaDefaults().getDateTimeTaken(); } if (exampleValue == null) exampleValue = new Date(); */ @@ -501,9 +495,9 @@ private boolean onRenamerPopupMenuClick(MenuItem item) { private boolean setFileRule(String namePart) { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this); - mCurrentData.setNumberFormat((namePart == null) ? "" : sharedPref.getString(PREF_LAST_RENAME_NUMBER_PATTERN, null)); - mCurrentData.setName((namePart == null) ? "" : namePart); - mCurrentData.setDateFormat((namePart == null) ? "" : sharedPref.getString(PREF_LAST_RENAME_DATE_PATTERN, null)); + mCurrentAutoprocessingData.setNumberFormat((namePart == null) ? "" : sharedPref.getString(PREF_LAST_RENAME_NUMBER_PATTERN, null)); + mCurrentAutoprocessingData.setName((namePart == null) ? "" : namePart); + mCurrentAutoprocessingData.setDateFormat((namePart == null) ? "" : sharedPref.getString(PREF_LAST_RENAME_DATE_PATTERN, null)); toGui(); @@ -526,18 +520,43 @@ private void saveLastFilePattern(String dateFormat, String numberFormat) { */ private void onPickExif() { fromGui(); - ExifEditActivity.showActivity("[4]", this, mCurrentData.getMediaDefaults(), + ExifEditActivity.showActivity("[4]", this, mCurrentAutoprocessingData.getMediaDefaults(), null, getSelectedFiles(mDebugPrefix+"EditExif-", getIntent(), false), EXIF_EDIT_RESULT_ID, false); } + /** + * #132: cmd exif long-press: infer exif from selected and schow exif editor + */ + private boolean onReInferExifAndPick() { + fromGui(); + IMetaApi currentMediaDefaults = mCurrentAutoprocessingData.getMediaDefaults(); + + SelectedFiles selectedFiles = getSelectedFiles(mDebugPrefix + "EditExif-", getIntent(), + false); + IMetaApi inferedMediaDefaults = MediaUtil.inferAutoprocessingExifDefaults(new MediaDTO(), selectedFiles.getFiles()); + + if (inferedMediaDefaults.getDescription() != null) currentMediaDefaults.setDescription(inferedMediaDefaults.getDescription()); + if (inferedMediaDefaults.getLatitude() != null) currentMediaDefaults.setLatitudeLongitude(inferedMediaDefaults.getLatitude(), inferedMediaDefaults.getLongitude()); + + if (inferedMediaDefaults.getTags() != null) { + List tags = currentMediaDefaults.getTags(); + ListUtils.include(tags, inferedMediaDefaults.getTags()); + inferedMediaDefaults.setTags(tags); + } + + ExifEditActivity.showActivity("[4]", this, currentMediaDefaults, + null, selectedFiles, + EXIF_EDIT_RESULT_ID, false); + return true; + } /** * exif editor result */ private void onExifChanged(IMetaApi modifiedExif) { if (modifiedExif != null) { - mCurrentData.setMediaDefaults(modifiedExif); + mCurrentAutoprocessingData.setMediaDefaults(modifiedExif); toGui(); } } @@ -593,7 +612,7 @@ public boolean onCreateOptionsMenu(Menu menu) { MenuItem item = menu.findItem(android.R.id.paste); final File clipboardDir = ClipboardUtil.getClipboardDir(this); - final File apmFile = (clipboardDir == null) ? null : PhotoWorkFlowDto.getApmFile(clipboardDir); + final File apmFile = (clipboardDir == null) ? null : PhotoAutoprocessingDto.getApmFile(clipboardDir); if ((item != null) && (apmFile != null) && apmFile.exists()) { item.setVisible(true); } @@ -645,9 +664,9 @@ private boolean onPaste() { File dir = ClipboardUtil.getClipboardDir(this); if (dir != null) { try { - PhotoWorkFlowDto srcApm = new PhotoWorkFlowDto().load(dir); + PhotoAutoprocessingDto srcApm = new PhotoAutoprocessingDto().load(dir); if (srcApm != null) { - mCurrentData.paste(srcApm); + mCurrentAutoprocessingData.paste(srcApm); toGui(); return true; } @@ -691,8 +710,8 @@ protected void onResume() { private void onOk() { fromGui(); try { - mCurrentData.save(); - saveLastFilePattern(mCurrentData.getDateFormat(), mCurrentData.getNumberFormat()); + mCurrentAutoprocessingData.save(); + saveLastFilePattern(mCurrentAutoprocessingData.getDateFormat(), mCurrentAutoprocessingData.getNumberFormat()); setResult(Activity.RESULT_OK, null); } catch (IOException e) { onFatalError("onOk()-save()", e); @@ -701,7 +720,7 @@ private void onOk() { } private void clearFilter() { - mCurrentData.clear(); + mCurrentAutoprocessingData.clear(); toGui(); } 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 9a829140..76f8977a 100644 --- a/app/src/main/java/de/k3b/android/util/AndroidFileCommands.java +++ b/app/src/main/java/de/k3b/android/util/AndroidFileCommands.java @@ -440,7 +440,7 @@ public int setGeo(double latitude, double longitude, SelectedFiles selectedItems String dbgContext = "setGeo"; if (!Double.isNaN(latitude) && !Double.isNaN(longitude) && (selectedItems != null) && (selectedItems.size() > 0)) { // in case that current activity is destroyed while running async, applicationContext will allow to finish database operation - File[] files = SelectedFiles.getFiles(selectedItems.getFileNames()); + File[] files = selectedItems.getFiles(); String errorMessage = checkWriteProtected(R.string.geo_edit_menu_title, files); if (errorMessage != null) { diff --git a/fotolib2/src/main/java/de/k3b/io/FileCommands.java b/fotolib2/src/main/java/de/k3b/io/FileCommands.java index 86b34c54..3f9565d7 100644 --- a/fotolib2/src/main/java/de/k3b/io/FileCommands.java +++ b/fotolib2/src/main/java/de/k3b/io/FileCommands.java @@ -164,7 +164,7 @@ protected boolean deleteFileWithSidecar(File file) { */ public int applyExifChanges(boolean move, MediaDiffCopy exifChanges, SelectedFiles selectedFiles, IProgessListener progessListener) { // source files are the same as dest files. - final File[] destFiles = SelectedFiles.getFiles(selectedFiles.getFileNames()); + final File[] destFiles = selectedFiles.getFiles(); return moveOrCopyFiles(move, "change_exif", exifChanges, selectedFiles, destFiles, progessListener); } @@ -177,7 +177,7 @@ public int applyExifChanges(boolean move, MediaDiffCopy exifChanges, SelectedFil * @param destDirFolder where files are moved/copied to * @param progessListener */ public int moveOrCopyFilesTo(boolean move, SelectedFiles selectedFiles, File destDirFolder, IProgessListener progessListener) { - PhotoWorkFlowDto autoProccessData = (!LibGlobal.apmEnabled) ? null : getPhotoWorkFlowDto(destDirFolder); + PhotoAutoprocessingDto autoProccessData = (!LibGlobal.apmEnabled) ? null : getPhotoAutoprocessingDto(destDirFolder); return moveOrCopyFilesTo(move, selectedFiles, destDirFolder, autoProccessData, progessListener); } @@ -193,7 +193,7 @@ public int moveOrCopyFilesTo(boolean move, SelectedFiles selectedFiles, File des * @param autoProccessData null or data for auto rename/exif data * @param progessListener */ int moveOrCopyFilesTo(boolean move, SelectedFiles selectedFiles, File destDirFolder, - PhotoWorkFlowDto autoProccessData, IProgessListener progessListener) { + PhotoAutoprocessingDto autoProccessData, IProgessListener progessListener) { boolean doNotRenameIfSourceInDestFolder = false; IFileNameProcessor renameProcessor = null; MediaDiffCopy exifChanges = null; @@ -227,7 +227,7 @@ int moveOrCopyFilesTo(boolean move, int result = 0; if (canProcessFile(move ? OP_MOVE : OP_COPY)) { if (osCreateDirIfNeccessary(destDirFolder)) { - File[] destFiles = createDestFiles(renameProcessor, destDirFolder, selectedFiles.getDatesPhotoTaken() , SelectedFiles.getFiles(selectedFiles.getFileNames())); + File[] destFiles = createDestFiles(renameProcessor, destDirFolder, selectedFiles.getDatesPhotoTaken() , selectedFiles.getFiles()); result = moveOrCopyFiles(move, (move ? "mov" : "copy"), exifChanges, selectedFiles, destFiles, progessListener); @@ -258,7 +258,7 @@ protected int moveOrCopyFiles(final boolean move, String what, MediaDiffCopy exi int fileCount = destFiles.length; Long[] ids = fotos.getIds(); - File[] sourceFiles = SelectedFiles.getFiles(fotos.getFileNames()); + File[] sourceFiles = fotos.getFiles(); mModifiedSrcFiles = (move) ? new ArrayList() : null; mModifiedDestFiles = new ArrayList(); @@ -373,10 +373,10 @@ protected int moveOrCopyFiles(final boolean move, String what, MediaDiffCopy exi return itemCount; } - private PhotoWorkFlowDto getPhotoWorkFlowDto(File destDirFolder) { - PhotoWorkFlowDto autoProccessData = null; + private PhotoAutoprocessingDto getPhotoAutoprocessingDto(File destDirFolder) { + PhotoAutoprocessingDto autoProccessData = null; try { - autoProccessData = new PhotoWorkFlowDto().load(destDirFolder); + autoProccessData = new PhotoAutoprocessingDto().load(destDirFolder); } catch (IOException e) { log("cannot load .apm file for '", destDirFolder, "'. ", e.getMessage()); autoProccessData = null; diff --git a/fotolib2/src/main/java/de/k3b/io/GeoUtil.java b/fotolib2/src/main/java/de/k3b/io/GeoUtil.java index 4d076233..08fa1ae6 100644 --- a/fotolib2/src/main/java/de/k3b/io/GeoUtil.java +++ b/fotolib2/src/main/java/de/k3b/io/GeoUtil.java @@ -162,9 +162,17 @@ public static boolean equals(Double lhs, Double rhs) { * @return always != null: either GeoUtil.NO_LAT_LON if null, empty, unknown or value */ public static Double getValue(Double value) { - if (value == null) return GeoUtil.NO_LAT_LON; + return getValue(value, GeoUtil.NO_LAT_LON); + } + + /** normalized getGeoValue with null or NaN are translated to NO_LAT_LON. + * #91: Fix Photo without geo may have different representations values for no-value + * @return always != null: either GeoUtil.NO_LAT_LON if null, empty, unknown or value + */ + public static Double getValue(Double value, Double noLatLonValue) { + if (value == null) return noLatLonValue; double result = value.doubleValue(); - if (Double.isNaN(result) || (result == IGeoPointInfo.NO_LAT_LON)) return GeoUtil.NO_LAT_LON; + if (Double.isNaN(result) || (result == IGeoPointInfo.NO_LAT_LON) || (value == GeoUtil.NO_LAT_LON)) return noLatLonValue; return value; } diff --git a/fotolib2/src/main/java/de/k3b/io/ListUtils.java b/fotolib2/src/main/java/de/k3b/io/ListUtils.java index 7a083330..5dfe4590 100644 --- a/fotolib2/src/main/java/de/k3b/io/ListUtils.java +++ b/fotolib2/src/main/java/de/k3b/io/ListUtils.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.List; /** @@ -62,7 +63,7 @@ public static List toStringList(Object... list) { return result; } - public static String toString(String elementDelimiter, List list) { + public static String toString(String elementDelimiter, Collection list) { StringBuilder result = new StringBuilder(); if (list != null) { String nextDelim = ""; @@ -95,15 +96,36 @@ public static String toString(String elementDelimiter, Object... list) { } return result.toString(); } + public static String[] asStringArray(List tags) { if ((tags == null) || (tags.size() == 0)) return null; String[] tagsArray = tags.toArray(new String[tags.size()]); return tagsArray; } - /** return null if list has no elements */ + /** + * return null if list has no elements + */ public static List emptyAsNull(List list) { if ((list != null) && (list.size() > 0)) return list; return null; } -} \ No newline at end of file + + /** add item "itemToBeAddedIfNotInList" to list if it is not in the list yet */ + public static List include(List list, T itemToBeAddedIfNotInList) { + if ((itemToBeAddedIfNotInList != null) && (!list.contains(itemToBeAddedIfNotInList))) { + list.add(itemToBeAddedIfNotInList); + } + return list; + } + + /** add all items from "itemsToBeAddedIfNotInList" to list that are not in the list yet */ + public static List include(List list, Collection itemsToBeAddedIfNotInList) { + if (itemsToBeAddedIfNotInList != null) { + for (T itemToBeAddedIfNotInList : itemsToBeAddedIfNotInList) { + include(list, itemToBeAddedIfNotInList); + } + } + return list; + } +} diff --git a/fotolib2/src/main/java/de/k3b/io/PhotoWorkFlowDto.java b/fotolib2/src/main/java/de/k3b/io/PhotoAutoprocessingDto.java similarity index 79% rename from fotolib2/src/main/java/de/k3b/io/PhotoWorkFlowDto.java rename to fotolib2/src/main/java/de/k3b/io/PhotoAutoprocessingDto.java index 6574866e..1f1663e5 100644 --- a/fotolib2/src/main/java/de/k3b/io/PhotoWorkFlowDto.java +++ b/fotolib2/src/main/java/de/k3b/io/PhotoAutoprocessingDto.java @@ -34,17 +34,20 @@ import de.k3b.media.MediaAsString; /** - * #93: Persistable data for autoproccessing images (auto-rename, auto-add-exif) + * #93: Persistable data for autoproccessing images (auto-rename, auto-add-exif). + * + * Implemented as Properties file. * * Created by k3b on 04.08.2017. */ -public class PhotoWorkFlowDto { +public class PhotoAutoprocessingDto { private static final Logger logger = LoggerFactory.getLogger(LibGlobal.LOG_TAG); /** added to every serialized item if != null. Example "Generated on 2015-10-19 with myApp Version 0815." */ public static String sFileComment = ""; + // KEY_xxx for properties file private static final String KEY_DATE_FORMAT = "DateFormat"; private static final String KEY_NAME = "Name"; private static final String KEY_NUMBER_FORMAT = "NumberFormat"; @@ -54,16 +57,16 @@ public class PhotoWorkFlowDto { private final Properties properties; private File outDir; - public PhotoWorkFlowDto() { + public PhotoAutoprocessingDto() { this(null, new Properties()); } - public PhotoWorkFlowDto(File outDir, Properties properties) { + public PhotoAutoprocessingDto(File outDir, Properties properties) { this.outDir = outDir; this.properties = properties; } - public PhotoWorkFlowDto load(File outDir) throws IOException { + public PhotoAutoprocessingDto load(File outDir) throws IOException { this.outDir = outDir; File apm = getApmFile(); properties.clear(); @@ -77,24 +80,30 @@ public PhotoWorkFlowDto load(File outDir) throws IOException { } return this; } finally { - FileUtils.close(inputStream,"PhotoWorkFlowDto.load(" + apm + ")"); + FileUtils.close(inputStream,"PhotoAutoprocessingDto.load(" + apm + ")"); } } return null; } - public void paste(PhotoWorkFlowDto newData) { + public void paste(PhotoAutoprocessingDto newData) { if (newData != null) { this.setDateFormat(newData.getDateFormat()); this.setNumberFormat(newData.getNumberFormat()); this.setMediaDefaults(newData.getMediaDefaults()); + + // Fix Autoprocessing/PhotoAutoprocessingDto renaming rules that contain source file direcory names. String name = getTranslateName(newData); this.setName(name); } } - public String getTranslateName(PhotoWorkFlowDto newData) { + /** + * Get the fixed rename-name part in case Autoprocessing/PhotoAutoprocessingDto was moved/copied to a + * different dir and renaming rules contain source file direcory names. + */ + public String getTranslateName(PhotoAutoprocessingDto newData) { if (newData != null) { final RuleFileNameProcessor srcData = (RuleFileNameProcessor) newData.createFileNameProcessor(); if (srcData != null) { @@ -127,25 +136,25 @@ public void save() throws IOException { logger.debug(this.getClass().getSimpleName() + ": save to " + apm + ":" + this); } stream = new FileOutputStream(apm); - properties.store(stream, PhotoWorkFlowDto.sFileComment); + properties.store(stream, PhotoAutoprocessingDto.sFileComment); } finally { - FileUtils.close(stream, "PhotoWorkFlowDto.load(" + apm + ")"); + FileUtils.close(stream, "PhotoAutoprocessingDto.load(" + apm + ")"); } } } /** Android support: to persist state and to transfer activites via intent. */ - public static PhotoWorkFlowDto load(Serializable content) { - PhotoWorkFlowDto photoWorkFlowDto = null; + public static PhotoAutoprocessingDto load(Serializable content) { + PhotoAutoprocessingDto photoAutoprocessingDto = null; if (content instanceof Properties ) { Properties properties = (Properties) content; String outDir = properties.getProperty(KEY_OUT_DIR); - photoWorkFlowDto = new PhotoWorkFlowDto((outDir != null) ? new File(outDir) : null, properties); + photoAutoprocessingDto = new PhotoAutoprocessingDto((outDir != null) ? new File(outDir) : null, properties); } if (LibGlobal.debugEnabled) { - logger.debug(PhotoWorkFlowDto.class.getSimpleName() + ": load De-Serialize:" + photoWorkFlowDto); + logger.debug(PhotoAutoprocessingDto.class.getSimpleName() + ": load De-Serialize:" + photoAutoprocessingDto); } - return photoWorkFlowDto; + return photoAutoprocessingDto; } /** Android support: to persist state and to transfer activites via intent */ @@ -162,7 +171,7 @@ public String getDateFormat() { } /** DateFormat part for {@link RuleFileNameProcessor} */ - public PhotoWorkFlowDto setDateFormat(String dateFormat) { + public PhotoAutoprocessingDto setDateFormat(String dateFormat) { setProperty(KEY_DATE_FORMAT,dateFormat); return this; } @@ -173,7 +182,7 @@ public String getName() { } /** fixed-Name part for {@link RuleFileNameProcessor} */ - public PhotoWorkFlowDto setName(String Name) { + public PhotoAutoprocessingDto setName(String Name) { setProperty(KEY_NAME,Name); return this; } @@ -184,7 +193,7 @@ public String getNumberFormat() { } /** NumberFormat part for {@link RuleFileNameProcessor} */ - public PhotoWorkFlowDto setNumberFormat(String NumberFormat) { + public PhotoAutoprocessingDto setNumberFormat(String NumberFormat) { setProperty(KEY_NUMBER_FORMAT,NumberFormat); return this; } @@ -192,7 +201,7 @@ public PhotoWorkFlowDto setNumberFormat(String NumberFormat) { public File getOutDir() { return outDir; } - public PhotoWorkFlowDto setOutDir(File outDir) { + public PhotoAutoprocessingDto setOutDir(File outDir) { this.outDir = outDir; return this; } @@ -201,12 +210,14 @@ public IFileNameProcessor createFileNameProcessor() { return new RuleFileNameProcessor(getDateFormat(), getName(), getNumberFormat(), getOutDir()); } + /** exif data that should be applied to every jpg file */ public IMetaApi getMediaDefaults() { String mediaDefaultString = getProperty(KEY_EXIF); return (mediaDefaultString == null) ? null : new MediaAsString().fromString(mediaDefaultString); } - public PhotoWorkFlowDto setMediaDefaults(IMetaApi mediaDefaults) { + /** exif data that should be applied to every jpg file */ + public PhotoAutoprocessingDto setMediaDefaults(IMetaApi mediaDefaults) { String mediaDefaultString = null; if (mediaDefaults != null) { mediaDefaultString = (mediaDefaults instanceof MediaAsString) diff --git a/fotolib2/src/main/java/de/k3b/io/RuleFileNameProcessor.java b/fotolib2/src/main/java/de/k3b/io/RuleFileNameProcessor.java index f160089f..b8d24c45 100644 --- a/fotolib2/src/main/java/de/k3b/io/RuleFileNameProcessor.java +++ b/fotolib2/src/main/java/de/k3b/io/RuleFileNameProcessor.java @@ -75,6 +75,9 @@ public RuleFileNameProcessor(String dateFormat, String name, String numberFormat set(dateFormat, name, numberFormat); } + /** + * Fix Autoprocessing/PhotoAutoprocessingDto renaming rules that contain source file direcory names. + */ public RuleFileNameProcessor(RuleFileNameProcessor ancestor, File newDir) { this(newDir); if (ancestor != null) { @@ -261,6 +264,9 @@ private static boolean isLetter(String name, int offset) { return result; } + /** + * Fix Autoprocessing/PhotoAutoprocessingDto renaming rules that contain source file direcory names. + */ public static String translateName(RuleFileNameProcessor srcData, File outDir) { RuleFileNameProcessor translated = new RuleFileNameProcessor(srcData, outDir); return translated.mName; diff --git a/fotolib2/src/main/java/de/k3b/io/collections/SelectedFiles.java b/fotolib2/src/main/java/de/k3b/io/collections/SelectedFiles.java index 38a2ab85..e2782302 100644 --- a/fotolib2/src/main/java/de/k3b/io/collections/SelectedFiles.java +++ b/fotolib2/src/main/java/de/k3b/io/collections/SelectedFiles.java @@ -105,6 +105,10 @@ public static File[] getFiles(String[] fileNames) { return result; } + public File[] getFiles() { + return SelectedFiles.getFiles(getFileNames()); + } + public int getNonEmptyNameCount() { int result = 0; if (mFileNames != null) { diff --git a/fotolib2/src/main/java/de/k3b/media/MediaUtil.java b/fotolib2/src/main/java/de/k3b/media/MediaUtil.java index b78b473f..9c46d986 100644 --- a/fotolib2/src/main/java/de/k3b/media/MediaUtil.java +++ b/fotolib2/src/main/java/de/k3b/media/MediaUtil.java @@ -19,17 +19,23 @@ package de.k3b.media; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.File; import java.io.FilenameFilter; +import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.EnumSet; import java.util.List; +import de.k3b.LibGlobal; import de.k3b.io.DateUtil; import de.k3b.io.FileUtils; import de.k3b.io.GeoUtil; +import de.k3b.io.ListUtils; import de.k3b.io.StringUtils; import de.k3b.io.VISIBILITY; import de.k3b.tagDB.TagConverter; @@ -39,6 +45,7 @@ */ public class MediaUtil { + private static final Logger logger = LoggerFactory.getLogger(LibGlobal.LOG_TAG); /** image will get this fileextension if updated from private image to public image. */ private static final String EXT_JPG = ".jpg"; @@ -421,4 +428,56 @@ public static int exifOrientationCode2RotationDegrees(int exifOrientationCode, i } return notFoundValue; } + + /** loads IMetaApi from jpg and corresponding xmp */ + public static IMetaApi loadExifAndXmp(String fileName, String dbg_context) { + try { + MediaXmpSegment xmp = MediaXmpSegment.loadXmpSidecarContentOrNull(fileName, dbg_context); + + ImageMetaReader jpg = new ImageMetaReader().load(fileName, null, xmp, dbg_context); + + return jpg; + } catch (IOException ex) { + logger.error(dbg_context, "MediaUtil.loadExifAndXmp", ex); + } + return null; + } + + /** #132: reads lat,lon,description,tags from files until tags and lat/long are found */ + public static T inferAutoprocessingExifDefaults(T result, File... files) { + return inferAutoprocessingExifDefaults(result, files, null,null,null, null); + } + + /** #132: reads lat,lon,description,tags from files until tags and lat/long are found */ + public static T inferAutoprocessingExifDefaults(T result, + File[] files, + Double latitude, + Double longitude, + String description, + List _tags) { + List tags = (_tags == null) ? new ArrayList() : _tags; + + int exampleCount = files.length; + int index = 0; + while ((index < exampleCount) && ((latitude == null) || (longitude == null) || (tags.size() == 0))) { + File exampleFile = files[index++]; + + if ((exampleFile != null) && (exampleFile.exists())) { + IMetaApi example = MediaUtil.loadExifAndXmp(exampleFile.getPath(),"infer defaults for autoprocessing"); + if (example != null) { + ListUtils.include(tags, example.getTags()); + latitude = GeoUtil.getValue(example.getLatitude(), latitude); + longitude = GeoUtil.getValue(example.getLongitude(), longitude); + if (StringUtils.isNullOrEmpty(description)) description = example.getDescription(); + } + } + } + result.setLatitudeLongitude(latitude,longitude) + .setDescription(description) + .setTags(tags); + + return result; + } + + } \ No newline at end of file diff --git a/fotolib2/src/test/java/de/k3b/TestUtil.java b/fotolib2/src/test/java/de/k3b/TestUtil.java index 1538b047..14c5c7be 100644 --- a/fotolib2/src/test/java/de/k3b/TestUtil.java +++ b/fotolib2/src/test/java/de/k3b/TestUtil.java @@ -35,8 +35,14 @@ import de.k3b.tagDB.TagConverter; public class TestUtil { + // where unittest-files are processed public static final File OUTDIR_ROOT = new File("./build/test-results/metafiles"); + // these test files exist as embedded resources + public static final String TEST_FILE_JPG_WITH_EXIF = "test-WitExtraData.jpg"; + public static final String TEST_FILE_XMP_WITH_EXIF = "test-WitExtraData.xmp"; + public static final String TEST_FILE_JPG_WITH_NO_EXIF = "NoExif.jpg"; + public static Reader createReader(String csvSrc) { return new java.io.StringReader(csvSrc); // return new InputStreamReader(new ByteArrayInputStream(csvSrc.getBytes("UTF-8"))); @@ -76,12 +82,23 @@ public static InputStream getResourceInputStream(String fileName) { return inputStream; } - public static void saveTestResourceAs(String resourceName, File destination) throws IOException { + public static File saveTestResourceAs(String resourceName, File destination) throws IOException { InputStream sourceStream = getResourceInputStream(resourceName); FileUtils.copyReplace(sourceStream, destination); FileUtils.close(sourceStream,resourceName); destination.setLastModified(DateUtil.parseIsoDate("1972-03-04T05:06:07").getTime()); + return destination; + } + + public static File[] saveTestResourcesIn(File destinationFolder, String... resourceNames) throws IOException { + File[] result = new File[resourceNames.length]; + + for(int i = 0; i testItems = new HashMap(); diff --git a/fotolib2/src/test/java/de/k3b/media/ImageMetaReaderIntegrationTests.java b/fotolib2/src/test/java/de/k3b/media/ImageMetaReaderIntegrationTests.java index 2f2211dd..07288f57 100644 --- a/fotolib2/src/test/java/de/k3b/media/ImageMetaReaderIntegrationTests.java +++ b/fotolib2/src/test/java/de/k3b/media/ImageMetaReaderIntegrationTests.java @@ -55,7 +55,7 @@ public static void initDirectories() { @Before public void setup() throws IOException { ImageMetaReader.DEBUG = true; - sut = getMeta("test-WitExtraData.jpg"); + sut = getMeta(TestUtil.TEST_FILE_JPG_WITH_EXIF); } @Test diff --git a/fotolib2/src/test/java/de/k3b/media/JpgMetaWorkflowIntegratoinTests.java b/fotolib2/src/test/java/de/k3b/media/JpgMetaWorkflowIntegratoinTests.java index 39241c9f..0fecabb5 100644 --- a/fotolib2/src/test/java/de/k3b/media/JpgMetaWorkflowIntegratoinTests.java +++ b/fotolib2/src/test/java/de/k3b/media/JpgMetaWorkflowIntegratoinTests.java @@ -64,7 +64,7 @@ public static void initDirectories() { public void shouldUpdateExistingExifWithCreateXmp() throws IOException { LibGlobal.mediaUpdateStrategy = "JXC"; - String fileNameSrc = "test-WitExtraData.jpg"; + String fileNameSrc = TestUtil.TEST_FILE_JPG_WITH_EXIF; String fileNameDest = "shouldUpdateExistingExifWithCreateXmp.jpg"; File testJpg = copy(fileNameSrc, fileNameDest); diff --git a/fotolib2/src/test/java/de/k3b/media/MediaUtilTests.java b/fotolib2/src/test/java/de/k3b/media/MediaUtilTests.java index 16538376..c7c28385 100644 --- a/fotolib2/src/test/java/de/k3b/media/MediaUtilTests.java +++ b/fotolib2/src/test/java/de/k3b/media/MediaUtilTests.java @@ -26,6 +26,8 @@ import org.junit.Assert; import org.junit.Test; +import java.io.File; +import java.io.IOException; import java.util.List; import de.k3b.TestUtil; @@ -179,9 +181,26 @@ public void shouldNotCalculateModifiedPath() { check(null, "/path/to/file.jpg", VISIBILITY.DEFAULT); } + private void check(String expected, String actual, VISIBILITY visibility) { Assert.assertEquals(visibility + "(" + actual + ")=>" +expected, expected, MediaUtil.getModifiedPath(actual,visibility)); } + /***** Integrationtests via file system *********/ + private static final File INDIR = new File(TestUtil.OUTDIR_ROOT, "MediaUtilTests"); + + @Test + public void shouldInferAutoprocessingExifDefaultsFromExistingFiles() throws IOException { + File[] jpgFilesToAnalyse = TestUtil.saveTestResourcesIn(INDIR, + TestUtil.TEST_FILE_JPG_WITH_NO_EXIF, + TestUtil.TEST_FILE_JPG_WITH_EXIF); + MediaAsString result = MediaUtil.inferAutoprocessingExifDefaults(new MediaAsString(), + jpgFilesToAnalyse); + + Assert.assertEquals( + "regression: description, lat, lon, tags should be identical to " + TestUtil.TEST_FILE_JPG_WITH_EXIF, + ",,ImageDescription,,27.818611,-15.764444,\"Marker1, Marker2\"", result.toString()); + } + } diff --git a/fotolib2/src/test/java/de/k3b/media/MediaXmpSegmentIntegrationTests.java b/fotolib2/src/test/java/de/k3b/media/MediaXmpSegmentIntegrationTests.java index db78d451..013802d8 100644 --- a/fotolib2/src/test/java/de/k3b/media/MediaXmpSegmentIntegrationTests.java +++ b/fotolib2/src/test/java/de/k3b/media/MediaXmpSegmentIntegrationTests.java @@ -52,7 +52,7 @@ public static void initDirectories() { @Before public void setup() throws IOException { // MediaXmpSegment.DEBUG = true; - sut = getMeta("test-WitExtraData.xmp"); + sut = getMeta(TestUtil.TEST_FILE_XMP_WITH_EXIF); TimeZone.setDefault(DateUtil.UTC); } diff --git a/fotolib2/src/test/java/de/k3b/media/MediaXmpTests.java b/fotolib2/src/test/java/de/k3b/media/MediaXmpTests.java index 84d10271..2775b947 100644 --- a/fotolib2/src/test/java/de/k3b/media/MediaXmpTests.java +++ b/fotolib2/src/test/java/de/k3b/media/MediaXmpTests.java @@ -54,7 +54,7 @@ public static void initDirectories() { public void shouldReadExistingXmpFile() throws IOException { TimeZone.setDefault(TimeZone.getTimeZone("GMT")); MediaXmpSegment sut = new MediaXmpSegment(); - InputStream fis = getStream("images/test-WitExtraData.xmp"); + InputStream fis = TestUtil.getResourceInputStream(TestUtil.TEST_FILE_XMP_WITH_EXIF); sut = new MediaXmpSegment(); sut.load(fis, "JUnit"); fis.close(); diff --git a/fotolib2/src/test/java/de/k3b/media/MetaWriterExifXmlIntegrationTests.java b/fotolib2/src/test/java/de/k3b/media/MetaWriterExifXmlIntegrationTests.java index b822b394..fb62d072 100644 --- a/fotolib2/src/test/java/de/k3b/media/MetaWriterExifXmlIntegrationTests.java +++ b/fotolib2/src/test/java/de/k3b/media/MetaWriterExifXmlIntegrationTests.java @@ -58,7 +58,7 @@ public void emptyWriteEmptyExifXmpCreate() throws IOException ExifInterfaceEx.fixDateOnSave = false; File out = new File(OUTDIR,"emptyWriteEmptyExifXmpCreate.jpg"); - TestUtil.saveTestResourceAs("NoExif.jpg", out); + TestUtil.saveTestResourceAs(TestUtil.TEST_FILE_JPG_WITH_NO_EXIF, out); MetaWriterExifXml sut = MetaWriterExifXml.create(out.getAbsolutePath(), null, false, "JUnit" , true, true, true); //exif, xmp, create @@ -87,8 +87,8 @@ public void existingWriteEmptyExifXmp() throws IOException ExifInterfaceEx.fixDateOnSave = false; File out = new File(OUTDIR,"existingWriteEmptyExifXmp.jpg"); - TestUtil.saveTestResourceAs("test-WitExtraData.jpg", out); - TestUtil.saveTestResourceAs("test-WitExtraData.xmp", FileCommands.getSidecar(out.getAbsolutePath(), false)); + TestUtil.saveTestResourceAs(TestUtil.TEST_FILE_JPG_WITH_EXIF, out); + TestUtil.saveTestResourceAs(TestUtil.TEST_FILE_XMP_WITH_EXIF, FileCommands.getSidecar(out.getAbsolutePath(), false)); MetaWriterExifXml sut = MetaWriterExifXml.create(out.getAbsolutePath(), null, false, "JUnit" , true, true, true); //exif, xmp, create @@ -114,7 +114,7 @@ public void existingWriteEmptyExifXmp() throws IOException public void existingWriteValueExifXmpCreate() throws IOException { File out = new File(OUTDIR,"existingWriteValueExifXmpCreate.jpg"); - TestUtil.saveTestResourceAs("test-WitExtraData.jpg", out); + TestUtil.saveTestResourceAs(TestUtil.TEST_FILE_JPG_WITH_EXIF, out); MetaWriterExifXml sut = MetaWriterExifXml.create(out.getAbsolutePath(), null, false, "JUnit" , true, true, true); //exif, xmp, create @@ -144,7 +144,7 @@ private static MediaDTO createTestValue() { public void emptyWriteValuesXmpCreate() throws IOException { File out = new File(OUTDIR,"emptyWriteValuesXmpCreate.jpg"); - TestUtil.saveTestResourceAs("NoExif.jpg", out); + TestUtil.saveTestResourceAs(TestUtil.TEST_FILE_JPG_WITH_NO_EXIF, out); MetaWriterExifXml sut = MetaWriterExifXml.create(out.getAbsolutePath(), null, false, "JUnit" , false, true, true); //exif, xmp, create @@ -165,7 +165,7 @@ public void emptyWriteValuesXmpCreate() throws IOException public void emptyWriteValuesExifOnly() throws IOException { File out = new File(OUTDIR,"emptyWriteValuesExifOnly.jpg"); - TestUtil.saveTestResourceAs("NoExif.jpg", out); + TestUtil.saveTestResourceAs(TestUtil.TEST_FILE_JPG_WITH_NO_EXIF, out); MetaWriterExifXml sut = MetaWriterExifXml.create(out.getAbsolutePath(), null, false, "JUnit" , true, false, false); //exif, xmp, create From 044bd4ce4b97423e9ca489b92ad6ee207d6522ac Mon Sep 17 00:00:00 2001 From: k3b <1374583+k3b@users.noreply.github.com> Date: Sun, 11 Nov 2018 11:53:29 +0100 Subject: [PATCH 04/35] #133: Additional filtercriteria date-last-modified from ... to --- .../GalleryFilterActivity.java | 42 +- .../androFotoFinder/queries/FotoSql.java | 120 +- .../de/k3b/android/util/MediaScanner.java | 7 +- .../k3b/android/widget/BaseQueryActivity.java | 118 +- .../res/layout/activity_gallery_filter.xml | 1001 ++++++++++------- .../tagDB/TagSqlQueryParserTests.java | 3 +- .../metadata/android/en-US/changelogs/41.txt | 2 + .../de/k3b/io/GalleryFilterParameter.java | 46 +- .../main/java/de/k3b/io/IGalleryFilter.java | 4 + .../de/k3b/io/GalleryFilterParameterTest.java | 7 +- 10 files changed, 875 insertions(+), 475 deletions(-) diff --git a/app/src/main/java/de/k3b/android/androFotoFinder/GalleryFilterActivity.java b/app/src/main/java/de/k3b/android/androFotoFinder/GalleryFilterActivity.java index 5a0e00dd..21d0d33b 100644 --- a/app/src/main/java/de/k3b/android/androFotoFinder/GalleryFilterActivity.java +++ b/app/src/main/java/de/k3b/android/androFotoFinder/GalleryFilterActivity.java @@ -213,6 +213,17 @@ public void onClick(View v) { LibGlobal.datePickerUseDecade, path); } }); + cmd = (Button) findViewById(R.id.cmd_date_modified); + cmd.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + String path = getAsGalleryFilter().getDateModifiedPath(); + showDirectoryPickerForFilterParamValue( + mDebugPrefix + " date modified picker " + path, + FotoSql.queryGroupByDateModified, false, + LibGlobal.datePickerUseDecade, path); + } + }); cmd = (Button) findViewById(R.id.cmd_select_lat_lon); cmd.setOnClickListener(new View.OnClickListener() { @Override @@ -342,6 +353,7 @@ private void loadLastFilter() { loadLastFilter(sharedPref, FotoSql.QUERY_TYPE_GALLERY); loadLastFilter(sharedPref, FotoSql.QUERY_TYPE_GROUP_DATE); loadLastFilter(sharedPref, FotoSql.QUERY_TYPE_GROUP_PLACE); + loadLastFilter(sharedPref, FotoSql.QUERY_TYPE_GROUP_DATE_MODIFIED); } private void loadLastFilter(SharedPreferences sharedPref, int queryTypeID) { @@ -394,6 +406,8 @@ private class FilterValue implements IGalleryFilter { private EditText mDateFrom; private EditText mDateTo; + private EditText mDateModifiedFrom; + private EditText mDateModifiedTo; private EditText mLongitudeFrom; private EditText mLongitudeTo; private EditText mLatitudeTo; @@ -415,6 +429,8 @@ private class FilterValue implements IGalleryFilter { this.mTagsExclude = (EditText) findViewById(R.id.edit_tags_exclude); this.mDateFrom = (EditText) findViewById(R.id.edit_date_from); this.mDateTo = (EditText) findViewById(R.id.edit_date_to); + this.mDateModifiedFrom = (EditText) findViewById(R.id.edit_date_modified_from); + this.mDateModifiedTo = (EditText) findViewById(R.id.edit_date_modified_to); this.mLatitudeFrom = (EditText) findViewById(R.id.edit_latitude_from); this.mLatitudeTo = (EditText) findViewById(R.id.edit_latitude_to); this.mLongitudeFrom = (EditText) findViewById(R.id.edit_longitude_from); @@ -451,13 +467,18 @@ public void onClick(View v) { R.id.cmd_path_history, R.id.cmd_date_from_history, R.id.cmd_date_to_history, + R.id.cmd_date_modified_from_history, + R.id.cmd_date_modified_to_history, R.id.cmd_lat_from_history, R.id.cmd_lat_to_history, R.id.cmd_lon_from_history, R.id.cmd_lon_to_history , R.id.cmd_any_history, R.id.cmd_tags_include_history, R.id.cmd_tags_exclude_history} , mPath , mDateFrom , - mDateTo, mLatitudeFrom, mLatitudeTo, mLongitudeFrom, mLongitudeTo, + mDateTo, + mDateModifiedFrom , + mDateModifiedTo, + mLatitudeFrom, mLatitudeTo, mLongitudeFrom, mLongitudeTo, mAny , mTagsInclude , mTagsExclude); @@ -508,7 +529,7 @@ protected void showLatLon(boolean noGeoInfo) { private void show(boolean checked, int... ids) { for(int id:ids) - findViewById(id).setVisibility((!checked) ? View.VISIBLE : View.INVISIBLE ); + findViewById(id).setVisibility((!checked) ? View.VISIBLE : View.GONE ); } /** minimum latitude, in degrees north. -90..+90 */ @@ -569,6 +590,16 @@ public long getDateMax() { return convertDate(mDateTo.getText().toString()); } + @Override + public long getDateModifiedMin() { + return convertDate(mDateModifiedFrom.getText().toString()); + } + + @Override + public long getDateModifiedMax() { + return convertDate(mDateModifiedTo.getText().toString()); + } + @Override public boolean isNonGeoOnly() { return mWithNoGeoInfo.isChecked(); @@ -615,6 +646,8 @@ public IGalleryFilter get(IGalleryFilter src) { mTagsExclude .setText(GalleryFilterParameter.convertList(src.getTagsAllExcluded())); mDateFrom.setText(convertDate(src.getDateMin())); mDateTo.setText(convertDate(src.getDateMax())); + mDateModifiedFrom.setText(convertDate(src.getDateModifiedMin())); + mDateModifiedTo.setText(convertDate(src.getDateModifiedMax())); mWithNoGeoInfo.setChecked(src.isNonGeoOnly()); mWithNoTags.setChecked(src.isWithNoTags()); mRatingBar.setRating(src.getRatingMin()); @@ -840,7 +873,10 @@ private void onDirectoryDataLoadCompleteForFilterParamValue(IDirectory directory int menuResId = 0; // no menu in app lock mode if (!LockScreen.isLocked(this)) { - menuResId = (queryId == FotoSql.QUERY_TYPE_GROUP_DATE) ? R.menu.menu_context_datepicker : R.menu.menu_context_dirpicker; + menuResId = R.menu.menu_context_dirpicker; + if ((queryId == FotoSql.QUERY_TYPE_GROUP_DATE) || (queryId == FotoSql.QUERY_TYPE_GROUP_DATE)) { + menuResId = R.menu.menu_context_datepicker; + } } dlg.setContextMenuId(menuResId); 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 ee853eaa..c13e5d9c 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 @@ -92,6 +92,9 @@ public class FotoSql extends FotoSqlBase { public static final int QUERY_TYPE_GROUP_PLACE = 14; public static final int QUERY_TYPE_GROUP_PLACE_MAP = 141; + public static final int QUERY_TYPE_GROUP_DATE_MODIFIED = 16; + + public static final int QUERY_TYPE_GROUP_COPY = 20; public static final int QUERY_TYPE_GROUP_MOVE = 21; @@ -139,6 +142,10 @@ public class FotoSql extends FotoSqlBase { public static final String SQL_COL_EXT_MEDIA_TYPE = MediaStore.Files.FileColumns.MEDIA_TYPE; public static final int MEDIA_TYPE_IMAGE = MediaStore.Files.FileColumns.MEDIA_TYPE_IMAGE; // 1 + + // used to translate between LAST_MODIFIED in database (secs since 1970) and internal format (java date milli secs simce 1970) + private static final int LAST_MODIFIED_FACTOR = 1000; + public static final int MEDIA_TYPE_IMAGE_PRIVATE = 1000 + MEDIA_TYPE_IMAGE; // 1001 APhoto manager specific public static final int MEDIA_TYPE_ALBUM_FILE = 0; @@ -156,12 +163,19 @@ public class FotoSql extends FotoSqlBase { private static final String FILTER_EXPR_LON_MIN = SQL_COL_LON + " >= ?"; protected static final String FILTER_EXPR_RATING_MIN = SQL_COL_EXT_RATING + " >= ?"; + // SQL_COL_DATE_TAKEN and "?" in milli-seconds since 1970 private static final String FILTER_EXPR_DATE_MAX = SQL_COL_DATE_TAKEN + " < ?"; private static final String FILTER_EXPR_DATE_MIN = SQL_COL_DATE_TAKEN + " >= ?"; + + // SQL_COL_LAST_MODIFIED in seconds since 1970; "?" in milli-seconds since 1970 + private static final String FILTER_EXPR_DATE_MODIFIED_MAX = SQL_COL_LAST_MODIFIED + " < ?"; + private static final String FILTER_EXPR_DATE_MODIFIED_MIN = SQL_COL_LAST_MODIFIED + " >= ?"; protected static final String FILTER_EXPR_PATH_LIKE = "(" + SQL_COL_PATH + " like ?)"; // same format as dir. i.e. description='/2014/12/24/' or '/mnt/sdcard/pictures/' - public static final String SQL_EXPR_DAY = "strftime('/%Y/%m/%d/', " + SQL_COL_DATE_TAKEN + " /1000, 'unixepoch', 'localtime')"; + public static final String SQL_EXPR_DAY = "strftime('/%Y/%m/%d/', " + SQL_COL_DATE_TAKEN + " / " + + LAST_MODIFIED_FACTOR + ", 'unixepoch', 'localtime')"; + public static final String SQL_EXPR_DAY_MODIFIED = "strftime('/%Y/%m/%d/', " + SQL_COL_LAST_MODIFIED + ", 'unixepoch', 'localtime')"; public static final QueryParameter queryGroupByDate = new QueryParameter() .setID(QUERY_TYPE_GROUP_DATE) @@ -176,6 +190,19 @@ public class FotoSql extends FotoSqlBase { .addGroupBy(SQL_EXPR_DAY) .addOrderBy(SQL_EXPR_DAY); + public static final QueryParameter queryGroupByDateModified = new QueryParameter() + .setID(QUERY_TYPE_GROUP_DATE_MODIFIED) + .addColumn( + "max(" + SQL_COL_PK + ") AS " + SQL_COL_PK, + SQL_EXPR_DAY_MODIFIED + " AS " + SQL_COL_DISPLAY_TEXT, + "count(*) AS " + SQL_COL_COUNT, + "max(" + SQL_COL_GPS + ") AS " + SQL_COL_GPS, + "max(" + SQL_COL_PATH + ") AS " + SQL_COL_PATH) + .addFrom(SQL_TABLE_EXTERNAL_CONTENT_URI_FILE_NAME) + .addWhere(FILTER_EXPR_PRIVATE_PUBLIC) + .addGroupBy(SQL_EXPR_DAY_MODIFIED) + .addOrderBy(SQL_EXPR_DAY_MODIFIED); + public static final String SQL_EXPR_FOLDER = "substr(" + SQL_COL_PATH + ",1,length(" + SQL_COL_PATH + ") - length(" + MediaStore.Images.Media.DISPLAY_NAME + "))"; public static final QueryParameter queryGroupByDir = new QueryParameter() .setID(QUERY_TYPE_GROUP_ALBUM) @@ -328,17 +355,27 @@ public static void filter2Query(QueryParameter resultQuery, IGalleryFilter filte addWhereFilterLatLon(resultQuery, filter); addWhereDateMinMax(resultQuery, filter.getDateMin(), filter.getDateMax()); + addWhereDateModifiedMinMax(resultQuery, filter.getDateModifiedMin(), filter.getDateModifiedMax()); String path = filter.getPath(); if ((path != null) && (path.length() > 0)) resultQuery.addWhere(FILTER_EXPR_PATH_LIKE, path); } } - public static void addWhereDateMinMax(QueryParameter resultQuery, final long dateMin, final long dateMax) { + public static void addWhereDateMinMax(QueryParameter resultQuery, final long dateMinInMilliSecs1970, final long dateMaxInMilliSecs1970) { + + // SQL_COL_DATE_TAKEN and "?" in milli-seconds since 1970 no translaton neccessary + if (dateMinInMilliSecs1970 != 0) resultQuery.addWhere(FILTER_EXPR_DATE_MIN, Long.toString(dateMinInMilliSecs1970)); + + if (dateMaxInMilliSecs1970 != 0) resultQuery.addWhere(FILTER_EXPR_DATE_MAX, Long.toString(dateMaxInMilliSecs1970)); + } + + public static void addWhereDateModifiedMinMax(QueryParameter resultQuery, final long dateMinInMilliSecs1970, final long dateMaxInMilliSecs1970) { - if (dateMin != 0) resultQuery.addWhere(FILTER_EXPR_DATE_MIN, Long.toString(dateMin)); + // SQL_COL_LAST_MODIFIED in seconds since 1970; translate from MilliSecs + if (dateMinInMilliSecs1970 != 0) resultQuery.addWhere(FILTER_EXPR_DATE_MODIFIED_MIN, Long.toString(dateMinInMilliSecs1970 / LAST_MODIFIED_FACTOR)); - if (dateMax != 0) resultQuery.addWhere(FILTER_EXPR_DATE_MAX, Long.toString(dateMax)); + if (dateMaxInMilliSecs1970 != 0) resultQuery.addWhere(FILTER_EXPR_DATE_MODIFIED_MAX, Long.toString(dateMaxInMilliSecs1970 / LAST_MODIFIED_FACTOR)); } /** translates a query back to filter */ @@ -348,9 +385,14 @@ public static IGalleryFilter parseQuery(QueryParameter query, boolean removeFrom parseQueryGeo(query, filter, removeFromSourceQuery); filter.setRatingMin(GalleryFilterParameter.parseRating(getParam(query, FILTER_EXPR_RATING_MIN, removeFromSourceQuery))); - filter.setDate(getParam(query, FILTER_EXPR_DATE_MIN, removeFromSourceQuery), getParam(query, FILTER_EXPR_DATE_MAX, removeFromSourceQuery)); + filter.setDate(getParam(query, FILTER_EXPR_DATE_MIN, removeFromSourceQuery), + getParam(query, FILTER_EXPR_DATE_MAX, removeFromSourceQuery)); filter.setPath(getFilePath(query, removeFromSourceQuery)); + // SQL_COL_LAST_MODIFIED in seconds since 1970; translate from MilliSecs + filter.setDateModified(getParamWithFix(query, FILTER_EXPR_DATE_MODIFIED_MIN, removeFromSourceQuery, LAST_MODIFIED_FACTOR), + getParamWithFix(query, FILTER_EXPR_DATE_MODIFIED_MAX, removeFromSourceQuery, LAST_MODIFIED_FACTOR)); + return filter; } return null; @@ -404,6 +446,18 @@ protected static String getParam(QueryParameter query, String expresion, boolean return ((result != null) && (result.length > 0)) ? result[0] : null; } + /** @return return param for expression inside query. null if expression is not in query or number of params is not 1. */ + protected static long getParamWithFix(QueryParameter query, String expresion, boolean removeFromSourceQuery, long factor) { + try { + String svalue = getParam(query, expresion, removeFromSourceQuery); + long lvalue = Long.parseLong(svalue); + return lvalue * factor; + } catch (Exception ignore) { + + } + return 0; + } + /** @return return all params for expression inside query. null if expression is not in query */ protected static String[] getParams(QueryParameter query, String expresion, boolean removeFromSourceQuery) { return query.getWhereParameter(expresion, removeFromSourceQuery); @@ -467,11 +521,16 @@ public static void addWhereFilterLatLon(QueryParameter query, double latitudeMin public static void addPathWhere(QueryParameter newQuery, String selectedAbsolutePath, int dirQueryID) { if ((selectedAbsolutePath != null) && (selectedAbsolutePath.length() > 0)) { - if (QUERY_TYPE_GROUP_DATE == dirQueryID) { - addWhereDatePath(newQuery, selectedAbsolutePath); - } else { - // selectedAbsolutePath is assumed to be a file path i.e. /mnt/sdcard/pictures/ - addWhereDirectoryPath(newQuery, selectedAbsolutePath); + switch (dirQueryID) { + case QUERY_TYPE_GROUP_DATE: + addWhereDatePath(newQuery, selectedAbsolutePath); + break; + case QUERY_TYPE_GROUP_DATE_MODIFIED: + addWhereDateModifiedPath(newQuery, selectedAbsolutePath); + break; + default: + // selectedAbsolutePath is assumed to be a file path i.e. /mnt/sdcard/pictures/ + addWhereDirectoryPath(newQuery, selectedAbsolutePath); } } } @@ -497,6 +556,17 @@ private static void addWhereDirectoryPath(QueryParameter newQuery, String select * path has format /year/month/day/ or /year/month/ or /year/ or / */ private static void addWhereDatePath(QueryParameter newQuery, String selectedAbsolutePath) { + addWhereDatePath(newQuery, selectedAbsolutePath, SQL_COL_DATE_TAKEN, FILTER_EXPR_DATE_MIN, FILTER_EXPR_DATE_MAX); + } + + /** + * path has format /year/month/day/ or /year/month/ or /year/ or / + */ + private static void addWhereDateModifiedPath(QueryParameter newQuery, String selectedAbsolutePath) { + addWhereDatePath(newQuery, selectedAbsolutePath, SQL_COL_LAST_MODIFIED, FILTER_EXPR_DATE_MODIFIED_MIN, FILTER_EXPR_DATE_MODIFIED_MAX); + } + + private static void addWhereDatePath(QueryParameter newQuery, String selectedAbsolutePath, String sqlColDate, String filterExprDateMin, String filterExprDateMax) { Date from = new Date(); Date to = new Date(); @@ -504,13 +574,13 @@ private static void addWhereDatePath(QueryParameter newQuery, String selectedAbs if (to.getTime() == 0) { newQuery - .addWhere(SQL_COL_DATE_TAKEN + " in (0,-1, null)") - .addOrderBy(SQL_COL_DATE_TAKEN + " desc"); + .addWhere(sqlColDate + " in (0,-1, null)") + .addOrderBy(sqlColDate + " desc"); } else { newQuery - .addWhere(FILTER_EXPR_DATE_MIN, "" + from.getTime()) - .addWhere(FILTER_EXPR_DATE_MAX, "" + to.getTime()) - .addOrderBy(SQL_COL_DATE_TAKEN + " desc"); + .addWhere(filterExprDateMin, "" + from.getTime()) + .addWhere(filterExprDateMax, "" + to.getTime()) + .addOrderBy(sqlColDate + " desc"); } } @@ -522,6 +592,8 @@ public static QueryParameter getQuery(int queryID) { return queryDetail; case QUERY_TYPE_GROUP_DATE: return queryGroupByDate; + case QUERY_TYPE_GROUP_DATE_MODIFIED: + return queryGroupByDateModified; case QUERY_TYPE_GROUP_ALBUM: return queryGroupByDir; case QUERY_TYPE_GROUP_PLACE: @@ -569,6 +641,8 @@ public static String getName(Context context, int id) { return context.getString(R.string.gallery_title); case QUERY_TYPE_GROUP_DATE: return context.getString(R.string.sort_by_date); + case QUERY_TYPE_GROUP_DATE_MODIFIED: + return context.getString(R.string.sort_by_modification); case QUERY_TYPE_GROUP_ALBUM: return context.getString(R.string.sort_by_folder); @@ -624,14 +698,22 @@ public static boolean set(GalleryFilterParameter dest, String selectedAbsolutePa case FotoSql.QUERY_TYPE_GROUP_ALBUM: dest.setPath(selectedAbsolutePath + "/%"); return true; - case FotoSql.QUERY_TYPE_GROUP_DATE: + case FotoSql.QUERY_TYPE_GROUP_DATE: { + Date from = new Date(); + Date to = new Date(); + + DirectoryFormatter.getDates(selectedAbsolutePath, from, to); + dest.setDate(from.getTime(), to.getTime()); + return true; + } + case FotoSql.QUERY_TYPE_GROUP_DATE_MODIFIED: { Date from = new Date(); Date to = new Date(); DirectoryFormatter.getDates(selectedAbsolutePath, from, to); - dest.setDateMin(from.getTime()); - dest.setDateMax(to.getTime()); + dest.setDateModified(from.getTime(), to.getTime()); return true; + } case FotoSql.QUERY_TYPE_GROUP_PLACE_MAP: case FotoSql.QUERY_TYPE_GROUP_PLACE: IGeoRectangle geo = DirectoryFormatter.parseLatLon(selectedAbsolutePath); @@ -1150,7 +1232,7 @@ public static Long getId(Uri uriWithId) { public static void addDateAdded(ContentValues values) { long now = new Date().getTime(); - values.put(SQL_COL_DATE_ADDED, now / 1000);//sec + values.put(SQL_COL_DATE_ADDED, now / LAST_MODIFIED_FACTOR);//sec } @NonNull diff --git a/app/src/main/java/de/k3b/android/util/MediaScanner.java b/app/src/main/java/de/k3b/android/util/MediaScanner.java index 06f19bb3..1ea4c3fc 100644 --- a/app/src/main/java/de/k3b/android/util/MediaScanner.java +++ b/app/src/main/java/de/k3b/android/util/MediaScanner.java @@ -75,9 +75,6 @@ abstract public class MediaScanner { protected static final String DB_LATITUDE = MediaStore.Images.Media.LATITUDE; */ - // the DB_XXXX fields are updated directly by the scanner - // private fields are updated by base scanner - private static final String DB_DATE_MODIFIED = MediaStore.MediaColumns.DATE_MODIFIED; private static final String DB_SIZE = MediaStore.MediaColumns.SIZE; private static final String DB_WIDTH = MediaStore.MediaColumns.WIDTH; private static final String DB_HEIGHT = MediaStore.MediaColumns.HEIGHT; @@ -342,7 +339,7 @@ protected MediaContentValues getExifFromFile(ContentValues values, File jpgFile) MediaXmpSegment xmpContent = MediaXmpSegment.loadXmpSidecarContentOrNull(absoluteJpgPath, "getExifFromFile"); final long xmpFilelastModified = getXmpFilelastModified(xmpContent); - values.put(DB_DATE_MODIFIED, jpgFile.lastModified() / 1000); + values.put(FotoSql.SQL_COL_LAST_MODIFIED, jpgFile.lastModified() / 1000); values.put(DB_SIZE, jpgFile.length()); if ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) && mWidth > 0 && mHeight > 0) { @@ -448,7 +445,7 @@ private static void setPathRelatedFieldsIfNeccessary(ContentValues values, Strin public static String setFileFields(ContentValues values, File file) { String newAbsolutePath = FileUtils.tryGetCanonicalPath(file, file.getAbsolutePath()); setPathRelatedFieldsIfNeccessary(values, newAbsolutePath, null); - values.put(DB_DATE_MODIFIED, file.lastModified() / 1000); + values.put(FotoSql.SQL_COL_LAST_MODIFIED, file.lastModified() / 1000); values.put(DB_SIZE, file.length()); return newAbsolutePath; } diff --git a/app/src/main/java/de/k3b/android/widget/BaseQueryActivity.java b/app/src/main/java/de/k3b/android/widget/BaseQueryActivity.java index d3e387a7..2e54f7c3 100644 --- a/app/src/main/java/de/k3b/android/widget/BaseQueryActivity.java +++ b/app/src/main/java/de/k3b/android/widget/BaseQueryActivity.java @@ -130,6 +130,8 @@ protected class GalleryQueryParameter { private static final int SUB_FILTER_MODE_ALBUM = 4; private static final int SUB_FILTER_MODE_DATE = 5; + private static final int SUB_FILTER_MODE_DATE_MODIFIED = 6; + /** * mCurrentSubFilterMode = SUB_FILTER_MODE_XXX: which filter addon is currently active: * Filter = basefilter + mCurrentSubFilterMode @@ -253,6 +255,9 @@ private QueryParameter calculateEffectiveGalleryContentQuery(QueryParameter root case SUB_FILTER_MODE_DATE: FotoSql.addWhereDateMinMax(result, currentSubFilterSettings.getDateMin(), currentSubFilterSettings.getDateMax()); break; + case SUB_FILTER_MODE_DATE_MODIFIED: + FotoSql.addWhereDateModifiedMinMax(result, currentSubFilterSettings.getDateModifiedMin(), currentSubFilterSettings.getDateModifiedMax()); + break; } } @@ -522,8 +527,11 @@ protected class FolderApi { // either folder picker or date picker private static final int QUERY_TYPE_GROUP_DATE = FotoSql.QUERY_TYPE_GROUP_DATE; + private static final int QUERY_TYPE_GROUP_DATE_MODIFIED = FotoSql.QUERY_TYPE_GROUP_DATE_MODIFIED; + private IDirectory mDirectoryRoot = null; private IDirectory mDateRoot = null; + private IDirectory mDateModifiedRoot = null; /** * true if activity should show navigator dialog after loading mDirectoryRoot is complete @@ -539,6 +547,10 @@ private void openDatePicker() { openPicker(BaseQueryActivity.GalleryQueryParameter.SUB_FILTER_MODE_DATE, QUERY_TYPE_GROUP_DATE); } + private void openDateModifiedPicker() { + openPicker(GalleryQueryParameter.SUB_FILTER_MODE_DATE_MODIFIED, QUERY_TYPE_GROUP_DATE_MODIFIED); + } + private void openFolderPicker() { openPicker(BaseQueryActivity.GalleryQueryParameter.SUB_FILTER_MODE_PATH, QUERY_TYPE_GROUP_ALBUM); } @@ -555,8 +567,8 @@ private void openPicker(final int filterMode, int _dirQueryID) { mGalleryQueryParameter.mDirQueryID = dirQueryID; - final boolean loadDate = (dirQueryID == QUERY_TYPE_GROUP_DATE); - final IDirectory currentDirectoryRoot = loadDate ? this.mDateRoot : this.mDirectoryRoot; + boolean loadDate = (dirQueryID == QUERY_TYPE_GROUP_DATE) || (dirQueryID == QUERY_TYPE_GROUP_DATE_MODIFIED); + final IDirectory currentDirectoryRoot = getiDirectoryRoot(dirQueryID); if (currentDirectoryRoot == null) { // not loaded yet. load directoryRoot in background ; @@ -567,28 +579,31 @@ private void openPicker(final int filterMode, int _dirQueryID) { mergedBaseQuery.setID(dirQueryID); DirectoryLoaderTask loader = new DirectoryLoaderTask(context, loadDate ? LibGlobal.datePickerUseDecade : false, - mDebugPrefix + " from openPicker(loadDate=" + - loadDate + ")") { + mDebugPrefix + " from openPicker(dirQueryID=" + + FotoSql.getName(getApplicationContext(), dirQueryID) + ")") { @Override protected void onPostExecute(IDirectory directoryRoot) { - onDirectoryDataLoadComplete(loadDate, directoryRoot); + onDirectoryDataLoadComplete(dirQueryID, directoryRoot); } }; - - if (!loadDate) { - // limit valbums to matching parent-path query - QueryParameter vAlbumQueryWithPathExpr = FotoSql.copyPathExpressions(FotoSql.queryVAlbum, mergedBaseQuery); - if (vAlbumQueryWithPathExpr == null) - vAlbumQueryWithPathExpr = FotoSql.queryVAlbum; - - // load dir-s + "*.album" - loader.execute(mergedBaseQuery, vAlbumQueryWithPathExpr); - } else { - loader.execute(mergedBaseQuery); + switch (dirQueryID) { + case QUERY_TYPE_GROUP_DATE: + case QUERY_TYPE_GROUP_DATE_MODIFIED: + loader.execute(mergedBaseQuery); + break; + default: + // limit valbums to matching parent-path query + QueryParameter vAlbumQueryWithPathExpr = FotoSql.copyPathExpressions(FotoSql.queryVAlbum, mergedBaseQuery); + if (vAlbumQueryWithPathExpr == null) + vAlbumQueryWithPathExpr = FotoSql.queryVAlbum; + + // load dir-s + "*.album" + loader.execute(mergedBaseQuery, vAlbumQueryWithPathExpr); } + } else { Log.e(Global.LOG_CONTEXT, mDebugPrefix + " this.mDirQueryID undefined " - + mGalleryQueryParameter.mDirQueryID); + + FotoSql.getName(getApplicationContext(), mGalleryQueryParameter.mDirQueryID)); } // if not loaded yet } else { @@ -620,18 +635,35 @@ protected void onPostExecute(IDirectory directoryRoot) { } } - private void onDirectoryDataLoadComplete(final boolean loadDate, IDirectory directoryRoot) { + private IDirectory getiDirectoryRoot(int dirQueryID) { + switch (dirQueryID) { + case QUERY_TYPE_GROUP_DATE: + return this.mDateRoot; + case QUERY_TYPE_GROUP_DATE_MODIFIED: + return this.mDateModifiedRoot; + default: + return this.mDirectoryRoot; + } + } + + private void onDirectoryDataLoadComplete(int dirQueryID, IDirectory directoryRoot) { if (directoryRoot == null) { final String message = getString(R.string.folder_err_load_failed_format, FotoSql.getName(BaseQueryActivity.this, mGalleryQueryParameter.getDirQueryID())); Toast.makeText(BaseQueryActivity.this, message, Toast.LENGTH_LONG).show(); } else { boolean mustDefineNavigation; - if (loadDate) { - mustDefineNavigation= (mGalleryQueryParameter.getCurrentSubFilterSettings().getDatePath() != null); - this.mDateRoot = directoryRoot; - } else { - mustDefineNavigation= (mGalleryQueryParameter.getCurrentSubFilterSettings().getPath() != null); - this.mDirectoryRoot = directoryRoot; + switch (dirQueryID) { + case QUERY_TYPE_GROUP_DATE: + mustDefineNavigation= (mGalleryQueryParameter.getCurrentSubFilterSettings().getDatePath() != null); + this.mDateRoot = directoryRoot; + break; + case QUERY_TYPE_GROUP_DATE_MODIFIED: + mustDefineNavigation = (mGalleryQueryParameter.getCurrentSubFilterSettings().getDateModifiedPath() != null); + this.mDateModifiedRoot = directoryRoot; + break; + default: + mustDefineNavigation = (mGalleryQueryParameter.getCurrentSubFilterSettings().getPath() != null); + this.mDirectoryRoot = directoryRoot; } final boolean mustShowFolderPicker = (directoryRoot != null) && (this.mMustShowNavigator); @@ -642,8 +674,8 @@ private void onDirectoryDataLoadComplete(final boolean loadDate, IDirectory dire Log.i(Global.LOG_CONTEXT, mDebugPrefix + "onDirectoryDataLoadComplete(" + "mustDefineNavigation=" + mustDefineNavigation + ", mustShowFolderPicker=" + mustShowFolderPicker + - ", content=" + name + ",loadDate=" + - loadDate + ")"); + ", content=" + name + ",dirQueryID=" + + FotoSql.getName(getApplicationContext(), dirQueryID) + ")"); } if (mustDefineNavigation) { @@ -652,10 +684,15 @@ private void onDirectoryDataLoadComplete(final boolean loadDate, IDirectory dire Global.debugMemory(mDebugPrefix, "onDirectoryDataLoadComplete"); if (mustShowFolderPicker) { - if (loadDate) { - openDatePicker(); - } else { - openFolderPicker(); + switch (dirQueryID) { + case QUERY_TYPE_GROUP_DATE: + openDatePicker(); + break; + case QUERY_TYPE_GROUP_DATE_MODIFIED: + openDateModifiedPicker(); + break; + default: + openFolderPicker(); } } } @@ -669,6 +706,7 @@ private void refreshSelection() { private void invalidateDirectories(String why) { mDirectoryRoot = invalidateDirectories(why, mDirectoryRoot); mDateRoot = invalidateDirectories(why, mDateRoot); + mDateModifiedRoot = invalidateDirectories(why, mDateModifiedRoot); } private IDirectory invalidateDirectories(String why, IDirectory directoryRoot) { @@ -841,6 +879,20 @@ private void navigateTo(String selectedAbsolutePath, int queryTypeId) { this.mGalleryQueryParameter.mDirQueryID = queryTypeId; setTitle(); + reloadGui(why); + } else if (mGalleryQueryParameter.mCurrentSubFilterMode == GalleryQueryParameter.SUB_FILTER_MODE_DATE_MODIFIED) { + final String why = "FotoGalleryActivity.navigateTo date modified"; + Log.d(Global.LOG_CONTEXT, why + selectedAbsolutePath + " from " + currentSubFilterSettings.getDateModifiedPath()); + + Date from = new Date(); + Date to = new Date(); + DirectoryFormatter.getDates(selectedAbsolutePath, from, to); + + currentSubFilterSettings.setDateModified(from.getTime(), to.getTime()); + this.mGalleryQueryParameter.mCurrentSubFilterMode = GalleryQueryParameter.SUB_FILTER_MODE_DATE_MODIFIED; + this.mGalleryQueryParameter.mDirQueryID = queryTypeId; + setTitle(); + reloadGui(why); } else if (mGalleryQueryParameter.mCurrentSubFilterMode == GalleryQueryParameter.SUB_FILTER_MODE_PATH) { GalleryFilterPathState state = new GalleryFilterPathState() @@ -966,11 +1018,17 @@ public boolean onPrepareOptionsMenu(Menu menu) { protected boolean onOptionsItemSelected(MenuItem item, SelectedItems selectedItems) { // Handle presses on the action bar items switch (item.getItemId()) { + case R.id.cmd_date: case R.id.cmd_select_date: getFolderApi().openDatePicker(); return true; + case R.id.cmd_date_modified: + getFolderApi().openDateModifiedPicker(); + return true; + case R.id.cmd_select_folder: + case R.id.cmd_path: getFolderApi().openFolderPicker(); return true; diff --git a/app/src/main/res/layout/activity_gallery_filter.xml b/app/src/main/res/layout/activity_gallery_filter.xml index ed028b10..58dda9cf 100644 --- a/app/src/main/res/layout/activity_gallery_filter.xml +++ b/app/src/main/res/layout/activity_gallery_filter.xml @@ -1,7 +1,7 @@ - - - -