Skip to content

Commit

Permalink
Merge branch 'master' into FDroid
Browse files Browse the repository at this point in the history
  • Loading branch information
k3b committed Dec 14, 2016
2 parents fc1ea4e + 5bbc475 commit 2f66407
Show file tree
Hide file tree
Showing 10 changed files with 197 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,15 +119,20 @@ private static class GalleryQueryParameter {
protected int mDirQueryID = FotoSql.QUERY_TYPE_GROUP_DEFAULT;

private boolean mHasUserDefinedQuery = false;

/** current sort order */
private int mCurrentSortID = FotoSql.SORT_BY_DEFAULT;
/** current sort order */
private boolean mCurrentSortAscending = false;

private String mCurrentPathFromFolderPicker = "/";

protected QueryParameter mGalleryContentQuery = null;

/** Filter parameter defining current visible items */
private IGalleryFilter mCurrentFilterSettings;

/** sql defines current visible items with optional sort order */
protected QueryParameter mGalleryContentQuery = null;

/** true: if activity started without special intent-parameters,
* the last mCurrentFilterSettings is saved/loaded for next use */
private boolean mSaveToSharedPrefs = true;
Expand Down Expand Up @@ -158,7 +163,7 @@ public void setSortID(int sortID) {
}

public String getSortDisplayName(Context context) {
return FotoSql.getName(context, this.mCurrentSortID) + ((mCurrentSortAscending) ? " ^" : " V");
return FotoSql.getName(context, this.mCurrentSortID) + " " + ((mCurrentSortAscending) ? IGalleryFilter.SORT_DIRECTION_ASCENDING : IGalleryFilter.SORT_DIRECTION_DESCENDING);
}

public boolean clearPathIfActive() {
Expand Down Expand Up @@ -194,7 +199,7 @@ private QueryParameter calculateEffectiveGalleryContentQuery(QueryParameter root
FotoSql.addPathWhere(result, this.mCurrentPathFromFolderPicker, this.getDirQueryID());
}

if (mCurrentSortID != FotoSql.SORT_BY_NONE) {
if (mCurrentSortID != IGalleryFilter.SORT_BY_NONE) {
FotoSql.setSort(result, mCurrentSortID, mCurrentSortAscending);
}
return result;
Expand Down Expand Up @@ -563,7 +568,7 @@ private void loadBookmark() {
public void setQuery(QueryParameter newQuery) {
final IGalleryFilter whereFilter = FotoSql.getWhereFilter(newQuery, true);
mGalleryQueryParameter.mGalleryContentQuery = newQuery;
mGalleryQueryParameter.setSortID(FotoSql.SORT_BY_NONE);
mGalleryQueryParameter.setSortID(IGalleryFilter.SORT_BY_NONE);
onFilterChanged(whereFilter, "loadBookmark");
invalidateDirectories(mDebugPrefix + "#loaded bookmark");
mGalleryQueryParameter.setHasUserDefinedQuery(true);
Expand Down Expand Up @@ -635,7 +640,7 @@ private void openFolderPicker() {
if (mDirectoryRoot == null) {
// not loaded yet. load directoryRoot in background
final QueryParameter currentDirContentQuery = new QueryParameter(FotoSql.getQuery(dirQueryID));
FotoSql.setWhereFilter(currentDirContentQuery, this.mGalleryQueryParameter.getCurrentFilterSettings(), this.mGalleryQueryParameter.getSortID() != FotoSql.SORT_BY_NONE);
FotoSql.setWhereFilter(currentDirContentQuery, this.mGalleryQueryParameter.getCurrentFilterSettings(), this.mGalleryQueryParameter.getSortID() != IGalleryFilter.SORT_BY_NONE);

this.mGalleryQueryParameter.mDirQueryID = (currentDirContentQuery != null) ? currentDirContentQuery.getID() : FotoSql.QUERY_TYPE_UNDEFINED;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static void showActivity(Activity context, IGalleryFilter filter, QueryPa
final Intent intent = new Intent().setClass(context,
GalleryFilterActivity.class);

if (filter != null) {
if (!GalleryFilterParameter.isEmpty(filter)) {
intent.putExtra(EXTRA_FILTER, filter.toString());
}

Expand Down Expand Up @@ -379,14 +379,32 @@ public boolean isNonGeoOnly() {
return mWithNoGeoInfo.isChecked();
}

/**
* number defining current sorting
*/
@Override
public int getSortID() {
return (mFilter != null) ? mFilter.getSortID() : SORT_BY_NONE;
}

/**
* false: sort descending
*/
@Override
public boolean isSortAscending() {
return (mFilter != null) ? mFilter.isSortAscending() : false;
}

@Override
public IGalleryFilter get(IGalleryFilter src) {
get((IGeoRectangle) src);
mPath .setText(src.getPath());
mDateFrom .setText(convertDate(src.getDateMin()));
mDateTo .setText(convertDate(src.getDateMax()));
mWithNoGeoInfo.setChecked(src.isNonGeoOnly());
showLatLon(src.isNonGeoOnly());
if (src != null) {
get((IGeoRectangle) src);
mPath.setText(src.getPath());
mDateFrom.setText(convertDate(src.getDateMin()));
mDateTo.setText(convertDate(src.getDateMax()));
mWithNoGeoInfo.setChecked(src.isNonGeoOnly());
showLatLon(src.isNonGeoOnly());
}
return this;
}

Expand Down Expand Up @@ -439,7 +457,9 @@ private void toGui(IGalleryFilter gf) {

private boolean fromGui(IGalleryFilter dest) {
try {
dest.get(mFilterValue);
if (dest != null) {
dest.get(mFilterValue);
}
return true;
} catch (RuntimeException ex) {
Toast.makeText(this, ex.getMessage(), Toast.LENGTH_LONG).show();
Expand All @@ -448,7 +468,13 @@ private boolean fromGui(IGalleryFilter dest) {
}

private void clearFilter() {
mFilter = new GalleryFilterParameter();
GalleryFilterParameter filter = new GalleryFilterParameter();

if (mFilter != null) {
filter.setSort(mFilter.getSortID(), mFilter.isSortAscending());
}

this.mFilter = filter;
toGui(mFilter);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public Loader<Cursor> onCreateLoader(int loaderID, Bundle bundle) {
@Override
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
// to be restored after refreshLocal if there is no mInitialFilePath
if (mInitialScrollPosition == NO_INITIAL_SCROLL_POSITION) {
if ((mInitialScrollPosition == NO_INITIAL_SCROLL_POSITION) && (mViewPager != null)) {
mInitialScrollPosition = mViewPager.getCurrentItem();
}
// do change the data
Expand Down Expand Up @@ -671,7 +671,7 @@ private void onLoadCompleted() {
}

private void refreshIfNecessary() {
if (mAdapter.isInArrayMode()) {
if ((mAdapter != null) && (mViewPager != null) && (mAdapter.isInArrayMode())) {
mAdapter.refreshLocal();
mViewPager.setAdapter(mAdapter);

Expand Down Expand Up @@ -983,18 +983,27 @@ protected SelectedFiles getCurrentFoto() {
}

private long getCurrentImageId() {
int itemPosition = mViewPager.getCurrentItem();
return this.mAdapter.getImageId(itemPosition);
if ((mViewPager != null) && (mAdapter != null)) {
int itemPosition = mViewPager.getCurrentItem();
return this.mAdapter.getImageId(itemPosition);
}
return -1;
}

protected String getCurrentFilePath() {
int itemPosition = mViewPager.getCurrentItem();
return this.mAdapter.getFullFilePath(itemPosition);
if ((mViewPager != null) && (mAdapter != null)) {
int itemPosition = mViewPager.getCurrentItem();
return this.mAdapter.getFullFilePath(itemPosition);
}
return "";
}

protected boolean hasCurrentGeo() {
int itemPosition = mViewPager.getCurrentItem();
return this.mAdapter.hasGeo(itemPosition);
if ((mViewPager != null) && (mAdapter != null)) {
int itemPosition = mViewPager.getCurrentItem();
return this.mAdapter.hasGeo(itemPosition);
}
return false;
}

private boolean isViewPagerActive() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import android.content.Context;
import android.content.CursorLoader;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.net.Uri;
import android.os.Build;
import android.provider.MediaStore;
Expand Down Expand Up @@ -65,11 +64,16 @@ public class FotoSql {
// public static final String SQL_EXPR_DAY = "(ROUND("
// + MediaStore.Images.Media.SQL_COL_DATE_TAKEN + "/" + PER_DAY + ") * " + PER_DAY + ")";

public static final int SORT_BY_NONE = 0;
public static final int SORT_BY_DATE = 1;
public static final int SORT_BY_NAME = 2;
public static final int SORT_BY_LOCATION = 3;
public static final int SORT_BY_NAME_LEN = 4;
public static final int SORT_BY_DATE_OLD = 1;
public static final int SORT_BY_NAME_OLD = 2;
public static final int SORT_BY_LOCATION_OLD = 3;
public static final int SORT_BY_NAME_LEN_OLD = 4;

public static final int SORT_BY_DATE = 'd';
public static final int SORT_BY_NAME = 'n';
public static final int SORT_BY_LOCATION = 'l';
public static final int SORT_BY_NAME_LEN = 's'; // size

public static final int SORT_BY_DEFAULT = SORT_BY_DATE;

public static final int QUERY_TYPE_UNDEFINED = 0;
Expand Down Expand Up @@ -249,7 +253,7 @@ public static QueryParameter getQueryGroupByPlace(double groupingFactor) {
.addFrom(SQL_TABLE_EXTERNAL_CONTENT_URI.toString());

public static void setWhereFilter(QueryParameter parameters, IGalleryFilter filter, boolean clearWhereBefore) {
if ((parameters != null) && (filter != null)) {
if ((parameters != null) && (!GalleryFilterParameter.isEmpty(filter))) {
if (clearWhereBefore) {
parameters.clearWhere();
}
Expand Down Expand Up @@ -415,14 +419,19 @@ public static QueryParameter getQuery(int queryID) {

public static String getName(Context context, int id) {
switch (id) {
case SORT_BY_NONE:
case IGalleryFilter.SORT_BY_NONE_OLD:
case IGalleryFilter.SORT_BY_NONE:
return context.getString(R.string.sort_by_none);
case SORT_BY_DATE_OLD:
case SORT_BY_DATE:
return context.getString(R.string.sort_by_date);
case SORT_BY_NAME_OLD:
case SORT_BY_NAME:
return context.getString(R.string.sort_by_name);
case SORT_BY_LOCATION_OLD:
case SORT_BY_LOCATION:
return context.getString(R.string.sort_by_place);
case SORT_BY_NAME_LEN_OLD:
case SORT_BY_NAME_LEN:
return context.getString(R.string.sort_by_name_len);

Expand All @@ -449,12 +458,16 @@ public static QueryParameter setSort(QueryParameter result, int sortID, boolean
String asc = (ascending) ? " asc" : " desc";
result.replaceOrderBy();
switch (sortID) {
case SORT_BY_DATE_OLD:
case SORT_BY_DATE:
return result.replaceOrderBy(SQL_COL_DATE_TAKEN + asc);
case SORT_BY_NAME_OLD:
case SORT_BY_NAME:
return result.replaceOrderBy(SQL_COL_PATH + asc);
case SORT_BY_LOCATION_OLD:
case SORT_BY_LOCATION:
return result.replaceOrderBy(SQL_COL_GPS + asc, MediaStore.Images.Media.LATITUDE + asc);
case SORT_BY_NAME_LEN_OLD:
case SORT_BY_NAME_LEN:
return result.replaceOrderBy("length(" + SQL_COL_PATH + ")"+asc);
default: return result;
Expand Down Expand Up @@ -563,7 +576,7 @@ public static IGeoRectangle execGetGeoRectangle(Context context, IGalleryFilter
)
.addFrom(SQL_TABLE_EXTERNAL_CONTENT_URI.toString());

if (filter != null) {
if (!GalleryFilterParameter.isEmpty(filter)) {
setWhereFilter(query, filter, true);
}

Expand Down
17 changes: 13 additions & 4 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@
<string name="copy_menu_title">Copia</string>
<string name="copy_result_format">Copiati %1$d/%2$d file</string>
<string name="delete_menu_title">Elimina</string>
<string name="delete_question_message_format">"Sei sicuro di volere eliminare in modo definitivo questi file?
%1$s

Questa operazione non può essere annullata."</string>
<string name="delete_question_message_format">"Sei sicuro di volere eliminare in modo definitivo questi file? %1$sQuesta operazione non può essere annullata."</string>
<string name="delete_question_title">Eliminare la/le foto?</string>
<string name="delete_result_format">Eliminati %1$d/%2$d file</string>
<string name="destination_copy">Copia destinazione</string>
Expand Down Expand Up @@ -146,4 +143,16 @@
<string name="settings_maps_forge_enable_summary">che hai scaricato manualmente tramite pc</string>
<string name="settings_maps_forge_dir_title">Cartella file di mappa *.map</string>
<string name="show_photo">Mostra foto</string>
<string name="fix_link_menu_title">Ripara duplicati</string>
<string name="geo_picker_from_photo_title">Scegli geo dalla foto</string>
<string name="geo_picker_from_map_title">Scegli geo dalla mappa</string>
<string name="folder_hide_images_menu_title">Nascondi immagini</string>
<string name="folder_hide_images_question_message_format">"Sei sicuro?

Vuoi rendere tutti i file multimediali (foto, video, audio) sotto

%1$s

invisibili ai database, app galleria e media scanner?
Puoi annullare l\'azione avviando il media scanner dal menu galleria."</string>
</resources>
14 changes: 10 additions & 4 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@
<string name="copy_menu_title">コピー</string>
<string name="copy_result_format">%1$d/%2$d ファイルをコピーしました</string>
<string name="delete_menu_title">削除</string>
<string name="delete_question_message_format">"これらのファイルを完全に削除してもよろしいですか?
%1$s

この操作を元に戻すことはできません。"</string>
<string name="delete_question_message_format">"これらのファイルを完全に削除してもよろしいですか?%1$sこの操作を元に戻すことはできません。"</string>
<string name="delete_question_title">写真を削除しますか?</string>
<string name="delete_result_format">%1$d/%2$d ファイルを削除しました</string>
<string name="destination_copy">コピー先</string>
Expand Down Expand Up @@ -146,4 +143,13 @@
<string name="settings_maps_forge_enable_summary">pc 経由で手動でダウンロードしたもの</string>
<string name="settings_maps_forge_dir_title">*.map 地図ファイル フォルダー</string>
<string name="show_photo">写真を表示</string>
<string name="fix_link_menu_title">重複を修復</string>
<string name="geo_picker_from_photo_title">写真から地域を選択</string>
<string name="geo_picker_from_map_title">地図から地域を選択</string>
<string name="folder_hide_images_menu_title">画像を非表示</string>
<string name="folder_hide_images_question_message_format">"よろしいですか?下のすべてのメディアファイル (写真、ビデオ、オーディオ)

%1$s

を、メディアデータベース、ギャラリーアプリ、メディアスキャナーから非表示にしますか?ギャラリーメニューからメディアスキャナーを呼び出して、非表示を元に戻すことができます。"</string>
</resources>
Loading

0 comments on commit 2f66407

Please sign in to comment.