Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor code refresh #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,5 @@ build/
.idea/
.gradle/

demo/demo.iml
*.iml
demo/pom.xml
Android-Exif-Extended.iml
library/library.iml
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:1.0.+'
classpath 'com.android.tools.build:gradle:1.2.+'
}
}

Expand Down
10 changes: 6 additions & 4 deletions demo/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@

apply plugin: 'signing'
apply plugin: 'android'
apply plugin: 'com.android.application'

dependencies {
compile project(':library')
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'commons-io:commons-io:2.4'
}

android {
compileSdkVersion 21
buildToolsVersion "21.1.1"
compileSdkVersion 22
buildToolsVersion "21.1.2"

defaultConfig {
minSdkVersion 9
targetSdkVersion 21
targetSdkVersion 22
}

sourceSets {
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Dec 01 15:40:48 EST 2014
#Wed Jun 10 00:32:55 KST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip
4 changes: 1 addition & 3 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apply plugin: 'android-library'
apply plugin: 'com.android.library'

group GROUP
version VERSION_NAME
Expand All @@ -23,8 +23,6 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.apache.commons:commons-lang3:3.3.2'
compile 'commons-io:commons-io:2.4'
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,17 @@

import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.SystemClock;
import android.util.Log;
import android.util.SparseIntArray;
import it.sephiroth.android.library.exif2.io.IOUtils;

import org.apache.commons.io.IOUtils;

import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.*;
import java.nio.ByteOrder;
import java.nio.channels.FileChannel;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.TimeZone;
import java.util.*;

/**
* This class provides methods and constants for reading and writing jpeg file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
* The constants of the IFD ID defined in EXIF spec.
*/
public interface IfdId {
public static final int TYPE_IFD_0 = 0;
public static final int TYPE_IFD_1 = 1;
public static final int TYPE_IFD_EXIF = 2;
public static final int TYPE_IFD_INTEROPERABILITY = 3;
public static final int TYPE_IFD_GPS = 4;
int TYPE_IFD_0 = 0;
int TYPE_IFD_1 = 1;
int TYPE_IFD_EXIF = 2;
int TYPE_IFD_INTEROPERABILITY = 3;
int TYPE_IFD_GPS = 4;
/* This is used in ExifData to allocate enough IfdData */
static final int TYPE_IFD_COUNT = 5;
int TYPE_IFD_COUNT = 5;

}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class JpegHeader {
/** Comment section * */
public static final short M_COM = (short) 0xFFFE; // Comment section

public static final boolean isSofMarker( short marker ) {
public static boolean isSofMarker( short marker ) {
return marker >= M_SOF0 && marker <= M_SOF15 && marker != M_DHT && marker != JPG && marker != DAC;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package it.sephiroth.android.library.exif2.io;

import java.io.*;

/**
* extract from org.apache.commons.io only related functions as the library is too large.
*/
public class IOUtils {

private static final int DEFAULT_BUFFER_SIZE = 1024 * 4;
private static final int EOF = -1;

public static int copy(final InputStream input, final OutputStream output) throws IOException {
final long count = copyLarge(input, output);
if (count > Integer.MAX_VALUE) {
return -1;
}
return (int) count;
}

public static long copy(final InputStream input, final OutputStream output, final int bufferSize) throws IOException {
return copyLarge(input, output, new byte[bufferSize]);
}

public static long copyLarge(final InputStream input, final OutputStream output, final byte[] buffer)
throws IOException {
long count = 0;
int n = 0;
while (EOF != (n = input.read(buffer))) {
output.write(buffer, 0, n);
count += n;
}
return count;
}

public static long copyLarge(final InputStream input, final OutputStream output)
throws IOException {
return copy(input, output, DEFAULT_BUFFER_SIZE);
}

public static void closeQuietly(final InputStream input) {
closeQuietly((Closeable)input);
}

public static void closeQuietly(final OutputStream output) {
closeQuietly((Closeable)output);
}

public static void closeQuietly(final Closeable closeable) {
try {
if (closeable != null) {
closeable.close();
}
} catch (final IOException ioe) {
// ignore
}
}
}