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 019951a6..3e3efbff 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 @@ -108,9 +108,9 @@ public class GalleryCursorFragment extends Fragment implements Queryable, Direc private static final String INSTANCE_STATE_SEL_ONLY = "selectedOnly"; private static final String INSTANCE_STATE_LOADER_ID = "loaderID"; - private static final int MODE_VIEW = 0; - private static final int MODE_PICK_SINGLE = 1; - private static final int MODE_PICK_MULTIBLE = 2; + private static final int MODE_VIEW_PICKER_NONE = 0; + private static final int MODE_VIEW_PICK_SINGLE = 1; + private static final int MODE_VIEW_PICK_MULTIBLE = 2; private static int nextLoaderID = 100; private int loaderID = -1; @@ -153,7 +153,8 @@ public class GalleryCursorFragment extends Fragment implements Queryable, Direc /** true pick geo; false pick image */ private boolean mGetGeo = false; - private int mMode = MODE_VIEW; + /** one of the MODE_VIEW_PICKER_XXXX */ + private int mMode = MODE_VIEW_PICKER_NONE; private MoveOrCopyDestDirPicker mDestDirPicker = null; /**************** construction ******************/ @@ -366,7 +367,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, String action = (intent != null) ? intent.getAction() : null; if ((action != null) && ((Intent.ACTION_PICK.compareTo(action) == 0) || (Intent.ACTION_GET_CONTENT.compareTo(action) == 0))) { - this.mMode = (intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE,false)) ? MODE_PICK_MULTIBLE : MODE_PICK_SINGLE; + this.mMode = (intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE,false)) ? MODE_VIEW_PICK_MULTIBLE : MODE_VIEW_PICK_SINGLE; mMustReplaceMenue = true; String schema = intent.getScheme(); mGetGeo = ((schema != null) && ("geo".compareTo(schema) == 0)); @@ -758,6 +759,27 @@ private void startMultiSelectionMode() { getActivity().invalidateOptionsMenu(); } + /** + * Different menu modes + * * normal name searchbar-icon folder map (tags) (filter) menu + * * R.menu.menu_gallery_non_selected_only R.menu.menu_gallery_non_multiselect + * * selected selected cancel seleted-only share (save) menu + * * (Filter not available; this.isMultiSelectionActive(); + * * R.menu.menu_gallery_multiselect_mode_all R.menu.menu_image_commands + * * locked name lock folder map menu + * * (no multiselection, no base-filters) + * * (this.locked; R.menu.menu_gallery_locked) + * * searchbar bar cancel-searc-bar (folder) (map) (tags) (filter) menu + * * picker-locked + * * R.menu.menu_gallery_pick R.menu.menu_gallery_locked + * * picker-non-locked selected ok cancel filter settings + * * R.menu.menu_gallery_pick R.menu.menu_gallery_non_multiselect + * + * (xxxx) with "IFROOM" (in wide screen only) + * searchbarmode is like "normal" where there is no "IFROOM" on no-searchbar items + * + * @param menu + */ @Override public void onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); @@ -769,12 +791,13 @@ public void onPrepareOptionsMenu(Menu menu) { mMustReplaceMenue = false; menu.clear(); mMenuRemoveAllSelected = null; - if (mMode == MODE_VIEW) { + if (mMode == MODE_VIEW_PICKER_NONE) { + // if (locked) { // view-locked mSelectedItems.clear(); inflater.inflate(R.menu.menu_gallery_locked, menu); LockScreen.fixMenu(menu); - } else if (isMultiSelectionActive()) { // view-multiselect + } else if (this.isMultiSelectionActive()) { // view-multiselect inflater.inflate(R.menu.menu_gallery_multiselect_mode_all, menu); mShareOnlyToggle = menu.findItem(R.id.cmd_selected_only); @@ -796,7 +819,7 @@ public void onPrepareOptionsMenu(Menu menu) { } - } else { + } else { // picker mode inflater.inflate(R.menu.menu_gallery_pick, menu); if (locked) { // pick-locked mSelectedItems.clear(); @@ -1316,7 +1339,7 @@ private void onDuplicatesFound(SelectedItems selectedItems, StringBuffer debugMe } private boolean isMultiSelectionActive() { - if (mMode != MODE_VIEW) return true; + if (mMode != MODE_VIEW_PICKER_NONE) return true; return !mSelectedItems.isEmpty(); } @@ -1344,7 +1367,7 @@ private void fix() { /** return true if included; false if excluded */ private boolean toggleSelection(long imageID) { boolean contains = mSelectedItems.contains(imageID); - if (mMode == MODE_PICK_SINGLE) { + if (mMode == MODE_VIEW_PICK_SINGLE) { clearSelections(); } if (contains) { 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 d8e77f31..8d770e34 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 @@ -94,9 +94,16 @@ public static IGalleryFilter parseQueryEx(QueryParameter query, boolean remove) // from more complex to less complex String[] params; - if ((params = getParams(query, FILTER_EXPR_ANY_LIKE, remove)) != null) { - resultFilter.setInAnyField(params[0]); + StringBuilder any = null; + while ((params = getParams(query, FILTER_EXPR_ANY_LIKE, remove)) != null) { + if (any == null) { + any = new StringBuilder().append(params[0]); + } else { + any.append(" ").append(params[0]); + + } } + if (any != null) resultFilter.setInAnyField(any.toString()); parseTagsFromQuery(query, remove, resultFilter); @@ -156,12 +163,17 @@ public static void filter2QueryEx(QueryParameter resultQuery, IGalleryFilter fil if ((resultQuery != null) && (!GalleryFilterParameter.isEmpty(filter))) { filter2Query(resultQuery, filter, clearWhereBefore); if (Global.Media.enableIptcMediaScanner) { - String any = filter.getInAnyField(); - if ((any != null) && (any.length() > 0)) { - if (!any.contains("%")) { - any = "%" + any + "%"; + String allAny = filter.getInAnyField(); + + if (allAny != null) { + for (String any : allAny.split(" ")) { + if ((any != null) && (any.length() > 0)) { + if (!any.contains("%")) { + any = "%" + any + "%"; + } + resultQuery.addWhere(FILTER_EXPR_ANY_LIKE, any, any, any, any); + } } - resultQuery.addWhere(FILTER_EXPR_ANY_LIKE, any, any, any, any); } diff --git a/app/src/test/java/de/k3b/android/androFotoFinder/tagDB/TagSqlQueryParserTests.java b/app/src/test/java/de/k3b/android/androFotoFinder/tagDB/TagSqlQueryParserTests.java index 1e21505c..db39b02e 100644 --- a/app/src/test/java/de/k3b/android/androFotoFinder/tagDB/TagSqlQueryParserTests.java +++ b/app/src/test/java/de/k3b/android/androFotoFinder/tagDB/TagSqlQueryParserTests.java @@ -67,6 +67,11 @@ public void shouldParsePublic() throws Exception { assertFilterQueryFilter(VISIBILITY.PUBLIC); } + @Test + public void shouldFilterFind() throws Exception { + assertFilterFind("hello world", "shouldFilterFind"); + } + // assert that input-string==output-string in input-string -> filter -> query -> filter -> output-string private QueryParameter assertFilterQueryFilter(VISIBILITY visibility) { String FILTER_STRING = ";;;;;;;;;" + visibility.value; @@ -79,29 +84,48 @@ private QueryParameter assertFilterQueryFilter(String filterString) { } // assert that input-string==output-string in input-string -> filter -> query -> filter -> output-string - private QueryParameter assertFilterQueryFilter(String filterString, String printSql) { - GalleryFilterParameter initialFilter = GalleryFilterParameter.parse(filterString, new GalleryFilterParameter()); + private QueryParameter assertFilterQueryFilter(String expectedFilterString, String printSql) { + GalleryFilterParameter initialFilter = GalleryFilterParameter.parse(expectedFilterString, new GalleryFilterParameter()); QueryParameter query = new QueryParameter(); - TagSql.filter2QueryEx(query, initialFilter, true); + GalleryFilterParameter parsedFilter = getParsedGalleryFilterParameter(query, initialFilter, printSql); - if (printSql != null) { - String sql = query.toSqlString(); + assertEquals(expectedFilterString, parsedFilter.toString()); + return query; + } + + // assert that input-string==output-string in input-string -> filter -> query -> filter -> output-string + private QueryParameter assertFilterFind(String expectedFilterFindValue, String debugPrefixPrintSql) { + GalleryFilterParameter initialFilter = new GalleryFilterParameter().setInAnyField(expectedFilterFindValue); + + QueryParameter query = new QueryParameter(); + GalleryFilterParameter parsedFilter = getParsedGalleryFilterParameter(query, initialFilter, debugPrefixPrintSql); + + assertEquals(query.toSqlString(), expectedFilterFindValue, parsedFilter.getInAnyField().replaceAll("%","")); + return query; + } + + private GalleryFilterParameter getParsedGalleryFilterParameter(QueryParameter resultQuery, GalleryFilterParameter initialFilter, String debugPrefixPrintSql) { + TagSql.filter2QueryEx(resultQuery, initialFilter, true); + + if (debugPrefixPrintSql != null) { + String sql = resultQuery.toSqlString(); int start = sql.indexOf("WHERE"); - System.out.println(printSql + ": " + sql.substring(start)); + System.out.println(debugPrefixPrintSql + ": " + sql.substring(start)); } - GalleryFilterParameter parsedFilter = (GalleryFilterParameter) TagSql.parseQueryEx(query, true); + // query is destroyed by parse so use a clone + QueryParameter queryToParse = new QueryParameter(resultQuery); + GalleryFilterParameter parsedFilter = (GalleryFilterParameter) TagSql.parseQueryEx(queryToParse, true); parsedFilter.setSort(initialFilter.getSortID(), initialFilter.isSortAscending()); // compensate that query might automatically add visibility if (initialFilter.getVisibility() == VISIBILITY.DEFAULT) { parsedFilter.setVisibility(VISIBILITY.DEFAULT); } - - assertEquals(filterString, parsedFilter.toString()); - return query; + return parsedFilter; } + //################ tag filter support @Test public void shouldTagsNoneOnly() throws Exception { diff --git a/fotolib2/src/main/java/de/k3b/io/GalleryFilterParameter.java b/fotolib2/src/main/java/de/k3b/io/GalleryFilterParameter.java index 1203f497..3571bbd4 100644 --- a/fotolib2/src/main/java/de/k3b/io/GalleryFilterParameter.java +++ b/fotolib2/src/main/java/de/k3b/io/GalleryFilterParameter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2017 by k3b. + * Copyright (c) 2015-2018 by k3b. * * This file is part of AndroFotoFinder / #APhotoManager. * @@ -39,6 +39,8 @@ public class GalleryFilterParameter extends GeoRectangle implements IGalleryFilt private List tagsAllIncluded; private List tagsAllExcluded; + + /** match if the text is in path, filename, title, description, tags. Wildcard "%" is allowed. Sub-expressions are seperated by " " */ private String inAnyField; private long dateMin = 0; @@ -152,12 +154,13 @@ public GalleryFilterParameter setTagsAllExcluded(List tagsAllExcluded) { return this; } - /** match if the text is in path, filename, title, description, tags */ + /** match if the text is in path, filename, title, description, tags. Wildcard "%" is allowed. Sub-expressions are seperated by " " */ @Override public String getInAnyField() { return inAnyField; } + /** match if the text is in path, filename, title, description, tags. Wildcard "%" is allowed. Sub-expressions are seperated by " " */ public GalleryFilterParameter setInAnyField(String inAnyField) { this.inAnyField = inAnyField; return this; diff --git a/fotolib2/src/main/java/de/k3b/io/IGalleryFilter.java b/fotolib2/src/main/java/de/k3b/io/IGalleryFilter.java index 842c0c23..681c75a7 100644 --- a/fotolib2/src/main/java/de/k3b/io/IGalleryFilter.java +++ b/fotolib2/src/main/java/de/k3b/io/IGalleryFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2017 by k3b. + * Copyright (c) 2015-2018 by k3b. * * This file is part of AndroFotoFinder / #APhotoManager. * @@ -57,7 +57,7 @@ public interface IGalleryFilter extends IGeoRectangle { /** None of the Tags/Keywords/Categories/VirtualAlbum that the image must NOT contain. ("AND NOT") */ List getTagsAllExcluded(); - /** match if the text is in path, filename, title, description, tags */ + /** match if the text is in path, filename, title, description, tags. Wildcard "%" is allowed. Sub-expressions are seperated by " " */ String getInAnyField(); /** one of the VISIBILITY_XXXX values for public/private images */ diff --git a/wiki/table-of-content.md b/wiki/table-of-content.md deleted file mode 100644 index c2ccff06..00000000 --- a/wiki/table-of-content.md +++ /dev/null @@ -1,52 +0,0 @@ -[table-of-content](table-of-content) - - - -![](https://raw.githubusercontent.com/k3b/AndroFotoFinder/master/wiki/png/s_unchecked.png) -![](https://raw.githubusercontent.com/k3b/AndroFotoFinder/master/wiki/png/s_cancel.png) -![](https://raw.githubusercontent.com/k3b/AndroFotoFinder/master/wiki/png/s_checked.png) -![](https://raw.githubusercontent.com/k3b/AndroFotoFinder/master/wiki/png/s_filter.png) -![](https://raw.githubusercontent.com/k3b/AndroFotoFinder/master/wiki/png/s_folder.png) -![](https://raw.githubusercontent.com/k3b/AndroFotoFinder/master/wiki/png/s_map.png) -![](https://raw.githubusercontent.com/k3b/AndroFotoFinder/master/wiki/png/s_share.png) - -![](https://raw.githubusercontent.com/k3b/AndroFotoFinder/master/wiki/png/Gallery.png) - - -* [Features](https://github.com/k3b/AndroFotoFinder/wiki/features) -* [Geographic-Map](https://github.com/k3b/AndroFotoFinder/wiki/geographic-map) - * ["geo:" picker](https://github.com/k3b/AndroFotoFinder/wiki/geographic-map#picker) -* [Gallery-View](https://github.com/k3b/AndroFotoFinder/wiki/Gallery-View) - * [multi selection mode](Gallery-View#Multiselection) - * [Gallery Navigation](Gallery-View#Navigation) - * [Current Visible Photos](Gallery-View#CurrentSet) -* [Image-View](https://github.com/k3b/AndroFotoFinder/wiki/Image-View) - * [Image-View Intent-API](Image-View#api) -* [Folder-Picker](https://github.com/k3b/AndroFotoFinder/wiki/Folder-Picker) -* [Intent API](https://github.com/k3b/AndroFotoFinder/wiki/intentapi) - * [Uri formats](intentapi#uri) - * [geo: uri format](intentapi#uri-geo) - * [android.intent.extra.TITLE string](intentapi#EXTRA_TITLE) - * [Intent-Extra parameter](intentapi#extra) - * [de.k3b.extra.FILTER string](intentapi#filter) - * [de.k3b.extra.SQL string string](intentapi#EXTRA_SQL) - * [de.k3b.extra.SELECTED_ITEMS string](intentapi#SelectedItems) - * [de.k3b.extra.SELECTED_ITEMS_PATH string](intentapi#SelectedPaths) - * [Internal sql format of .query files](intentapi#sql) - -* [Filter-View](https://github.com/k3b/AndroFotoFinder/wiki/Filter-View) -* [Bookmarks](Bookmarks) -* [Settings](https://github.com/k3b/AndroFotoFinder/wiki/settings) -* [pc android meta sync](https://github.com/k3b/AndroFotoFinder/wiki/sync) -* [Metadata](https://github.com/k3b/AndroFotoFinder/wiki/Metadata) -* [Tags](Tags) - -