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 Oct 24, 2018
2 parents ed2d0b9 + 61fa729 commit 7a0370d
Show file tree
Hide file tree
Showing 25 changed files with 329 additions and 195 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Privacy:
* Geotagging: Shows photos in a [geographic map](https://github.com/k3b/APhotoManager/wiki/geographic-map) from [openstreetmap](http://www.openstreetmap.org)
* Buildin file manager for photos: find, sort, view, copy, delete, Show in map, set gps exif data, send, edit exif, ... .
* Fast [find](https://github.com/k3b/APhotoManager/wiki/Filter-View) local photos by (sub-)folder, date, [geographic map](https://github.com/k3b/APhotoManager/wiki/geographic-map)or [tags (keywords)](https://github.com/k3b/APhotoManager/wiki/Tags).
* [Translations](https://crowdin.com/project/AndroFotoFinder): &nbsp;ar,&nbsp;<a href="https://github.com/k3b/APhotoManager/wiki/de-home">de</a>,&nbsp;<a href="https://github.com/k3b/APhotoManager/wiki/home" >en</a>,&nbsp;<a href="https://github.com/k3b/APhotoManager/wiki/it-home">it</a>,&nbsp;<a href="https://github.com/k3b/APhotoManager/wiki/fr-home">fr</a>,&nbsp;<a href="https://github.com/k3b/APhotoManager/wiki/ja-home">ja</a>,&nbsp;nl,&nbsp;pl,&nbsp;<a href="https://github.com/k3b/APhotoManager/wiki/ro-home">ro</a>,&nbsp;ru&nbsp;<a href="https://github.com/k3b/APhotoManager/wiki/tr-home">tr</a>,&nbsp;<a href="https://github.com/k3b/APhotoManager/wiki/zh-CN-home">zh-CN</a>,&nbsp;<a href="https://github.com/k3b/APhotoManager/wiki/zh-TW-home">zh-TW</a>
* [Translations](https://crowdin.com/project/AndroFotoFinder): &nbsp;ar,&nbsp;<a href="https://github.com/k3b/APhotoManager/wiki/de-home">de</a>,&nbsp;<a href="https://github.com/k3b/APhotoManager/wiki/home" >en</a>,&nbsp;<a href="https://github.com/k3b/APhotoManager/wiki/it-home">it</a>,&nbsp;<a href="https://github.com/k3b/APhotoManager/wiki/fr-home">fr</a>,&nbsp;<a href="https://github.com/k3b/APhotoManager/wiki/ja-home">ja</a>,&nbsp;nl,&nbsp;pl,&nbsp;<a href="https://github.com/k3b/APhotoManager/wiki/ro-home">ro</a>,&nbsp;ru&nbsp;<a href="https://github.com/k3b/APhotoManager/wiki/tr-home">tr</a>,&nbsp;<a href="https://github.com/k3b/APhotoManager/wiki/uk-home">uk</a>,&nbsp;<a href="https://github.com/k3b/APhotoManager/wiki/zh-CN-home">zh-CN</a>,&nbsp;<a href="https://github.com/k3b/APhotoManager/wiki/zh-TW-home">zh-TW</a>
* [![Crowdin](https://d322cqt584bo4o.cloudfront.net/androFotoFinder/localized.svg)](https://crowdin.com/project/androFotoFinder)<a href="https://github.com/k3b/APhotoManager/issues/21">Help us to translate into other languages.</a>

---
Expand Down
10 changes: 5 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ android {
// 0.6.9.180813 (37) public betta: Searchbar, vitual-folder, new icons
// 0.7.0.180823 (38) Searchbar, vitual-folder, new icons
// 0.7.1.180830 (39) Bugfix for 38; translation uk
// 0.7.2.181027 (40) Bugfixes: image orientation, media scanner

versionCode = 39
versionName = '0.7.1.180830'
versionCode = 40
versionName = '0.7.2.181027'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
Expand Down Expand Up @@ -111,9 +112,8 @@ dependencies {
// zoomable image view
// from https://github.com/chrisbanes/PhotoView
// compile 'com.github.chrisbanes.photoview:library:1.2.3'
// compile project(':fotoview.library')
// compile 'com.github.k3b.PhotoView:library:v1.2.6.k3b-SNAPSHOT' // via jitpack.io
compile 'com.github.k3b:PhotoView:v1.2.6.k3b-5-SNAPSHOT' // via jitpack.io
// compile project(':fotoview.library') // local copy of PhotoView
compile 'com.github.k3b:PhotoView:v1.2.6.k3b-7-SNAPSHOT' // via jitpack.io last bugfix on 2018-10-17

// for view-pager
compile 'com.android.support:support-v4:21.0.2'
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/java/de/k3b/android/androFotoFinder/Global.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public class Global {
/** true every time a .nomedia dir/file is opend remeove items from db. */
public static final boolean mustRemoveNOMEDIAfromDB = true;

// #127: Folderpicker: moving pathbar makes it discoverable. stop animation once the pathbar is touched
public static final boolean showPathBarAnimation = true;

private static final File externalStorageDirectory = Environment.getExternalStorageDirectory();

/** defines the filesystem's directory where [Bookmark files](Bookmarks) are stored and loaded from. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.util.Log;
import android.widget.ImageView;

import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
Expand All @@ -36,6 +38,7 @@
import java.io.IOException;

import de.k3b.android.androFotoFinder.queries.FotoSql;
import de.k3b.media.MediaUtil;

/**
* Service facade hiding com.nostra13.universalimageloader
Expand All @@ -47,7 +50,7 @@ public class ThumbNailUtils {
public static final String LOG_TAG = "ImageLoader";
public static final int MAX_CACHE_SIZE_50MB = 50 * 1024 * 1024;
public static final int MAX_FILE_COUNT = 1024;
public static boolean DEBUG = false;
public static boolean DEBUG = false; // in settings via debugEnableLibs

public static void init(Context context, File previousCacheRoot) {

Expand Down Expand Up @@ -104,14 +107,45 @@ private static DisplayImageOptions createThumbnailOptions() {
private static final DisplayImageOptions mDisplayImageOptions = ThumbNailUtils.createThumbnailOptions();

public static void getThumb(int iconID, ImageView imageView) {
ImageLoader.getInstance().displayImage( FotoSql.getUriString(iconID), imageView, mDisplayImageOptions);
String uriString = FotoSql.getUriString(iconID);
displayImageImpl(uriString, imageView, "iconID:", iconID);
}

public static void getThumb(String fullPath, ImageView imageView) {

if ((imageView != null) && (fullPath != null) && (fullPath.length() > 0)) {
ImageLoader.getInstance().displayImage("file://" + fullPath, imageView, mDisplayImageOptions);
String uriString = "file://" + fullPath;
displayImageImpl(uriString, imageView, "fullPath:" , fullPath);
}
}

private static void displayImageImpl(String uriString, ImageView imageView, String debugContext, Object debugParam) {
if (ThumbNailUtils.DEBUG && Global.debugEnabledViewItem) {
Log.i(ThumbNailUtils.LOG_TAG, "displayImageImpl " + uriString +
" because of " + debugContext + debugParam);
}

ImageLoader.getInstance().displayImage(uriString, imageView, mDisplayImageOptions);
}

/** @param exifOrientationCode either code 0..8 or rotation angle 0, 90, 180, 270 */
public static Bitmap rotateBitmap(Bitmap source, int exifOrientationCode) {
if (exifOrientationCode != 0) {
int angle = MediaUtil.exifOrientationCode2RotationDegrees(exifOrientationCode, exifOrientationCode);

if (ThumbNailUtils.DEBUG && Global.debugEnabledViewItem) {
Log.i(ThumbNailUtils.LOG_TAG, "rotateBitmap code=" + exifOrientationCode +
" ==> " + angle);
}

if (angle != 0) {
Matrix matrix = new Matrix();
matrix.postRotate(angle);
return Bitmap.createBitmap(source, 0, 0, source.getWidth(),
source.getHeight(), matrix, true);
}
}
return source;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package de.k3b.android.androFotoFinder.directory;

import android.animation.ValueAnimator;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
Expand All @@ -29,12 +30,14 @@
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
Expand Down Expand Up @@ -147,6 +150,10 @@ protected void onProgressUpdate(Integer... values) {
private Button mCmdOk = null;
private Button mCmdPopup = null;

// #127: Folderpicker: moving pathbar makes it discoverable. stop animation once the pathbar is touched
private boolean showPathBarAnimation = Global.showPathBarAnimation;
private ValueAnimator mPathbarAnimation = null;

private View.OnClickListener mPathButtonClickHandler;
private View.OnLongClickListener mPathButtonLongClickHandler = null;
// local data
Expand Down Expand Up @@ -227,6 +234,7 @@ public void onClick(View v) {
mPathButtonLongClickHandler = new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
showPathBarAnimation = false;
onShowPopUp(v, (IDirectory) v.getTag());
return true;
}
Expand All @@ -235,6 +243,15 @@ public boolean onLongClick(View v) {

this.mParentPathBar = (LinearLayout) view.findViewById(R.id.parent_owner);
this.mParentPathBarScroller = (HorizontalScrollView) view.findViewById(R.id.parent_scroller);
this.mParentPathBarScroller.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
animationPathBarStop();
// #127: stop animation once the pathbar is touched
showPathBarAnimation = false;
return false; // assume that the event is not handled yet so button can do it-s function
}
});

mTreeView = (ExpandableListView)view.findViewById(R.id.directory_tree);
mTreeView.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
Expand Down Expand Up @@ -825,6 +842,9 @@ private void onParentPathBarButtonClick(IDirectory selectedChild) {
Log.d(TAG, debugPrefix + "onParentPathBarButtonClick(" +
selectedChild.getAbsolute() + ")");

showPathBarAnimation = false;
animationPathBarStop();

// naviationchange only if there are children below child
IDirectory newGrandParent = ((selectedChild != null) && (Directory.getChildCount(selectedChild) > 0)) ? selectedChild.getParent() : null;
List<IDirectory> siblings = (newGrandParent != null) ? newGrandParent.getChildren() : null;
Expand Down Expand Up @@ -915,6 +935,7 @@ private void updateParentPathBar(IDirectory selectedChild) {

// scroll to right where deepest child is
mParentPathBarScroller.requestChildFocus(mParentPathBar, first);

}

if (mImage != null) {
Expand All @@ -924,6 +945,47 @@ private void updateParentPathBar(IDirectory selectedChild) {
this.mCurrentSelection = selectedChild;

updateStatus();

if (showPathBarAnimation) {
new Handler().postDelayed(new Runnable() {
public void run() {
// start animation after some delay
animationPathBarInit();
}
}, 800);
}
}

// #127: Folderpicker: moving pathbar makes it discoverable. stop animation once the pathbar is touched
private void animationPathBarInit() {
animationPathBarStop();

if (showPathBarAnimation) {
int delta = mParentPathBar.getWidth() - mParentPathBarScroller.getWidth();
if (delta > 0) {
mPathbarAnimation = ValueAnimator.ofInt(delta, 0);
mPathbarAnimation.setDuration(5000); // 5 from right to left seconds
mPathbarAnimation.setRepeatCount(ValueAnimator.INFINITE);
mPathbarAnimation.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator updatedAnimation) {
int x = (int) updatedAnimation.getAnimatedValue();
mParentPathBarScroller.smoothScrollTo(x, 0);
}
});
mPathbarAnimation.setRepeatMode(ValueAnimator.REVERSE);
mPathbarAnimation.start();
}
}
}

// #127: Folderpicker: moving pathbar makes it discoverable. stop animation once the pathbar is touched
private void animationPathBarStop() {
if (mPathbarAnimation != null) {
mPathbarAnimation.end();
mPathbarAnimation.removeAllUpdateListeners();
mPathbarAnimation = null;
}
}

private void updateBitmap(int iconID) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.provider.MediaStore;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -128,6 +130,9 @@ public void bindView(View view, Context context, Cursor cursor) {
imageSize = DBUtils.getLong(cursor, FotoSql.SQL_COL_SIZE, 0);
}

// either code 0..8 or rotation angle 0, 90, 180, 270
int exifOrientationCode = DBUtils.getInt(cursor, FotoSql.SQL_COL_ORIENTATION, 0);

holder.filter = DBUtils.getString(cursor, FotoSql.SQL_COL_WHERE_PARAM, null);

String description = DBUtils.getString(cursor, FotoSql.SQL_COL_DISPLAY_TEXT, "");
Expand All @@ -143,7 +148,8 @@ public void bindView(View view, Context context, Cursor cursor) {
if ((imageSize > 0) && (imageSize <= Global.imageDetailThumbnailIfBiggerThan)) {
try {
// #53, #83 Optimisation: no need for thumbnail - saves cache memory but may throw OutOfMemoryError
holder.image.setImageBitmap(HugeImageLoader.loadImage(new File(uri), MAX_IMAGE_DIMENSION, MAX_IMAGE_DIMENSION));
Bitmap bitmap = HugeImageLoader.loadImage(new File(uri), MAX_IMAGE_DIMENSION, MAX_IMAGE_DIMENSION);
holder.image.setImageBitmap(ThumbNailUtils.rotateBitmap(bitmap, exifOrientationCode));
} catch (OutOfMemoryError err) {
ThumbNailUtils.getThumb(uri, holder.image);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.net.Uri;
import android.util.Log;
import android.view.View;
Expand All @@ -36,6 +37,8 @@
import de.k3b.android.util.MediaScanner;
import de.k3b.io.collections.SelectedFiles;
import de.k3b.io.collections.SelectedItems;
import de.k3b.media.ExifInterface;
import de.k3b.media.ExifInterfaceEx;

/**
* Created by k3b on 30.05.2016.
Expand Down Expand Up @@ -108,8 +111,9 @@ public View getView(int position, View convertView, ViewGroup parent) {
holder.url = fullPhotoPathFromArray;

final File file = new File(fullPhotoPathFromArray);
ThumbNailUtils.getThumb(fullPhotoPathFromArray, holder.image);
holder.image.setImageBitmap(HugeImageLoader.loadImage(file, 32,32));
int exifOrientationCode = ExifInterfaceEx.getOrientationId (fullPhotoPathFromArray);
Bitmap bitmap = HugeImageLoader.loadImage(file, 32, 32);
holder.image.setImageBitmap(ThumbNailUtils.rotateBitmap(bitmap, exifOrientationCode));

holder.image.setImageURI(Uri.parse(holder.url));
holder.imageID = this.getImageId(position);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,18 +308,23 @@ protected View createViewWithContent(int position, ViewGroup container, String f
try {
// #53 Optimisation: no need for thumbnail - saves cache memory but may throw OutOfMemoryError
loadType = "image small enough ";
photoView.setImageBitmap(HugeImageLoader.loadImage(imageFile, MAX_IMAGE_DIMENSION, MAX_IMAGE_DIMENSION));
Bitmap bitmap = HugeImageLoader.loadImage(imageFile, MAX_IMAGE_DIMENSION, MAX_IMAGE_DIMENSION);
// rotation is done by photoView
photoView.setImageBitmap(bitmap);
photoView.setImageReloadFile(null);
photoView.setDebugPrefix(imageFile.getName());
} catch (OutOfMemoryError err) {
loadType = "small image out of memory using thumb ";
setImageFromThumbnail(photoView, imageFile);
}
}
photoView.setRotationTo(JpgMetaWorkflow.getRotationFromExifOrientation(fullPhotoPath));
final int rotationInDegrees = JpgMetaWorkflow.getRotationFromExifOrientation(fullPhotoPath);
if (Global.debugEnabledViewItem) {
Log.i(Global.LOG_CONTEXT, mDebugPrefix + debugContext + position +", "
Log.i(Global.LOG_CONTEXT, mDebugPrefix + debugContext + position +", rotation=" +
rotationInDegrees + ", "
+ loadType + ") => " + fullPhotoPath + " => " + photoView);
}
photoView.setRotationTo(rotationInDegrees);

container.addView(root, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
return root;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.ImageView;

import java.io.File;
Expand All @@ -23,6 +24,7 @@
* Created by k3b on 14.07.2016.
*/
public class PhotoViewEx extends PhotoView {
private static final String LOG_CONTEXT = PhotoViewAttacher.LOG_TAG; // ;Global.LOG_CONTEXT;
private PhotoViewAttacherEx mAttacher;

public PhotoViewEx(Context context) {
Expand All @@ -37,16 +39,27 @@ public PhotoViewEx(Context context, AttributeSet attr, int defStyle) {
super(context, attr, defStyle);
}

/** Required to have my own enhanced attacher that contains the additional functionality */
protected IPhotoViewAttacher onCreatePhotoViewAttacher(PhotoView photoView) {
mAttacher = new PhotoViewAttacherEx(photoView);
/** factory method to be overwritten if you need different attacher functionality */
@Override
protected PhotoViewAttacher createPhotoViewAttacher() {
mAttacher = new PhotoViewAttacherEx(this);
return mAttacher;
}


/** k3b 20150913 #10: Faster initial loading: initially the view is loaded with low res image.
* on first zoom it is reloaded with this uri */
public void setImageReloadFile(File file) {
mAttacher.setImageReloadFile(file);
if (file != null) {
setDebugPrefix(file.getName());
}
}

@Override
public ScaleType getScaleType() {
if (mAttacher != null) return super.getScaleType();
return ScaleType.CENTER;
}

static class PhotoViewAttacherEx extends PhotoViewAttacher {
Expand All @@ -64,6 +77,9 @@ public PhotoViewAttacherEx(PhotoView photoView) {
* on first zoom it is reloaded with this uri */
public void setImageReloadFile(File imageReloadURI) {
this.mImageReloadFile = imageReloadURI;
if (imageReloadURI != null) {
setDebugPrefix(imageReloadURI.getName());
}
}

/** invoked by the guesture detector */
Expand Down
Loading

0 comments on commit 7a0370d

Please sign in to comment.