());
-
- /**
- * @param cacheDir Directory for file caching
- * @param maxAge Max file age (in seconds). If file age will exceed this value then it'll be removed on next
- * treatment (and therefore be reloaded).
- */
- public LimitedAgeDiskCache(File cacheDir, long maxAge) {
- this(cacheDir, null, DefaultConfigurationFactory.createFileNameGenerator(), maxAge);
- }
-
- /**
- * @param cacheDir Directory for file caching
- * @param maxAge Max file age (in seconds). If file age will exceed this value then it'll be removed on next
- * treatment (and therefore be reloaded).
- */
- public LimitedAgeDiskCache(File cacheDir, File reserveCacheDir, long maxAge) {
- this(cacheDir, reserveCacheDir, DefaultConfigurationFactory.createFileNameGenerator(), maxAge);
- }
-
- /**
- * @param cacheDir Directory for file caching
- * @param reserveCacheDir null-ok; Reserve directory for file caching. It's used when the primary directory isn't available.
- * @param fileNameGenerator Name generator for cached files
- * @param maxAge Max file age (in seconds). If file age will exceed this value then it'll be removed on next
- * treatment (and therefore be reloaded).
- */
- public LimitedAgeDiskCache(File cacheDir, File reserveCacheDir, FileNameGenerator fileNameGenerator, long maxAge) {
- super(cacheDir, reserveCacheDir, fileNameGenerator);
- this.maxFileAge = maxAge * 1000; // to milliseconds
- }
-
- @Override
- public File get(String imageUri) {
- File file = super.get(imageUri);
- if (file != null && file.exists()) {
- boolean cached;
- Long loadingDate = loadingDates.get(file);
- if (loadingDate == null) {
- cached = false;
- loadingDate = file.lastModified();
- } else {
- cached = true;
- }
-
- if (System.currentTimeMillis() - loadingDate > maxFileAge) {
- file.delete();
- loadingDates.remove(file);
- } else if (!cached) {
- loadingDates.put(file, loadingDate);
- }
- }
- return file;
- }
-
- @Override
- public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException {
- boolean saved = super.save(imageUri, imageStream, listener);
- rememberUsage(imageUri);
- return saved;
- }
-
- @Override
- public boolean save(String imageUri, Bitmap bitmap) throws IOException {
- boolean saved = super.save(imageUri, bitmap);
- rememberUsage(imageUri);
- return saved;
- }
-
- @Override
- public boolean remove(String imageUri) {
- loadingDates.remove(getFile(imageUri));
- return super.remove(imageUri);
- }
-
- @Override
- public void clear() {
- super.clear();
- loadingDates.clear();
- }
-
- private void rememberUsage(String imageUri) {
- File file = getFile(imageUri);
- long currentTime = System.currentTimeMillis();
- file.setLastModified(currentTime);
- loadingDates.put(file, currentTime);
- }
-}
\ No newline at end of file
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/impl/UnlimitedDiskCache.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/impl/UnlimitedDiskCache.java
deleted file mode 100644
index 03fad1e96..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/impl/UnlimitedDiskCache.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.cache.disc.impl;
-
-import com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator;
-
-import java.io.File;
-
-/**
- * Default implementation of {@linkplain com.nostra13.universalimageloader.cache.disc.DiskCache disk cache}.
- * Cache size is unlimited.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.0.0
- */
-public class UnlimitedDiskCache extends BaseDiskCache {
- /** @param cacheDir Directory for file caching */
- public UnlimitedDiskCache(File cacheDir) {
- super(cacheDir);
- }
-
- /**
- * @param cacheDir Directory for file caching
- * @param reserveCacheDir null-ok; Reserve directory for file caching. It's used when the primary directory isn't available.
- */
- public UnlimitedDiskCache(File cacheDir, File reserveCacheDir) {
- super(cacheDir, reserveCacheDir);
- }
-
- /**
- * @param cacheDir Directory for file caching
- * @param reserveCacheDir null-ok; Reserve directory for file caching. It's used when the primary directory isn't available.
- * @param fileNameGenerator {@linkplain com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator
- * Name generator} for cached files
- */
- public UnlimitedDiskCache(File cacheDir, File reserveCacheDir, FileNameGenerator fileNameGenerator) {
- super(cacheDir, reserveCacheDir, fileNameGenerator);
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/impl/ext/DiskLruCache.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/impl/ext/DiskLruCache.java
deleted file mode 100644
index 6e18f31ff..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/impl/ext/DiskLruCache.java
+++ /dev/null
@@ -1,974 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed 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 com.nostra13.universalimageloader.cache.disc.impl.ext;
-
-import java.io.BufferedWriter;
-import java.io.Closeable;
-import java.io.EOFException;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.concurrent.Callable;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * A cache that uses a bounded amount of space on a filesystem. Each cache
- * entry has a string key and a fixed number of values. Each key must match
- * the regex [a-z0-9_-]{1,64}. Values are byte sequences,
- * accessible as streams or files. Each value must be between {@code 0} and
- * {@code Integer.MAX_VALUE} bytes in length.
- *
- * The cache stores its data in a directory on the filesystem. This
- * directory must be exclusive to the cache; the cache may delete or overwrite
- * files from its directory. It is an error for multiple processes to use the
- * same cache directory at the same time.
- *
- *
This cache limits the number of bytes that it will store on the
- * filesystem. When the number of stored bytes exceeds the limit, the cache will
- * remove entries in the background until the limit is satisfied. The limit is
- * not strict: the cache may temporarily exceed it while waiting for files to be
- * deleted. The limit does not include filesystem overhead or the cache
- * journal so space-sensitive applications should set a conservative limit.
- *
- *
Clients call {@link #edit} to create or update the values of an entry. An
- * entry may have only one editor at one time; if a value is not available to be
- * edited then {@link #edit} will return null.
- *
- * - When an entry is being created it is necessary to
- * supply a full set of values; the empty value should be used as a
- * placeholder if necessary.
- *
- When an entry is being edited, it is not necessary
- * to supply data for every value; values default to their previous
- * value.
- *
- * Every {@link #edit} call must be matched by a call to {@link Editor#commit}
- * or {@link Editor#abort}. Committing is atomic: a read observes the full set
- * of values as they were before or after the commit, but never a mix of values.
- *
- * Clients call {@link #get} to read a snapshot of an entry. The read will
- * observe the value at the time that {@link #get} was called. Updates and
- * removals after the call do not impact ongoing reads.
- *
- *
This class is tolerant of some I/O errors. If files are missing from the
- * filesystem, the corresponding entries will be dropped from the cache. If
- * an error occurs while writing a cache value, the edit will fail silently.
- * Callers should handle other problems by catching {@code IOException} and
- * responding appropriately.
- */
-final class DiskLruCache implements Closeable {
- static final String JOURNAL_FILE = "journal";
- static final String JOURNAL_FILE_TEMP = "journal.tmp";
- static final String JOURNAL_FILE_BACKUP = "journal.bkp";
- static final String MAGIC = "libcore.io.DiskLruCache";
- static final String VERSION_1 = "1";
- static final long ANY_SEQUENCE_NUMBER = -1;
- static final Pattern LEGAL_KEY_PATTERN = Pattern.compile("[a-z0-9_-]{1,64}");
- private static final String CLEAN = "CLEAN";
- private static final String DIRTY = "DIRTY";
- private static final String REMOVE = "REMOVE";
- private static final String READ = "READ";
-
- /*
- * This cache uses a journal file named "journal". A typical journal file
- * looks like this:
- * libcore.io.DiskLruCache
- * 1
- * 100
- * 2
- *
- * CLEAN 3400330d1dfc7f3f7f4b8d4d803dfcf6 832 21054
- * DIRTY 335c4c6028171cfddfbaae1a9c313c52
- * CLEAN 335c4c6028171cfddfbaae1a9c313c52 3934 2342
- * REMOVE 335c4c6028171cfddfbaae1a9c313c52
- * DIRTY 1ab96a171faeeee38496d8b330771a7a
- * CLEAN 1ab96a171faeeee38496d8b330771a7a 1600 234
- * READ 335c4c6028171cfddfbaae1a9c313c52
- * READ 3400330d1dfc7f3f7f4b8d4d803dfcf6
- *
- * The first five lines of the journal form its header. They are the
- * constant string "libcore.io.DiskLruCache", the disk cache's version,
- * the application's version, the value count, and a blank line.
- *
- * Each of the subsequent lines in the file is a record of the state of a
- * cache entry. Each line contains space-separated values: a state, a key,
- * and optional state-specific values.
- * o DIRTY lines track that an entry is actively being created or updated.
- * Every successful DIRTY action should be followed by a CLEAN or REMOVE
- * action. DIRTY lines without a matching CLEAN or REMOVE indicate that
- * temporary files may need to be deleted.
- * o CLEAN lines track a cache entry that has been successfully published
- * and may be read. A publish line is followed by the lengths of each of
- * its values.
- * o READ lines track accesses for LRU.
- * o REMOVE lines track entries that have been deleted.
- *
- * The journal file is appended to as cache operations occur. The journal may
- * occasionally be compacted by dropping redundant lines. A temporary file named
- * "journal.tmp" will be used during compaction; that file should be deleted if
- * it exists when the cache is opened.
- */
-
- private final File directory;
- private final File journalFile;
- private final File journalFileTmp;
- private final File journalFileBackup;
- private final int appVersion;
- private long maxSize;
- private int maxFileCount;
- private final int valueCount;
- private long size = 0;
- private int fileCount = 0;
- private Writer journalWriter;
- private final LinkedHashMap lruEntries =
- new LinkedHashMap(0, 0.75f, true);
- private int redundantOpCount;
-
- /**
- * To differentiate between old and current snapshots, each entry is given
- * a sequence number each time an edit is committed. A snapshot is stale if
- * its sequence number is not equal to its entry's sequence number.
- */
- private long nextSequenceNumber = 0;
-
- /** This cache uses a single background thread to evict entries. */
- final ThreadPoolExecutor executorService =
- new ThreadPoolExecutor(0, 1, 60L, TimeUnit.SECONDS, new LinkedBlockingQueue());
- private final Callable cleanupCallable = new Callable() {
- public Void call() throws Exception {
- synchronized (DiskLruCache.this) {
- if (journalWriter == null) {
- return null; // Closed.
- }
- trimToSize();
- trimToFileCount();
- if (journalRebuildRequired()) {
- rebuildJournal();
- redundantOpCount = 0;
- }
- }
- return null;
- }
- };
-
- private DiskLruCache(File directory, int appVersion, int valueCount, long maxSize, int maxFileCount) {
- this.directory = directory;
- this.appVersion = appVersion;
- this.journalFile = new File(directory, JOURNAL_FILE);
- this.journalFileTmp = new File(directory, JOURNAL_FILE_TEMP);
- this.journalFileBackup = new File(directory, JOURNAL_FILE_BACKUP);
- this.valueCount = valueCount;
- this.maxSize = maxSize;
- this.maxFileCount = maxFileCount;
- }
-
- /**
- * Opens the cache in {@code directory}, creating a cache if none exists
- * there.
- *
- * @param directory a writable directory
- * @param valueCount the number of values per cache entry. Must be positive.
- * @param maxSize the maximum number of bytes this cache should use to store
- * @param maxFileCount the maximum file count this cache should store
- * @throws IOException if reading or writing the cache directory fails
- */
- public static DiskLruCache open(File directory, int appVersion, int valueCount, long maxSize, int maxFileCount)
- throws IOException {
- if (maxSize <= 0) {
- throw new IllegalArgumentException("maxSize <= 0");
- }
- if (maxFileCount <= 0) {
- throw new IllegalArgumentException("maxFileCount <= 0");
- }
- if (valueCount <= 0) {
- throw new IllegalArgumentException("valueCount <= 0");
- }
-
- // If a bkp file exists, use it instead.
- File backupFile = new File(directory, JOURNAL_FILE_BACKUP);
- if (backupFile.exists()) {
- File journalFile = new File(directory, JOURNAL_FILE);
- // If journal file also exists just delete backup file.
- if (journalFile.exists()) {
- backupFile.delete();
- } else {
- renameTo(backupFile, journalFile, false);
- }
- }
-
- // Prefer to pick up where we left off.
- DiskLruCache cache = new DiskLruCache(directory, appVersion, valueCount, maxSize, maxFileCount);
- if (cache.journalFile.exists()) {
- try {
- cache.readJournal();
- cache.processJournal();
- cache.journalWriter = new BufferedWriter(
- new OutputStreamWriter(new FileOutputStream(cache.journalFile, true), Util.US_ASCII));
- return cache;
- } catch (IOException journalIsCorrupt) {
- System.out
- .println("DiskLruCache "
- + directory
- + " is corrupt: "
- + journalIsCorrupt.getMessage()
- + ", removing");
- cache.delete();
- }
- }
-
- // Create a new empty cache.
- directory.mkdirs();
- cache = new DiskLruCache(directory, appVersion, valueCount, maxSize, maxFileCount);
- cache.rebuildJournal();
- return cache;
- }
-
- private void readJournal() throws IOException {
- StrictLineReader reader = new StrictLineReader(new FileInputStream(journalFile), Util.US_ASCII);
- try {
- String magic = reader.readLine();
- String version = reader.readLine();
- String appVersionString = reader.readLine();
- String valueCountString = reader.readLine();
- String blank = reader.readLine();
- if (!MAGIC.equals(magic)
- || !VERSION_1.equals(version)
- || !Integer.toString(appVersion).equals(appVersionString)
- || !Integer.toString(valueCount).equals(valueCountString)
- || !"".equals(blank)) {
- throw new IOException("unexpected journal header: [" + magic + ", " + version + ", "
- + valueCountString + ", " + blank + "]");
- }
-
- int lineCount = 0;
- while (true) {
- try {
- readJournalLine(reader.readLine());
- lineCount++;
- } catch (EOFException endOfJournal) {
- break;
- }
- }
- redundantOpCount = lineCount - lruEntries.size();
- } finally {
- Util.closeQuietly(reader);
- }
- }
-
- private void readJournalLine(String line) throws IOException {
- int firstSpace = line.indexOf(' ');
- if (firstSpace == -1) {
- throw new IOException("unexpected journal line: " + line);
- }
-
- int keyBegin = firstSpace + 1;
- int secondSpace = line.indexOf(' ', keyBegin);
- final String key;
- if (secondSpace == -1) {
- key = line.substring(keyBegin);
- if (firstSpace == REMOVE.length() && line.startsWith(REMOVE)) {
- lruEntries.remove(key);
- return;
- }
- } else {
- key = line.substring(keyBegin, secondSpace);
- }
-
- Entry entry = lruEntries.get(key);
- if (entry == null) {
- entry = new Entry(key);
- lruEntries.put(key, entry);
- }
-
- if (secondSpace != -1 && firstSpace == CLEAN.length() && line.startsWith(CLEAN)) {
- String[] parts = line.substring(secondSpace + 1).split(" ");
- entry.readable = true;
- entry.currentEditor = null;
- entry.setLengths(parts);
- } else if (secondSpace == -1 && firstSpace == DIRTY.length() && line.startsWith(DIRTY)) {
- entry.currentEditor = new Editor(entry);
- } else if (secondSpace == -1 && firstSpace == READ.length() && line.startsWith(READ)) {
- // This work was already done by calling lruEntries.get().
- } else {
- throw new IOException("unexpected journal line: " + line);
- }
- }
-
- /**
- * Computes the initial size and collects garbage as a part of opening the
- * cache. Dirty entries are assumed to be inconsistent and will be deleted.
- */
- private void processJournal() throws IOException {
- deleteIfExists(journalFileTmp);
- for (Iterator i = lruEntries.values().iterator(); i.hasNext(); ) {
- Entry entry = i.next();
- if (entry.currentEditor == null) {
- for (int t = 0; t < valueCount; t++) {
- size += entry.lengths[t];
- fileCount++;
- }
- } else {
- entry.currentEditor = null;
- for (int t = 0; t < valueCount; t++) {
- deleteIfExists(entry.getCleanFile(t));
- deleteIfExists(entry.getDirtyFile(t));
- }
- i.remove();
- }
- }
- }
-
- /**
- * Creates a new journal that omits redundant information. This replaces the
- * current journal if it exists.
- */
- private synchronized void rebuildJournal() throws IOException {
- if (journalWriter != null) {
- journalWriter.close();
- }
-
- Writer writer = new BufferedWriter(
- new OutputStreamWriter(new FileOutputStream(journalFileTmp), Util.US_ASCII));
- try {
- writer.write(MAGIC);
- writer.write("\n");
- writer.write(VERSION_1);
- writer.write("\n");
- writer.write(Integer.toString(appVersion));
- writer.write("\n");
- writer.write(Integer.toString(valueCount));
- writer.write("\n");
- writer.write("\n");
-
- for (Entry entry : lruEntries.values()) {
- if (entry.currentEditor != null) {
- writer.write(DIRTY + ' ' + entry.key + '\n');
- } else {
- writer.write(CLEAN + ' ' + entry.key + entry.getLengths() + '\n');
- }
- }
- } finally {
- writer.close();
- }
-
- if (journalFile.exists()) {
- renameTo(journalFile, journalFileBackup, true);
- }
- renameTo(journalFileTmp, journalFile, false);
- journalFileBackup.delete();
-
- journalWriter = new BufferedWriter(
- new OutputStreamWriter(new FileOutputStream(journalFile, true), Util.US_ASCII));
- }
-
- private static void deleteIfExists(File file) throws IOException {
- if (file.exists() && !file.delete()) {
- throw new IOException();
- }
- }
-
- private static void renameTo(File from, File to, boolean deleteDestination) throws IOException {
- if (deleteDestination) {
- deleteIfExists(to);
- }
- if (!from.renameTo(to)) {
- throw new IOException();
- }
- }
-
- /**
- * Returns a snapshot of the entry named {@code key}, or null if it doesn't
- * exist is not currently readable. If a value is returned, it is moved to
- * the head of the LRU queue.
- */
- public synchronized Snapshot get(String key) throws IOException {
- checkNotClosed();
- validateKey(key);
- Entry entry = lruEntries.get(key);
- if (entry == null) {
- return null;
- }
-
- if (!entry.readable) {
- return null;
- }
-
- // Open all streams eagerly to guarantee that we see a single published
- // snapshot. If we opened streams lazily then the streams could come
- // from different edits.
- File[] files = new File[valueCount];
- InputStream[] ins = new InputStream[valueCount];
- try {
- File file;
- for (int i = 0; i < valueCount; i++) {
- file = entry.getCleanFile(i);
- files[i] = file;
- ins[i] = new FileInputStream(file);
- }
- } catch (FileNotFoundException e) {
- // A file must have been deleted manually!
- for (int i = 0; i < valueCount; i++) {
- if (ins[i] != null) {
- Util.closeQuietly(ins[i]);
- } else {
- break;
- }
- }
- return null;
- }
-
- redundantOpCount++;
- journalWriter.append(READ + ' ' + key + '\n');
- if (journalRebuildRequired()) {
- executorService.submit(cleanupCallable);
- }
-
- return new Snapshot(key, entry.sequenceNumber, files, ins, entry.lengths);
- }
-
- /**
- * Returns an editor for the entry named {@code key}, or null if another
- * edit is in progress.
- */
- public Editor edit(String key) throws IOException {
- return edit(key, ANY_SEQUENCE_NUMBER);
- }
-
- private synchronized Editor edit(String key, long expectedSequenceNumber) throws IOException {
- checkNotClosed();
- validateKey(key);
- Entry entry = lruEntries.get(key);
- if (expectedSequenceNumber != ANY_SEQUENCE_NUMBER && (entry == null
- || entry.sequenceNumber != expectedSequenceNumber)) {
- return null; // Snapshot is stale.
- }
- if (entry == null) {
- entry = new Entry(key);
- lruEntries.put(key, entry);
- } else if (entry.currentEditor != null) {
- return null; // Another edit is in progress.
- }
-
- Editor editor = new Editor(entry);
- entry.currentEditor = editor;
-
- // Flush the journal before creating files to prevent file leaks.
- journalWriter.write(DIRTY + ' ' + key + '\n');
- journalWriter.flush();
- return editor;
- }
-
- /** Returns the directory where this cache stores its data. */
- public File getDirectory() {
- return directory;
- }
-
- /**
- * Returns the maximum number of bytes that this cache should use to store
- * its data.
- */
- public synchronized long getMaxSize() {
- return maxSize;
- }
-
- /** Returns the maximum number of files that this cache should store */
- public synchronized int getMaxFileCount() {
- return maxFileCount;
- }
-
- /**
- * Changes the maximum number of bytes the cache can store and queues a job
- * to trim the existing store, if necessary.
- */
- public synchronized void setMaxSize(long maxSize) {
- this.maxSize = maxSize;
- executorService.submit(cleanupCallable);
- }
-
- /**
- * Returns the number of bytes currently being used to store the values in
- * this cache. This may be greater than the max size if a background
- * deletion is pending.
- */
- public synchronized long size() {
- return size;
- }
-
- /**
- * Returns the number of files currently being used to store the values in
- * this cache. This may be greater than the max file count if a background
- * deletion is pending.
- */
- public synchronized long fileCount() {
- return fileCount;
- }
-
- private synchronized void completeEdit(Editor editor, boolean success) throws IOException {
- Entry entry = editor.entry;
- if (entry.currentEditor != editor) {
- throw new IllegalStateException();
- }
-
- // If this edit is creating the entry for the first time, every index must have a value.
- if (success && !entry.readable) {
- for (int i = 0; i < valueCount; i++) {
- if (!editor.written[i]) {
- editor.abort();
- throw new IllegalStateException("Newly created entry didn't create value for index " + i);
- }
- if (!entry.getDirtyFile(i).exists()) {
- editor.abort();
- return;
- }
- }
- }
-
- for (int i = 0; i < valueCount; i++) {
- File dirty = entry.getDirtyFile(i);
- if (success) {
- if (dirty.exists()) {
- File clean = entry.getCleanFile(i);
- dirty.renameTo(clean);
- long oldLength = entry.lengths[i];
- long newLength = clean.length();
- entry.lengths[i] = newLength;
- size = size - oldLength + newLength;
- fileCount++;
- }
- } else {
- deleteIfExists(dirty);
- }
- }
-
- redundantOpCount++;
- entry.currentEditor = null;
- if (entry.readable | success) {
- entry.readable = true;
- journalWriter.write(CLEAN + ' ' + entry.key + entry.getLengths() + '\n');
- if (success) {
- entry.sequenceNumber = nextSequenceNumber++;
- }
- } else {
- lruEntries.remove(entry.key);
- journalWriter.write(REMOVE + ' ' + entry.key + '\n');
- }
- journalWriter.flush();
-
- if (size > maxSize || fileCount > maxFileCount || journalRebuildRequired()) {
- executorService.submit(cleanupCallable);
- }
- }
-
- /**
- * We only rebuild the journal when it will halve the size of the journal
- * and eliminate at least 2000 ops.
- */
- private boolean journalRebuildRequired() {
- final int redundantOpCompactThreshold = 2000;
- return redundantOpCount >= redundantOpCompactThreshold //
- && redundantOpCount >= lruEntries.size();
- }
-
- /**
- * Drops the entry for {@code key} if it exists and can be removed. Entries
- * actively being edited cannot be removed.
- *
- * @return true if an entry was removed.
- */
- public synchronized boolean remove(String key) throws IOException {
- checkNotClosed();
- validateKey(key);
- Entry entry = lruEntries.get(key);
- if (entry == null || entry.currentEditor != null) {
- return false;
- }
-
- for (int i = 0; i < valueCount; i++) {
- File file = entry.getCleanFile(i);
- if (file.exists() && !file.delete()) {
- throw new IOException("failed to delete " + file);
- }
- size -= entry.lengths[i];
- fileCount--;
- entry.lengths[i] = 0;
- }
-
- redundantOpCount++;
- journalWriter.append(REMOVE + ' ' + key + '\n');
- lruEntries.remove(key);
-
- if (journalRebuildRequired()) {
- executorService.submit(cleanupCallable);
- }
-
- return true;
- }
-
- /** Returns true if this cache has been closed. */
- public synchronized boolean isClosed() {
- return journalWriter == null;
- }
-
- private void checkNotClosed() {
- if (journalWriter == null) {
- throw new IllegalStateException("cache is closed");
- }
- }
-
- /** Force buffered operations to the filesystem. */
- public synchronized void flush() throws IOException {
- checkNotClosed();
- trimToSize();
- trimToFileCount();
- journalWriter.flush();
- }
-
- /** Closes this cache. Stored values will remain on the filesystem. */
- public synchronized void close() throws IOException {
- if (journalWriter == null) {
- return; // Already closed.
- }
- for (Entry entry : new ArrayList(lruEntries.values())) {
- if (entry.currentEditor != null) {
- entry.currentEditor.abort();
- }
- }
- trimToSize();
- trimToFileCount();
- journalWriter.close();
- journalWriter = null;
- }
-
- private void trimToSize() throws IOException {
- while (size > maxSize) {
- Map.Entry toEvict = lruEntries.entrySet().iterator().next();
- remove(toEvict.getKey());
- }
- }
-
- private void trimToFileCount() throws IOException {
- while (fileCount > maxFileCount) {
- Map.Entry toEvict = lruEntries.entrySet().iterator().next();
- remove(toEvict.getKey());
- }
- }
-
- /**
- * Closes the cache and deletes all of its stored values. This will delete
- * all files in the cache directory including files that weren't created by
- * the cache.
- */
- public void delete() throws IOException {
- close();
- Util.deleteContents(directory);
- }
-
- private void validateKey(String key) {
- Matcher matcher = LEGAL_KEY_PATTERN.matcher(key);
- if (!matcher.matches()) {
- throw new IllegalArgumentException("keys must match regex [a-z0-9_-]{1,64}: \"" + key + "\"");
- }
- }
-
- private static String inputStreamToString(InputStream in) throws IOException {
- return Util.readFully(new InputStreamReader(in, Util.UTF_8));
- }
-
- /** A snapshot of the values for an entry. */
- public final class Snapshot implements Closeable {
- private final String key;
- private final long sequenceNumber;
- private File[] files;
- private final InputStream[] ins;
- private final long[] lengths;
-
- private Snapshot(String key, long sequenceNumber, File[] files, InputStream[] ins, long[] lengths) {
- this.key = key;
- this.sequenceNumber = sequenceNumber;
- this.files = files;
- this.ins = ins;
- this.lengths = lengths;
- }
-
- /**
- * Returns an editor for this snapshot's entry, or null if either the
- * entry has changed since this snapshot was created or if another edit
- * is in progress.
- */
- public Editor edit() throws IOException {
- return DiskLruCache.this.edit(key, sequenceNumber);
- }
-
- /** Returns file with the value for {@code index}. */
- public File getFile(int index) {
- return files[index];
- }
-
- /** Returns the unbuffered stream with the value for {@code index}. */
- public InputStream getInputStream(int index) {
- return ins[index];
- }
-
- /** Returns the string value for {@code index}. */
- public String getString(int index) throws IOException {
- return inputStreamToString(getInputStream(index));
- }
-
- /** Returns the byte length of the value for {@code index}. */
- public long getLength(int index) {
- return lengths[index];
- }
-
- public void close() {
- for (InputStream in : ins) {
- Util.closeQuietly(in);
- }
- }
- }
-
- private static final OutputStream NULL_OUTPUT_STREAM = new OutputStream() {
- @Override
- public void write(int b) throws IOException {
- // Eat all writes silently. Nom nom.
- }
- };
-
- /** Edits the values for an entry. */
- public final class Editor {
- private final Entry entry;
- private final boolean[] written;
- private boolean hasErrors;
- private boolean committed;
-
- private Editor(Entry entry) {
- this.entry = entry;
- this.written = (entry.readable) ? null : new boolean[valueCount];
- }
-
- /**
- * Returns an unbuffered input stream to read the last committed value,
- * or null if no value has been committed.
- */
- public InputStream newInputStream(int index) throws IOException {
- synchronized (DiskLruCache.this) {
- if (entry.currentEditor != this) {
- throw new IllegalStateException();
- }
- if (!entry.readable) {
- return null;
- }
- try {
- return new FileInputStream(entry.getCleanFile(index));
- } catch (FileNotFoundException e) {
- return null;
- }
- }
- }
-
- /**
- * Returns the last committed value as a string, or null if no value
- * has been committed.
- */
- public String getString(int index) throws IOException {
- InputStream in = newInputStream(index);
- return in != null ? inputStreamToString(in) : null;
- }
-
- /**
- * Returns a new unbuffered output stream to write the value at
- * {@code index}. If the underlying output stream encounters errors
- * when writing to the filesystem, this edit will be aborted when
- * {@link #commit} is called. The returned output stream does not throw
- * IOExceptions.
- */
- public OutputStream newOutputStream(int index) throws IOException {
- synchronized (DiskLruCache.this) {
- if (entry.currentEditor != this) {
- throw new IllegalStateException();
- }
- if (!entry.readable) {
- written[index] = true;
- }
- File dirtyFile = entry.getDirtyFile(index);
- FileOutputStream outputStream;
- try {
- outputStream = new FileOutputStream(dirtyFile);
- } catch (FileNotFoundException e) {
- // Attempt to recreate the cache directory.
- directory.mkdirs();
- try {
- outputStream = new FileOutputStream(dirtyFile);
- } catch (FileNotFoundException e2) {
- // We are unable to recover. Silently eat the writes.
- return NULL_OUTPUT_STREAM;
- }
- }
- return new FaultHidingOutputStream(outputStream);
- }
- }
-
- /** Sets the value at {@code index} to {@code value}. */
- public void set(int index, String value) throws IOException {
- Writer writer = null;
- try {
- writer = new OutputStreamWriter(newOutputStream(index), Util.UTF_8);
- writer.write(value);
- } finally {
- Util.closeQuietly(writer);
- }
- }
-
- /**
- * Commits this edit so it is visible to readers. This releases the
- * edit lock so another edit may be started on the same key.
- */
- public void commit() throws IOException {
- if (hasErrors) {
- completeEdit(this, false);
- remove(entry.key); // The previous entry is stale.
- } else {
- completeEdit(this, true);
- }
- committed = true;
- }
-
- /**
- * Aborts this edit. This releases the edit lock so another edit may be
- * started on the same key.
- */
- public void abort() throws IOException {
- completeEdit(this, false);
- }
-
- public void abortUnlessCommitted() {
- if (!committed) {
- try {
- abort();
- } catch (IOException ignored) {
- }
- }
- }
-
- private class FaultHidingOutputStream extends FilterOutputStream {
- private FaultHidingOutputStream(OutputStream out) {
- super(out);
- }
-
- @Override public void write(int oneByte) {
- try {
- out.write(oneByte);
- } catch (IOException e) {
- hasErrors = true;
- }
- }
-
- @Override public void write(byte[] buffer, int offset, int length) {
- try {
- out.write(buffer, offset, length);
- } catch (IOException e) {
- hasErrors = true;
- }
- }
-
- @Override public void close() {
- try {
- out.close();
- } catch (IOException e) {
- hasErrors = true;
- }
- }
-
- @Override public void flush() {
- try {
- out.flush();
- } catch (IOException e) {
- hasErrors = true;
- }
- }
- }
- }
-
- private final class Entry {
- private final String key;
-
- /** Lengths of this entry's files. */
- private final long[] lengths;
-
- /** True if this entry has ever been published. */
- private boolean readable;
-
- /** The ongoing edit or null if this entry is not being edited. */
- private Editor currentEditor;
-
- /** The sequence number of the most recently committed edit to this entry. */
- private long sequenceNumber;
-
- private Entry(String key) {
- this.key = key;
- this.lengths = new long[valueCount];
- }
-
- public String getLengths() throws IOException {
- StringBuilder result = new StringBuilder();
- for (long size : lengths) {
- result.append(' ').append(size);
- }
- return result.toString();
- }
-
- /** Set lengths using decimal numbers like "10123". */
- private void setLengths(String[] strings) throws IOException {
- if (strings.length != valueCount) {
- throw invalidLengths(strings);
- }
-
- try {
- for (int i = 0; i < strings.length; i++) {
- lengths[i] = Long.parseLong(strings[i]);
- }
- } catch (NumberFormatException e) {
- throw invalidLengths(strings);
- }
- }
-
- private IOException invalidLengths(String[] strings) throws IOException {
- throw new IOException("unexpected journal line: " + java.util.Arrays.toString(strings));
- }
-
- public File getCleanFile(int i) {
- return new File(directory, key + "." + i);
- }
-
- public File getDirtyFile(int i) {
- return new File(directory, key + "." + i + ".tmp");
- }
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/impl/ext/LruDiskCache.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/impl/ext/LruDiskCache.java
deleted file mode 100644
index aa0d91ec0..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/impl/ext/LruDiskCache.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*******************************************************************************
- * Copyright 2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.cache.disc.impl.ext;
-
-import android.graphics.Bitmap;
-import com.nostra13.universalimageloader.cache.disc.DiskCache;
-import com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator;
-import com.nostra13.universalimageloader.utils.IoUtils;
-import com.nostra13.universalimageloader.utils.L;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * Disk cache based on "Least-Recently Used" principle. Adapter pattern, adapts
- * {@link com.nostra13.universalimageloader.cache.disc.impl.ext.DiskLruCache DiskLruCache} to
- * {@link com.nostra13.universalimageloader.cache.disc.DiskCache DiskCache}
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @see FileNameGenerator
- * @since 1.9.2
- */
-public class LruDiskCache implements DiskCache {
- /** {@value */
- public static final int DEFAULT_BUFFER_SIZE = 32 * 1024; // 32 Kb
- /** {@value */
- public static final Bitmap.CompressFormat DEFAULT_COMPRESS_FORMAT = Bitmap.CompressFormat.PNG;
- /** {@value */
- public static final int DEFAULT_COMPRESS_QUALITY = 100;
-
- private static final String ERROR_ARG_NULL = " argument must be not null";
- private static final String ERROR_ARG_NEGATIVE = " argument must be positive number";
-
- protected DiskLruCache cache;
- private File reserveCacheDir;
-
- protected final FileNameGenerator fileNameGenerator;
-
- protected int bufferSize = DEFAULT_BUFFER_SIZE;
-
- protected Bitmap.CompressFormat compressFormat = DEFAULT_COMPRESS_FORMAT;
- protected int compressQuality = DEFAULT_COMPRESS_QUALITY;
-
- /**
- * @param cacheDir Directory for file caching
- * @param fileNameGenerator {@linkplain com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator
- * Name generator} for cached files. Generated names must match the regex
- * [a-z0-9_-]{1,64}
- * @param cacheMaxSize Max cache size in bytes. 0 means cache size is unlimited.
- * @throws IOException if cache can't be initialized (e.g. "No space left on device")
- */
- public LruDiskCache(File cacheDir, FileNameGenerator fileNameGenerator, long cacheMaxSize) throws IOException {
- this(cacheDir, null, fileNameGenerator, cacheMaxSize, 0);
- }
-
- /**
- * @param cacheDir Directory for file caching
- * @param reserveCacheDir null-ok; Reserve directory for file caching. It's used when the primary directory isn't available.
- * @param fileNameGenerator {@linkplain com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator
- * Name generator} for cached files. Generated names must match the regex
- * [a-z0-9_-]{1,64}
- * @param cacheMaxSize Max cache size in bytes. 0 means cache size is unlimited.
- * @param cacheMaxFileCount Max file count in cache. 0 means file count is unlimited.
- * @throws IOException if cache can't be initialized (e.g. "No space left on device")
- */
- public LruDiskCache(File cacheDir, File reserveCacheDir, FileNameGenerator fileNameGenerator, long cacheMaxSize,
- int cacheMaxFileCount) throws IOException {
- if (cacheDir == null) {
- throw new IllegalArgumentException("cacheDir" + ERROR_ARG_NULL);
- }
- if (cacheMaxSize < 0) {
- throw new IllegalArgumentException("cacheMaxSize" + ERROR_ARG_NEGATIVE);
- }
- if (cacheMaxFileCount < 0) {
- throw new IllegalArgumentException("cacheMaxFileCount" + ERROR_ARG_NEGATIVE);
- }
- if (fileNameGenerator == null) {
- throw new IllegalArgumentException("fileNameGenerator" + ERROR_ARG_NULL);
- }
-
- if (cacheMaxSize == 0) {
- cacheMaxSize = Long.MAX_VALUE;
- }
- if (cacheMaxFileCount == 0) {
- cacheMaxFileCount = Integer.MAX_VALUE;
- }
-
- this.reserveCacheDir = reserveCacheDir;
- this.fileNameGenerator = fileNameGenerator;
- initCache(cacheDir, reserveCacheDir, cacheMaxSize, cacheMaxFileCount);
- }
-
- private void initCache(File cacheDir, File reserveCacheDir, long cacheMaxSize, int cacheMaxFileCount)
- throws IOException {
- try {
- cache = DiskLruCache.open(cacheDir, 1, 1, cacheMaxSize, cacheMaxFileCount);
- } catch (IOException e) {
- L.e(e);
- if (reserveCacheDir != null) {
- initCache(reserveCacheDir, null, cacheMaxSize, cacheMaxFileCount);
- }
- if (cache == null) {
- throw e; //new RuntimeException("Can't initialize disk cache", e);
- }
- }
- }
-
- @Override
- public File getDirectory() {
- return cache.getDirectory();
- }
-
- @Override
- public File get(String imageUri) {
- DiskLruCache.Snapshot snapshot = null;
- try {
- snapshot = cache.get(getKey(imageUri));
- return snapshot == null ? null : snapshot.getFile(0);
- } catch (IOException e) {
- L.e(e);
- return null;
- } finally {
- if (snapshot != null) {
- snapshot.close();
- }
- }
- }
-
- @Override
- public boolean save(String imageUri, InputStream imageStream, IoUtils.CopyListener listener) throws IOException {
- DiskLruCache.Editor editor = cache.edit(getKey(imageUri));
- if (editor == null) {
- return false;
- }
-
- OutputStream os = new BufferedOutputStream(editor.newOutputStream(0), bufferSize);
- boolean copied = false;
- try {
- copied = IoUtils.copyStream(imageStream, os, listener, bufferSize);
- } finally {
- IoUtils.closeSilently(os);
- if (copied) {
- editor.commit();
- } else {
- editor.abort();
- }
- }
- return copied;
- }
-
- @Override
- public boolean save(String imageUri, Bitmap bitmap) throws IOException {
- DiskLruCache.Editor editor = cache.edit(getKey(imageUri));
- if (editor == null) {
- return false;
- }
-
- OutputStream os = new BufferedOutputStream(editor.newOutputStream(0), bufferSize);
- boolean savedSuccessfully = false;
- try {
- savedSuccessfully = bitmap.compress(compressFormat, compressQuality, os);
- } finally {
- IoUtils.closeSilently(os);
- }
- if (savedSuccessfully) {
- editor.commit();
- } else {
- editor.abort();
- }
- return savedSuccessfully;
- }
-
- @Override
- public boolean remove(String imageUri) {
- try {
- return cache.remove(getKey(imageUri));
- } catch (IOException e) {
- L.e(e);
- return false;
- }
- }
-
- @Override
- public void close() {
- try {
- cache.close();
- } catch (IOException e) {
- L.e(e);
- }
- cache = null;
- }
-
- @Override
- public void clear() {
- try {
- cache.delete();
- } catch (IOException e) {
- L.e(e);
- }
- try {
- initCache(cache.getDirectory(), reserveCacheDir, cache.getMaxSize(), cache.getMaxFileCount());
- } catch (IOException e) {
- L.e(e);
- }
- }
-
- private String getKey(String imageUri) {
- return fileNameGenerator.generate(imageUri);
- }
-
- public void setBufferSize(int bufferSize) {
- this.bufferSize = bufferSize;
- }
-
- public void setCompressFormat(Bitmap.CompressFormat compressFormat) {
- this.compressFormat = compressFormat;
- }
-
- public void setCompressQuality(int compressQuality) {
- this.compressQuality = compressQuality;
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/impl/ext/StrictLineReader.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/impl/ext/StrictLineReader.java
deleted file mode 100644
index 0f3e0f56e..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/impl/ext/StrictLineReader.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed 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 com.nostra13.universalimageloader.cache.disc.impl.ext;
-
-import java.io.ByteArrayOutputStream;
-import java.io.Closeable;
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
-
-/**
- * Buffers input from an {@link InputStream} for reading lines.
- *
- * This class is used for buffered reading of lines. For purposes of this class, a line ends
- * with "\n" or "\r\n". End of input is reported by throwing {@code EOFException}. Unterminated
- * line at end of input is invalid and will be ignored, the caller may use {@code
- * hasUnterminatedLine()} to detect it after catching the {@code EOFException}.
- *
- *
This class is intended for reading input that strictly consists of lines, such as line-based
- * cache entries or cache journal. Unlike the {@link java.io.BufferedReader} which in conjunction
- * with {@link java.io.InputStreamReader} provides similar functionality, this class uses different
- * end-of-input reporting and a more restrictive definition of a line.
- *
- *
This class supports only charsets that encode '\r' and '\n' as a single byte with value 13
- * and 10, respectively, and the representation of no other character contains these values.
- * We currently check in constructor that the charset is one of US-ASCII, UTF-8 and ISO-8859-1.
- * The default charset is US_ASCII.
- */
-class StrictLineReader implements Closeable {
- private static final byte CR = (byte) '\r';
- private static final byte LF = (byte) '\n';
-
- private final InputStream in;
- private final Charset charset;
-
- /*
- * Buffered data is stored in {@code buf}. As long as no exception occurs, 0 <= pos <= end
- * and the data in the range [pos, end) is buffered for reading. At end of input, if there is
- * an unterminated line, we set end == -1, otherwise end == pos. If the underlying
- * {@code InputStream} throws an {@code IOException}, end may remain as either pos or -1.
- */
- private byte[] buf;
- private int pos;
- private int end;
-
- /**
- * Constructs a new {@code LineReader} with the specified charset and the default capacity.
- *
- * @param in the {@code InputStream} to read data from.
- * @param charset the charset used to decode data. Only US-ASCII, UTF-8 and ISO-8859-1 are
- * supported.
- * @throws NullPointerException if {@code in} or {@code charset} is null.
- * @throws IllegalArgumentException if the specified charset is not supported.
- */
- public StrictLineReader(InputStream in, Charset charset) {
- this(in, 8192, charset);
- }
-
- /**
- * Constructs a new {@code LineReader} with the specified capacity and charset.
- *
- * @param in the {@code InputStream} to read data from.
- * @param capacity the capacity of the buffer.
- * @param charset the charset used to decode data. Only US-ASCII, UTF-8 and ISO-8859-1 are
- * supported.
- * @throws NullPointerException if {@code in} or {@code charset} is null.
- * @throws IllegalArgumentException if {@code capacity} is negative or zero
- * or the specified charset is not supported.
- */
- public StrictLineReader(InputStream in, int capacity, Charset charset) {
- if (in == null || charset == null) {
- throw new NullPointerException();
- }
- if (capacity < 0) {
- throw new IllegalArgumentException("capacity <= 0");
- }
- if (!(charset.equals(Util.US_ASCII))) {
- throw new IllegalArgumentException("Unsupported encoding");
- }
-
- this.in = in;
- this.charset = charset;
- buf = new byte[capacity];
- }
-
- /**
- * Closes the reader by closing the underlying {@code InputStream} and
- * marking this reader as closed.
- *
- * @throws IOException for errors when closing the underlying {@code InputStream}.
- */
- public void close() throws IOException {
- synchronized (in) {
- if (buf != null) {
- buf = null;
- in.close();
- }
- }
- }
-
- /**
- * Reads the next line. A line ends with {@code "\n"} or {@code "\r\n"},
- * this end of line marker is not included in the result.
- *
- * @return the next line from the input.
- * @throws IOException for underlying {@code InputStream} errors.
- * @throws EOFException for the end of source stream.
- */
- public String readLine() throws IOException {
- synchronized (in) {
- if (buf == null) {
- throw new IOException("LineReader is closed");
- }
-
- // Read more data if we are at the end of the buffered data.
- // Though it's an error to read after an exception, we will let {@code fillBuf()}
- // throw again if that happens; thus we need to handle end == -1 as well as end == pos.
- if (pos >= end) {
- fillBuf();
- }
- // Try to find LF in the buffered data and return the line if successful.
- for (int i = pos; i != end; ++i) {
- if (buf[i] == LF) {
- int lineEnd = (i != pos && buf[i - 1] == CR) ? i - 1 : i;
- String res = new String(buf, pos, lineEnd - pos, charset.name());
- pos = i + 1;
- return res;
- }
- }
-
- // Let's anticipate up to 80 characters on top of those already read.
- ByteArrayOutputStream out = new ByteArrayOutputStream(end - pos + 80) {
- @Override
- public String toString() {
- int length = (count > 0 && buf[count - 1] == CR) ? count - 1 : count;
- try {
- return new String(buf, 0, length, charset.name());
- } catch (UnsupportedEncodingException e) {
- throw new AssertionError(e); // Since we control the charset this will never happen.
- }
- }
- };
-
- while (true) {
- out.write(buf, pos, end - pos);
- // Mark unterminated line in case fillBuf throws EOFException or IOException.
- end = -1;
- fillBuf();
- // Try to find LF in the buffered data and return the line if successful.
- for (int i = pos; i != end; ++i) {
- if (buf[i] == LF) {
- if (i != pos) {
- out.write(buf, pos, i - pos);
- }
- pos = i + 1;
- return out.toString();
- }
- }
- }
- }
- }
-
- /**
- * Reads new input data into the buffer. Call only with pos == end or end == -1,
- * depending on the desired outcome if the function throws.
- */
- private void fillBuf() throws IOException {
- int result = in.read(buf, 0, buf.length);
- if (result == -1) {
- throw new EOFException();
- }
- pos = 0;
- end = result;
- }
-}
-
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/impl/ext/Util.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/impl/ext/Util.java
deleted file mode 100644
index fd7a4ba17..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/impl/ext/Util.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed 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 com.nostra13.universalimageloader.cache.disc.impl.ext;
-
-import java.io.Closeable;
-import java.io.File;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringWriter;
-import java.nio.charset.Charset;
-
-/** Junk drawer of utility methods. */
-final class Util {
- static final Charset US_ASCII = Charset.forName("US-ASCII");
- static final Charset UTF_8 = Charset.forName("UTF-8");
-
- private Util() {
- }
-
- static String readFully(Reader reader) throws IOException {
- try {
- StringWriter writer = new StringWriter();
- char[] buffer = new char[1024];
- int count;
- while ((count = reader.read(buffer)) != -1) {
- writer.write(buffer, 0, count);
- }
- return writer.toString();
- } finally {
- reader.close();
- }
- }
-
- /**
- * Deletes the contents of {@code dir}. Throws an IOException if any file
- * could not be deleted, or if {@code dir} is not a readable directory.
- */
- static void deleteContents(File dir) throws IOException {
- File[] files = dir.listFiles();
- if (files == null) {
- throw new IOException("not a readable directory: " + dir);
- }
- for (File file : files) {
- if (file.isDirectory()) {
- deleteContents(file);
- }
- if (!file.delete()) {
- throw new IOException("failed to delete file: " + file);
- }
- }
- }
-
- static void closeQuietly(/*Auto*/Closeable closeable) {
- if (closeable != null) {
- try {
- closeable.close();
- } catch (RuntimeException rethrown) {
- throw rethrown;
- } catch (Exception ignored) {
- }
- }
- }
-}
\ No newline at end of file
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/naming/FileNameGenerator.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/naming/FileNameGenerator.java
deleted file mode 100644
index 20e1d664b..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/naming/FileNameGenerator.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2013 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.cache.disc.naming;
-
-/**
- * Generates names for files at disk cache
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.3.1
- */
-public interface FileNameGenerator {
-
- /** Generates unique file name for image defined by URI */
- String generate(String imageUri);
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/naming/HashCodeFileNameGenerator.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/naming/HashCodeFileNameGenerator.java
deleted file mode 100644
index a284b53b0..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/naming/HashCodeFileNameGenerator.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2013 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.cache.disc.naming;
-
-/**
- * Names image file as image URI {@linkplain String#hashCode() hashcode}
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.3.1
- */
-public class HashCodeFileNameGenerator implements FileNameGenerator {
- @Override
- public String generate(String imageUri) {
- return String.valueOf(imageUri.hashCode());
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/naming/Md5FileNameGenerator.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/naming/Md5FileNameGenerator.java
deleted file mode 100644
index 9d50bc6cd..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/disc/naming/Md5FileNameGenerator.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2013 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.cache.disc.naming;
-
-import com.nostra13.universalimageloader.utils.L;
-
-import java.math.BigInteger;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-/**
- * Names image file as MD5 hash of image URI
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.4.0
- */
-public class Md5FileNameGenerator implements FileNameGenerator {
-
- private static final String HASH_ALGORITHM = "MD5";
- private static final int RADIX = 10 + 26; // 10 digits + 26 letters
-
- @Override
- public String generate(String imageUri) {
- byte[] md5 = getMD5(imageUri.getBytes());
- BigInteger bi = new BigInteger(md5).abs();
- return bi.toString(RADIX);
- }
-
- private byte[] getMD5(byte[] data) {
- byte[] hash = null;
- try {
- MessageDigest digest = MessageDigest.getInstance(HASH_ALGORITHM);
- digest.update(data);
- hash = digest.digest();
- } catch (NoSuchAlgorithmException e) {
- L.e(e);
- }
- return hash;
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/BaseMemoryCache.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/BaseMemoryCache.java
deleted file mode 100644
index 4043719b5..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/BaseMemoryCache.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.cache.memory;
-
-import android.graphics.Bitmap;
-
-import java.lang.ref.Reference;
-import java.util.*;
-
-/**
- * Base memory cache. Implements common functionality for memory cache. Provides object references (
- * {@linkplain Reference not strong}) storing.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.0.0
- */
-public abstract class BaseMemoryCache implements MemoryCache {
-
- /** Stores not strong references to objects */
- private final Map> softMap = Collections.synchronizedMap(new HashMap>());
-
- @Override
- public Bitmap get(String key) {
- Bitmap result = null;
- Reference reference = softMap.get(key);
- if (reference != null) {
- result = reference.get();
- }
- return result;
- }
-
- @Override
- public boolean put(String key, Bitmap value) {
- softMap.put(key, createReference(value));
- return true;
- }
-
- @Override
- public Bitmap remove(String key) {
- Reference bmpRef = softMap.remove(key);
- return bmpRef == null ? null : bmpRef.get();
- }
-
- @Override
- public Collection keys() {
- synchronized (softMap) {
- return new HashSet(softMap.keySet());
- }
- }
-
- @Override
- public void clear() {
- softMap.clear();
- }
-
- /** Creates {@linkplain Reference not strong} reference of value */
- protected abstract Reference createReference(Bitmap value);
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/LimitedMemoryCache.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/LimitedMemoryCache.java
deleted file mode 100644
index d1782aaa6..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/LimitedMemoryCache.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.cache.memory;
-
-import android.graphics.Bitmap;
-
-import com.nostra13.universalimageloader.utils.L;
-
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Limited cache. Provides object storing. Size of all stored bitmaps will not to exceed size limit (
- * {@link #getSizeLimit()}).
- *
- * NOTE: This cache uses strong and weak references for stored Bitmaps. Strong references - for limited count of
- * Bitmaps (depends on cache size), weak references - for all other cached Bitmaps.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @see BaseMemoryCache
- * @since 1.0.0
- */
-public abstract class LimitedMemoryCache extends BaseMemoryCache {
-
- private static final int MAX_NORMAL_CACHE_SIZE_IN_MB = 16;
- private static final int MAX_NORMAL_CACHE_SIZE = MAX_NORMAL_CACHE_SIZE_IN_MB * 1024 * 1024;
-
- private final int sizeLimit;
-
- private final AtomicInteger cacheSize;
-
- /**
- * Contains strong references to stored objects. Each next object is added last. If hard cache size will exceed
- * limit then first object is deleted (but it continue exist at {@link #softMap} and can be collected by GC at any
- * time)
- */
- private final List hardCache = Collections.synchronizedList(new LinkedList());
-
- /** @param sizeLimit Maximum size for cache (in bytes) */
- public LimitedMemoryCache(int sizeLimit) {
- this.sizeLimit = sizeLimit;
- cacheSize = new AtomicInteger();
- if (sizeLimit > MAX_NORMAL_CACHE_SIZE) {
- L.w("You set too large memory cache size (more than %1$d Mb)", MAX_NORMAL_CACHE_SIZE_IN_MB);
- }
- }
-
- @Override
- public boolean put(String key, Bitmap value) {
- boolean putSuccessfully = false;
- // Try to add value to hard cache
- int valueSize = getSize(value);
- int sizeLimit = getSizeLimit();
- int curCacheSize = cacheSize.get();
- if (valueSize < sizeLimit) {
- while (curCacheSize + valueSize > sizeLimit) {
- Bitmap removedValue = removeNext();
- if (hardCache.remove(removedValue)) {
- curCacheSize = cacheSize.addAndGet(-getSize(removedValue));
- }
- }
- hardCache.add(value);
- cacheSize.addAndGet(valueSize);
-
- putSuccessfully = true;
- }
- // Add value to soft cache
- super.put(key, value);
- return putSuccessfully;
- }
-
- @Override
- public Bitmap remove(String key) {
- Bitmap value = super.get(key);
- if (value != null) {
- if (hardCache.remove(value)) {
- cacheSize.addAndGet(-getSize(value));
- }
- }
- return super.remove(key);
- }
-
- @Override
- public void clear() {
- hardCache.clear();
- cacheSize.set(0);
- super.clear();
- }
-
- protected int getSizeLimit() {
- return sizeLimit;
- }
-
- protected abstract int getSize(Bitmap value);
-
- protected abstract Bitmap removeNext();
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/MemoryCache.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/MemoryCache.java
deleted file mode 100644
index 6a6dd582e..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/MemoryCache.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright 2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.cache.memory;
-
-import android.graphics.Bitmap;
-
-import java.util.Collection;
-
-/**
- * Interface for memory cache
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.9.2
- */
-public interface MemoryCache {
- /**
- * Puts value into cache by key
- *
- * @return true - if value was put into cache successfully, false - if value was not put into
- * cache
- */
- boolean put(String key, Bitmap value);
-
- /** Returns value by key. If there is no value for key then null will be returned. */
- Bitmap get(String key);
-
- /** Removes item by key */
- Bitmap remove(String key);
-
- /** Returns all keys of cache */
- Collection keys();
-
- /** Remove all items from cache */
- void clear();
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/FIFOLimitedMemoryCache.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/FIFOLimitedMemoryCache.java
deleted file mode 100644
index e56b1a394..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/FIFOLimitedMemoryCache.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.cache.memory.impl;
-
-import android.graphics.Bitmap;
-import com.nostra13.universalimageloader.cache.memory.LimitedMemoryCache;
-
-import java.lang.ref.Reference;
-import java.lang.ref.WeakReference;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * Limited {@link Bitmap bitmap} cache. Provides {@link Bitmap bitmaps} storing. Size of all stored bitmaps will not to
- * exceed size limit. When cache reaches limit size then cache clearing is processed by FIFO principle.
- *
- * NOTE: This cache uses strong and weak references for stored Bitmaps. Strong references - for limited count of
- * Bitmaps (depends on cache size), weak references - for all other cached Bitmaps.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.0.0
- */
-public class FIFOLimitedMemoryCache extends LimitedMemoryCache {
-
- private final List queue = Collections.synchronizedList(new LinkedList());
-
- public FIFOLimitedMemoryCache(int sizeLimit) {
- super(sizeLimit);
- }
-
- @Override
- public boolean put(String key, Bitmap value) {
- if (super.put(key, value)) {
- queue.add(value);
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public Bitmap remove(String key) {
- Bitmap value = super.get(key);
- if (value != null) {
- queue.remove(value);
- }
- return super.remove(key);
- }
-
- @Override
- public void clear() {
- queue.clear();
- super.clear();
- }
-
- @Override
- protected int getSize(Bitmap value) {
- return value.getRowBytes() * value.getHeight();
- }
-
- @Override
- protected Bitmap removeNext() {
- return queue.remove(0);
- }
-
- @Override
- protected Reference createReference(Bitmap value) {
- return new WeakReference(value);
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/FuzzyKeyMemoryCache.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/FuzzyKeyMemoryCache.java
deleted file mode 100644
index 982c8128a..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/FuzzyKeyMemoryCache.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.cache.memory.impl;
-
-import android.graphics.Bitmap;
-
-import com.nostra13.universalimageloader.cache.memory.MemoryCache;
-
-import java.util.Collection;
-import java.util.Comparator;
-
-/**
- * Decorator for {@link MemoryCache}. Provides special feature for cache: some different keys are considered as
- * equals (using {@link Comparator comparator}). And when you try to put some value into cache by key so entries with
- * "equals" keys will be removed from cache before.
- * NOTE: Used for internal needs. Normally you don't need to use this class.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.0.0
- */
-public class FuzzyKeyMemoryCache implements MemoryCache {
-
- private final MemoryCache cache;
- private final Comparator keyComparator;
-
- public FuzzyKeyMemoryCache(MemoryCache cache, Comparator keyComparator) {
- this.cache = cache;
- this.keyComparator = keyComparator;
- }
-
- @Override
- public boolean put(String key, Bitmap value) {
- // Search equal key and remove this entry
- synchronized (cache) {
- String keyToRemove = null;
- for (String cacheKey : cache.keys()) {
- if (keyComparator.compare(key, cacheKey) == 0) {
- keyToRemove = cacheKey;
- break;
- }
- }
- if (keyToRemove != null) {
- cache.remove(keyToRemove);
- }
- }
- return cache.put(key, value);
- }
-
- @Override
- public Bitmap get(String key) {
- return cache.get(key);
- }
-
- @Override
- public Bitmap remove(String key) {
- return cache.remove(key);
- }
-
- @Override
- public void clear() {
- cache.clear();
- }
-
- @Override
- public Collection keys() {
- return cache.keys();
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/LRULimitedMemoryCache.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/LRULimitedMemoryCache.java
deleted file mode 100644
index 2d25cde2f..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/LRULimitedMemoryCache.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.cache.memory.impl;
-
-import android.graphics.Bitmap;
-import com.nostra13.universalimageloader.cache.memory.LimitedMemoryCache;
-
-import java.lang.ref.Reference;
-import java.lang.ref.WeakReference;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-
-/**
- * Limited {@link Bitmap bitmap} cache. Provides {@link Bitmap bitmaps} storing. Size of all stored bitmaps will not to
- * exceed size limit. When cache reaches limit size then the least recently used bitmap is deleted from cache.
- *
- * NOTE: This cache uses strong and weak references for stored Bitmaps. Strong references - for limited count of
- * Bitmaps (depends on cache size), weak references - for all other cached Bitmaps.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.3.0
- */
-public class LRULimitedMemoryCache extends LimitedMemoryCache {
-
- private static final int INITIAL_CAPACITY = 10;
- private static final float LOAD_FACTOR = 1.1f;
-
- /** Cache providing Least-Recently-Used logic */
- private final Map lruCache = Collections.synchronizedMap(new LinkedHashMap(INITIAL_CAPACITY, LOAD_FACTOR, true));
-
- /** @param maxSize Maximum sum of the sizes of the Bitmaps in this cache */
- public LRULimitedMemoryCache(int maxSize) {
- super(maxSize);
- }
-
- @Override
- public boolean put(String key, Bitmap value) {
- if (super.put(key, value)) {
- lruCache.put(key, value);
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public Bitmap get(String key) {
- lruCache.get(key); // call "get" for LRU logic
- return super.get(key);
- }
-
- @Override
- public Bitmap remove(String key) {
- lruCache.remove(key);
- return super.remove(key);
- }
-
- @Override
- public void clear() {
- lruCache.clear();
- super.clear();
- }
-
- @Override
- protected int getSize(Bitmap value) {
- return value.getRowBytes() * value.getHeight();
- }
-
- @Override
- protected Bitmap removeNext() {
- Bitmap mostLongUsedValue = null;
- synchronized (lruCache) {
- Iterator> it = lruCache.entrySet().iterator();
- if (it.hasNext()) {
- Entry entry = it.next();
- mostLongUsedValue = entry.getValue();
- it.remove();
- }
- }
- return mostLongUsedValue;
- }
-
- @Override
- protected Reference createReference(Bitmap value) {
- return new WeakReference(value);
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/LargestLimitedMemoryCache.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/LargestLimitedMemoryCache.java
deleted file mode 100644
index d7a8d19e2..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/LargestLimitedMemoryCache.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.cache.memory.impl;
-
-import android.graphics.Bitmap;
-import com.nostra13.universalimageloader.cache.memory.LimitedMemoryCache;
-
-import java.lang.ref.Reference;
-import java.lang.ref.WeakReference;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-/**
- * Limited {@link Bitmap bitmap} cache. Provides {@link Bitmap bitmaps} storing. Size of all stored bitmaps will not to
- * exceed size limit. When cache reaches limit size then the bitmap which has the largest size is deleted from
- * cache.
- *
- * NOTE: This cache uses strong and weak references for stored Bitmaps. Strong references - for limited count of
- * Bitmaps (depends on cache size), weak references - for all other cached Bitmaps.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.0.0
- */
-public class LargestLimitedMemoryCache extends LimitedMemoryCache {
- /**
- * Contains strong references to stored objects (keys) and sizes of the objects. If hard cache
- * size will exceed limit then object with the largest size is deleted (but it continue exist at
- * {@link #softMap} and can be collected by GC at any time)
- */
- private final Map valueSizes = Collections.synchronizedMap(new HashMap());
-
- public LargestLimitedMemoryCache(int sizeLimit) {
- super(sizeLimit);
- }
-
- @Override
- public boolean put(String key, Bitmap value) {
- if (super.put(key, value)) {
- valueSizes.put(value, getSize(value));
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public Bitmap remove(String key) {
- Bitmap value = super.get(key);
- if (value != null) {
- valueSizes.remove(value);
- }
- return super.remove(key);
- }
-
- @Override
- public void clear() {
- valueSizes.clear();
- super.clear();
- }
-
- @Override
- protected int getSize(Bitmap value) {
- return value.getRowBytes() * value.getHeight();
- }
-
- @Override
- protected Bitmap removeNext() {
- Integer maxSize = null;
- Bitmap largestValue = null;
- Set> entries = valueSizes.entrySet();
- synchronized (valueSizes) {
- for (Entry entry : entries) {
- if (largestValue == null) {
- largestValue = entry.getKey();
- maxSize = entry.getValue();
- } else {
- Integer size = entry.getValue();
- if (size > maxSize) {
- maxSize = size;
- largestValue = entry.getKey();
- }
- }
- }
- }
- valueSizes.remove(largestValue);
- return largestValue;
- }
-
- @Override
- protected Reference createReference(Bitmap value) {
- return new WeakReference(value);
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/LimitedAgeMemoryCache.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/LimitedAgeMemoryCache.java
deleted file mode 100644
index 2925b6315..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/LimitedAgeMemoryCache.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.cache.memory.impl;
-
-import android.graphics.Bitmap;
-
-import com.nostra13.universalimageloader.cache.memory.MemoryCache;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Decorator for {@link MemoryCache}. Provides special feature for cache: if some cached object age exceeds defined
- * value then this object will be removed from cache.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @see MemoryCache
- * @since 1.3.1
- */
-public class LimitedAgeMemoryCache implements MemoryCache {
-
- private final MemoryCache cache;
-
- private final long maxAge;
- private final Map loadingDates = Collections.synchronizedMap(new HashMap());
-
- /**
- * @param cache Wrapped memory cache
- * @param maxAge Max object age (in seconds). If object age will exceed this value then it'll be removed from
- * cache on next treatment (and therefore be reloaded).
- */
- public LimitedAgeMemoryCache(MemoryCache cache, long maxAge) {
- this.cache = cache;
- this.maxAge = maxAge * 1000; // to milliseconds
- }
-
- @Override
- public boolean put(String key, Bitmap value) {
- boolean putSuccesfully = cache.put(key, value);
- if (putSuccesfully) {
- loadingDates.put(key, System.currentTimeMillis());
- }
- return putSuccesfully;
- }
-
- @Override
- public Bitmap get(String key) {
- Long loadingDate = loadingDates.get(key);
- if (loadingDate != null && System.currentTimeMillis() - loadingDate > maxAge) {
- cache.remove(key);
- loadingDates.remove(key);
- }
-
- return cache.get(key);
- }
-
- @Override
- public Bitmap remove(String key) {
- loadingDates.remove(key);
- return cache.remove(key);
- }
-
- @Override
- public Collection keys() {
- return cache.keys();
- }
-
- @Override
- public void clear() {
- cache.clear();
- loadingDates.clear();
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/LruMemoryCache.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/LruMemoryCache.java
deleted file mode 100644
index 134a4f838..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/LruMemoryCache.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package com.nostra13.universalimageloader.cache.memory.impl;
-
-import android.graphics.Bitmap;
-
-import com.nostra13.universalimageloader.cache.memory.MemoryCache;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * A cache that holds strong references to a limited number of Bitmaps. Each time a Bitmap is accessed, it is moved to
- * the head of a queue. When a Bitmap is added to a full cache, the Bitmap at the end of that queue is evicted and may
- * become eligible for garbage collection.
- *
- * NOTE: This cache uses only strong references for stored Bitmaps.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.8.1
- */
-public class LruMemoryCache implements MemoryCache {
-
- private final LinkedHashMap map;
-
- private final int maxSize;
- /** Size of this cache in bytes */
- private int size;
-
- /** @param maxSize Maximum sum of the sizes of the Bitmaps in this cache */
- public LruMemoryCache(int maxSize) {
- if (maxSize <= 0) {
- throw new IllegalArgumentException("maxSize <= 0");
- }
- this.maxSize = maxSize;
- this.map = new LinkedHashMap(0, 0.75f, true);
- }
-
- /**
- * Returns the Bitmap for {@code key} if it exists in the cache. If a Bitmap was returned, it is moved to the head
- * of the queue. This returns null if a Bitmap is not cached.
- */
- @Override
- public final Bitmap get(String key) {
- if (key == null) {
- throw new NullPointerException("key == null");
- }
-
- synchronized (this) {
- return map.get(key);
- }
- }
-
- /** Caches {@code Bitmap} for {@code key}. The Bitmap is moved to the head of the queue. */
- @Override
- public final boolean put(String key, Bitmap value) {
- if (key == null || value == null) {
- throw new NullPointerException("key == null || value == null");
- }
-
- synchronized (this) {
- size += sizeOf(key, value);
- Bitmap previous = map.put(key, value);
- if (previous != null) {
- size -= sizeOf(key, previous);
- }
- }
-
- trimToSize(maxSize);
- return true;
- }
-
- /**
- * Remove the eldest entries until the total of remaining entries is at or below the requested size.
- *
- * @param maxSize the maximum size of the cache before returning. May be -1 to evict even 0-sized elements.
- */
- private void trimToSize(int maxSize) {
- while (true) {
- String key;
- Bitmap value;
- synchronized (this) {
- if (size < 0 || (map.isEmpty() && size != 0)) {
- throw new IllegalStateException(getClass().getName() + ".sizeOf() is reporting inconsistent results!");
- }
-
- if (size <= maxSize || map.isEmpty()) {
- break;
- }
-
- Map.Entry toEvict = map.entrySet().iterator().next();
- if (toEvict == null) {
- break;
- }
- key = toEvict.getKey();
- value = toEvict.getValue();
- map.remove(key);
- size -= sizeOf(key, value);
- }
- }
- }
-
- /** Removes the entry for {@code key} if it exists. */
- @Override
- public final Bitmap remove(String key) {
- if (key == null) {
- throw new NullPointerException("key == null");
- }
-
- synchronized (this) {
- Bitmap previous = map.remove(key);
- if (previous != null) {
- size -= sizeOf(key, previous);
- }
- return previous;
- }
- }
-
- @Override
- public Collection keys() {
- synchronized (this) {
- return new HashSet(map.keySet());
- }
- }
-
- @Override
- public void clear() {
- trimToSize(-1); // -1 will evict 0-sized elements
- }
-
- /**
- * Returns the size {@code Bitmap} in bytes.
- *
- * An entry's size must not change while it is in the cache.
- */
- private int sizeOf(String key, Bitmap value) {
- return value.getRowBytes() * value.getHeight();
- }
-
- @Override
- public synchronized final String toString() {
- return String.format("LruCache[maxSize=%d]", maxSize);
- }
-}
\ No newline at end of file
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/UsingFreqLimitedMemoryCache.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/UsingFreqLimitedMemoryCache.java
deleted file mode 100644
index 1c78dc1bc..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/UsingFreqLimitedMemoryCache.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.cache.memory.impl;
-
-import android.graphics.Bitmap;
-import com.nostra13.universalimageloader.cache.memory.LimitedMemoryCache;
-
-import java.lang.ref.Reference;
-import java.lang.ref.WeakReference;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-/**
- * Limited {@link Bitmap bitmap} cache. Provides {@link Bitmap bitmaps} storing. Size of all stored bitmaps will not to
- * exceed size limit. When cache reaches limit size then the bitmap which used the least frequently is deleted from
- * cache.
- *
- * NOTE: This cache uses strong and weak references for stored Bitmaps. Strong references - for limited count of
- * Bitmaps (depends on cache size), weak references - for all other cached Bitmaps.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.0.0
- */
-public class UsingFreqLimitedMemoryCache extends LimitedMemoryCache {
- /**
- * Contains strong references to stored objects (keys) and last object usage date (in milliseconds). If hard cache
- * size will exceed limit then object with the least frequently usage is deleted (but it continue exist at
- * {@link #softMap} and can be collected by GC at any time)
- */
- private final Map usingCounts = Collections.synchronizedMap(new HashMap());
-
- public UsingFreqLimitedMemoryCache(int sizeLimit) {
- super(sizeLimit);
- }
-
- @Override
- public boolean put(String key, Bitmap value) {
- if (super.put(key, value)) {
- usingCounts.put(value, 0);
- return true;
- } else {
- return false;
- }
- }
-
- @Override
- public Bitmap get(String key) {
- Bitmap value = super.get(key);
- // Increment usage count for value if value is contained in hardCahe
- if (value != null) {
- Integer usageCount = usingCounts.get(value);
- if (usageCount != null) {
- usingCounts.put(value, usageCount + 1);
- }
- }
- return value;
- }
-
- @Override
- public Bitmap remove(String key) {
- Bitmap value = super.get(key);
- if (value != null) {
- usingCounts.remove(value);
- }
- return super.remove(key);
- }
-
- @Override
- public void clear() {
- usingCounts.clear();
- super.clear();
- }
-
- @Override
- protected int getSize(Bitmap value) {
- return value.getRowBytes() * value.getHeight();
- }
-
- @Override
- protected Bitmap removeNext() {
- Integer minUsageCount = null;
- Bitmap leastUsedValue = null;
- Set> entries = usingCounts.entrySet();
- synchronized (usingCounts) {
- for (Entry entry : entries) {
- if (leastUsedValue == null) {
- leastUsedValue = entry.getKey();
- minUsageCount = entry.getValue();
- } else {
- Integer lastValueUsage = entry.getValue();
- if (lastValueUsage < minUsageCount) {
- minUsageCount = lastValueUsage;
- leastUsedValue = entry.getKey();
- }
- }
- }
- }
- usingCounts.remove(leastUsedValue);
- return leastUsedValue;
- }
-
- @Override
- protected Reference createReference(Bitmap value) {
- return new WeakReference(value);
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/WeakMemoryCache.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/WeakMemoryCache.java
deleted file mode 100644
index 456257476..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/cache/memory/impl/WeakMemoryCache.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.cache.memory.impl;
-
-import android.graphics.Bitmap;
-import com.nostra13.universalimageloader.cache.memory.BaseMemoryCache;
-
-import java.lang.ref.Reference;
-import java.lang.ref.WeakReference;
-
-/**
- * Memory cache with {@linkplain WeakReference weak references} to {@linkplain android.graphics.Bitmap bitmaps}
- *
- * NOTE: This cache uses only weak references for stored Bitmaps.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.5.3
- */
-public class WeakMemoryCache extends BaseMemoryCache {
- @Override
- protected Reference createReference(Bitmap value) {
- return new WeakReference(value);
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/DefaultConfigurationFactory.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/DefaultConfigurationFactory.java
deleted file mode 100644
index af244d651..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/DefaultConfigurationFactory.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core;
-
-import android.annotation.TargetApi;
-import android.app.ActivityManager;
-import android.content.Context;
-import android.content.pm.ApplicationInfo;
-import android.os.Build;
-import com.nostra13.universalimageloader.cache.disc.DiskCache;
-import com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache;
-import com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache;
-import com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator;
-import com.nostra13.universalimageloader.cache.disc.naming.HashCodeFileNameGenerator;
-import com.nostra13.universalimageloader.cache.memory.MemoryCache;
-import com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache;
-import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
-import com.nostra13.universalimageloader.core.assist.deque.LIFOLinkedBlockingDeque;
-import com.nostra13.universalimageloader.core.decode.BaseImageDecoder;
-import com.nostra13.universalimageloader.core.decode.ImageDecoder;
-import com.nostra13.universalimageloader.core.display.BitmapDisplayer;
-import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
-import com.nostra13.universalimageloader.core.download.BaseImageDownloader;
-import com.nostra13.universalimageloader.core.download.ImageDownloader;
-import com.nostra13.universalimageloader.utils.L;
-import com.nostra13.universalimageloader.utils.StorageUtils;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.Executor;
-import java.util.concurrent.Executors;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadFactory;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Factory for providing of default options for {@linkplain ImageLoaderConfiguration configuration}
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.5.6
- */
-public class DefaultConfigurationFactory {
-
- /** Creates default implementation of task executor */
- public static Executor createExecutor(int threadPoolSize, int threadPriority,
- QueueProcessingType tasksProcessingType) {
- boolean lifo = tasksProcessingType == QueueProcessingType.LIFO;
- BlockingQueue taskQueue =
- lifo ? new LIFOLinkedBlockingDeque() : new LinkedBlockingQueue();
- return new ThreadPoolExecutor(threadPoolSize, threadPoolSize, 0L, TimeUnit.MILLISECONDS, taskQueue,
- createThreadFactory(threadPriority, "uil-pool-"));
- }
-
- /** Creates default implementation of task distributor */
- public static Executor createTaskDistributor() {
- return Executors.newCachedThreadPool(createThreadFactory(Thread.NORM_PRIORITY, "uil-pool-d-"));
- }
-
- /** Creates {@linkplain HashCodeFileNameGenerator default implementation} of FileNameGenerator */
- public static FileNameGenerator createFileNameGenerator() {
- return new HashCodeFileNameGenerator();
- }
-
- /**
- * Creates default implementation of {@link DiskCache} depends on incoming parameters
- */
- public static DiskCache createDiskCache(Context context, FileNameGenerator diskCacheFileNameGenerator,
- long diskCacheSize, int diskCacheFileCount) {
- File reserveCacheDir = createReserveDiskCacheDir(context);
- if (diskCacheSize > 0 || diskCacheFileCount > 0) {
- File individualCacheDir = StorageUtils.getIndividualCacheDirectory(context);
- try {
- return new LruDiskCache(individualCacheDir, reserveCacheDir, diskCacheFileNameGenerator, diskCacheSize,
- diskCacheFileCount);
- } catch (IOException e) {
- L.e(e);
- // continue and create unlimited cache
- }
- }
- File cacheDir = StorageUtils.getCacheDirectory(context);
- return new UnlimitedDiskCache(cacheDir, reserveCacheDir, diskCacheFileNameGenerator);
- }
-
- /** Creates reserve disk cache folder which will be used if primary disk cache folder becomes unavailable */
- private static File createReserveDiskCacheDir(Context context) {
- File cacheDir = StorageUtils.getCacheDirectory(context, false);
- File individualDir = new File(cacheDir, "uil-images");
- if (individualDir.exists() || individualDir.mkdir()) {
- cacheDir = individualDir;
- }
- return cacheDir;
- }
-
- /**
- * Creates default implementation of {@link MemoryCache} - {@link LruMemoryCache}
- * Default cache size = 1/8 of available app memory.
- */
- public static MemoryCache createMemoryCache(Context context, int memoryCacheSize) {
- if (memoryCacheSize == 0) {
- ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
- int memoryClass = am.getMemoryClass();
- if (hasHoneycomb() && isLargeHeap(context)) {
- memoryClass = getLargeMemoryClass(am);
- }
- memoryCacheSize = 1024 * 1024 * memoryClass / 8;
- }
- return new LruMemoryCache(memoryCacheSize);
- }
-
- private static boolean hasHoneycomb() {
- return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
- }
-
- @TargetApi(Build.VERSION_CODES.HONEYCOMB)
- private static boolean isLargeHeap(Context context) {
- return (context.getApplicationInfo().flags & ApplicationInfo.FLAG_LARGE_HEAP) != 0;
- }
-
- @TargetApi(Build.VERSION_CODES.HONEYCOMB)
- private static int getLargeMemoryClass(ActivityManager am) {
- return am.getLargeMemoryClass();
- }
-
- /** Creates default implementation of {@link ImageDownloader} - {@link BaseImageDownloader} */
- public static ImageDownloader createImageDownloader(Context context) {
- return new BaseImageDownloader(context);
- }
-
- /** Creates default implementation of {@link ImageDecoder} - {@link BaseImageDecoder} */
- public static ImageDecoder createImageDecoder(boolean loggingEnabled) {
- return new BaseImageDecoder(loggingEnabled);
- }
-
- /** Creates default implementation of {@link BitmapDisplayer} - {@link SimpleBitmapDisplayer} */
- public static BitmapDisplayer createBitmapDisplayer() {
- return new SimpleBitmapDisplayer();
- }
-
- /** Creates default implementation of {@linkplain ThreadFactory thread factory} for task executor */
- private static ThreadFactory createThreadFactory(int threadPriority, String threadNamePrefix) {
- return new DefaultThreadFactory(threadPriority, threadNamePrefix);
- }
-
- private static class DefaultThreadFactory implements ThreadFactory {
-
- private static final AtomicInteger poolNumber = new AtomicInteger(1);
-
- private final ThreadGroup group;
- private final AtomicInteger threadNumber = new AtomicInteger(1);
- private final String namePrefix;
- private final int threadPriority;
-
- DefaultThreadFactory(int threadPriority, String threadNamePrefix) {
- this.threadPriority = threadPriority;
- group = Thread.currentThread().getThreadGroup();
- namePrefix = threadNamePrefix + poolNumber.getAndIncrement() + "-thread-";
- }
-
- @Override
- public Thread newThread(Runnable r) {
- Thread t = new Thread(group, r, namePrefix + threadNumber.getAndIncrement(), 0);
- if (t.isDaemon()) t.setDaemon(false);
- t.setPriority(threadPriority);
- return t;
- }
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/DisplayBitmapTask.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/DisplayBitmapTask.java
deleted file mode 100644
index fbdf762ff..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/DisplayBitmapTask.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core;
-
-import android.graphics.Bitmap;
-import com.nostra13.universalimageloader.core.assist.LoadedFrom;
-import com.nostra13.universalimageloader.core.display.BitmapDisplayer;
-import com.nostra13.universalimageloader.core.imageaware.ImageAware;
-import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
-import com.nostra13.universalimageloader.utils.L;
-
-/**
- * Displays bitmap in {@link com.nostra13.universalimageloader.core.imageaware.ImageAware}. Must be called on UI thread.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @see ImageLoadingListener
- * @see BitmapDisplayer
- * @since 1.3.1
- */
-final class DisplayBitmapTask implements Runnable {
-
- private static final String LOG_DISPLAY_IMAGE_IN_IMAGEAWARE = "Display image in ImageAware (loaded from %1$s) [%2$s]";
- private static final String LOG_TASK_CANCELLED_IMAGEAWARE_REUSED = "ImageAware is reused for another image. Task is cancelled. [%s]";
- private static final String LOG_TASK_CANCELLED_IMAGEAWARE_COLLECTED = "ImageAware was collected by GC. Task is cancelled. [%s]";
-
- private final Bitmap bitmap;
- private final String imageUri;
- private final ImageAware imageAware;
- private final String memoryCacheKey;
- private final BitmapDisplayer displayer;
- private final ImageLoadingListener listener;
- private final ImageLoaderEngine engine;
- private final LoadedFrom loadedFrom;
-
- public DisplayBitmapTask(Bitmap bitmap, ImageLoadingInfo imageLoadingInfo, ImageLoaderEngine engine,
- LoadedFrom loadedFrom) {
- this.bitmap = bitmap;
- imageUri = imageLoadingInfo.uri;
- imageAware = imageLoadingInfo.imageAware;
- memoryCacheKey = imageLoadingInfo.memoryCacheKey;
- displayer = imageLoadingInfo.options.getDisplayer();
- listener = imageLoadingInfo.listener;
- this.engine = engine;
- this.loadedFrom = loadedFrom;
- }
-
- @Override
- public void run() {
- if (imageAware.isCollected()) {
- L.d(LOG_TASK_CANCELLED_IMAGEAWARE_COLLECTED, memoryCacheKey);
- listener.onLoadingCancelled(imageUri, imageAware.getWrappedView());
- } else if (isViewWasReused()) {
- L.d(LOG_TASK_CANCELLED_IMAGEAWARE_REUSED, memoryCacheKey);
- listener.onLoadingCancelled(imageUri, imageAware.getWrappedView());
- } else {
- L.d(LOG_DISPLAY_IMAGE_IN_IMAGEAWARE, loadedFrom, memoryCacheKey);
- displayer.display(bitmap, imageAware, loadedFrom);
- engine.cancelDisplayTaskFor(imageAware);
- listener.onLoadingComplete(imageUri, imageAware.getWrappedView(), bitmap);
- }
- }
-
- /** Checks whether memory cache key (image URI) for current ImageAware is actual */
- private boolean isViewWasReused() {
- String currentCacheKey = engine.getLoadingUriForView(imageAware);
- return !memoryCacheKey.equals(currentCacheKey);
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/DisplayImageOptions.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/DisplayImageOptions.java
deleted file mode 100644
index b94d3baac..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/DisplayImageOptions.java
+++ /dev/null
@@ -1,509 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core;
-
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory.Options;
-import android.graphics.drawable.Drawable;
-import android.os.Handler;
-import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
-import com.nostra13.universalimageloader.core.assist.ImageScaleType;
-import com.nostra13.universalimageloader.core.display.BitmapDisplayer;
-import com.nostra13.universalimageloader.core.display.SimpleBitmapDisplayer;
-import com.nostra13.universalimageloader.core.download.ImageDownloader;
-import com.nostra13.universalimageloader.core.process.BitmapProcessor;
-
-/**
- * Contains options for image display. Defines:
- *
- * - whether stub image will be displayed in {@link com.nostra13.universalimageloader.core.imageaware.ImageAware
- * image aware view} during image loading
- * - whether stub image will be displayed in {@link com.nostra13.universalimageloader.core.imageaware.ImageAware
- * image aware view} if empty URI is passed
- * - whether stub image will be displayed in {@link com.nostra13.universalimageloader.core.imageaware.ImageAware
- * image aware view} if image loading fails
- * - whether {@link com.nostra13.universalimageloader.core.imageaware.ImageAware image aware view} should be reset
- * before image loading start
- * - whether loaded image will be cached in memory
- * - whether loaded image will be cached on disk
- * - image scale type
- * - decoding options (including bitmap decoding configuration)
- * - delay before loading of image
- * - whether consider EXIF parameters of image
- * - auxiliary object which will be passed to {@link ImageDownloader#getStream(String, Object) ImageDownloader}
- * - pre-processor for image Bitmap (before caching in memory)
- * - post-processor for image Bitmap (after caching in memory, before displaying)
- * - how decoded {@link Bitmap} will be displayed
- *
- *
- * You can create instance:
- *
- * - with {@link Builder}:
- * i.e. :
- * new {@link DisplayImageOptions}.{@link Builder#Builder() Builder()}.{@link Builder#cacheInMemory() cacheInMemory()}.
- * {@link Builder#showImageOnLoading(int) showImageOnLoading()}.{@link Builder#build() build()}
- *
- * - or by static method: {@link #createSimple()}
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.0.0
- */
-public final class DisplayImageOptions {
-
- private final int imageResOnLoading;
- private final int imageResForEmptyUri;
- private final int imageResOnFail;
- private final Drawable imageOnLoading;
- private final Drawable imageForEmptyUri;
- private final Drawable imageOnFail;
- private final boolean resetViewBeforeLoading;
- private final boolean cacheInMemory;
- private final boolean cacheOnDisk;
- private final ImageScaleType imageScaleType;
- private final Options decodingOptions;
- private final int delayBeforeLoading;
- private final boolean considerExifParams;
- private final Object extraForDownloader;
- private final BitmapProcessor preProcessor;
- private final BitmapProcessor postProcessor;
- private final BitmapDisplayer displayer;
- private final Handler handler;
- private final boolean isSyncLoading;
-
- private DisplayImageOptions(Builder builder) {
- imageResOnLoading = builder.imageResOnLoading;
- imageResForEmptyUri = builder.imageResForEmptyUri;
- imageResOnFail = builder.imageResOnFail;
- imageOnLoading = builder.imageOnLoading;
- imageForEmptyUri = builder.imageForEmptyUri;
- imageOnFail = builder.imageOnFail;
- resetViewBeforeLoading = builder.resetViewBeforeLoading;
- cacheInMemory = builder.cacheInMemory;
- cacheOnDisk = builder.cacheOnDisk;
- imageScaleType = builder.imageScaleType;
- decodingOptions = builder.decodingOptions;
- delayBeforeLoading = builder.delayBeforeLoading;
- considerExifParams = builder.considerExifParams;
- extraForDownloader = builder.extraForDownloader;
- preProcessor = builder.preProcessor;
- postProcessor = builder.postProcessor;
- displayer = builder.displayer;
- handler = builder.handler;
- isSyncLoading = builder.isSyncLoading;
- }
-
- public boolean shouldShowImageOnLoading() {
- return imageOnLoading != null || imageResOnLoading != 0;
- }
-
- public boolean shouldShowImageForEmptyUri() {
- return imageForEmptyUri != null || imageResForEmptyUri != 0;
- }
-
- public boolean shouldShowImageOnFail() {
- return imageOnFail != null || imageResOnFail != 0;
- }
-
- public boolean shouldPreProcess() {
- return preProcessor != null;
- }
-
- public boolean shouldPostProcess() {
- return postProcessor != null;
- }
-
- public boolean shouldDelayBeforeLoading() {
- return delayBeforeLoading > 0;
- }
-
- public Drawable getImageOnLoading(Resources res) {
- return imageResOnLoading != 0 ? res.getDrawable(imageResOnLoading) : imageOnLoading;
- }
-
- public Drawable getImageForEmptyUri(Resources res) {
- return imageResForEmptyUri != 0 ? res.getDrawable(imageResForEmptyUri) : imageForEmptyUri;
- }
-
- public Drawable getImageOnFail(Resources res) {
- return imageResOnFail != 0 ? res.getDrawable(imageResOnFail) : imageOnFail;
- }
-
- public boolean isResetViewBeforeLoading() {
- return resetViewBeforeLoading;
- }
-
- public boolean isCacheInMemory() {
- return cacheInMemory;
- }
-
- public boolean isCacheOnDisk() {
- return cacheOnDisk;
- }
-
- public ImageScaleType getImageScaleType() {
- return imageScaleType;
- }
-
- public Options getDecodingOptions() {
- return decodingOptions;
- }
-
- public int getDelayBeforeLoading() {
- return delayBeforeLoading;
- }
-
- public boolean isConsiderExifParams() {
- return considerExifParams;
- }
-
- public Object getExtraForDownloader() {
- return extraForDownloader;
- }
-
- public BitmapProcessor getPreProcessor() {
- return preProcessor;
- }
-
- public BitmapProcessor getPostProcessor() {
- return postProcessor;
- }
-
- public BitmapDisplayer getDisplayer() {
- return displayer;
- }
-
- public Handler getHandler() {
- return handler;
- }
-
- boolean isSyncLoading() {
- return isSyncLoading;
- }
-
- /**
- * Builder for {@link DisplayImageOptions}
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- */
- public static class Builder {
- private int imageResOnLoading = 0;
- private int imageResForEmptyUri = 0;
- private int imageResOnFail = 0;
- private Drawable imageOnLoading = null;
- private Drawable imageForEmptyUri = null;
- private Drawable imageOnFail = null;
- private boolean resetViewBeforeLoading = false;
- private boolean cacheInMemory = false;
- private boolean cacheOnDisk = false;
- private ImageScaleType imageScaleType = ImageScaleType.IN_SAMPLE_POWER_OF_2;
- private Options decodingOptions = new Options();
- private int delayBeforeLoading = 0;
- private boolean considerExifParams = false;
- private Object extraForDownloader = null;
- private BitmapProcessor preProcessor = null;
- private BitmapProcessor postProcessor = null;
- private BitmapDisplayer displayer = DefaultConfigurationFactory.createBitmapDisplayer();
- private Handler handler = null;
- private boolean isSyncLoading = false;
-
- public Builder() {
- decodingOptions.inPurgeable = true;
- decodingOptions.inInputShareable = true;
- }
-
- /**
- * Stub image will be displayed in {@link com.nostra13.universalimageloader.core.imageaware.ImageAware
- * image aware view} during image loading
- *
- * @param imageRes Stub image resource
- * @deprecated Use {@link #showImageOnLoading(int)} instead
- */
- @Deprecated
- public Builder showStubImage(int imageRes) {
- imageResOnLoading = imageRes;
- return this;
- }
-
- /**
- * Incoming image will be displayed in {@link com.nostra13.universalimageloader.core.imageaware.ImageAware
- * image aware view} during image loading
- *
- * @param imageRes Image resource
- */
- public Builder showImageOnLoading(int imageRes) {
- imageResOnLoading = imageRes;
- return this;
- }
-
- /**
- * Incoming drawable will be displayed in {@link com.nostra13.universalimageloader.core.imageaware.ImageAware
- * image aware view} during image loading.
- * This option will be ignored if {@link DisplayImageOptions.Builder#showImageOnLoading(int)} is set.
- */
- public Builder showImageOnLoading(Drawable drawable) {
- imageOnLoading = drawable;
- return this;
- }
-
- /**
- * Incoming image will be displayed in {@link com.nostra13.universalimageloader.core.imageaware.ImageAware
- * image aware view} if empty URI (null or empty
- * string) will be passed to ImageLoader.displayImage(...) method.
- *
- * @param imageRes Image resource
- */
- public Builder showImageForEmptyUri(int imageRes) {
- imageResForEmptyUri = imageRes;
- return this;
- }
-
- /**
- * Incoming drawable will be displayed in {@link com.nostra13.universalimageloader.core.imageaware.ImageAware
- * image aware view} if empty URI (null or empty
- * string) will be passed to ImageLoader.displayImage(...) method.
- * This option will be ignored if {@link DisplayImageOptions.Builder#showImageForEmptyUri(int)} is set.
- */
- public Builder showImageForEmptyUri(Drawable drawable) {
- imageForEmptyUri = drawable;
- return this;
- }
-
- /**
- * Incoming image will be displayed in {@link com.nostra13.universalimageloader.core.imageaware.ImageAware
- * image aware view} if some error occurs during
- * requested image loading/decoding.
- *
- * @param imageRes Image resource
- */
- public Builder showImageOnFail(int imageRes) {
- imageResOnFail = imageRes;
- return this;
- }
-
- /**
- * Incoming drawable will be displayed in {@link com.nostra13.universalimageloader.core.imageaware.ImageAware
- * image aware view} if some error occurs during
- * requested image loading/decoding.
- * This option will be ignored if {@link DisplayImageOptions.Builder#showImageOnFail(int)} is set.
- */
- public Builder showImageOnFail(Drawable drawable) {
- imageOnFail = drawable;
- return this;
- }
-
- /**
- * {@link com.nostra13.universalimageloader.core.imageaware.ImageAware
- * image aware view} will be reset (set null) before image loading start
- *
- * @deprecated Use {@link #resetViewBeforeLoading(boolean) resetViewBeforeLoading(true)} instead
- */
- public Builder resetViewBeforeLoading() {
- resetViewBeforeLoading = true;
- return this;
- }
-
- /**
- * Sets whether {@link com.nostra13.universalimageloader.core.imageaware.ImageAware
- * image aware view} will be reset (set null) before image loading start
- */
- public Builder resetViewBeforeLoading(boolean resetViewBeforeLoading) {
- this.resetViewBeforeLoading = resetViewBeforeLoading;
- return this;
- }
-
- /**
- * Loaded image will be cached in memory
- *
- * @deprecated Use {@link #cacheInMemory(boolean) cacheInMemory(true)} instead
- */
- @Deprecated
- public Builder cacheInMemory() {
- cacheInMemory = true;
- return this;
- }
-
- /** Sets whether loaded image will be cached in memory */
- public Builder cacheInMemory(boolean cacheInMemory) {
- this.cacheInMemory = cacheInMemory;
- return this;
- }
-
- /**
- * Loaded image will be cached on disk
- *
- * @deprecated Use {@link #cacheOnDisk(boolean) cacheOnDisk(true)} instead
- */
- @Deprecated
- public Builder cacheOnDisc() {
- return cacheOnDisk(true);
- }
-
- /**
- * Sets whether loaded image will be cached on disk
- *
- * @deprecated Use {@link #cacheOnDisk(boolean)} instead
- */
- @Deprecated
- public Builder cacheOnDisc(boolean cacheOnDisk) {
- return cacheOnDisk(cacheOnDisk);
- }
-
- /** Sets whether loaded image will be cached on disk */
- public Builder cacheOnDisk(boolean cacheOnDisk) {
- this.cacheOnDisk = cacheOnDisk;
- return this;
- }
-
- /**
- * Sets {@linkplain ImageScaleType scale type} for decoding image. This parameter is used while define scale
- * size for decoding image to Bitmap. Default value - {@link ImageScaleType#IN_SAMPLE_POWER_OF_2}
- */
- public Builder imageScaleType(ImageScaleType imageScaleType) {
- this.imageScaleType = imageScaleType;
- return this;
- }
-
- /** Sets {@link Bitmap.Config bitmap config} for image decoding. Default value - {@link Bitmap.Config#ARGB_8888} */
- public Builder bitmapConfig(Bitmap.Config bitmapConfig) {
- if (bitmapConfig == null) throw new IllegalArgumentException("bitmapConfig can't be null");
- decodingOptions.inPreferredConfig = bitmapConfig;
- return this;
- }
-
- /**
- * Sets options for image decoding.
- * NOTE: {@link Options#inSampleSize} of incoming options will NOT be considered. Library
- * calculate the most appropriate sample size itself according yo {@link #imageScaleType(ImageScaleType)}
- * options.
- * NOTE: This option overlaps {@link #bitmapConfig(android.graphics.Bitmap.Config) bitmapConfig()}
- * option.
- */
- public Builder decodingOptions(Options decodingOptions) {
- if (decodingOptions == null) throw new IllegalArgumentException("decodingOptions can't be null");
- this.decodingOptions = decodingOptions;
- return this;
- }
-
- /** Sets delay time before starting loading task. Default - no delay. */
- public Builder delayBeforeLoading(int delayInMillis) {
- this.delayBeforeLoading = delayInMillis;
- return this;
- }
-
- /** Sets auxiliary object which will be passed to {@link ImageDownloader#getStream(String, Object)} */
- public Builder extraForDownloader(Object extra) {
- this.extraForDownloader = extra;
- return this;
- }
-
- /** Sets whether ImageLoader will consider EXIF parameters of JPEG image (rotate, flip) */
- public Builder considerExifParams(boolean considerExifParams) {
- this.considerExifParams = considerExifParams;
- return this;
- }
-
- /**
- * Sets bitmap processor which will be process bitmaps before they will be cached in memory. So memory cache
- * will contain bitmap processed by incoming preProcessor.
- * Image will be pre-processed even if caching in memory is disabled.
- */
- public Builder preProcessor(BitmapProcessor preProcessor) {
- this.preProcessor = preProcessor;
- return this;
- }
-
- /**
- * Sets bitmap processor which will be process bitmaps before they will be displayed in
- * {@link com.nostra13.universalimageloader.core.imageaware.ImageAware image aware view} but
- * after they'll have been saved in memory cache.
- */
- public Builder postProcessor(BitmapProcessor postProcessor) {
- this.postProcessor = postProcessor;
- return this;
- }
-
- /**
- * Sets custom {@link BitmapDisplayer displayer} for image loading task. Default value -
- * {@link DefaultConfigurationFactory#createBitmapDisplayer()}
- */
- public Builder displayer(BitmapDisplayer displayer) {
- if (displayer == null) throw new IllegalArgumentException("displayer can't be null");
- this.displayer = displayer;
- return this;
- }
-
- Builder syncLoading(boolean isSyncLoading) {
- this.isSyncLoading = isSyncLoading;
- return this;
- }
-
- /**
- * Sets custom {@linkplain Handler handler} for displaying images and firing {@linkplain ImageLoadingListener
- * listener} events.
- */
- public Builder handler(Handler handler) {
- this.handler = handler;
- return this;
- }
-
- /** Sets all options equal to incoming options */
- public Builder cloneFrom(DisplayImageOptions options) {
- imageResOnLoading = options.imageResOnLoading;
- imageResForEmptyUri = options.imageResForEmptyUri;
- imageResOnFail = options.imageResOnFail;
- imageOnLoading = options.imageOnLoading;
- imageForEmptyUri = options.imageForEmptyUri;
- imageOnFail = options.imageOnFail;
- resetViewBeforeLoading = options.resetViewBeforeLoading;
- cacheInMemory = options.cacheInMemory;
- cacheOnDisk = options.cacheOnDisk;
- imageScaleType = options.imageScaleType;
- decodingOptions = options.decodingOptions;
- delayBeforeLoading = options.delayBeforeLoading;
- considerExifParams = options.considerExifParams;
- extraForDownloader = options.extraForDownloader;
- preProcessor = options.preProcessor;
- postProcessor = options.postProcessor;
- displayer = options.displayer;
- handler = options.handler;
- isSyncLoading = options.isSyncLoading;
- return this;
- }
-
- /** Builds configured {@link DisplayImageOptions} object */
- public DisplayImageOptions build() {
- return new DisplayImageOptions(this);
- }
- }
-
- /**
- * Creates options appropriate for single displaying:
- *
- * - View will not be reset before loading
- * - Loaded image will not be cached in memory
- * - Loaded image will not be cached on disk
- * - {@link ImageScaleType#IN_SAMPLE_POWER_OF_2} decoding type will be used
- * - {@link Bitmap.Config#ARGB_8888} bitmap config will be used for image decoding
- * - {@link SimpleBitmapDisplayer} will be used for image displaying
- *
- *
- * These option are appropriate for simple single-use image (from drawables or from Internet) displaying.
- */
- public static DisplayImageOptions createSimple() {
- return new Builder().build();
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/ImageLoader.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/ImageLoader.java
deleted file mode 100644
index e0163e6fc..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/ImageLoader.java
+++ /dev/null
@@ -1,768 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core;
-
-import android.graphics.Bitmap;
-import android.os.Handler;
-import android.os.Looper;
-import android.text.TextUtils;
-import android.view.View;
-import android.widget.ImageView;
-import com.nostra13.universalimageloader.cache.disc.DiskCache;
-import com.nostra13.universalimageloader.cache.memory.MemoryCache;
-import com.nostra13.universalimageloader.core.assist.FailReason;
-import com.nostra13.universalimageloader.core.assist.FlushedInputStream;
-import com.nostra13.universalimageloader.core.assist.ImageSize;
-import com.nostra13.universalimageloader.core.assist.LoadedFrom;
-import com.nostra13.universalimageloader.core.assist.ViewScaleType;
-import com.nostra13.universalimageloader.core.imageaware.ImageAware;
-import com.nostra13.universalimageloader.core.imageaware.ImageViewAware;
-import com.nostra13.universalimageloader.core.imageaware.NonViewAware;
-import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
-import com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener;
-import com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener;
-import com.nostra13.universalimageloader.utils.ImageSizeUtils;
-import com.nostra13.universalimageloader.utils.L;
-import com.nostra13.universalimageloader.utils.MemoryCacheUtils;
-
-/**
- * Singletone for image loading and displaying at {@link ImageView ImageViews}
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before any other method.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.0.0
- */
-public class ImageLoader {
-
- public static final String TAG = ImageLoader.class.getSimpleName();
-
- static final String LOG_INIT_CONFIG = "Initialize ImageLoader with configuration";
- static final String LOG_DESTROY = "Destroy ImageLoader";
- static final String LOG_LOAD_IMAGE_FROM_MEMORY_CACHE = "Load image from memory cache [%s]";
-
- private static final String WARNING_RE_INIT_CONFIG = "Try to initialize ImageLoader which had already been initialized before. " + "To re-init ImageLoader with new configuration call ImageLoader.destroy() at first.";
- private static final String ERROR_WRONG_ARGUMENTS = "Wrong arguments were passed to displayImage() method (ImageView reference must not be null)";
- private static final String ERROR_NOT_INIT = "ImageLoader must be init with configuration before using";
- private static final String ERROR_INIT_CONFIG_WITH_NULL = "ImageLoader configuration can not be initialized with null";
-
- private ImageLoaderConfiguration configuration;
- private ImageLoaderEngine engine;
-
- private ImageLoadingListener defaultListener = new SimpleImageLoadingListener();
-
- private volatile static ImageLoader instance;
-
- /** Returns singleton class instance */
- public static ImageLoader getInstance() {
- if (instance == null) {
- synchronized (ImageLoader.class) {
- if (instance == null) {
- instance = new ImageLoader();
- }
- }
- }
- return instance;
- }
-
- protected ImageLoader() {
- }
-
- /**
- * Initializes ImageLoader instance with configuration.
- * If configurations was set before ( {@link #isInited()} == true) then this method does nothing.
- * To force initialization with new configuration you should {@linkplain #destroy() destroy ImageLoader} at first.
- *
- * @param configuration {@linkplain ImageLoaderConfiguration ImageLoader configuration}
- * @throws IllegalArgumentException if configuration parameter is null
- */
- public synchronized void init(ImageLoaderConfiguration configuration) {
- if (configuration == null) {
- throw new IllegalArgumentException(ERROR_INIT_CONFIG_WITH_NULL);
- }
- if (this.configuration == null) {
- L.d(LOG_INIT_CONFIG);
- engine = new ImageLoaderEngine(configuration);
- this.configuration = configuration;
- } else {
- L.w(WARNING_RE_INIT_CONFIG);
- }
- }
-
- /**
- * Returns true - if ImageLoader {@linkplain #init(ImageLoaderConfiguration) is initialized with
- * configuration}; false - otherwise
- */
- public boolean isInited() {
- return configuration != null;
- }
-
- /**
- * Adds display image task to execution pool. Image will be set to ImageAware when it's turn.
- * Default {@linkplain DisplayImageOptions display image options} from {@linkplain ImageLoaderConfiguration
- * configuration} will be used.
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before this method call
- *
- * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
- * @param imageAware {@linkplain com.nostra13.universalimageloader.core.imageaware.ImageAware Image aware view}
- * which should display image
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- * @throws IllegalArgumentException if passed imageAware is null
- */
- public void displayImage(String uri, ImageAware imageAware) {
- displayImage(uri, imageAware, null, null, null);
- }
-
- /**
- * Adds display image task to execution pool. Image will be set to ImageAware when it's turn.
- * Default {@linkplain DisplayImageOptions display image options} from {@linkplain ImageLoaderConfiguration
- * configuration} will be used.
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before this method call
- *
- * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
- * @param imageAware {@linkplain com.nostra13.universalimageloader.core.imageaware.ImageAware Image aware view}
- * which should display image
- * @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener fires events on
- * UI thread if this method is called on UI thread.
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- * @throws IllegalArgumentException if passed imageAware is null
- */
- public void displayImage(String uri, ImageAware imageAware, ImageLoadingListener listener) {
- displayImage(uri, imageAware, null, listener, null);
- }
-
- /**
- * Adds display image task to execution pool. Image will be set to ImageAware when it's turn.
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before this method call
- *
- * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
- * @param imageAware {@linkplain com.nostra13.universalimageloader.core.imageaware.ImageAware Image aware view}
- * which should display image
- * @param options {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions Options} for image
- * decoding and displaying. If null - default display image options
- * {@linkplain ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions)
- * from configuration} will be used.
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- * @throws IllegalArgumentException if passed imageAware is null
- */
- public void displayImage(String uri, ImageAware imageAware, DisplayImageOptions options) {
- displayImage(uri, imageAware, options, null, null);
- }
-
- /**
- * Adds display image task to execution pool. Image will be set to ImageAware when it's turn.
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before this method call
- *
- * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
- * @param imageAware {@linkplain com.nostra13.universalimageloader.core.imageaware.ImageAware Image aware view}
- * which should display image
- * @param options {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions Options} for image
- * decoding and displaying. If null - default display image options
- * {@linkplain ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions)
- * from configuration} will be used.
- * @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener fires events on
- * UI thread if this method is called on UI thread.
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- * @throws IllegalArgumentException if passed imageAware is null
- */
- public void displayImage(String uri, ImageAware imageAware, DisplayImageOptions options,
- ImageLoadingListener listener) {
- displayImage(uri, imageAware, options, listener, null);
- }
-
- /**
- * Adds display image task to execution pool. Image will be set to ImageAware when it's turn.
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before this method call
- *
- * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
- * @param imageAware {@linkplain com.nostra13.universalimageloader.core.imageaware.ImageAware Image aware view}
- * which should display image
- * @param options {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions Options} for image
- * decoding and displaying. If null - default display image options
- * {@linkplain ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions)
- * from configuration} will be used.
- * @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener fires
- * events on UI thread if this method is called on UI thread.
- * @param progressListener {@linkplain com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener
- * Listener} for image loading progress. Listener fires events on UI thread if this method
- * is called on UI thread. Caching on disk should be enabled in
- * {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions options} to make
- * this listener work.
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- * @throws IllegalArgumentException if passed imageAware is null
- */
- public void displayImage(String uri, ImageAware imageAware, DisplayImageOptions options,
- ImageLoadingListener listener, ImageLoadingProgressListener progressListener) {
- checkConfiguration();
- if (imageAware == null) {
- throw new IllegalArgumentException(ERROR_WRONG_ARGUMENTS);
- }
- if (listener == null) {
- listener = defaultListener;
- }
- if (options == null) {
- options = configuration.defaultDisplayImageOptions;
- }
-
- if (TextUtils.isEmpty(uri)) {
- engine.cancelDisplayTaskFor(imageAware);
- listener.onLoadingStarted(uri, imageAware.getWrappedView());
- if (options.shouldShowImageForEmptyUri()) {
- imageAware.setImageDrawable(options.getImageForEmptyUri(configuration.resources));
- } else {
- imageAware.setImageDrawable(null);
- }
- listener.onLoadingComplete(uri, imageAware.getWrappedView(), null);
- return;
- }
-
- ImageSize targetSize = ImageSizeUtils.defineTargetSizeForView(imageAware, configuration.getMaxImageSize());
- String memoryCacheKey = MemoryCacheUtils.generateKey(uri, targetSize);
- engine.prepareDisplayTaskFor(imageAware, memoryCacheKey);
-
- listener.onLoadingStarted(uri, imageAware.getWrappedView());
-
- Bitmap bmp = configuration.memoryCache.get(memoryCacheKey);
- if (bmp != null && !bmp.isRecycled()) {
- L.d(LOG_LOAD_IMAGE_FROM_MEMORY_CACHE, memoryCacheKey);
-
- if (options.shouldPostProcess()) {
- ImageLoadingInfo imageLoadingInfo = new ImageLoadingInfo(uri, imageAware, targetSize, memoryCacheKey,
- options, listener, progressListener, engine.getLockForUri(uri));
- ProcessAndDisplayImageTask displayTask = new ProcessAndDisplayImageTask(engine, bmp, imageLoadingInfo,
- defineHandler(options));
- if (options.isSyncLoading()) {
- displayTask.run();
- } else {
- engine.submit(displayTask);
- }
- } else {
- options.getDisplayer().display(bmp, imageAware, LoadedFrom.MEMORY_CACHE);
- listener.onLoadingComplete(uri, imageAware.getWrappedView(), bmp);
- }
- } else {
- if (options.shouldShowImageOnLoading()) {
- imageAware.setImageDrawable(options.getImageOnLoading(configuration.resources));
- } else if (options.isResetViewBeforeLoading()) {
- imageAware.setImageDrawable(null);
- }
-
- ImageLoadingInfo imageLoadingInfo = new ImageLoadingInfo(uri, imageAware, targetSize, memoryCacheKey,
- options, listener, progressListener, engine.getLockForUri(uri));
- LoadAndDisplayImageTask displayTask = new LoadAndDisplayImageTask(engine, imageLoadingInfo,
- defineHandler(options));
- if (options.isSyncLoading()) {
- displayTask.run();
- } else {
- engine.submit(displayTask);
- }
- }
- }
-
- /**
- * Adds display image task to execution pool. Image will be set to ImageView when it's turn.
- * Default {@linkplain DisplayImageOptions display image options} from {@linkplain ImageLoaderConfiguration
- * configuration} will be used.
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before this method call
- *
- * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
- * @param imageView {@link ImageView} which should display image
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- * @throws IllegalArgumentException if passed imageView is null
- */
- public void displayImage(String uri, ImageView imageView) {
- displayImage(uri, new ImageViewAware(imageView), null, null, null);
- }
-
- /**
- * Adds display image task to execution pool. Image will be set to ImageView when it's turn.
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before this method call
- *
- * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
- * @param imageView {@link ImageView} which should display image
- * @param options {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions Options} for image
- * decoding and displaying. If null - default display image options
- * {@linkplain ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions)
- * from configuration} will be used.
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- * @throws IllegalArgumentException if passed imageView is null
- */
- public void displayImage(String uri, ImageView imageView, DisplayImageOptions options) {
- displayImage(uri, new ImageViewAware(imageView), options, null, null);
- }
-
- /**
- * Adds display image task to execution pool. Image will be set to ImageView when it's turn.
- * Default {@linkplain DisplayImageOptions display image options} from {@linkplain ImageLoaderConfiguration
- * configuration} will be used.
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before this method call
- *
- * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
- * @param imageView {@link ImageView} which should display image
- * @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener fires events on
- * UI thread if this method is called on UI thread.
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- * @throws IllegalArgumentException if passed imageView is null
- */
- public void displayImage(String uri, ImageView imageView, ImageLoadingListener listener) {
- displayImage(uri, new ImageViewAware(imageView), null, listener, null);
- }
-
- /**
- * Adds display image task to execution pool. Image will be set to ImageView when it's turn.
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before this method call
- *
- * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
- * @param imageView {@link ImageView} which should display image
- * @param options {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions Options} for image
- * decoding and displaying. If null - default display image options
- * {@linkplain ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions)
- * from configuration} will be used.
- * @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener fires events on
- * UI thread if this method is called on UI thread.
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- * @throws IllegalArgumentException if passed imageView is null
- */
- public void displayImage(String uri, ImageView imageView, DisplayImageOptions options,
- ImageLoadingListener listener) {
- displayImage(uri, imageView, options, listener, null);
- }
-
- /**
- * Adds display image task to execution pool. Image will be set to ImageView when it's turn.
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before this method call
- *
- * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
- * @param imageView {@link ImageView} which should display image
- * @param options {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions Options} for image
- * decoding and displaying. If null - default display image options
- * {@linkplain ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions)
- * from configuration} will be used.
- * @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener fires
- * events on UI thread if this method is called on UI thread.
- * @param progressListener {@linkplain com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener
- * Listener} for image loading progress. Listener fires events on UI thread if this method
- * is called on UI thread. Caching on disk should be enabled in
- * {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions options} to make
- * this listener work.
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- * @throws IllegalArgumentException if passed imageView is null
- */
- public void displayImage(String uri, ImageView imageView, DisplayImageOptions options,
- ImageLoadingListener listener, ImageLoadingProgressListener progressListener) {
- displayImage(uri, new ImageViewAware(imageView), options, listener, progressListener);
- }
-
- /**
- * Adds load image task to execution pool. Image will be returned with
- * {@link ImageLoadingListener#onLoadingComplete(String, android.view.View, android.graphics.Bitmap)} callback}.
- *
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before this method call
- *
- * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
- * @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener fires events on UI
- * thread if this method is called on UI thread.
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- */
- public void loadImage(String uri, ImageLoadingListener listener) {
- loadImage(uri, null, null, listener, null);
- }
-
- /**
- * Adds load image task to execution pool. Image will be returned with
- * {@link ImageLoadingListener#onLoadingComplete(String, android.view.View, android.graphics.Bitmap)} callback}.
- *
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before this method call
- *
- * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
- * @param targetImageSize Minimal size for {@link Bitmap} which will be returned in
- * {@linkplain ImageLoadingListener#onLoadingComplete(String, android.view.View,
- * android.graphics.Bitmap)} callback}. Downloaded image will be decoded
- * and scaled to {@link Bitmap} of the size which is equal or larger (usually a bit
- * larger) than incoming targetImageSize.
- * @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener fires
- * events on UI thread if this method is called on UI thread.
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- */
- public void loadImage(String uri, ImageSize targetImageSize, ImageLoadingListener listener) {
- loadImage(uri, targetImageSize, null, listener, null);
- }
-
- /**
- * Adds load image task to execution pool. Image will be returned with
- * {@link ImageLoadingListener#onLoadingComplete(String, android.view.View, android.graphics.Bitmap)} callback}.
- *
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before this method call
- *
- * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
- * @param options {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions Options} for image
- * decoding and displaying. If null - default display image options
- * {@linkplain ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions) from
- * configuration} will be used.
- * @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener fires events on UI
- * thread if this method is called on UI thread.
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- */
- public void loadImage(String uri, DisplayImageOptions options, ImageLoadingListener listener) {
- loadImage(uri, null, options, listener, null);
- }
-
- /**
- * Adds load image task to execution pool. Image will be returned with
- * {@link ImageLoadingListener#onLoadingComplete(String, android.view.View, android.graphics.Bitmap)} callback}.
- *
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before this method call
- *
- * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
- * @param targetImageSize Minimal size for {@link Bitmap} which will be returned in
- * {@linkplain ImageLoadingListener#onLoadingComplete(String, android.view.View,
- * android.graphics.Bitmap)} callback}. Downloaded image will be decoded
- * and scaled to {@link Bitmap} of the size which is equal or larger (usually a bit
- * larger) than incoming targetImageSize.
- * @param options {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions Options} for image
- * decoding and displaying. If null - default display image options
- * {@linkplain ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions)
- * from configuration} will be used.
- * @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener fires
- * events on UI thread if this method is called on UI thread.
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- */
- public void loadImage(String uri, ImageSize targetImageSize, DisplayImageOptions options,
- ImageLoadingListener listener) {
- loadImage(uri, targetImageSize, options, listener, null);
- }
-
- /**
- * Adds load image task to execution pool. Image will be returned with
- * {@link ImageLoadingListener#onLoadingComplete(String, android.view.View, android.graphics.Bitmap)} callback}.
- *
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before this method call
- *
- * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
- * @param targetImageSize Minimal size for {@link Bitmap} which will be returned in
- * {@linkplain ImageLoadingListener#onLoadingComplete(String, android.view.View,
- * android.graphics.Bitmap)} callback}. Downloaded image will be decoded
- * and scaled to {@link Bitmap} of the size which is equal or larger (usually a bit
- * larger) than incoming targetImageSize.
- * @param options {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions Options} for image
- * decoding and displaying. If null - default display image options
- * {@linkplain ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions)
- * from configuration} will be used.
- * @param listener {@linkplain ImageLoadingListener Listener} for image loading process. Listener fires
- * events on UI thread if this method is called on UI thread.
- * @param progressListener {@linkplain com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener
- * Listener} for image loading progress. Listener fires events on UI thread if this method
- * is called on UI thread. Caching on disk should be enabled in
- * {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions options} to make
- * this listener work.
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- */
- public void loadImage(String uri, ImageSize targetImageSize, DisplayImageOptions options,
- ImageLoadingListener listener, ImageLoadingProgressListener progressListener) {
- checkConfiguration();
- if (targetImageSize == null) {
- targetImageSize = configuration.getMaxImageSize();
- }
- if (options == null) {
- options = configuration.defaultDisplayImageOptions;
- }
-
- NonViewAware imageAware = new NonViewAware(uri, targetImageSize, ViewScaleType.CROP);
- displayImage(uri, imageAware, options, listener, progressListener);
- }
-
- /**
- * Loads and decodes image synchronously.
- * Default display image options
- * {@linkplain ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions) from
- * configuration} will be used.
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before this method call
- *
- * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
- * @return Result image Bitmap. Can be null if image loading/decoding was failed or cancelled.
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- */
- public Bitmap loadImageSync(String uri) {
- return loadImageSync(uri, null, null);
- }
-
- /**
- * Loads and decodes image synchronously.
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before this method call
- *
- * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
- * @param options {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions Options} for image
- * decoding and scaling. If null - default display image options
- * {@linkplain ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions) from
- * configuration} will be used.
- * @return Result image Bitmap. Can be null if image loading/decoding was failed or cancelled.
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- */
- public Bitmap loadImageSync(String uri, DisplayImageOptions options) {
- return loadImageSync(uri, null, options);
- }
-
- /**
- * Loads and decodes image synchronously.
- * Default display image options
- * {@linkplain ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions) from
- * configuration} will be used.
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before this method call
- *
- * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
- * @param targetImageSize Minimal size for {@link Bitmap} which will be returned. Downloaded image will be decoded
- * and scaled to {@link Bitmap} of the size which is equal or larger (usually a bit
- * larger) than incoming targetImageSize.
- * @return Result image Bitmap. Can be null if image loading/decoding was failed or cancelled.
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- */
- public Bitmap loadImageSync(String uri, ImageSize targetImageSize) {
- return loadImageSync(uri, targetImageSize, null);
- }
-
- /**
- * Loads and decodes image synchronously.
- * NOTE: {@link #init(ImageLoaderConfiguration)} method must be called before this method call
- *
- * @param uri Image URI (i.e. "http://site.com/image.png", "file:///mnt/sdcard/image.png")
- * @param targetImageSize Minimal size for {@link Bitmap} which will be returned. Downloaded image will be decoded
- * and scaled to {@link Bitmap} of the size which is equal or larger (usually a bit
- * larger) than incoming targetImageSize.
- * @param options {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions Options} for image
- * decoding and scaling. If null - default display image options
- * {@linkplain ImageLoaderConfiguration.Builder#defaultDisplayImageOptions(DisplayImageOptions)
- * from configuration} will be used.
- * @return Result image Bitmap. Can be null if image loading/decoding was failed or cancelled.
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- */
- public Bitmap loadImageSync(String uri, ImageSize targetImageSize, DisplayImageOptions options) {
- if (options == null) {
- options = configuration.defaultDisplayImageOptions;
- }
- options = new DisplayImageOptions.Builder().cloneFrom(options).syncLoading(true).build();
-
- SyncImageLoadingListener listener = new SyncImageLoadingListener();
- loadImage(uri, targetImageSize, options, listener);
- return listener.getLoadedBitmap();
- }
-
- /**
- * Checks if ImageLoader's configuration was initialized
- *
- * @throws IllegalStateException if configuration wasn't initialized
- */
- private void checkConfiguration() {
- if (configuration == null) {
- throw new IllegalStateException(ERROR_NOT_INIT);
- }
- }
-
- /** Sets a default loading listener for all display and loading tasks. */
- public void setDefaultLoadingListener(ImageLoadingListener listener) {
- defaultListener = listener == null ? new SimpleImageLoadingListener() : listener;
- }
-
- /**
- * Returns memory cache
- *
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- */
- public MemoryCache getMemoryCache() {
- checkConfiguration();
- return configuration.memoryCache;
- }
-
- /**
- * Clears memory cache
- *
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- */
- public void clearMemoryCache() {
- checkConfiguration();
- configuration.memoryCache.clear();
- }
-
- /**
- * Returns disk cache
- *
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- * @deprecated Use {@link #getDiskCache()} instead
- */
- @Deprecated
- public DiskCache getDiscCache() {
- return getDiskCache();
- }
-
- /**
- * Returns disk cache
- *
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- */
- public DiskCache getDiskCache() {
- checkConfiguration();
- return configuration.diskCache;
- }
-
- /**
- * Clears disk cache.
- *
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- * @deprecated Use {@link #clearDiskCache()} instead
- */
- @Deprecated
- public void clearDiscCache() {
- clearDiskCache();
- }
-
- /**
- * Clears disk cache.
- *
- * @throws IllegalStateException if {@link #init(ImageLoaderConfiguration)} method wasn't called before
- */
- public void clearDiskCache() {
- checkConfiguration();
- configuration.diskCache.clear();
- }
-
- /**
- * Returns URI of image which is loading at this moment into passed
- * {@link com.nostra13.universalimageloader.core.imageaware.ImageAware ImageAware}
- */
- public String getLoadingUriForView(ImageAware imageAware) {
- return engine.getLoadingUriForView(imageAware);
- }
-
- /**
- * Returns URI of image which is loading at this moment into passed
- * {@link android.widget.ImageView ImageView}
- */
- public String getLoadingUriForView(ImageView imageView) {
- return engine.getLoadingUriForView(new ImageViewAware(imageView));
- }
-
- /**
- * Cancel the task of loading and displaying image for passed
- * {@link com.nostra13.universalimageloader.core.imageaware.ImageAware ImageAware}.
- *
- * @param imageAware {@link com.nostra13.universalimageloader.core.imageaware.ImageAware ImageAware} for
- * which display task will be cancelled
- */
- public void cancelDisplayTask(ImageAware imageAware) {
- engine.cancelDisplayTaskFor(imageAware);
- }
-
- /**
- * Cancel the task of loading and displaying image for passed
- * {@link android.widget.ImageView ImageView}.
- *
- * @param imageView {@link android.widget.ImageView ImageView} for which display task will be cancelled
- */
- public void cancelDisplayTask(ImageView imageView) {
- engine.cancelDisplayTaskFor(new ImageViewAware(imageView));
- }
-
- /**
- * Denies or allows ImageLoader to download images from the network.
- *
- * If downloads are denied and if image isn't cached then
- * {@link ImageLoadingListener#onLoadingFailed(String, View, FailReason)} callback will be fired with
- * {@link FailReason.FailType#NETWORK_DENIED}
- *
- * @param denyNetworkDownloads pass true - to deny engine to download images from the network; false -
- * to allow engine to download images from network.
- */
- public void denyNetworkDownloads(boolean denyNetworkDownloads) {
- engine.denyNetworkDownloads(denyNetworkDownloads);
- }
-
- /**
- * Sets option whether ImageLoader will use {@link FlushedInputStream} for network downloads to handle this known problem or not.
- *
- * @param handleSlowNetwork pass true - to use {@link FlushedInputStream} for network downloads; false
- * - otherwise.
- */
- public void handleSlowNetwork(boolean handleSlowNetwork) {
- engine.handleSlowNetwork(handleSlowNetwork);
- }
-
- /**
- * Pause ImageLoader. All new "load&display" tasks won't be executed until ImageLoader is {@link #resume() resumed}.
- *
- * Already running tasks are not paused.
- */
- public void pause() {
- engine.pause();
- }
-
- /** Resumes waiting "load&display" tasks */
- public void resume() {
- engine.resume();
- }
-
- /**
- * Cancels all running and scheduled display image tasks.
- * NOTE: This method doesn't shutdown
- * {@linkplain com.nostra13.universalimageloader.core.ImageLoaderConfiguration.Builder#taskExecutor(java.util.concurrent.Executor)
- * custom task executors} if you set them.
- * ImageLoader still can be used after calling this method.
- */
- public void stop() {
- engine.stop();
- }
-
- /**
- * {@linkplain #stop() Stops ImageLoader} and clears current configuration.
- * You can {@linkplain #init(ImageLoaderConfiguration) init} ImageLoader with new configuration after calling this
- * method.
- */
- public void destroy() {
- if (configuration != null) L.d(LOG_DESTROY);
- stop();
- configuration.diskCache.close();
- engine = null;
- configuration = null;
- }
-
- private static Handler defineHandler(DisplayImageOptions options) {
- Handler handler = options.getHandler();
- if (options.isSyncLoading()) {
- handler = null;
- } else if (handler == null && Looper.myLooper() == Looper.getMainLooper()) {
- handler = new Handler();
- }
- return handler;
- }
-
- /**
- * Listener which is designed for synchronous image loading.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.9.0
- */
- private static class SyncImageLoadingListener extends SimpleImageLoadingListener {
-
- private Bitmap loadedImage;
-
- @Override
- public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
- this.loadedImage = loadedImage;
- }
-
- public Bitmap getLoadedBitmap() {
- return loadedImage;
- }
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/ImageLoaderConfiguration.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/ImageLoaderConfiguration.java
deleted file mode 100644
index f9f6f74ce..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/ImageLoaderConfiguration.java
+++ /dev/null
@@ -1,655 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.util.DisplayMetrics;
-import com.nostra13.universalimageloader.cache.disc.DiskCache;
-import com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator;
-import com.nostra13.universalimageloader.cache.memory.MemoryCache;
-import com.nostra13.universalimageloader.cache.memory.impl.FuzzyKeyMemoryCache;
-import com.nostra13.universalimageloader.core.assist.FlushedInputStream;
-import com.nostra13.universalimageloader.core.assist.ImageSize;
-import com.nostra13.universalimageloader.core.assist.QueueProcessingType;
-import com.nostra13.universalimageloader.core.decode.ImageDecoder;
-import com.nostra13.universalimageloader.core.download.ImageDownloader;
-import com.nostra13.universalimageloader.core.process.BitmapProcessor;
-import com.nostra13.universalimageloader.utils.L;
-import com.nostra13.universalimageloader.utils.MemoryCacheUtils;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.concurrent.Executor;
-
-/**
- * Presents configuration for {@link ImageLoader}
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @see ImageLoader
- * @see MemoryCache
- * @see DiskCache
- * @see DisplayImageOptions
- * @see ImageDownloader
- * @see FileNameGenerator
- * @since 1.0.0
- */
-public final class ImageLoaderConfiguration {
-
- final Resources resources;
-
- final int maxImageWidthForMemoryCache;
- final int maxImageHeightForMemoryCache;
- final int maxImageWidthForDiskCache;
- final int maxImageHeightForDiskCache;
- final BitmapProcessor processorForDiskCache;
-
- final Executor taskExecutor;
- final Executor taskExecutorForCachedImages;
- final boolean customExecutor;
- final boolean customExecutorForCachedImages;
-
- final int threadPoolSize;
- final int threadPriority;
- final QueueProcessingType tasksProcessingType;
-
- final MemoryCache memoryCache;
- final DiskCache diskCache;
- final ImageDownloader downloader;
- final ImageDecoder decoder;
- final DisplayImageOptions defaultDisplayImageOptions;
-
- final ImageDownloader networkDeniedDownloader;
- final ImageDownloader slowNetworkDownloader;
-
- private ImageLoaderConfiguration(final Builder builder) {
- resources = builder.context.getResources();
- maxImageWidthForMemoryCache = builder.maxImageWidthForMemoryCache;
- maxImageHeightForMemoryCache = builder.maxImageHeightForMemoryCache;
- maxImageWidthForDiskCache = builder.maxImageWidthForDiskCache;
- maxImageHeightForDiskCache = builder.maxImageHeightForDiskCache;
- processorForDiskCache = builder.processorForDiskCache;
- taskExecutor = builder.taskExecutor;
- taskExecutorForCachedImages = builder.taskExecutorForCachedImages;
- threadPoolSize = builder.threadPoolSize;
- threadPriority = builder.threadPriority;
- tasksProcessingType = builder.tasksProcessingType;
- diskCache = builder.diskCache;
- memoryCache = builder.memoryCache;
- defaultDisplayImageOptions = builder.defaultDisplayImageOptions;
- downloader = builder.downloader;
- decoder = builder.decoder;
-
- customExecutor = builder.customExecutor;
- customExecutorForCachedImages = builder.customExecutorForCachedImages;
-
- networkDeniedDownloader = new NetworkDeniedImageDownloader(downloader);
- slowNetworkDownloader = new SlowNetworkImageDownloader(downloader);
-
- L.writeDebugLogs(builder.writeLogs);
- }
-
- /**
- * Creates default configuration for {@link ImageLoader}
- * Default values:
- *
- * - maxImageWidthForMemoryCache = device's screen width
- * - maxImageHeightForMemoryCache = device's screen height
- * - maxImageWidthForDikcCache = unlimited
- * - maxImageHeightForDiskCache = unlimited
- * - threadPoolSize = {@link Builder#DEFAULT_THREAD_POOL_SIZE this}
- * - threadPriority = {@link Builder#DEFAULT_THREAD_PRIORITY this}
- * - allow to cache different sizes of image in memory
- * - memoryCache = {@link DefaultConfigurationFactory#createMemoryCache(android.content.Context, int)}
- * - diskCache = {@link com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache}
- * - imageDownloader = {@link DefaultConfigurationFactory#createImageDownloader(Context)}
- * - imageDecoder = {@link DefaultConfigurationFactory#createImageDecoder(boolean)}
- * - diskCacheFileNameGenerator = {@link DefaultConfigurationFactory#createFileNameGenerator()}
- * - defaultDisplayImageOptions = {@link DisplayImageOptions#createSimple() Simple options}
- * - tasksProcessingOrder = {@link QueueProcessingType#FIFO}
- * - detailed logging disabled
- *
- */
- public static ImageLoaderConfiguration createDefault(Context context) {
- return new Builder(context).build();
- }
-
- ImageSize getMaxImageSize() {
- DisplayMetrics displayMetrics = resources.getDisplayMetrics();
-
- int width = maxImageWidthForMemoryCache;
- if (width <= 0) {
- width = displayMetrics.widthPixels;
- }
- int height = maxImageHeightForMemoryCache;
- if (height <= 0) {
- height = displayMetrics.heightPixels;
- }
- return new ImageSize(width, height);
- }
-
- /**
- * Builder for {@link ImageLoaderConfiguration}
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- */
- public static class Builder {
-
- private static final String WARNING_OVERLAP_DISK_CACHE_PARAMS = "diskCache(), diskCacheSize() and diskCacheFileCount calls overlap each other";
- private static final String WARNING_OVERLAP_DISK_CACHE_NAME_GENERATOR = "diskCache() and diskCacheFileNameGenerator() calls overlap each other";
- private static final String WARNING_OVERLAP_MEMORY_CACHE = "memoryCache() and memoryCacheSize() calls overlap each other";
- private static final String WARNING_OVERLAP_EXECUTOR = "threadPoolSize(), threadPriority() and tasksProcessingOrder() calls "
- + "can overlap taskExecutor() and taskExecutorForCachedImages() calls.";
-
- /** {@value} */
- public static final int DEFAULT_THREAD_POOL_SIZE = 3;
- /** {@value} */
- public static final int DEFAULT_THREAD_PRIORITY = Thread.NORM_PRIORITY - 2;
- /** {@value} */
- public static final QueueProcessingType DEFAULT_TASK_PROCESSING_TYPE = QueueProcessingType.FIFO;
-
- private Context context;
-
- private int maxImageWidthForMemoryCache = 0;
- private int maxImageHeightForMemoryCache = 0;
- private int maxImageWidthForDiskCache = 0;
- private int maxImageHeightForDiskCache = 0;
- private BitmapProcessor processorForDiskCache = null;
-
- private Executor taskExecutor = null;
- private Executor taskExecutorForCachedImages = null;
- private boolean customExecutor = false;
- private boolean customExecutorForCachedImages = false;
-
- private int threadPoolSize = DEFAULT_THREAD_POOL_SIZE;
- private int threadPriority = DEFAULT_THREAD_PRIORITY;
- private boolean denyCacheImageMultipleSizesInMemory = false;
- private QueueProcessingType tasksProcessingType = DEFAULT_TASK_PROCESSING_TYPE;
-
- private int memoryCacheSize = 0;
- private long diskCacheSize = 0;
- private int diskCacheFileCount = 0;
-
- private MemoryCache memoryCache = null;
- private DiskCache diskCache = null;
- private FileNameGenerator diskCacheFileNameGenerator = null;
- private ImageDownloader downloader = null;
- private ImageDecoder decoder;
- private DisplayImageOptions defaultDisplayImageOptions = null;
-
- private boolean writeLogs = false;
-
- public Builder(Context context) {
- this.context = context.getApplicationContext();
- }
-
- /**
- * Sets options for memory cache
- *
- * @param maxImageWidthForMemoryCache Maximum image width which will be used for memory saving during decoding
- * an image to {@link android.graphics.Bitmap Bitmap}. Default value - device's screen width
- * @param maxImageHeightForMemoryCache Maximum image height which will be used for memory saving during decoding
- * an image to {@link android.graphics.Bitmap Bitmap}. Default value - device's screen height
- */
- public Builder memoryCacheExtraOptions(int maxImageWidthForMemoryCache, int maxImageHeightForMemoryCache) {
- this.maxImageWidthForMemoryCache = maxImageWidthForMemoryCache;
- this.maxImageHeightForMemoryCache = maxImageHeightForMemoryCache;
- return this;
- }
-
- /**
- * @deprecated Use
- * {@link #diskCacheExtraOptions(int, int, com.nostra13.universalimageloader.core.process.BitmapProcessor)}
- * instead
- */
- @Deprecated
- public Builder discCacheExtraOptions(int maxImageWidthForDiskCache, int maxImageHeightForDiskCache,
- BitmapProcessor processorForDiskCache) {
- return diskCacheExtraOptions(maxImageWidthForDiskCache, maxImageHeightForDiskCache, processorForDiskCache);
- }
-
- /**
- * Sets options for resizing/compressing of downloaded images before saving to disk cache.
- * NOTE: Use this option only when you have appropriate needs. It can make ImageLoader slower.
- *
- * @param maxImageWidthForDiskCache Maximum width of downloaded images for saving at disk cache
- * @param maxImageHeightForDiskCache Maximum height of downloaded images for saving at disk cache
- * @param processorForDiskCache null-ok; {@linkplain BitmapProcessor Bitmap processor} which process images before saving them in disc cache
- */
- public Builder diskCacheExtraOptions(int maxImageWidthForDiskCache, int maxImageHeightForDiskCache,
- BitmapProcessor processorForDiskCache) {
- this.maxImageWidthForDiskCache = maxImageWidthForDiskCache;
- this.maxImageHeightForDiskCache = maxImageHeightForDiskCache;
- this.processorForDiskCache = processorForDiskCache;
- return this;
- }
-
- /**
- * Sets custom {@linkplain Executor executor} for tasks of loading and displaying images.
- *
- * NOTE: If you set custom executor then following configuration options will not be considered for this
- * executor:
- *
- * - {@link #threadPoolSize(int)}
- * - {@link #threadPriority(int)}
- * - {@link #tasksProcessingOrder(QueueProcessingType)}
- *
- *
- * @see #taskExecutorForCachedImages(Executor)
- */
- public Builder taskExecutor(Executor executor) {
- if (threadPoolSize != DEFAULT_THREAD_POOL_SIZE || threadPriority != DEFAULT_THREAD_PRIORITY || tasksProcessingType != DEFAULT_TASK_PROCESSING_TYPE) {
- L.w(WARNING_OVERLAP_EXECUTOR);
- }
-
- this.taskExecutor = executor;
- return this;
- }
-
- /**
- * Sets custom {@linkplain Executor executor} for tasks of displaying cached on disk images (these tasks
- * are executed quickly so UIL prefer to use separate executor for them).
- *
- * If you set the same executor for {@linkplain #taskExecutor(Executor) general tasks} and
- * tasks about cached images (this method) then these tasks will be in the
- * same thread pool. So short-lived tasks can wait a long time for their turn.
- *
- * NOTE: If you set custom executor then following configuration options will not be considered for this
- * executor:
- *
- * - {@link #threadPoolSize(int)}
- * - {@link #threadPriority(int)}
- * - {@link #tasksProcessingOrder(QueueProcessingType)}
- *
- *
- * @see #taskExecutor(Executor)
- */
- public Builder taskExecutorForCachedImages(Executor executorForCachedImages) {
- if (threadPoolSize != DEFAULT_THREAD_POOL_SIZE || threadPriority != DEFAULT_THREAD_PRIORITY || tasksProcessingType != DEFAULT_TASK_PROCESSING_TYPE) {
- L.w(WARNING_OVERLAP_EXECUTOR);
- }
-
- this.taskExecutorForCachedImages = executorForCachedImages;
- return this;
- }
-
- /**
- * Sets thread pool size for image display tasks.
- * Default value - {@link #DEFAULT_THREAD_POOL_SIZE this}
- */
- public Builder threadPoolSize(int threadPoolSize) {
- if (taskExecutor != null || taskExecutorForCachedImages != null) {
- L.w(WARNING_OVERLAP_EXECUTOR);
- }
-
- this.threadPoolSize = threadPoolSize;
- return this;
- }
-
- /**
- * Sets the priority for image loading threads. Should be NOT greater than {@link Thread#MAX_PRIORITY} or
- * less than {@link Thread#MIN_PRIORITY}
- * Default value - {@link #DEFAULT_THREAD_PRIORITY this}
- */
- public Builder threadPriority(int threadPriority) {
- if (taskExecutor != null || taskExecutorForCachedImages != null) {
- L.w(WARNING_OVERLAP_EXECUTOR);
- }
-
- if (threadPriority < Thread.MIN_PRIORITY) {
- this.threadPriority = Thread.MIN_PRIORITY;
- } else {
- if (threadPriority > Thread.MAX_PRIORITY) {
- this.threadPriority = Thread.MAX_PRIORITY;
- } else {
- this.threadPriority = threadPriority;
- }
- }
- return this;
- }
-
- /**
- * When you display an image in a small {@link android.widget.ImageView ImageView} and later you try to display
- * this image (from identical URI) in a larger {@link android.widget.ImageView ImageView} so decoded image of
- * bigger size will be cached in memory as a previous decoded image of smaller size.
- * So the default behavior is to allow to cache multiple sizes of one image in memory. You can
- * deny it by calling this method: so when some image will be cached in memory then previous
- * cached size of this image (if it exists) will be removed from memory cache before.
- */
- public Builder denyCacheImageMultipleSizesInMemory() {
- this.denyCacheImageMultipleSizesInMemory = true;
- return this;
- }
-
- /**
- * Sets type of queue processing for tasks for loading and displaying images.
- * Default value - {@link QueueProcessingType#FIFO}
- */
- public Builder tasksProcessingOrder(QueueProcessingType tasksProcessingType) {
- if (taskExecutor != null || taskExecutorForCachedImages != null) {
- L.w(WARNING_OVERLAP_EXECUTOR);
- }
-
- this.tasksProcessingType = tasksProcessingType;
- return this;
- }
-
- /**
- * Sets maximum memory cache size for {@link android.graphics.Bitmap bitmaps} (in bytes).
- * Default value - 1/8 of available app memory.
- * NOTE: If you use this method then
- * {@link com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache LruMemoryCache} will be used as
- * memory cache. You can use {@link #memoryCache(MemoryCache)} method to set your own implementation of
- * {@link MemoryCache}.
- */
- public Builder memoryCacheSize(int memoryCacheSize) {
- if (memoryCacheSize <= 0) throw new IllegalArgumentException("memoryCacheSize must be a positive number");
-
- if (memoryCache != null) {
- L.w(WARNING_OVERLAP_MEMORY_CACHE);
- }
-
- this.memoryCacheSize = memoryCacheSize;
- return this;
- }
-
- /**
- * Sets maximum memory cache size (in percent of available app memory) for {@link android.graphics.Bitmap
- * bitmaps}.
- * Default value - 1/8 of available app memory.
- * NOTE: If you use this method then
- * {@link com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache LruMemoryCache} will be used as
- * memory cache. You can use {@link #memoryCache(MemoryCache)} method to set your own implementation of
- * {@link MemoryCache}.
- */
- public Builder memoryCacheSizePercentage(int availableMemoryPercent) {
- if (availableMemoryPercent <= 0 || availableMemoryPercent >= 100) {
- throw new IllegalArgumentException("availableMemoryPercent must be in range (0 < % < 100)");
- }
-
- if (memoryCache != null) {
- L.w(WARNING_OVERLAP_MEMORY_CACHE);
- }
-
- long availableMemory = Runtime.getRuntime().maxMemory();
- memoryCacheSize = (int) (availableMemory * (availableMemoryPercent / 100f));
- return this;
- }
-
- /**
- * Sets memory cache for {@link android.graphics.Bitmap bitmaps}.
- * Default value - {@link com.nostra13.universalimageloader.cache.memory.impl.LruMemoryCache LruMemoryCache}
- * with limited memory cache size (size = 1/8 of available app memory)
- *
- * NOTE: If you set custom memory cache then following configuration option will not be considered:
- *
- * - {@link #memoryCacheSize(int)}
- *
- */
- public Builder memoryCache(MemoryCache memoryCache) {
- if (memoryCacheSize != 0) {
- L.w(WARNING_OVERLAP_MEMORY_CACHE);
- }
-
- this.memoryCache = memoryCache;
- return this;
- }
-
- /** @deprecated Use {@link #diskCacheSize(int)} instead */
- @Deprecated
- public Builder discCacheSize(int maxCacheSize) {
- return diskCacheSize(maxCacheSize);
- }
-
- /**
- * Sets maximum disk cache size for images (in bytes).
- * By default: disk cache is unlimited.
- * NOTE: If you use this method then
- * {@link com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache LruDiskCache}
- * will be used as disk cache. You can use {@link #diskCache(DiskCache)} method for introduction your own
- * implementation of {@link DiskCache}
- */
- public Builder diskCacheSize(int maxCacheSize) {
- if (maxCacheSize <= 0) throw new IllegalArgumentException("maxCacheSize must be a positive number");
-
- if (diskCache != null) {
- L.w(WARNING_OVERLAP_DISK_CACHE_PARAMS);
- }
-
- this.diskCacheSize = maxCacheSize;
- return this;
- }
-
- /** @deprecated Use {@link #diskCacheFileCount(int)} instead */
- @Deprecated
- public Builder discCacheFileCount(int maxFileCount) {
- return diskCacheFileCount(maxFileCount);
- }
-
- /**
- * Sets maximum file count in disk cache directory.
- * By default: disk cache is unlimited.
- * NOTE: If you use this method then
- * {@link com.nostra13.universalimageloader.cache.disc.impl.ext.LruDiskCache LruDiskCache}
- * will be used as disk cache. You can use {@link #diskCache(DiskCache)} method for introduction your own
- * implementation of {@link DiskCache}
- */
- public Builder diskCacheFileCount(int maxFileCount) {
- if (maxFileCount <= 0) throw new IllegalArgumentException("maxFileCount must be a positive number");
-
- if (diskCache != null) {
- L.w(WARNING_OVERLAP_DISK_CACHE_PARAMS);
- }
-
- this.diskCacheFileCount = maxFileCount;
- return this;
- }
-
- /** @deprecated Use {@link #diskCacheFileNameGenerator(com.nostra13.universalimageloader.cache.disc.naming.FileNameGenerator)} */
- @Deprecated
- public Builder discCacheFileNameGenerator(FileNameGenerator fileNameGenerator) {
- return diskCacheFileNameGenerator(fileNameGenerator);
- }
-
- /**
- * Sets name generator for files cached in disk cache.
- * Default value -
- * {@link com.nostra13.universalimageloader.core.DefaultConfigurationFactory#createFileNameGenerator()
- * DefaultConfigurationFactory.createFileNameGenerator()}
- */
- public Builder diskCacheFileNameGenerator(FileNameGenerator fileNameGenerator) {
- if (diskCache != null) {
- L.w(WARNING_OVERLAP_DISK_CACHE_NAME_GENERATOR);
- }
-
- this.diskCacheFileNameGenerator = fileNameGenerator;
- return this;
- }
-
- /** @deprecated Use {@link #diskCache(com.nostra13.universalimageloader.cache.disc.DiskCache)} */
- @Deprecated
- public Builder discCache(DiskCache diskCache) {
- return diskCache(diskCache);
- }
-
- /**
- * Sets disk cache for images.
- * Default value - {@link com.nostra13.universalimageloader.cache.disc.impl.UnlimitedDiskCache
- * UnlimitedDiskCache}. Cache directory is defined by
- * {@link com.nostra13.universalimageloader.utils.StorageUtils#getCacheDirectory(Context)
- * StorageUtils.getCacheDirectory(Context)}.
- *
- * NOTE: If you set custom disk cache then following configuration option will not be considered:
- *
- * - {@link #diskCacheSize(int)}
- * - {@link #diskCacheFileCount(int)}
- * - {@link #diskCacheFileNameGenerator(FileNameGenerator)}
- *
- */
- public Builder diskCache(DiskCache diskCache) {
- if (diskCacheSize > 0 || diskCacheFileCount > 0) {
- L.w(WARNING_OVERLAP_DISK_CACHE_PARAMS);
- }
- if (diskCacheFileNameGenerator != null) {
- L.w(WARNING_OVERLAP_DISK_CACHE_NAME_GENERATOR);
- }
-
- this.diskCache = diskCache;
- return this;
- }
-
- /**
- * Sets utility which will be responsible for downloading of image.
- * Default value -
- * {@link com.nostra13.universalimageloader.core.DefaultConfigurationFactory#createImageDownloader(Context)
- * DefaultConfigurationFactory.createImageDownloader()}
- */
- public Builder imageDownloader(ImageDownloader imageDownloader) {
- this.downloader = imageDownloader;
- return this;
- }
-
- /**
- * Sets utility which will be responsible for decoding of image stream.
- * Default value -
- * {@link com.nostra13.universalimageloader.core.DefaultConfigurationFactory#createImageDecoder(boolean)
- * DefaultConfigurationFactory.createImageDecoder()}
- */
- public Builder imageDecoder(ImageDecoder imageDecoder) {
- this.decoder = imageDecoder;
- return this;
- }
-
- /**
- * Sets default {@linkplain DisplayImageOptions display image options} for image displaying. These options will
- * be used for every {@linkplain ImageLoader#displayImage(String, android.widget.ImageView) image display call}
- * without passing custom {@linkplain DisplayImageOptions options}
- * Default value - {@link DisplayImageOptions#createSimple() Simple options}
- */
- public Builder defaultDisplayImageOptions(DisplayImageOptions defaultDisplayImageOptions) {
- this.defaultDisplayImageOptions = defaultDisplayImageOptions;
- return this;
- }
-
- /**
- * Enables detail logging of {@link ImageLoader} work. To prevent detail logs don't call this method.
- * Consider {@link com.nostra13.universalimageloader.utils.L#disableLogging()} to disable
- * ImageLoader logging completely (even error logs)
- */
- public Builder writeDebugLogs() {
- this.writeLogs = true;
- return this;
- }
-
- /** Builds configured {@link ImageLoaderConfiguration} object */
- public ImageLoaderConfiguration build() {
- initEmptyFieldsWithDefaultValues();
- return new ImageLoaderConfiguration(this);
- }
-
- private void initEmptyFieldsWithDefaultValues() {
- if (taskExecutor == null) {
- taskExecutor = DefaultConfigurationFactory
- .createExecutor(threadPoolSize, threadPriority, tasksProcessingType);
- } else {
- customExecutor = true;
- }
- if (taskExecutorForCachedImages == null) {
- taskExecutorForCachedImages = DefaultConfigurationFactory
- .createExecutor(threadPoolSize, threadPriority, tasksProcessingType);
- } else {
- customExecutorForCachedImages = true;
- }
- if (diskCache == null) {
- if (diskCacheFileNameGenerator == null) {
- diskCacheFileNameGenerator = DefaultConfigurationFactory.createFileNameGenerator();
- }
- diskCache = DefaultConfigurationFactory
- .createDiskCache(context, diskCacheFileNameGenerator, diskCacheSize, diskCacheFileCount);
- }
- if (memoryCache == null) {
- memoryCache = DefaultConfigurationFactory.createMemoryCache(context, memoryCacheSize);
- }
- if (denyCacheImageMultipleSizesInMemory) {
- memoryCache = new FuzzyKeyMemoryCache(memoryCache, MemoryCacheUtils.createFuzzyKeyComparator());
- }
- if (downloader == null) {
- downloader = DefaultConfigurationFactory.createImageDownloader(context);
- }
- if (decoder == null) {
- decoder = DefaultConfigurationFactory.createImageDecoder(writeLogs);
- }
- if (defaultDisplayImageOptions == null) {
- defaultDisplayImageOptions = DisplayImageOptions.createSimple();
- }
- }
- }
-
- /**
- * Decorator. Prevents downloads from network (throws {@link IllegalStateException exception}).
- * In most cases this downloader shouldn't be used directly.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.8.0
- */
- private static class NetworkDeniedImageDownloader implements ImageDownloader {
-
- private final ImageDownloader wrappedDownloader;
-
- public NetworkDeniedImageDownloader(ImageDownloader wrappedDownloader) {
- this.wrappedDownloader = wrappedDownloader;
- }
-
- @Override
- public InputStream getStream(String imageUri, Object extra) throws IOException {
- switch (Scheme.ofUri(imageUri)) {
- case HTTP:
- case HTTPS:
- throw new IllegalStateException();
- default:
- return wrappedDownloader.getStream(imageUri, extra);
- }
- }
- }
-
- /**
- * Decorator. Handles this problem on slow networks
- * using {@link com.nostra13.universalimageloader.core.assist.FlushedInputStream}.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.8.1
- */
- private static class SlowNetworkImageDownloader implements ImageDownloader {
-
- private final ImageDownloader wrappedDownloader;
-
- public SlowNetworkImageDownloader(ImageDownloader wrappedDownloader) {
- this.wrappedDownloader = wrappedDownloader;
- }
-
- @Override
- public InputStream getStream(String imageUri, Object extra) throws IOException {
- InputStream imageStream = wrappedDownloader.getStream(imageUri, extra);
- switch (Scheme.ofUri(imageUri)) {
- case HTTP:
- case HTTPS:
- return new FlushedInputStream(imageStream);
- default:
- return imageStream;
- }
- }
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/ImageLoaderEngine.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/ImageLoaderEngine.java
deleted file mode 100644
index 378ce225f..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/ImageLoaderEngine.java
+++ /dev/null
@@ -1,217 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core;
-
-import android.view.View;
-import com.nostra13.universalimageloader.core.assist.FailReason;
-import com.nostra13.universalimageloader.core.assist.FlushedInputStream;
-import com.nostra13.universalimageloader.core.imageaware.ImageAware;
-import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
-
-import java.io.File;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.WeakHashMap;
-import java.util.concurrent.Executor;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.locks.ReentrantLock;
-
-/**
- * {@link ImageLoader} engine which responsible for {@linkplain LoadAndDisplayImageTask display task} execution.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.7.1
- */
-class ImageLoaderEngine {
-
- final ImageLoaderConfiguration configuration;
-
- private Executor taskExecutor;
- private Executor taskExecutorForCachedImages;
- private Executor taskDistributor;
-
- private final Map cacheKeysForImageAwares = Collections
- .synchronizedMap(new HashMap());
- private final Map uriLocks = new WeakHashMap();
-
- private final AtomicBoolean paused = new AtomicBoolean(false);
- private final AtomicBoolean networkDenied = new AtomicBoolean(false);
- private final AtomicBoolean slowNetwork = new AtomicBoolean(false);
-
- private final Object pauseLock = new Object();
-
- ImageLoaderEngine(ImageLoaderConfiguration configuration) {
- this.configuration = configuration;
-
- taskExecutor = configuration.taskExecutor;
- taskExecutorForCachedImages = configuration.taskExecutorForCachedImages;
-
- taskDistributor = DefaultConfigurationFactory.createTaskDistributor();
- }
-
- /** Submits task to execution pool */
- void submit(final LoadAndDisplayImageTask task) {
- taskDistributor.execute(new Runnable() {
- @Override
- public void run() {
- File image = configuration.diskCache.get(task.getLoadingUri());
- boolean isImageCachedOnDisk = image != null && image.exists();
- initExecutorsIfNeed();
- if (isImageCachedOnDisk) {
- taskExecutorForCachedImages.execute(task);
- } else {
- taskExecutor.execute(task);
- }
- }
- });
- }
-
- /** Submits task to execution pool */
- void submit(ProcessAndDisplayImageTask task) {
- initExecutorsIfNeed();
- taskExecutorForCachedImages.execute(task);
- }
-
- private void initExecutorsIfNeed() {
- if (!configuration.customExecutor && ((ExecutorService) taskExecutor).isShutdown()) {
- taskExecutor = createTaskExecutor();
- }
- if (!configuration.customExecutorForCachedImages && ((ExecutorService) taskExecutorForCachedImages)
- .isShutdown()) {
- taskExecutorForCachedImages = createTaskExecutor();
- }
- }
-
- private Executor createTaskExecutor() {
- return DefaultConfigurationFactory
- .createExecutor(configuration.threadPoolSize, configuration.threadPriority,
- configuration.tasksProcessingType);
- }
-
- /**
- * Returns URI of image which is loading at this moment into passed {@link com.nostra13.universalimageloader.core.imageaware.ImageAware}
- */
- String getLoadingUriForView(ImageAware imageAware) {
- return cacheKeysForImageAwares.get(imageAware.getId());
- }
-
- /**
- * Associates memoryCacheKey with imageAware. Then it helps to define image URI is loaded into View at
- * exact moment.
- */
- void prepareDisplayTaskFor(ImageAware imageAware, String memoryCacheKey) {
- cacheKeysForImageAwares.put(imageAware.getId(), memoryCacheKey);
- }
-
- /**
- * Cancels the task of loading and displaying image for incoming imageAware.
- *
- * @param imageAware {@link com.nostra13.universalimageloader.core.imageaware.ImageAware} for which display task
- * will be cancelled
- */
- void cancelDisplayTaskFor(ImageAware imageAware) {
- cacheKeysForImageAwares.remove(imageAware.getId());
- }
-
- /**
- * Denies or allows engine to download images from the network.
If downloads are denied and if image
- * isn't cached then {@link ImageLoadingListener#onLoadingFailed(String, View, FailReason)} callback will be fired
- * with {@link FailReason.FailType#NETWORK_DENIED}
- *
- * @param denyNetworkDownloads pass true - to deny engine to download images from the network; false -
- * to allow engine to download images from network.
- */
- void denyNetworkDownloads(boolean denyNetworkDownloads) {
- networkDenied.set(denyNetworkDownloads);
- }
-
- /**
- * Sets option whether ImageLoader will use {@link FlushedInputStream} for network downloads to handle this known problem or not.
- *
- * @param handleSlowNetwork pass true - to use {@link FlushedInputStream} for network downloads; false
- * - otherwise.
- */
- void handleSlowNetwork(boolean handleSlowNetwork) {
- slowNetwork.set(handleSlowNetwork);
- }
-
- /**
- * Pauses engine. All new "load&display" tasks won't be executed until ImageLoader is {@link #resume() resumed}.
Already running tasks are not paused.
- */
- void pause() {
- paused.set(true);
- }
-
- /** Resumes engine work. Paused "load&display" tasks will continue its work. */
- void resume() {
- paused.set(false);
- synchronized (pauseLock) {
- pauseLock.notifyAll();
- }
- }
-
- /**
- * Stops engine, cancels all running and scheduled display image tasks. Clears internal data.
- *
- * NOTE: This method doesn't shutdown
- * {@linkplain com.nostra13.universalimageloader.core.ImageLoaderConfiguration.Builder#taskExecutor(java.util.concurrent.Executor)
- * custom task executors} if you set them.
- */
- void stop() {
- if (!configuration.customExecutor) {
- ((ExecutorService) taskExecutor).shutdownNow();
- }
- if (!configuration.customExecutorForCachedImages) {
- ((ExecutorService) taskExecutorForCachedImages).shutdownNow();
- }
-
- cacheKeysForImageAwares.clear();
- uriLocks.clear();
- }
-
- void fireCallback(Runnable r) {
- taskDistributor.execute(r);
- }
-
- ReentrantLock getLockForUri(String uri) {
- ReentrantLock lock = uriLocks.get(uri);
- if (lock == null) {
- lock = new ReentrantLock();
- uriLocks.put(uri, lock);
- }
- return lock;
- }
-
- AtomicBoolean getPause() {
- return paused;
- }
-
- Object getPauseLock() {
- return pauseLock;
- }
-
- boolean isNetworkDenied() {
- return networkDenied.get();
- }
-
- boolean isSlowNetwork() {
- return slowNetwork.get();
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/ImageLoadingInfo.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/ImageLoadingInfo.java
deleted file mode 100644
index 2950fc771..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/ImageLoadingInfo.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2013 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core;
-
-import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
-import com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener;
-import com.nostra13.universalimageloader.core.assist.ImageSize;
-import com.nostra13.universalimageloader.core.imageaware.ImageAware;
-
-import java.util.concurrent.locks.ReentrantLock;
-
-/**
- * Information for load'n'display image task
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @see com.nostra13.universalimageloader.utils.MemoryCacheUtils
- * @see DisplayImageOptions
- * @see ImageLoadingListener
- * @see com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener
- * @since 1.3.1
- */
-final class ImageLoadingInfo {
-
- final String uri;
- final String memoryCacheKey;
- final ImageAware imageAware;
- final ImageSize targetSize;
- final DisplayImageOptions options;
- final ImageLoadingListener listener;
- final ImageLoadingProgressListener progressListener;
- final ReentrantLock loadFromUriLock;
-
- public ImageLoadingInfo(String uri, ImageAware imageAware, ImageSize targetSize, String memoryCacheKey,
- DisplayImageOptions options, ImageLoadingListener listener,
- ImageLoadingProgressListener progressListener, ReentrantLock loadFromUriLock) {
- this.uri = uri;
- this.imageAware = imageAware;
- this.targetSize = targetSize;
- this.options = options;
- this.listener = listener;
- this.progressListener = progressListener;
- this.loadFromUriLock = loadFromUriLock;
- this.memoryCacheKey = memoryCacheKey;
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/LoadAndDisplayImageTask.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/LoadAndDisplayImageTask.java
deleted file mode 100644
index 90a737b41..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/LoadAndDisplayImageTask.java
+++ /dev/null
@@ -1,482 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core;
-
-import android.graphics.Bitmap;
-import android.os.Handler;
-import com.nostra13.universalimageloader.core.assist.FailReason;
-import com.nostra13.universalimageloader.core.assist.FailReason.FailType;
-import com.nostra13.universalimageloader.core.assist.ImageScaleType;
-import com.nostra13.universalimageloader.core.assist.ImageSize;
-import com.nostra13.universalimageloader.core.assist.LoadedFrom;
-import com.nostra13.universalimageloader.core.assist.ViewScaleType;
-import com.nostra13.universalimageloader.core.decode.ImageDecoder;
-import com.nostra13.universalimageloader.core.decode.ImageDecodingInfo;
-import com.nostra13.universalimageloader.core.download.ImageDownloader;
-import com.nostra13.universalimageloader.core.download.ImageDownloader.Scheme;
-import com.nostra13.universalimageloader.core.imageaware.ImageAware;
-import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
-import com.nostra13.universalimageloader.core.listener.ImageLoadingProgressListener;
-import com.nostra13.universalimageloader.utils.IoUtils;
-import com.nostra13.universalimageloader.utils.L;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.locks.ReentrantLock;
-
-/**
- * Presents load'n'display image task. Used to load image from Internet or file system, decode it to {@link Bitmap}, and
- * display it in {@link com.nostra13.universalimageloader.core.imageaware.ImageAware} using {@link DisplayBitmapTask}.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @see ImageLoaderConfiguration
- * @see ImageLoadingInfo
- * @since 1.3.1
- */
-final class LoadAndDisplayImageTask implements Runnable, IoUtils.CopyListener {
-
- private static final String LOG_WAITING_FOR_RESUME = "ImageLoader is paused. Waiting... [%s]";
- private static final String LOG_RESUME_AFTER_PAUSE = ".. Resume loading [%s]";
- private static final String LOG_DELAY_BEFORE_LOADING = "Delay %d ms before loading... [%s]";
- private static final String LOG_START_DISPLAY_IMAGE_TASK = "Start display image task [%s]";
- private static final String LOG_WAITING_FOR_IMAGE_LOADED = "Image already is loading. Waiting... [%s]";
- private static final String LOG_GET_IMAGE_FROM_MEMORY_CACHE_AFTER_WAITING = "...Get cached bitmap from memory after waiting. [%s]";
- private static final String LOG_LOAD_IMAGE_FROM_NETWORK = "Load image from network [%s]";
- private static final String LOG_LOAD_IMAGE_FROM_DISK_CACHE = "Load image from disk cache [%s]";
- private static final String LOG_RESIZE_CACHED_IMAGE_FILE = "Resize image in disk cache [%s]";
- private static final String LOG_PREPROCESS_IMAGE = "PreProcess image before caching in memory [%s]";
- private static final String LOG_POSTPROCESS_IMAGE = "PostProcess image before displaying [%s]";
- private static final String LOG_CACHE_IMAGE_IN_MEMORY = "Cache image in memory [%s]";
- private static final String LOG_CACHE_IMAGE_ON_DISK = "Cache image on disk [%s]";
- private static final String LOG_PROCESS_IMAGE_BEFORE_CACHE_ON_DISK = "Process image before cache on disk [%s]";
- private static final String LOG_TASK_CANCELLED_IMAGEAWARE_REUSED = "ImageAware is reused for another image. Task is cancelled. [%s]";
- private static final String LOG_TASK_CANCELLED_IMAGEAWARE_COLLECTED = "ImageAware was collected by GC. Task is cancelled. [%s]";
- private static final String LOG_TASK_INTERRUPTED = "Task was interrupted [%s]";
-
- private static final String ERROR_NO_IMAGE_STREAM = "No stream for image [%s]";
- private static final String ERROR_PRE_PROCESSOR_NULL = "Pre-processor returned null [%s]";
- private static final String ERROR_POST_PROCESSOR_NULL = "Post-processor returned null [%s]";
- private static final String ERROR_PROCESSOR_FOR_DISK_CACHE_NULL = "Bitmap processor for disk cache returned null [%s]";
-
- private final ImageLoaderEngine engine;
- private final ImageLoadingInfo imageLoadingInfo;
- private final Handler handler;
-
- // Helper references
- private final ImageLoaderConfiguration configuration;
- private final ImageDownloader downloader;
- private final ImageDownloader networkDeniedDownloader;
- private final ImageDownloader slowNetworkDownloader;
- private final ImageDecoder decoder;
- final String uri;
- private final String memoryCacheKey;
- final ImageAware imageAware;
- private final ImageSize targetSize;
- final DisplayImageOptions options;
- final ImageLoadingListener listener;
- final ImageLoadingProgressListener progressListener;
- private final boolean syncLoading;
-
- // State vars
- private LoadedFrom loadedFrom = LoadedFrom.NETWORK;
-
- public LoadAndDisplayImageTask(ImageLoaderEngine engine, ImageLoadingInfo imageLoadingInfo, Handler handler) {
- this.engine = engine;
- this.imageLoadingInfo = imageLoadingInfo;
- this.handler = handler;
-
- configuration = engine.configuration;
- downloader = configuration.downloader;
- networkDeniedDownloader = configuration.networkDeniedDownloader;
- slowNetworkDownloader = configuration.slowNetworkDownloader;
- decoder = configuration.decoder;
- uri = imageLoadingInfo.uri;
- memoryCacheKey = imageLoadingInfo.memoryCacheKey;
- imageAware = imageLoadingInfo.imageAware;
- targetSize = imageLoadingInfo.targetSize;
- options = imageLoadingInfo.options;
- listener = imageLoadingInfo.listener;
- progressListener = imageLoadingInfo.progressListener;
- syncLoading = options.isSyncLoading();
- }
-
- @Override
- public void run() {
- if (waitIfPaused()) return;
- if (delayIfNeed()) return;
-
- ReentrantLock loadFromUriLock = imageLoadingInfo.loadFromUriLock;
- L.d(LOG_START_DISPLAY_IMAGE_TASK, memoryCacheKey);
- if (loadFromUriLock.isLocked()) {
- L.d(LOG_WAITING_FOR_IMAGE_LOADED, memoryCacheKey);
- }
-
- loadFromUriLock.lock();
- Bitmap bmp;
- try {
- checkTaskNotActual();
-
- bmp = configuration.memoryCache.get(memoryCacheKey);
- if (bmp == null || bmp.isRecycled()) {
- bmp = tryLoadBitmap();
- if (bmp == null) return; // listener callback already was fired
-
- checkTaskNotActual();
- checkTaskInterrupted();
-
- if (options.shouldPreProcess()) {
- L.d(LOG_PREPROCESS_IMAGE, memoryCacheKey);
- bmp = options.getPreProcessor().process(bmp);
- if (bmp == null) {
- L.e(ERROR_PRE_PROCESSOR_NULL, memoryCacheKey);
- }
- }
-
- if (bmp != null && options.isCacheInMemory()) {
- L.d(LOG_CACHE_IMAGE_IN_MEMORY, memoryCacheKey);
- configuration.memoryCache.put(memoryCacheKey, bmp);
- }
- } else {
- loadedFrom = LoadedFrom.MEMORY_CACHE;
- L.d(LOG_GET_IMAGE_FROM_MEMORY_CACHE_AFTER_WAITING, memoryCacheKey);
- }
-
- if (bmp != null && options.shouldPostProcess()) {
- L.d(LOG_POSTPROCESS_IMAGE, memoryCacheKey);
- bmp = options.getPostProcessor().process(bmp);
- if (bmp == null) {
- L.e(ERROR_POST_PROCESSOR_NULL, memoryCacheKey);
- }
- }
- checkTaskNotActual();
- checkTaskInterrupted();
- } catch (TaskCancelledException e) {
- fireCancelEvent();
- return;
- } finally {
- loadFromUriLock.unlock();
- }
-
- DisplayBitmapTask displayBitmapTask = new DisplayBitmapTask(bmp, imageLoadingInfo, engine, loadedFrom);
- runTask(displayBitmapTask, syncLoading, handler, engine);
- }
-
- /** @return true - if task should be interrupted; false - otherwise */
- private boolean waitIfPaused() {
- AtomicBoolean pause = engine.getPause();
- if (pause.get()) {
- synchronized (engine.getPauseLock()) {
- if (pause.get()) {
- L.d(LOG_WAITING_FOR_RESUME, memoryCacheKey);
- try {
- engine.getPauseLock().wait();
- } catch (InterruptedException e) {
- L.e(LOG_TASK_INTERRUPTED, memoryCacheKey);
- return true;
- }
- L.d(LOG_RESUME_AFTER_PAUSE, memoryCacheKey);
- }
- }
- }
- return isTaskNotActual();
- }
-
- /** @return true - if task should be interrupted; false - otherwise */
- private boolean delayIfNeed() {
- if (options.shouldDelayBeforeLoading()) {
- L.d(LOG_DELAY_BEFORE_LOADING, options.getDelayBeforeLoading(), memoryCacheKey);
- try {
- Thread.sleep(options.getDelayBeforeLoading());
- } catch (InterruptedException e) {
- L.e(LOG_TASK_INTERRUPTED, memoryCacheKey);
- return true;
- }
- return isTaskNotActual();
- }
- return false;
- }
-
- private Bitmap tryLoadBitmap() throws TaskCancelledException {
- Bitmap bitmap = null;
- try {
- File imageFile = configuration.diskCache.get(uri);
- if (imageFile != null && imageFile.exists() && imageFile.length() > 0) {
- L.d(LOG_LOAD_IMAGE_FROM_DISK_CACHE, memoryCacheKey);
- loadedFrom = LoadedFrom.DISC_CACHE;
-
- checkTaskNotActual();
- bitmap = decodeImage(Scheme.FILE.wrap(imageFile.getAbsolutePath()));
- }
- if (bitmap == null || bitmap.getWidth() <= 0 || bitmap.getHeight() <= 0) {
- L.d(LOG_LOAD_IMAGE_FROM_NETWORK, memoryCacheKey);
- loadedFrom = LoadedFrom.NETWORK;
-
- String imageUriForDecoding = uri;
- if (options.isCacheOnDisk() && tryCacheImageOnDisk()) {
- imageFile = configuration.diskCache.get(uri);
- if (imageFile != null) {
- imageUriForDecoding = Scheme.FILE.wrap(imageFile.getAbsolutePath());
- }
- }
-
- checkTaskNotActual();
- bitmap = decodeImage(imageUriForDecoding);
-
- if (bitmap == null || bitmap.getWidth() <= 0 || bitmap.getHeight() <= 0) {
- fireFailEvent(FailType.DECODING_ERROR, null);
- }
- }
- } catch (IllegalStateException e) {
- fireFailEvent(FailType.NETWORK_DENIED, null);
- } catch (TaskCancelledException e) {
- throw e;
- } catch (IOException e) {
- L.e(e);
- fireFailEvent(FailType.IO_ERROR, e);
- } catch (OutOfMemoryError e) {
- L.e(e);
- fireFailEvent(FailType.OUT_OF_MEMORY, e);
- } catch (Throwable e) {
- L.e(e);
- fireFailEvent(FailType.UNKNOWN, e);
- }
- return bitmap;
- }
-
- private Bitmap decodeImage(String imageUri) throws IOException {
- ViewScaleType viewScaleType = imageAware.getScaleType();
- ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey, imageUri, uri, targetSize, viewScaleType,
- getDownloader(), options);
- return decoder.decode(decodingInfo);
- }
-
- /** @return true - if image was downloaded successfully; false - otherwise */
- private boolean tryCacheImageOnDisk() throws TaskCancelledException {
- L.d(LOG_CACHE_IMAGE_ON_DISK, memoryCacheKey);
-
- boolean loaded;
- try {
- loaded = downloadImage();
- if (loaded) {
- int width = configuration.maxImageWidthForDiskCache;
- int height = configuration.maxImageHeightForDiskCache;
- if (width > 0 || height > 0) {
- L.d(LOG_RESIZE_CACHED_IMAGE_FILE, memoryCacheKey);
- resizeAndSaveImage(width, height); // TODO : process boolean result
- }
- }
- } catch (IOException e) {
- L.e(e);
- loaded = false;
- }
- return loaded;
- }
-
- private boolean downloadImage() throws IOException {
- InputStream is = getDownloader().getStream(uri, options.getExtraForDownloader());
- if (is == null) {
- L.e(ERROR_NO_IMAGE_STREAM, memoryCacheKey);
- return false;
- } else {
- try {
- return configuration.diskCache.save(uri, is, this);
- } finally {
- IoUtils.closeSilently(is);
- }
- }
- }
-
- /** Decodes image file into Bitmap, resize it and save it back */
- private boolean resizeAndSaveImage(int maxWidth, int maxHeight) throws IOException {
- // Decode image file, compress and re-save it
- boolean saved = false;
- File targetFile = configuration.diskCache.get(uri);
- if (targetFile != null && targetFile.exists()) {
- ImageSize targetImageSize = new ImageSize(maxWidth, maxHeight);
- DisplayImageOptions specialOptions = new DisplayImageOptions.Builder().cloneFrom(options)
- .imageScaleType(ImageScaleType.IN_SAMPLE_INT).build();
- ImageDecodingInfo decodingInfo = new ImageDecodingInfo(memoryCacheKey,
- Scheme.FILE.wrap(targetFile.getAbsolutePath()), uri, targetImageSize, ViewScaleType.FIT_INSIDE,
- getDownloader(), specialOptions);
- Bitmap bmp = decoder.decode(decodingInfo);
- if (bmp != null && configuration.processorForDiskCache != null) {
- L.d(LOG_PROCESS_IMAGE_BEFORE_CACHE_ON_DISK, memoryCacheKey);
- bmp = configuration.processorForDiskCache.process(bmp);
- if (bmp == null) {
- L.e(ERROR_PROCESSOR_FOR_DISK_CACHE_NULL, memoryCacheKey);
- }
- }
- if (bmp != null) {
- saved = configuration.diskCache.save(uri, bmp);
- bmp.recycle();
- }
- }
- return saved;
- }
-
- @Override
- public boolean onBytesCopied(int current, int total) {
- return syncLoading || fireProgressEvent(current, total);
- }
-
- /** @return true - if loading should be continued; false - if loading should be interrupted */
- private boolean fireProgressEvent(final int current, final int total) {
- if (isTaskInterrupted() || isTaskNotActual()) return false;
- if (progressListener != null) {
- Runnable r = new Runnable() {
- @Override
- public void run() {
- progressListener.onProgressUpdate(uri, imageAware.getWrappedView(), current, total);
- }
- };
- runTask(r, false, handler, engine);
- }
- return true;
- }
-
- private void fireFailEvent(final FailType failType, final Throwable failCause) {
- if (syncLoading || isTaskInterrupted() || isTaskNotActual()) return;
- Runnable r = new Runnable() {
- @Override
- public void run() {
- if (options.shouldShowImageOnFail()) {
- imageAware.setImageDrawable(options.getImageOnFail(configuration.resources));
- }
- listener.onLoadingFailed(uri, imageAware.getWrappedView(), new FailReason(failType, failCause));
- }
- };
- runTask(r, false, handler, engine);
- }
-
- private void fireCancelEvent() {
- if (syncLoading || isTaskInterrupted()) return;
- Runnable r = new Runnable() {
- @Override
- public void run() {
- listener.onLoadingCancelled(uri, imageAware.getWrappedView());
- }
- };
- runTask(r, false, handler, engine);
- }
-
- private ImageDownloader getDownloader() {
- ImageDownloader d;
- if (engine.isNetworkDenied()) {
- d = networkDeniedDownloader;
- } else if (engine.isSlowNetwork()) {
- d = slowNetworkDownloader;
- } else {
- d = downloader;
- }
- return d;
- }
-
- /**
- * @throws TaskCancelledException if task is not actual (target ImageAware is collected by GC or the image URI of
- * this task doesn't match to image URI which is actual for current ImageAware at
- * this moment)
- */
- private void checkTaskNotActual() throws TaskCancelledException {
- checkViewCollected();
- checkViewReused();
- }
-
- /**
- * @return true - if task is not actual (target ImageAware is collected by GC or the image URI of this task
- * doesn't match to image URI which is actual for current ImageAware at this moment)); false - otherwise
- */
- private boolean isTaskNotActual() {
- return isViewCollected() || isViewReused();
- }
-
- /** @throws TaskCancelledException if target ImageAware is collected */
- private void checkViewCollected() throws TaskCancelledException {
- if (isViewCollected()) {
- throw new TaskCancelledException();
- }
- }
-
- /** @return true - if target ImageAware is collected by GC; false - otherwise */
- private boolean isViewCollected() {
- if (imageAware.isCollected()) {
- L.d(LOG_TASK_CANCELLED_IMAGEAWARE_COLLECTED, memoryCacheKey);
- return true;
- }
- return false;
- }
-
- /** @throws TaskCancelledException if target ImageAware is collected by GC */
- private void checkViewReused() throws TaskCancelledException {
- if (isViewReused()) {
- throw new TaskCancelledException();
- }
- }
-
- /** @return true - if current ImageAware is reused for displaying another image; false - otherwise */
- private boolean isViewReused() {
- String currentCacheKey = engine.getLoadingUriForView(imageAware);
- // Check whether memory cache key (image URI) for current ImageAware is actual.
- // If ImageAware is reused for another task then current task should be cancelled.
- boolean imageAwareWasReused = !memoryCacheKey.equals(currentCacheKey);
- if (imageAwareWasReused) {
- L.d(LOG_TASK_CANCELLED_IMAGEAWARE_REUSED, memoryCacheKey);
- return true;
- }
- return false;
- }
-
- /** @throws TaskCancelledException if current task was interrupted */
- private void checkTaskInterrupted() throws TaskCancelledException {
- if (isTaskInterrupted()) {
- throw new TaskCancelledException();
- }
- }
-
- /** @return true - if current task was interrupted; false - otherwise */
- private boolean isTaskInterrupted() {
- if (Thread.interrupted()) {
- L.d(LOG_TASK_INTERRUPTED, memoryCacheKey);
- return true;
- }
- return false;
- }
-
- String getLoadingUri() {
- return uri;
- }
-
- static void runTask(Runnable r, boolean sync, Handler handler, ImageLoaderEngine engine) {
- if (sync) {
- r.run();
- } else if (handler == null) {
- engine.fireCallback(r);
- } else {
- handler.post(r);
- }
- }
-
- /**
- * Exceptions for case when task is cancelled (thread is interrupted, image view is reused for another task, view is
- * collected by GC).
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.9.1
- */
- class TaskCancelledException extends Exception {
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/ProcessAndDisplayImageTask.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/ProcessAndDisplayImageTask.java
deleted file mode 100644
index d09dc5a3a..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/ProcessAndDisplayImageTask.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core;
-
-import android.graphics.Bitmap;
-import android.os.Handler;
-import android.widget.ImageView;
-import com.nostra13.universalimageloader.core.assist.LoadedFrom;
-import com.nostra13.universalimageloader.core.process.BitmapProcessor;
-import com.nostra13.universalimageloader.utils.L;
-
-/**
- * Presents process'n'display image task. Processes image {@linkplain Bitmap} and display it in {@link ImageView} using
- * {@link DisplayBitmapTask}.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.8.0
- */
-final class ProcessAndDisplayImageTask implements Runnable {
-
- private static final String LOG_POSTPROCESS_IMAGE = "PostProcess image before displaying [%s]";
-
- private final ImageLoaderEngine engine;
- private final Bitmap bitmap;
- private final ImageLoadingInfo imageLoadingInfo;
- private final Handler handler;
-
- public ProcessAndDisplayImageTask(ImageLoaderEngine engine, Bitmap bitmap, ImageLoadingInfo imageLoadingInfo,
- Handler handler) {
- this.engine = engine;
- this.bitmap = bitmap;
- this.imageLoadingInfo = imageLoadingInfo;
- this.handler = handler;
- }
-
- @Override
- public void run() {
- L.d(LOG_POSTPROCESS_IMAGE, imageLoadingInfo.memoryCacheKey);
-
- BitmapProcessor processor = imageLoadingInfo.options.getPostProcessor();
- Bitmap processedBitmap = processor.process(bitmap);
- DisplayBitmapTask displayBitmapTask = new DisplayBitmapTask(processedBitmap, imageLoadingInfo, engine,
- LoadedFrom.MEMORY_CACHE);
- LoadAndDisplayImageTask.runTask(displayBitmapTask, imageLoadingInfo.options.isSyncLoading(), handler, engine);
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/ContentLengthInputStream.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/ContentLengthInputStream.java
deleted file mode 100644
index 316a52d06..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/ContentLengthInputStream.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright 2013-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.assist;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Decorator for {@link java.io.InputStream InputStream}. Provides possibility to return defined stream length by
- * {@link #available()} method.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com), Mariotaku
- * @since 1.9.1
- */
-public class ContentLengthInputStream extends InputStream {
-
- private final InputStream stream;
- private final int length;
-
- public ContentLengthInputStream(InputStream stream, int length) {
- this.stream = stream;
- this.length = length;
- }
-
- @Override
- public int available() {
- return length;
- }
-
- @Override
- public void close() throws IOException {
- stream.close();
- }
-
- @Override
- public void mark(int readLimit) {
- stream.mark(readLimit);
- }
-
- @Override
- public int read() throws IOException {
- return stream.read();
- }
-
- @Override
- public int read(byte[] buffer) throws IOException {
- return stream.read(buffer);
- }
-
- @Override
- public int read(byte[] buffer, int byteOffset, int byteCount) throws IOException {
- return stream.read(buffer, byteOffset, byteCount);
- }
-
- @Override
- public void reset() throws IOException {
- stream.reset();
- }
-
- @Override
- public long skip(long byteCount) throws IOException {
- return stream.skip(byteCount);
- }
-
- @Override
- public boolean markSupported() {
- return stream.markSupported();
- }
-}
\ No newline at end of file
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/FailReason.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/FailReason.java
deleted file mode 100644
index 061acffe1..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/FailReason.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.assist;
-
-/**
- * Presents the reason why image loading and displaying was failed
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.0.0
- */
-public class FailReason {
-
- private final FailType type;
-
- private final Throwable cause;
-
- public FailReason(FailType type, Throwable cause) {
- this.type = type;
- this.cause = cause;
- }
-
- /** @return {@linkplain FailType Fail type} */
- public FailType getType() {
- return type;
- }
-
- /** @return Thrown exception/error, can be null */
- public Throwable getCause() {
- return cause;
- }
-
- /** Presents type of fail while image loading */
- public static enum FailType {
- /** Input/output error. Can be caused by network communication fail or error while caching image on file system. */
- IO_ERROR,
- /**
- * Error while
- * {@linkplain android.graphics.BitmapFactory#decodeStream(java.io.InputStream, android.graphics.Rect, android.graphics.BitmapFactory.Options)
- * decode image to Bitmap}
- */
- DECODING_ERROR,
- /**
- * {@linkplain com.nostra13.universalimageloader.core.ImageLoader#denyNetworkDownloads(boolean) Network
- * downloads are denied} and requested image wasn't cached in disk cache before.
- */
- NETWORK_DENIED,
- /** Not enough memory to create needed Bitmap for image */
- OUT_OF_MEMORY,
- /** Unknown error was occurred while loading image */
- UNKNOWN
- }
-}
\ No newline at end of file
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/FlushedInputStream.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/FlushedInputStream.java
deleted file mode 100644
index b2e450607..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/FlushedInputStream.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package com.nostra13.universalimageloader.core.assist;
-
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Many streams obtained over slow connection show this
- * problem.
- */
-public class FlushedInputStream extends FilterInputStream {
-
- public FlushedInputStream(InputStream inputStream) {
- super(inputStream);
- }
-
- @Override
- public long skip(long n) throws IOException {
- long totalBytesSkipped = 0L;
- while (totalBytesSkipped < n) {
- long bytesSkipped = in.skip(n - totalBytesSkipped);
- if (bytesSkipped == 0L) {
- int by_te = read();
- if (by_te < 0) {
- break; // we reached EOF
- } else {
- bytesSkipped = 1; // we read one byte
- }
- }
- totalBytesSkipped += bytesSkipped;
- }
- return totalBytesSkipped;
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/ImageScaleType.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/ImageScaleType.java
deleted file mode 100644
index 4dfd894e0..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/ImageScaleType.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.assist;
-
-/**
- * Type of image scaling during decoding.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.5.0
- */
-public enum ImageScaleType {
- /** Image won't be scaled */
- NONE,
- /**
- * Image will be scaled down only if image size is greater than
- * {@linkplain javax.microedition.khronos.opengles.GL10#GL_MAX_TEXTURE_SIZE maximum acceptable texture size}.
- * Usually it's 2048x2048.
- * If Bitmap is expected to display than it must not exceed this size (otherwise you'll get the exception
- * "OpenGLRenderer: Bitmap too large to be uploaded into a texture".
- * Image will be subsampled in an integer number of times (1, 2, 3, ...) to maximum texture size of device.
- */
- NONE_SAFE,
- /**
- * Image will be reduces 2-fold until next reduce step make image smaller target size.
- * It's fast type and it's preferable for usage in lists/grids/galleries (and other
- * {@linkplain android.widget.AdapterView adapter-views}) .
- * Relates to {@link android.graphics.BitmapFactory.Options#inSampleSize}
- * Note: If original image size is smaller than target size then original image won't be scaled.
- */
- IN_SAMPLE_POWER_OF_2,
- /**
- * Image will be subsampled in an integer number of times (1, 2, 3, ...). Use it if memory economy is quite
- * important.
- * Relates to {@link android.graphics.BitmapFactory.Options#inSampleSize}
- * Note: If original image size is smaller than target size then original image won't be scaled.
- */
- IN_SAMPLE_INT,
- /**
- * Image will scaled-down exactly to target size (scaled width or height or both will be equal to target size;
- * depends on {@linkplain android.widget.ImageView.ScaleType ImageView's scale type}). Use it if memory economy is
- * critically important.
- * Note: If original image size is smaller than target size then original image won't be scaled.
- *
- * NOTE: For creating result Bitmap (of exact size) additional Bitmap will be created with
- * {@link android.graphics.Bitmap#createBitmap(android.graphics.Bitmap, int, int, int, int, android.graphics.Matrix, boolean)
- * Bitmap.createBitmap(...)}.
- * Cons: Saves memory by keeping smaller Bitmap in memory cache (comparing with IN_SAMPLE... scale types)
- * Pros: Requires more memory in one time for creation of result Bitmap.
- */
- EXACTLY,
- /**
- * Image will scaled exactly to target size (scaled width or height or both will be equal to target size; depends on
- * {@linkplain android.widget.ImageView.ScaleType ImageView's scale type}). Use it if memory economy is critically
- * important.
- * Note: If original image size is smaller than target size then original image will be stretched to
- * target size.
- *
- * NOTE: For creating result Bitmap (of exact size) additional Bitmap will be created with
- * {@link android.graphics.Bitmap#createBitmap(android.graphics.Bitmap, int, int, int, int, android.graphics.Matrix, boolean)
- * Bitmap.createBitmap(...)}.
- * Cons: Saves memory by keeping smaller Bitmap in memory cache (comparing with IN_SAMPLE... scale types)
- * Pros: Requires more memory in one time for creation of result Bitmap.
- */
- EXACTLY_STRETCHED
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/ImageSize.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/ImageSize.java
deleted file mode 100644
index 54c97ca64..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/ImageSize.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2013 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.assist;
-
-/**
- * Present width and height values
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.0.0
- */
-public class ImageSize {
-
- private static final int TO_STRING_MAX_LENGHT = 9; // "9999x9999".length()
- private static final String SEPARATOR = "x";
-
- private final int width;
- private final int height;
-
- public ImageSize(int width, int height) {
- this.width = width;
- this.height = height;
- }
-
- public ImageSize(int width, int height, int rotation) {
- if (rotation % 180 == 0) {
- this.width = width;
- this.height = height;
- } else {
- this.width = height;
- this.height = width;
- }
- }
-
- public int getWidth() {
- return width;
- }
-
- public int getHeight() {
- return height;
- }
-
- /** Scales down dimensions in sampleSize times. Returns new object. */
- public ImageSize scaleDown(int sampleSize) {
- return new ImageSize(width / sampleSize, height / sampleSize);
- }
-
- /** Scales dimensions according to incoming scale. Returns new object. */
- public ImageSize scale(float scale) {
- return new ImageSize((int) (width * scale), (int) (height * scale));
- }
-
- @Override
- public String toString() {
- return new StringBuilder(TO_STRING_MAX_LENGHT).append(width).append(SEPARATOR).append(height).toString();
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/LoadedFrom.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/LoadedFrom.java
deleted file mode 100644
index 6889ce45a..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/LoadedFrom.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.nostra13.universalimageloader.core.assist;
-
-/**
- * Source image loaded from.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- */
-public enum LoadedFrom {
- NETWORK, DISC_CACHE, MEMORY_CACHE
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/QueueProcessingType.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/QueueProcessingType.java
deleted file mode 100644
index 0bbca5868..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/QueueProcessingType.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2013 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.assist;
-
-/**
- * Queue processing type which will be used for display task processing
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.6.3
- */
-public enum QueueProcessingType {
- FIFO, LIFO
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/ViewScaleType.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/ViewScaleType.java
deleted file mode 100644
index c618cfba8..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/ViewScaleType.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2013 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.assist;
-
-import android.widget.ImageView;
-import android.widget.ImageView.ScaleType;
-
-/**
- * Simplify {@linkplain ScaleType ImageView's scale type} to 2 types: {@link #FIT_INSIDE} and {@link #CROP}
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.6.1
- */
-public enum ViewScaleType {
- /**
- * Scale the image uniformly (maintain the image's aspect ratio) so that at least one dimension (width or height) of
- * the image will be equal to or less the corresponding dimension of the view.
- */
- FIT_INSIDE,
- /**
- * Scale the image uniformly (maintain the image's aspect ratio) so that both dimensions (width and height) of the
- * image will be equal to or larger than the corresponding dimension of the view.
- */
- CROP;
-
- /**
- * Defines scale type of ImageView.
- *
- * @param imageView {@link ImageView}
- * @return {@link #FIT_INSIDE} for
- *
- * - {@link ScaleType#FIT_CENTER}
- * - {@link ScaleType#FIT_XY}
- * - {@link ScaleType#FIT_START}
- * - {@link ScaleType#FIT_END}
- * - {@link ScaleType#CENTER_INSIDE}
- *
- * {@link #CROP} for
- *
- * - {@link ScaleType#CENTER}
- * - {@link ScaleType#CENTER_CROP}
- * - {@link ScaleType#MATRIX}
- *
- */
- public static ViewScaleType fromImageView(ImageView imageView) {
- switch (imageView.getScaleType()) {
- case FIT_CENTER:
- case FIT_XY:
- case FIT_START:
- case FIT_END:
- case CENTER_INSIDE:
- return FIT_INSIDE;
- case MATRIX:
- case CENTER:
- case CENTER_CROP:
- default:
- return CROP;
- }
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/deque/BlockingDeque.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/deque/BlockingDeque.java
deleted file mode 100644
index 571eb6ca5..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/deque/BlockingDeque.java
+++ /dev/null
@@ -1,616 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- */
-
-package com.nostra13.universalimageloader.core.assist.deque;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.TimeUnit;
-
-/**
- * A {@link Deque} that additionally supports blocking operations that wait
- * for the deque to become non-empty when retrieving an element, and wait for
- * space to become available in the deque when storing an element.
- *
- * BlockingDeque methods come in four forms, with different ways
- * of handling operations that cannot be satisfied immediately, but may be
- * satisfied at some point in the future:
- * one throws an exception, the second returns a special value (either
- * null or false, depending on the operation), the third
- * blocks the current thread indefinitely until the operation can succeed,
- * and the fourth blocks for only a given maximum time limit before giving
- * up. These methods are summarized in the following table:
- *
- *
- *
- *
- * First Element (Head) |
- *
- *
- * |
- * Throws exception |
- * Special value |
- * Blocks |
- * Times out |
- *
- *
- * Insert |
- * {@link #addFirst addFirst(e)} |
- * {@link #offerFirst offerFirst(e)} |
- * {@link #putFirst putFirst(e)} |
- * {@link #offerFirst offerFirst(e, time, unit)} |
- *
- *
- * Remove |
- * {@link #removeFirst removeFirst()} |
- * {@link #pollFirst pollFirst()} |
- * {@link #takeFirst takeFirst()} |
- * {@link #pollFirst(long, TimeUnit) pollFirst(time, unit)} |
- *
- *
- * Examine |
- * {@link #getFirst getFirst()} |
- * {@link #peekFirst peekFirst()} |
- * not applicable |
- * not applicable |
- *
- *
- * Last Element (Tail) |
- *
- *
- * |
- * Throws exception |
- * Special value |
- * Blocks |
- * Times out |
- *
- *
- * Insert |
- * {@link #addLast addLast(e)} |
- * {@link #offerLast offerLast(e)} |
- * {@link #putLast putLast(e)} |
- * {@link #offerLast offerLast(e, time, unit)} |
- *
- *
- * Remove |
- * {@link #removeLast() removeLast()} |
- * {@link #pollLast() pollLast()} |
- * {@link #takeLast takeLast()} |
- * {@link #pollLast(long, TimeUnit) pollLast(time, unit)} |
- *
- *
- * Examine |
- * {@link #getLast getLast()} |
- * {@link #peekLast peekLast()} |
- * not applicable |
- * not applicable |
- *
- *
- *
- * Like any {@link BlockingQueue}, a BlockingDeque is thread safe,
- * does not permit null elements, and may (or may not) be
- * capacity-constrained.
- *
- *
A BlockingDeque implementation may be used directly as a FIFO
- * BlockingQueue. The methods inherited from the
- * BlockingQueue interface are precisely equivalent to
- * BlockingDeque methods as indicated in the following table:
- *
- *
- *
- *
- * BlockingQueue Method |
- * Equivalent BlockingDeque Method |
- *
- *
- * Insert |
- *
- *
- * {@link #add add(e)} |
- * {@link #addLast addLast(e)} |
- *
- *
- * {@link #offer offer(e)} |
- * {@link #offerLast offerLast(e)} |
- *
- *
- * {@link #put put(e)} |
- * {@link #putLast putLast(e)} |
- *
- *
- * {@link #offer offer(e, time, unit)} |
- * {@link #offerLast offerLast(e, time, unit)} |
- *
- *
- * Remove |
- *
- *
- * {@link #remove() remove()} |
- * {@link #removeFirst() removeFirst()} |
- *
- *
- * {@link #poll() poll()} |
- * {@link #pollFirst() pollFirst()} |
- *
- *
- * {@link #take() take()} |
- * {@link #takeFirst() takeFirst()} |
- *
- *
- * {@link #poll(long, TimeUnit) poll(time, unit)} |
- * {@link #pollFirst(long, TimeUnit) pollFirst(time, unit)} |
- *
- *
- * Examine |
- *
- *
- * {@link #element() element()} |
- * {@link #getFirst() getFirst()} |
- *
- *
- * {@link #peek() peek()} |
- * {@link #peekFirst() peekFirst()} |
- *
- *
- *
- * Memory consistency effects: As with other concurrent
- * collections, actions in a thread prior to placing an object into a
- * {@code BlockingDeque}
- * happen-before
- * actions subsequent to the access or removal of that element from
- * the {@code BlockingDeque} in another thread.
- *
- *
This interface is a member of the
- *
- * Java Collections Framework.
- *
- * @since 1.6
- * @author Doug Lea
- * @param the type of elements held in this collection
- */
-public interface BlockingDeque extends BlockingQueue, Deque {
- /*
- * We have "diamond" multiple interface inheritance here, and that
- * introduces ambiguities. Methods might end up with different
- * specs depending on the branch chosen by javadoc. Thus a lot of
- * methods specs here are copied from superinterfaces.
- */
-
- /**
- * Inserts the specified element at the front of this deque if it is
- * possible to do so immediately without violating capacity restrictions,
- * throwing an IllegalStateException if no space is currently
- * available. When using a capacity-restricted deque, it is generally
- * preferable to use {@link #offerFirst offerFirst}.
- *
- * @param e the element to add
- * @throws IllegalStateException {@inheritDoc}
- * @throws ClassCastException {@inheritDoc}
- * @throws NullPointerException if the specified element is null
- * @throws IllegalArgumentException {@inheritDoc}
- */
- void addFirst(E e);
-
- /**
- * Inserts the specified element at the end of this deque if it is
- * possible to do so immediately without violating capacity restrictions,
- * throwing an IllegalStateException if no space is currently
- * available. When using a capacity-restricted deque, it is generally
- * preferable to use {@link #offerLast offerLast}.
- *
- * @param e the element to add
- * @throws IllegalStateException {@inheritDoc}
- * @throws ClassCastException {@inheritDoc}
- * @throws NullPointerException if the specified element is null
- * @throws IllegalArgumentException {@inheritDoc}
- */
- void addLast(E e);
-
- /**
- * Inserts the specified element at the front of this deque if it is
- * possible to do so immediately without violating capacity restrictions,
- * returning true upon success and false if no space is
- * currently available.
- * When using a capacity-restricted deque, this method is generally
- * preferable to the {@link #addFirst addFirst} method, which can
- * fail to insert an element only by throwing an exception.
- *
- * @param e the element to add
- * @throws ClassCastException {@inheritDoc}
- * @throws NullPointerException if the specified element is null
- * @throws IllegalArgumentException {@inheritDoc}
- */
- boolean offerFirst(E e);
-
- /**
- * Inserts the specified element at the end of this deque if it is
- * possible to do so immediately without violating capacity restrictions,
- * returning true upon success and false if no space is
- * currently available.
- * When using a capacity-restricted deque, this method is generally
- * preferable to the {@link #addLast addLast} method, which can
- * fail to insert an element only by throwing an exception.
- *
- * @param e the element to add
- * @throws ClassCastException {@inheritDoc}
- * @throws NullPointerException if the specified element is null
- * @throws IllegalArgumentException {@inheritDoc}
- */
- boolean offerLast(E e);
-
- /**
- * Inserts the specified element at the front of this deque,
- * waiting if necessary for space to become available.
- *
- * @param e the element to add
- * @throws InterruptedException if interrupted while waiting
- * @throws ClassCastException if the class of the specified element
- * prevents it from being added to this deque
- * @throws NullPointerException if the specified element is null
- * @throws IllegalArgumentException if some property of the specified
- * element prevents it from being added to this deque
- */
- void putFirst(E e) throws InterruptedException;
-
- /**
- * Inserts the specified element at the end of this deque,
- * waiting if necessary for space to become available.
- *
- * @param e the element to add
- * @throws InterruptedException if interrupted while waiting
- * @throws ClassCastException if the class of the specified element
- * prevents it from being added to this deque
- * @throws NullPointerException if the specified element is null
- * @throws IllegalArgumentException if some property of the specified
- * element prevents it from being added to this deque
- */
- void putLast(E e) throws InterruptedException;
-
- /**
- * Inserts the specified element at the front of this deque,
- * waiting up to the specified wait time if necessary for space to
- * become available.
- *
- * @param e the element to add
- * @param timeout how long to wait before giving up, in units of
- * unit
- * @param unit a TimeUnit determining how to interpret the
- * timeout parameter
- * @return true if successful, or false if
- * the specified waiting time elapses before space is available
- * @throws InterruptedException if interrupted while waiting
- * @throws ClassCastException if the class of the specified element
- * prevents it from being added to this deque
- * @throws NullPointerException if the specified element is null
- * @throws IllegalArgumentException if some property of the specified
- * element prevents it from being added to this deque
- */
- boolean offerFirst(E e, long timeout, TimeUnit unit)
- throws InterruptedException;
-
- /**
- * Inserts the specified element at the end of this deque,
- * waiting up to the specified wait time if necessary for space to
- * become available.
- *
- * @param e the element to add
- * @param timeout how long to wait before giving up, in units of
- * unit
- * @param unit a TimeUnit determining how to interpret the
- * timeout parameter
- * @return true if successful, or false if
- * the specified waiting time elapses before space is available
- * @throws InterruptedException if interrupted while waiting
- * @throws ClassCastException if the class of the specified element
- * prevents it from being added to this deque
- * @throws NullPointerException if the specified element is null
- * @throws IllegalArgumentException if some property of the specified
- * element prevents it from being added to this deque
- */
- boolean offerLast(E e, long timeout, TimeUnit unit)
- throws InterruptedException;
-
- /**
- * Retrieves and removes the first element of this deque, waiting
- * if necessary until an element becomes available.
- *
- * @return the head of this deque
- * @throws InterruptedException if interrupted while waiting
- */
- E takeFirst() throws InterruptedException;
-
- /**
- * Retrieves and removes the last element of this deque, waiting
- * if necessary until an element becomes available.
- *
- * @return the tail of this deque
- * @throws InterruptedException if interrupted while waiting
- */
- E takeLast() throws InterruptedException;
-
- /**
- * Retrieves and removes the first element of this deque, waiting
- * up to the specified wait time if necessary for an element to
- * become available.
- *
- * @param timeout how long to wait before giving up, in units of
- * unit
- * @param unit a TimeUnit determining how to interpret the
- * timeout parameter
- * @return the head of this deque, or null if the specified
- * waiting time elapses before an element is available
- * @throws InterruptedException if interrupted while waiting
- */
- E pollFirst(long timeout, TimeUnit unit)
- throws InterruptedException;
-
- /**
- * Retrieves and removes the last element of this deque, waiting
- * up to the specified wait time if necessary for an element to
- * become available.
- *
- * @param timeout how long to wait before giving up, in units of
- * unit
- * @param unit a TimeUnit determining how to interpret the
- * timeout parameter
- * @return the tail of this deque, or null if the specified
- * waiting time elapses before an element is available
- * @throws InterruptedException if interrupted while waiting
- */
- E pollLast(long timeout, TimeUnit unit)
- throws InterruptedException;
-
- /**
- * Removes the first occurrence of the specified element from this deque.
- * If the deque does not contain the element, it is unchanged.
- * More formally, removes the first element e such that
- * o.equals(e) (if such an element exists).
- * Returns true if this deque contained the specified element
- * (or equivalently, if this deque changed as a result of the call).
- *
- * @param o element to be removed from this deque, if present
- * @return true if an element was removed as a result of this call
- * @throws ClassCastException if the class of the specified element
- * is incompatible with this deque (optional)
- * @throws NullPointerException if the specified element is null (optional)
- */
- boolean removeFirstOccurrence(Object o);
-
- /**
- * Removes the last occurrence of the specified element from this deque.
- * If the deque does not contain the element, it is unchanged.
- * More formally, removes the last element e such that
- * o.equals(e) (if such an element exists).
- * Returns true if this deque contained the specified element
- * (or equivalently, if this deque changed as a result of the call).
- *
- * @param o element to be removed from this deque, if present
- * @return true if an element was removed as a result of this call
- * @throws ClassCastException if the class of the specified element
- * is incompatible with this deque (optional)
- * @throws NullPointerException if the specified element is null (optional)
- */
- boolean removeLastOccurrence(Object o);
-
- // *** BlockingQueue methods ***
-
- /**
- * Inserts the specified element into the queue represented by this deque
- * (in other words, at the tail of this deque) if it is possible to do so
- * immediately without violating capacity restrictions, returning
- * true upon success and throwing an
- * IllegalStateException if no space is currently available.
- * When using a capacity-restricted deque, it is generally preferable to
- * use {@link #offer offer}.
- *
- * This method is equivalent to {@link #addLast addLast}.
- *
- * @param e the element to add
- * @throws IllegalStateException {@inheritDoc}
- * @throws ClassCastException if the class of the specified element
- * prevents it from being added to this deque
- * @throws NullPointerException if the specified element is null
- * @throws IllegalArgumentException if some property of the specified
- * element prevents it from being added to this deque
- */
- boolean add(E e);
-
- /**
- * Inserts the specified element into the queue represented by this deque
- * (in other words, at the tail of this deque) if it is possible to do so
- * immediately without violating capacity restrictions, returning
- * true upon success and false if no space is currently
- * available. When using a capacity-restricted deque, this method is
- * generally preferable to the {@link #add} method, which can fail to
- * insert an element only by throwing an exception.
- *
- *
This method is equivalent to {@link #offerLast offerLast}.
- *
- * @param e the element to add
- * @throws ClassCastException if the class of the specified element
- * prevents it from being added to this deque
- * @throws NullPointerException if the specified element is null
- * @throws IllegalArgumentException if some property of the specified
- * element prevents it from being added to this deque
- */
- boolean offer(E e);
-
- /**
- * Inserts the specified element into the queue represented by this deque
- * (in other words, at the tail of this deque), waiting if necessary for
- * space to become available.
- *
- *
This method is equivalent to {@link #putLast putLast}.
- *
- * @param e the element to add
- * @throws InterruptedException {@inheritDoc}
- * @throws ClassCastException if the class of the specified element
- * prevents it from being added to this deque
- * @throws NullPointerException if the specified element is null
- * @throws IllegalArgumentException if some property of the specified
- * element prevents it from being added to this deque
- */
- void put(E e) throws InterruptedException;
-
- /**
- * Inserts the specified element into the queue represented by this deque
- * (in other words, at the tail of this deque), waiting up to the
- * specified wait time if necessary for space to become available.
- *
- *
This method is equivalent to
- * {@link #offerLast offerLast}.
- *
- * @param e the element to add
- * @return true if the element was added to this deque, else
- * false
- * @throws InterruptedException {@inheritDoc}
- * @throws ClassCastException if the class of the specified element
- * prevents it from being added to this deque
- * @throws NullPointerException if the specified element is null
- * @throws IllegalArgumentException if some property of the specified
- * element prevents it from being added to this deque
- */
- boolean offer(E e, long timeout, TimeUnit unit)
- throws InterruptedException;
-
- /**
- * Retrieves and removes the head of the queue represented by this deque
- * (in other words, the first element of this deque).
- * This method differs from {@link #poll poll} only in that it
- * throws an exception if this deque is empty.
- *
- *
This method is equivalent to {@link #removeFirst() removeFirst}.
- *
- * @return the head of the queue represented by this deque
- * @throws NoSuchElementException if this deque is empty
- */
- E remove();
-
- /**
- * Retrieves and removes the head of the queue represented by this deque
- * (in other words, the first element of this deque), or returns
- * null if this deque is empty.
- *
- *
This method is equivalent to {@link #pollFirst()}.
- *
- * @return the head of this deque, or null if this deque is empty
- */
- E poll();
-
- /**
- * Retrieves and removes the head of the queue represented by this deque
- * (in other words, the first element of this deque), waiting if
- * necessary until an element becomes available.
- *
- *
This method is equivalent to {@link #takeFirst() takeFirst}.
- *
- * @return the head of this deque
- * @throws InterruptedException if interrupted while waiting
- */
- E take() throws InterruptedException;
-
- /**
- * Retrieves and removes the head of the queue represented by this deque
- * (in other words, the first element of this deque), waiting up to the
- * specified wait time if necessary for an element to become available.
- *
- *
This method is equivalent to
- * {@link #pollFirst(long,TimeUnit) pollFirst}.
- *
- * @return the head of this deque, or null if the
- * specified waiting time elapses before an element is available
- * @throws InterruptedException if interrupted while waiting
- */
- E poll(long timeout, TimeUnit unit)
- throws InterruptedException;
-
- /**
- * Retrieves, but does not remove, the head of the queue represented by
- * this deque (in other words, the first element of this deque).
- * This method differs from {@link #peek peek} only in that it throws an
- * exception if this deque is empty.
- *
- *
This method is equivalent to {@link #getFirst() getFirst}.
- *
- * @return the head of this deque
- * @throws NoSuchElementException if this deque is empty
- */
- E element();
-
- /**
- * Retrieves, but does not remove, the head of the queue represented by
- * this deque (in other words, the first element of this deque), or
- * returns null if this deque is empty.
- *
- *
This method is equivalent to {@link #peekFirst() peekFirst}.
- *
- * @return the head of this deque, or null if this deque is empty
- */
- E peek();
-
- /**
- * Removes the first occurrence of the specified element from this deque.
- * If the deque does not contain the element, it is unchanged.
- * More formally, removes the first element e such that
- * o.equals(e) (if such an element exists).
- * Returns true if this deque contained the specified element
- * (or equivalently, if this deque changed as a result of the call).
- *
- *
This method is equivalent to
- * {@link #removeFirstOccurrence removeFirstOccurrence}.
- *
- * @param o element to be removed from this deque, if present
- * @return true if this deque changed as a result of the call
- * @throws ClassCastException if the class of the specified element
- * is incompatible with this deque (optional)
- * @throws NullPointerException if the specified element is null (optional)
- */
- boolean remove(Object o);
-
- /**
- * Returns true if this deque contains the specified element.
- * More formally, returns true if and only if this deque contains
- * at least one element e such that o.equals(e).
- *
- * @param o object to be checked for containment in this deque
- * @return true if this deque contains the specified element
- * @throws ClassCastException if the class of the specified element
- * is incompatible with this deque (optional)
- * @throws NullPointerException if the specified element is null (optional)
- */
- public boolean contains(Object o);
-
- /**
- * Returns the number of elements in this deque.
- *
- * @return the number of elements in this deque
- */
- public int size();
-
- /**
- * Returns an iterator over the elements in this deque in proper sequence.
- * The elements will be returned in order from first (head) to last (tail).
- *
- * @return an iterator over the elements in this deque in proper sequence
- */
- Iterator iterator();
-
- // *** Stack methods ***
-
- /**
- * Pushes an element onto the stack represented by this deque. In other
- * words, inserts the element at the front of this deque unless it would
- * violate capacity restrictions.
- *
- * This method is equivalent to {@link #addFirst addFirst}.
- *
- * @throws IllegalStateException {@inheritDoc}
- * @throws ClassCastException {@inheritDoc}
- * @throws NullPointerException if the specified element is null
- * @throws IllegalArgumentException {@inheritDoc}
- */
- void push(E e);
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/deque/Deque.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/deque/Deque.java
deleted file mode 100644
index 1b359ffdf..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/deque/Deque.java
+++ /dev/null
@@ -1,550 +0,0 @@
-/*
- * Written by Doug Lea and Josh Bloch with assistance from members of
- * JCP JSR-166 Expert Group and released to the public domain, as explained
- * at http://creativecommons.org/licenses/publicdomain
- */
-
-package com.nostra13.universalimageloader.core.assist.deque;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Queue;
-import java.util.Stack;
-
-/**
- * A linear collection that supports element insertion and removal at
- * both ends. The name deque is short for "double ended queue"
- * and is usually pronounced "deck". Most Deque
- * implementations place no fixed limits on the number of elements
- * they may contain, but this interface supports capacity-restricted
- * deques as well as those with no fixed size limit.
- *
- *
This interface defines methods to access the elements at both
- * ends of the deque. Methods are provided to insert, remove, and
- * examine the element. Each of these methods exists in two forms:
- * one throws an exception if the operation fails, the other returns a
- * special value (either null or false, depending on
- * the operation). The latter form of the insert operation is
- * designed specifically for use with capacity-restricted
- * Deque implementations; in most implementations, insert
- * operations cannot fail.
- *
- *
The twelve methods described above are summarized in the
- * following table:
- *
- *
- *
- *
- * |
- * First Element (Head) |
- * Last Element (Tail) |
- *
- *
- * |
- * Throws exception |
- * Special value |
- * Throws exception |
- * Special value |
- *
- *
- * Insert |
- * {@link #addFirst addFirst(e)} |
- * {@link #offerFirst offerFirst(e)} |
- * {@link #addLast addLast(e)} |
- * {@link #offerLast offerLast(e)} |
- *
- *
- * Remove |
- * {@link #removeFirst removeFirst()} |
- * {@link #pollFirst pollFirst()} |
- * {@link #removeLast removeLast()} |
- * {@link #pollLast pollLast()} |
- *
- *
- * Examine |
- * {@link #getFirst getFirst()} |
- * {@link #peekFirst peekFirst()} |
- * {@link #getLast getLast()} |
- * {@link #peekLast peekLast()} |
- *
- *
- *
- * This interface extends the {@link Queue} interface. When a deque is
- * used as a queue, FIFO (First-In-First-Out) behavior results. Elements are
- * added at the end of the deque and removed from the beginning. The methods
- * inherited from the Queue interface are precisely equivalent to
- * Deque methods as indicated in the following table:
- *
- *
- *
- *
- * Queue Method |
- * Equivalent Deque Method |
- *
- *
- * {@link java.util.Queue#add add(e)} |
- * {@link #addLast addLast(e)} |
- *
- *
- * {@link java.util.Queue#offer offer(e)} |
- * {@link #offerLast offerLast(e)} |
- *
- *
- * {@link java.util.Queue#remove remove()} |
- * {@link #removeFirst removeFirst()} |
- *
- *
- * {@link java.util.Queue#poll poll()} |
- * {@link #pollFirst pollFirst()} |
- *
- *
- * {@link java.util.Queue#element element()} |
- * {@link #getFirst getFirst()} |
- *
- *
- * {@link java.util.Queue#peek peek()} |
- * {@link #peek peekFirst()} |
- *
- *
- *
- * Deques can also be used as LIFO (Last-In-First-Out) stacks. This
- * interface should be used in preference to the legacy {@link Stack} class.
- * When a deque is used as a stack, elements are pushed and popped from the
- * beginning of the deque. Stack methods are precisely equivalent to
- * Deque methods as indicated in the table below:
- *
- *
- *
- *
- * Stack Method |
- * Equivalent Deque Method |
- *
- *
- * {@link #push push(e)} |
- * {@link #addFirst addFirst(e)} |
- *
- *
- * {@link #pop pop()} |
- * {@link #removeFirst removeFirst()} |
- *
- *
- * {@link #peek peek()} |
- * {@link #peekFirst peekFirst()} |
- *
- *
- *
- * Note that the {@link #peek peek} method works equally well when
- * a deque is used as a queue or a stack; in either case, elements are
- * drawn from the beginning of the deque.
- *
- *
This interface provides two methods to remove interior
- * elements, {@link #removeFirstOccurrence removeFirstOccurrence} and
- * {@link #removeLastOccurrence removeLastOccurrence}.
- *
- *
Unlike the {@link List} interface, this interface does not
- * provide support for indexed access to elements.
- *
- *
While Deque implementations are not strictly required
- * to prohibit the insertion of null elements, they are strongly
- * encouraged to do so. Users of any Deque implementations
- * that do allow null elements are strongly encouraged not to
- * take advantage of the ability to insert nulls. This is so because
- * null is used as a special return value by various methods
- * to indicated that the deque is empty.
- *
- *
Deque implementations generally do not define
- * element-based versions of the equals and hashCode
- * methods, but instead inherit the identity-based versions from class
- * Object.
- *
- * @author Doug Lea
- * @author Josh Bloch
- * @since 1.6
- * @param the type of elements held in this collection
- */
-
-public interface Deque extends Queue {
- /**
- * Inserts the specified element at the front of this deque if it is
- * possible to do so immediately without violating capacity restrictions.
- * When using a capacity-restricted deque, it is generally preferable to
- * use method {@link #offerFirst}.
- *
- * @param e the element to add
- * @throws IllegalStateException if the element cannot be added at this
- * time due to capacity restrictions
- * @throws ClassCastException if the class of the specified element
- * prevents it from being added to this deque
- * @throws NullPointerException if the specified element is null and this
- * deque does not permit null elements
- * @throws IllegalArgumentException if some property of the specified
- * element prevents it from being added to this deque
- */
- void addFirst(E e);
-
- /**
- * Inserts the specified element at the end of this deque if it is
- * possible to do so immediately without violating capacity restrictions.
- * When using a capacity-restricted deque, it is generally preferable to
- * use method {@link #offerLast}.
- *
- * This method is equivalent to {@link #add}.
- *
- * @param e the element to add
- * @throws IllegalStateException if the element cannot be added at this
- * time due to capacity restrictions
- * @throws ClassCastException if the class of the specified element
- * prevents it from being added to this deque
- * @throws NullPointerException if the specified element is null and this
- * deque does not permit null elements
- * @throws IllegalArgumentException if some property of the specified
- * element prevents it from being added to this deque
- */
- void addLast(E e);
-
- /**
- * Inserts the specified element at the front of this deque unless it would
- * violate capacity restrictions. When using a capacity-restricted deque,
- * this method is generally preferable to the {@link #addFirst} method,
- * which can fail to insert an element only by throwing an exception.
- *
- * @param e the element to add
- * @return true if the element was added to this deque, else
- * false
- * @throws ClassCastException if the class of the specified element
- * prevents it from being added to this deque
- * @throws NullPointerException if the specified element is null and this
- * deque does not permit null elements
- * @throws IllegalArgumentException if some property of the specified
- * element prevents it from being added to this deque
- */
- boolean offerFirst(E e);
-
- /**
- * Inserts the specified element at the end of this deque unless it would
- * violate capacity restrictions. When using a capacity-restricted deque,
- * this method is generally preferable to the {@link #addLast} method,
- * which can fail to insert an element only by throwing an exception.
- *
- * @param e the element to add
- * @return true if the element was added to this deque, else
- * false
- * @throws ClassCastException if the class of the specified element
- * prevents it from being added to this deque
- * @throws NullPointerException if the specified element is null and this
- * deque does not permit null elements
- * @throws IllegalArgumentException if some property of the specified
- * element prevents it from being added to this deque
- */
- boolean offerLast(E e);
-
- /**
- * Retrieves and removes the first element of this deque. This method
- * differs from {@link #pollFirst pollFirst} only in that it throws an
- * exception if this deque is empty.
- *
- * @return the head of this deque
- * @throws NoSuchElementException if this deque is empty
- */
- E removeFirst();
-
- /**
- * Retrieves and removes the last element of this deque. This method
- * differs from {@link #pollLast pollLast} only in that it throws an
- * exception if this deque is empty.
- *
- * @return the tail of this deque
- * @throws NoSuchElementException if this deque is empty
- */
- E removeLast();
-
- /**
- * Retrieves and removes the first element of this deque,
- * or returns null if this deque is empty.
- *
- * @return the head of this deque, or null if this deque is empty
- */
- E pollFirst();
-
- /**
- * Retrieves and removes the last element of this deque,
- * or returns null if this deque is empty.
- *
- * @return the tail of this deque, or null if this deque is empty
- */
- E pollLast();
-
- /**
- * Retrieves, but does not remove, the first element of this deque.
- *
- * This method differs from {@link #peekFirst peekFirst} only in that it
- * throws an exception if this deque is empty.
- *
- * @return the head of this deque
- * @throws NoSuchElementException if this deque is empty
- */
- E getFirst();
-
- /**
- * Retrieves, but does not remove, the last element of this deque.
- * This method differs from {@link #peekLast peekLast} only in that it
- * throws an exception if this deque is empty.
- *
- * @return the tail of this deque
- * @throws NoSuchElementException if this deque is empty
- */
- E getLast();
-
- /**
- * Retrieves, but does not remove, the first element of this deque,
- * or returns null if this deque is empty.
- *
- * @return the head of this deque, or null if this deque is empty
- */
- E peekFirst();
-
- /**
- * Retrieves, but does not remove, the last element of this deque,
- * or returns null if this deque is empty.
- *
- * @return the tail of this deque, or null if this deque is empty
- */
- E peekLast();
-
- /**
- * Removes the first occurrence of the specified element from this deque.
- * If the deque does not contain the element, it is unchanged.
- * More formally, removes the first element e such that
- * (o==null ? e==null : o.equals(e))
- * (if such an element exists).
- * Returns true if this deque contained the specified element
- * (or equivalently, if this deque changed as a result of the call).
- *
- * @param o element to be removed from this deque, if present
- * @return true if an element was removed as a result of this call
- * @throws ClassCastException if the class of the specified element
- * is incompatible with this deque (optional)
- * @throws NullPointerException if the specified element is null and this
- * deque does not permit null elements (optional)
- */
- boolean removeFirstOccurrence(Object o);
-
- /**
- * Removes the last occurrence of the specified element from this deque.
- * If the deque does not contain the element, it is unchanged.
- * More formally, removes the last element e such that
- * (o==null ? e==null : o.equals(e))
- * (if such an element exists).
- * Returns true if this deque contained the specified element
- * (or equivalently, if this deque changed as a result of the call).
- *
- * @param o element to be removed from this deque, if present
- * @return true if an element was removed as a result of this call
- * @throws ClassCastException if the class of the specified element
- * is incompatible with this deque (optional)
- * @throws NullPointerException if the specified element is null and this
- * deque does not permit null elements (optional)
- */
- boolean removeLastOccurrence(Object o);
-
- // *** Queue methods ***
-
- /**
- * Inserts the specified element into the queue represented by this deque
- * (in other words, at the tail of this deque) if it is possible to do so
- * immediately without violating capacity restrictions, returning
- * true upon success and throwing an
- * IllegalStateException if no space is currently available.
- * When using a capacity-restricted deque, it is generally preferable to
- * use {@link #offer offer}.
- *
- *
This method is equivalent to {@link #addLast}.
- *
- * @param e the element to add
- * @return true (as specified by {@link Collection#add})
- * @throws IllegalStateException if the element cannot be added at this
- * time due to capacity restrictions
- * @throws ClassCastException if the class of the specified element
- * prevents it from being added to this deque
- * @throws NullPointerException if the specified element is null and this
- * deque does not permit null elements
- * @throws IllegalArgumentException if some property of the specified
- * element prevents it from being added to this deque
- */
- boolean add(E e);
-
- /**
- * Inserts the specified element into the queue represented by this deque
- * (in other words, at the tail of this deque) if it is possible to do so
- * immediately without violating capacity restrictions, returning
- * true upon success and false if no space is currently
- * available. When using a capacity-restricted deque, this method is
- * generally preferable to the {@link #add} method, which can fail to
- * insert an element only by throwing an exception.
- *
- *
This method is equivalent to {@link #offerLast}.
- *
- * @param e the element to add
- * @return true if the element was added to this deque, else
- * false
- * @throws ClassCastException if the class of the specified element
- * prevents it from being added to this deque
- * @throws NullPointerException if the specified element is null and this
- * deque does not permit null elements
- * @throws IllegalArgumentException if some property of the specified
- * element prevents it from being added to this deque
- */
- boolean offer(E e);
-
- /**
- * Retrieves and removes the head of the queue represented by this deque
- * (in other words, the first element of this deque).
- * This method differs from {@link #poll poll} only in that it throws an
- * exception if this deque is empty.
- *
- *
This method is equivalent to {@link #removeFirst()}.
- *
- * @return the head of the queue represented by this deque
- * @throws NoSuchElementException if this deque is empty
- */
- E remove();
-
- /**
- * Retrieves and removes the head of the queue represented by this deque
- * (in other words, the first element of this deque), or returns
- * null if this deque is empty.
- *
- *
This method is equivalent to {@link #pollFirst()}.
- *
- * @return the first element of this deque, or null if
- * this deque is empty
- */
- E poll();
-
- /**
- * Retrieves, but does not remove, the head of the queue represented by
- * this deque (in other words, the first element of this deque).
- * This method differs from {@link #peek peek} only in that it throws an
- * exception if this deque is empty.
- *
- *
This method is equivalent to {@link #getFirst()}.
- *
- * @return the head of the queue represented by this deque
- * @throws NoSuchElementException if this deque is empty
- */
- E element();
-
- /**
- * Retrieves, but does not remove, the head of the queue represented by
- * this deque (in other words, the first element of this deque), or
- * returns null if this deque is empty.
- *
- *
This method is equivalent to {@link #peekFirst()}.
- *
- * @return the head of the queue represented by this deque, or
- * null if this deque is empty
- */
- E peek();
-
-
- // *** Stack methods ***
-
- /**
- * Pushes an element onto the stack represented by this deque (in other
- * words, at the head of this deque) if it is possible to do so
- * immediately without violating capacity restrictions, returning
- * true upon success and throwing an
- * IllegalStateException if no space is currently available.
- *
- *
This method is equivalent to {@link #addFirst}.
- *
- * @param e the element to push
- * @throws IllegalStateException if the element cannot be added at this
- * time due to capacity restrictions
- * @throws ClassCastException if the class of the specified element
- * prevents it from being added to this deque
- * @throws NullPointerException if the specified element is null and this
- * deque does not permit null elements
- * @throws IllegalArgumentException if some property of the specified
- * element prevents it from being added to this deque
- */
- void push(E e);
-
- /**
- * Pops an element from the stack represented by this deque. In other
- * words, removes and returns the first element of this deque.
- *
- *
This method is equivalent to {@link #removeFirst()}.
- *
- * @return the element at the front of this deque (which is the top
- * of the stack represented by this deque)
- * @throws NoSuchElementException if this deque is empty
- */
- E pop();
-
-
- // *** Collection methods ***
-
- /**
- * Removes the first occurrence of the specified element from this deque.
- * If the deque does not contain the element, it is unchanged.
- * More formally, removes the first element e such that
- * (o==null ? e==null : o.equals(e))
- * (if such an element exists).
- * Returns true if this deque contained the specified element
- * (or equivalently, if this deque changed as a result of the call).
- *
- *
This method is equivalent to {@link #removeFirstOccurrence}.
- *
- * @param o element to be removed from this deque, if present
- * @return true if an element was removed as a result of this call
- * @throws ClassCastException if the class of the specified element
- * is incompatible with this deque (optional)
- * @throws NullPointerException if the specified element is null and this
- * deque does not permit null elements (optional)
- */
- boolean remove(Object o);
-
- /**
- * Returns true if this deque contains the specified element.
- * More formally, returns true if and only if this deque contains
- * at least one element e such that
- * (o==null ? e==null : o.equals(e)).
- *
- * @param o element whose presence in this deque is to be tested
- * @return true if this deque contains the specified element
- * @throws ClassCastException if the type of the specified element
- * is incompatible with this deque (optional)
- * @throws NullPointerException if the specified element is null and this
- * deque does not permit null elements (optional)
- */
- boolean contains(Object o);
-
- /**
- * Returns the number of elements in this deque.
- *
- * @return the number of elements in this deque
- */
- public int size();
-
- /**
- * Returns an iterator over the elements in this deque in proper sequence.
- * The elements will be returned in order from first (head) to last (tail).
- *
- * @return an iterator over the elements in this deque in proper sequence
- */
- Iterator iterator();
-
- /**
- * Returns an iterator over the elements in this deque in reverse
- * sequential order. The elements will be returned in order from
- * last (tail) to first (head).
- *
- * @return an iterator over the elements in this deque in reverse
- * sequence
- */
- Iterator descendingIterator();
-
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/deque/LIFOLinkedBlockingDeque.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/deque/LIFOLinkedBlockingDeque.java
deleted file mode 100644
index 0a2cf02c8..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/deque/LIFOLinkedBlockingDeque.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.nostra13.universalimageloader.core.assist.deque;
-
-import java.util.NoSuchElementException;
-
-/**
- * {@link LinkedBlockingDeque} using LIFO algorithm
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.6.3
- */
-public class LIFOLinkedBlockingDeque extends LinkedBlockingDeque {
-
- private static final long serialVersionUID = -4114786347960826192L;
-
- /**
- * Inserts the specified element at the front of this deque if it is possible to do so immediately without violating
- * capacity restrictions, returning true upon success and false if no space is currently
- * available. When using a capacity-restricted deque, this method is generally preferable to the {@link #addFirst
- * addFirst} method, which can fail to insert an element only by throwing an exception.
- *
- * @param e
- * the element to add
- * @throws ClassCastException
- * {@inheritDoc}
- * @throws NullPointerException
- * if the specified element is null
- * @throws IllegalArgumentException
- * {@inheritDoc}
- */
- @Override
- public boolean offer(T e) {
- return super.offerFirst(e);
- }
-
- /**
- * Retrieves and removes the first element of this deque. This method differs from {@link #pollFirst pollFirst} only
- * in that it throws an exception if this deque is empty.
- *
- * @return the head of this deque
- * @throws NoSuchElementException
- * if this deque is empty
- */
- @Override
- public T remove() {
- return super.removeFirst();
- }
-}
\ No newline at end of file
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/deque/LinkedBlockingDeque.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/deque/LinkedBlockingDeque.java
deleted file mode 100644
index 75d6994fa..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/assist/deque/LinkedBlockingDeque.java
+++ /dev/null
@@ -1,1169 +0,0 @@
-/*
- * Written by Doug Lea with assistance from members of JCP JSR-166
- * Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
- */
-
-package com.nostra13.universalimageloader.core.assist.deque;
-
-import java.util.AbstractQueue;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.locks.Condition;
-import java.util.concurrent.locks.ReentrantLock;
-
-/**
- * An optionally-bounded {@linkplain BlockingDeque blocking deque} based on
- * linked nodes.
- *
- * The optional capacity bound constructor argument serves as a
- * way to prevent excessive expansion. The capacity, if unspecified,
- * is equal to {@link Integer#MAX_VALUE}. Linked nodes are
- * dynamically created upon each insertion unless this would bring the
- * deque above capacity.
- *
- *
Most operations run in constant time (ignoring time spent
- * blocking). Exceptions include {@link #remove(Object) remove},
- * {@link #removeFirstOccurrence removeFirstOccurrence}, {@link
- * #removeLastOccurrence removeLastOccurrence}, {@link #contains
- * contains}, {@link #iterator iterator.remove()}, and the bulk
- * operations, all of which run in linear time.
- *
- *
This class and its iterator implement all of the
- * optional methods of the {@link Collection} and {@link
- * Iterator} interfaces.
- *
- *
This class is a member of the
- *
- * Java Collections Framework.
- *
- * @since 1.6
- * @author Doug Lea
- * @param the type of elements held in this collection
- */
-public class LinkedBlockingDeque
- extends AbstractQueue
- implements BlockingDeque, java.io.Serializable {
-
- /*
- * Implemented as a simple doubly-linked list protected by a
- * single lock and using conditions to manage blocking.
- *
- * To implement weakly consistent iterators, it appears we need to
- * keep all Nodes GC-reachable from a predecessor dequeued Node.
- * That would cause two problems:
- * - allow a rogue Iterator to cause unbounded memory retention
- * - cause cross-generational linking of old Nodes to new Nodes if
- * a Node was tenured while live, which generational GCs have a
- * hard time dealing with, causing repeated major collections.
- * However, only non-deleted Nodes need to be reachable from
- * dequeued Nodes, and reachability does not necessarily have to
- * be of the kind understood by the GC. We use the trick of
- * linking a Node that has just been dequeued to itself. Such a
- * self-link implicitly means to jump to "first" (for next links)
- * or "last" (for prev links).
- */
-
- /*
- * We have "diamond" multiple interface/abstract class inheritance
- * here, and that introduces ambiguities. Often we want the
- * BlockingDeque javadoc combined with the AbstractQueue
- * implementation, so a lot of method specs are duplicated here.
- */
-
- private static final long serialVersionUID = -387911632671998426L;
-
- /** Doubly-linked list node class */
- static final class Node {
- /**
- * The item, or null if this node has been removed.
- */
- E item;
-
- /**
- * One of:
- * - the real predecessor Node
- * - this Node, meaning the predecessor is tail
- * - null, meaning there is no predecessor
- */
- Node prev;
-
- /**
- * One of:
- * - the real successor Node
- * - this Node, meaning the successor is head
- * - null, meaning there is no successor
- */
- Node next;
-
- Node(E x) {
- item = x;
- }
- }
-
- /**
- * Pointer to first node.
- * Invariant: (first == null && last == null) ||
- * (first.prev == null && first.item != null)
- */
- transient Node first;
-
- /**
- * Pointer to last node.
- * Invariant: (first == null && last == null) ||
- * (last.next == null && last.item != null)
- */
- transient Node last;
-
- /** Number of items in the deque */
- private transient int count;
-
- /** Maximum number of items in the deque */
- private final int capacity;
-
- /** Main lock guarding all access */
- final ReentrantLock lock = new ReentrantLock();
-
- /** Condition for waiting takes */
- private final Condition notEmpty = lock.newCondition();
-
- /** Condition for waiting puts */
- private final Condition notFull = lock.newCondition();
-
- /**
- * Creates a {@code LinkedBlockingDeque} with a capacity of
- * {@link Integer#MAX_VALUE}.
- */
- public LinkedBlockingDeque() {
- this(Integer.MAX_VALUE);
- }
-
- /**
- * Creates a {@code LinkedBlockingDeque} with the given (fixed) capacity.
- *
- * @param capacity the capacity of this deque
- * @throws IllegalArgumentException if {@code capacity} is less than 1
- */
- public LinkedBlockingDeque(int capacity) {
- if (capacity <= 0) throw new IllegalArgumentException();
- this.capacity = capacity;
- }
-
- /**
- * Creates a {@code LinkedBlockingDeque} with a capacity of
- * {@link Integer#MAX_VALUE}, initially containing the elements of
- * the given collection, added in traversal order of the
- * collection's iterator.
- *
- * @param c the collection of elements to initially contain
- * @throws NullPointerException if the specified collection or any
- * of its elements are null
- */
- public LinkedBlockingDeque(Collection extends E> c) {
- this(Integer.MAX_VALUE);
- final ReentrantLock lock = this.lock;
- lock.lock(); // Never contended, but necessary for visibility
- try {
- for (E e : c) {
- if (e == null)
- throw new NullPointerException();
- if (!linkLast(new Node(e)))
- throw new IllegalStateException("Deque full");
- }
- } finally {
- lock.unlock();
- }
- }
-
-
- // Basic linking and unlinking operations, called only while holding lock
-
- /**
- * Links node as first element, or returns false if full.
- */
- private boolean linkFirst(Node node) {
- // assert lock.isHeldByCurrentThread();
- if (count >= capacity)
- return false;
- Node f = first;
- node.next = f;
- first = node;
- if (last == null)
- last = node;
- else
- f.prev = node;
- ++count;
- notEmpty.signal();
- return true;
- }
-
- /**
- * Links node as last element, or returns false if full.
- */
- private boolean linkLast(Node node) {
- // assert lock.isHeldByCurrentThread();
- if (count >= capacity)
- return false;
- Node l = last;
- node.prev = l;
- last = node;
- if (first == null)
- first = node;
- else
- l.next = node;
- ++count;
- notEmpty.signal();
- return true;
- }
-
- /**
- * Removes and returns first element, or null if empty.
- */
- private E unlinkFirst() {
- // assert lock.isHeldByCurrentThread();
- Node f = first;
- if (f == null)
- return null;
- Node n = f.next;
- E item = f.item;
- f.item = null;
- f.next = f; // help GC
- first = n;
- if (n == null)
- last = null;
- else
- n.prev = null;
- --count;
- notFull.signal();
- return item;
- }
-
- /**
- * Removes and returns last element, or null if empty.
- */
- private E unlinkLast() {
- // assert lock.isHeldByCurrentThread();
- Node l = last;
- if (l == null)
- return null;
- Node p = l.prev;
- E item = l.item;
- l.item = null;
- l.prev = l; // help GC
- last = p;
- if (p == null)
- first = null;
- else
- p.next = null;
- --count;
- notFull.signal();
- return item;
- }
-
- /**
- * Unlinks x.
- */
- void unlink(Node x) {
- // assert lock.isHeldByCurrentThread();
- Node p = x.prev;
- Node n = x.next;
- if (p == null) {
- unlinkFirst();
- } else if (n == null) {
- unlinkLast();
- } else {
- p.next = n;
- n.prev = p;
- x.item = null;
- // Don't mess with x's links. They may still be in use by
- // an iterator.
- --count;
- notFull.signal();
- }
- }
-
- // BlockingDeque methods
-
- /**
- * @throws IllegalStateException {@inheritDoc}
- * @throws NullPointerException {@inheritDoc}
- */
- public void addFirst(E e) {
- if (!offerFirst(e))
- throw new IllegalStateException("Deque full");
- }
-
- /**
- * @throws IllegalStateException {@inheritDoc}
- * @throws NullPointerException {@inheritDoc}
- */
- public void addLast(E e) {
- if (!offerLast(e))
- throw new IllegalStateException("Deque full");
- }
-
- /**
- * @throws NullPointerException {@inheritDoc}
- */
- public boolean offerFirst(E e) {
- if (e == null) throw new NullPointerException();
- Node node = new Node(e);
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- return linkFirst(node);
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * @throws NullPointerException {@inheritDoc}
- */
- public boolean offerLast(E e) {
- if (e == null) throw new NullPointerException();
- Node node = new Node(e);
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- return linkLast(node);
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * @throws NullPointerException {@inheritDoc}
- * @throws InterruptedException {@inheritDoc}
- */
- public void putFirst(E e) throws InterruptedException {
- if (e == null) throw new NullPointerException();
- Node node = new Node(e);
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- while (!linkFirst(node))
- notFull.await();
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * @throws NullPointerException {@inheritDoc}
- * @throws InterruptedException {@inheritDoc}
- */
- public void putLast(E e) throws InterruptedException {
- if (e == null) throw new NullPointerException();
- Node node = new Node(e);
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- while (!linkLast(node))
- notFull.await();
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * @throws NullPointerException {@inheritDoc}
- * @throws InterruptedException {@inheritDoc}
- */
- public boolean offerFirst(E e, long timeout, TimeUnit unit)
- throws InterruptedException {
- if (e == null) throw new NullPointerException();
- Node node = new Node(e);
- long nanos = unit.toNanos(timeout);
- final ReentrantLock lock = this.lock;
- lock.lockInterruptibly();
- try {
- while (!linkFirst(node)) {
- if (nanos <= 0)
- return false;
- nanos = notFull.awaitNanos(nanos);
- }
- return true;
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * @throws NullPointerException {@inheritDoc}
- * @throws InterruptedException {@inheritDoc}
- */
- public boolean offerLast(E e, long timeout, TimeUnit unit)
- throws InterruptedException {
- if (e == null) throw new NullPointerException();
- Node node = new Node(e);
- long nanos = unit.toNanos(timeout);
- final ReentrantLock lock = this.lock;
- lock.lockInterruptibly();
- try {
- while (!linkLast(node)) {
- if (nanos <= 0)
- return false;
- nanos = notFull.awaitNanos(nanos);
- }
- return true;
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * @throws NoSuchElementException {@inheritDoc}
- */
- public E removeFirst() {
- E x = pollFirst();
- if (x == null) throw new NoSuchElementException();
- return x;
- }
-
- /**
- * @throws NoSuchElementException {@inheritDoc}
- */
- public E removeLast() {
- E x = pollLast();
- if (x == null) throw new NoSuchElementException();
- return x;
- }
-
- public E pollFirst() {
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- return unlinkFirst();
- } finally {
- lock.unlock();
- }
- }
-
- public E pollLast() {
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- return unlinkLast();
- } finally {
- lock.unlock();
- }
- }
-
- public E takeFirst() throws InterruptedException {
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- E x;
- while ( (x = unlinkFirst()) == null)
- notEmpty.await();
- return x;
- } finally {
- lock.unlock();
- }
- }
-
- public E takeLast() throws InterruptedException {
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- E x;
- while ( (x = unlinkLast()) == null)
- notEmpty.await();
- return x;
- } finally {
- lock.unlock();
- }
- }
-
- public E pollFirst(long timeout, TimeUnit unit)
- throws InterruptedException {
- long nanos = unit.toNanos(timeout);
- final ReentrantLock lock = this.lock;
- lock.lockInterruptibly();
- try {
- E x;
- while ( (x = unlinkFirst()) == null) {
- if (nanos <= 0)
- return null;
- nanos = notEmpty.awaitNanos(nanos);
- }
- return x;
- } finally {
- lock.unlock();
- }
- }
-
- public E pollLast(long timeout, TimeUnit unit)
- throws InterruptedException {
- long nanos = unit.toNanos(timeout);
- final ReentrantLock lock = this.lock;
- lock.lockInterruptibly();
- try {
- E x;
- while ( (x = unlinkLast()) == null) {
- if (nanos <= 0)
- return null;
- nanos = notEmpty.awaitNanos(nanos);
- }
- return x;
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * @throws NoSuchElementException {@inheritDoc}
- */
- public E getFirst() {
- E x = peekFirst();
- if (x == null) throw new NoSuchElementException();
- return x;
- }
-
- /**
- * @throws NoSuchElementException {@inheritDoc}
- */
- public E getLast() {
- E x = peekLast();
- if (x == null) throw new NoSuchElementException();
- return x;
- }
-
- public E peekFirst() {
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- return (first == null) ? null : first.item;
- } finally {
- lock.unlock();
- }
- }
-
- public E peekLast() {
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- return (last == null) ? null : last.item;
- } finally {
- lock.unlock();
- }
- }
-
- public boolean removeFirstOccurrence(Object o) {
- if (o == null) return false;
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- for (Node p = first; p != null; p = p.next) {
- if (o.equals(p.item)) {
- unlink(p);
- return true;
- }
- }
- return false;
- } finally {
- lock.unlock();
- }
- }
-
- public boolean removeLastOccurrence(Object o) {
- if (o == null) return false;
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- for (Node p = last; p != null; p = p.prev) {
- if (o.equals(p.item)) {
- unlink(p);
- return true;
- }
- }
- return false;
- } finally {
- lock.unlock();
- }
- }
-
- // BlockingQueue methods
-
- /**
- * Inserts the specified element at the end of this deque unless it would
- * violate capacity restrictions. When using a capacity-restricted deque,
- * it is generally preferable to use method {@link #offer offer}.
- *
- * This method is equivalent to {@link #addLast}.
- *
- * @throws IllegalStateException if the element cannot be added at this
- * time due to capacity restrictions
- * @throws NullPointerException if the specified element is null
- */
- public boolean add(E e) {
- addLast(e);
- return true;
- }
-
- /**
- * @throws NullPointerException if the specified element is null
- */
- public boolean offer(E e) {
- return offerLast(e);
- }
-
- /**
- * @throws NullPointerException {@inheritDoc}
- * @throws InterruptedException {@inheritDoc}
- */
- public void put(E e) throws InterruptedException {
- putLast(e);
- }
-
- /**
- * @throws NullPointerException {@inheritDoc}
- * @throws InterruptedException {@inheritDoc}
- */
- public boolean offer(E e, long timeout, TimeUnit unit)
- throws InterruptedException {
- return offerLast(e, timeout, unit);
- }
-
- /**
- * Retrieves and removes the head of the queue represented by this deque.
- * This method differs from {@link #poll poll} only in that it throws an
- * exception if this deque is empty.
- *
- *
This method is equivalent to {@link #removeFirst() removeFirst}.
- *
- * @return the head of the queue represented by this deque
- * @throws NoSuchElementException if this deque is empty
- */
- public E remove() {
- return removeFirst();
- }
-
- public E poll() {
- return pollFirst();
- }
-
- public E take() throws InterruptedException {
- return takeFirst();
- }
-
- public E poll(long timeout, TimeUnit unit) throws InterruptedException {
- return pollFirst(timeout, unit);
- }
-
- /**
- * Retrieves, but does not remove, the head of the queue represented by
- * this deque. This method differs from {@link #peek peek} only in that
- * it throws an exception if this deque is empty.
- *
- *
This method is equivalent to {@link #getFirst() getFirst}.
- *
- * @return the head of the queue represented by this deque
- * @throws NoSuchElementException if this deque is empty
- */
- public E element() {
- return getFirst();
- }
-
- public E peek() {
- return peekFirst();
- }
-
- /**
- * Returns the number of additional elements that this deque can ideally
- * (in the absence of memory or resource constraints) accept without
- * blocking. This is always equal to the initial capacity of this deque
- * less the current {@code size} of this deque.
- *
- *
Note that you cannot always tell if an attempt to insert
- * an element will succeed by inspecting {@code remainingCapacity}
- * because it may be the case that another thread is about to
- * insert or remove an element.
- */
- public int remainingCapacity() {
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- return capacity - count;
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * @throws UnsupportedOperationException {@inheritDoc}
- * @throws ClassCastException {@inheritDoc}
- * @throws NullPointerException {@inheritDoc}
- * @throws IllegalArgumentException {@inheritDoc}
- */
- public int drainTo(Collection super E> c) {
- return drainTo(c, Integer.MAX_VALUE);
- }
-
- /**
- * @throws UnsupportedOperationException {@inheritDoc}
- * @throws ClassCastException {@inheritDoc}
- * @throws NullPointerException {@inheritDoc}
- * @throws IllegalArgumentException {@inheritDoc}
- */
- public int drainTo(Collection super E> c, int maxElements) {
- if (c == null)
- throw new NullPointerException();
- if (c == this)
- throw new IllegalArgumentException();
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- int n = Math.min(maxElements, count);
- for (int i = 0; i < n; i++) {
- c.add(first.item); // In this order, in case add() throws.
- unlinkFirst();
- }
- return n;
- } finally {
- lock.unlock();
- }
- }
-
- // Stack methods
-
- /**
- * @throws IllegalStateException {@inheritDoc}
- * @throws NullPointerException {@inheritDoc}
- */
- public void push(E e) {
- addFirst(e);
- }
-
- /**
- * @throws NoSuchElementException {@inheritDoc}
- */
- public E pop() {
- return removeFirst();
- }
-
- // Collection methods
-
- /**
- * Removes the first occurrence of the specified element from this deque.
- * If the deque does not contain the element, it is unchanged.
- * More formally, removes the first element {@code e} such that
- * {@code o.equals(e)} (if such an element exists).
- * Returns {@code true} if this deque contained the specified element
- * (or equivalently, if this deque changed as a result of the call).
- *
- *
This method is equivalent to
- * {@link #removeFirstOccurrence(Object) removeFirstOccurrence}.
- *
- * @param o element to be removed from this deque, if present
- * @return {@code true} if this deque changed as a result of the call
- */
- public boolean remove(Object o) {
- return removeFirstOccurrence(o);
- }
-
- /**
- * Returns the number of elements in this deque.
- *
- * @return the number of elements in this deque
- */
- public int size() {
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- return count;
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * Returns {@code true} if this deque contains the specified element.
- * More formally, returns {@code true} if and only if this deque contains
- * at least one element {@code e} such that {@code o.equals(e)}.
- *
- * @param o object to be checked for containment in this deque
- * @return {@code true} if this deque contains the specified element
- */
- public boolean contains(Object o) {
- if (o == null) return false;
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- for (Node p = first; p != null; p = p.next)
- if (o.equals(p.item))
- return true;
- return false;
- } finally {
- lock.unlock();
- }
- }
-
- /*
- * TODO: Add support for more efficient bulk operations.
- *
- * We don't want to acquire the lock for every iteration, but we
- * also want other threads a chance to interact with the
- * collection, especially when count is close to capacity.
- */
-
-// /**
-// * Adds all of the elements in the specified collection to this
-// * queue. Attempts to addAll of a queue to itself result in
-// * {@code IllegalArgumentException}. Further, the behavior of
-// * this operation is undefined if the specified collection is
-// * modified while the operation is in progress.
-// *
-// * @param c collection containing elements to be added to this queue
-// * @return {@code true} if this queue changed as a result of the call
-// * @throws ClassCastException {@inheritDoc}
-// * @throws NullPointerException {@inheritDoc}
-// * @throws IllegalArgumentException {@inheritDoc}
-// * @throws IllegalStateException {@inheritDoc}
-// * @see #add(Object)
-// */
-// public boolean addAll(Collection extends E> c) {
-// if (c == null)
-// throw new NullPointerException();
-// if (c == this)
-// throw new IllegalArgumentException();
-// final ReentrantLock lock = this.lock;
-// lock.lock();
-// try {
-// boolean modified = false;
-// for (E e : c)
-// if (linkLast(e))
-// modified = true;
-// return modified;
-// } finally {
-// lock.unlock();
-// }
-// }
-
- /**
- * Returns an array containing all of the elements in this deque, in
- * proper sequence (from first to last element).
- *
- * The returned array will be "safe" in that no references to it are
- * maintained by this deque. (In other words, this method must allocate
- * a new array). The caller is thus free to modify the returned array.
- *
- *
This method acts as bridge between array-based and collection-based
- * APIs.
- *
- * @return an array containing all of the elements in this deque
- */
- public Object[] toArray() {
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- Object[] a = new Object[count];
- int k = 0;
- for (Node p = first; p != null; p = p.next)
- a[k++] = p.item;
- return a;
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * Returns an array containing all of the elements in this deque, in
- * proper sequence; the runtime type of the returned array is that of
- * the specified array. If the deque fits in the specified array, it
- * is returned therein. Otherwise, a new array is allocated with the
- * runtime type of the specified array and the size of this deque.
- *
- * If this deque fits in the specified array with room to spare
- * (i.e., the array has more elements than this deque), the element in
- * the array immediately following the end of the deque is set to
- * {@code null}.
- *
- *
Like the {@link #toArray()} method, this method acts as bridge between
- * array-based and collection-based APIs. Further, this method allows
- * precise control over the runtime type of the output array, and may,
- * under certain circumstances, be used to save allocation costs.
- *
- *
Suppose {@code x} is a deque known to contain only strings.
- * The following code can be used to dump the deque into a newly
- * allocated array of {@code String}:
- *
- *
- * String[] y = x.toArray(new String[0]);
- *
- * Note that {@code toArray(new Object[0])} is identical in function to
- * {@code toArray()}.
- *
- * @param a the array into which the elements of the deque are to
- * be stored, if it is big enough; otherwise, a new array of the
- * same runtime type is allocated for this purpose
- * @return an array containing all of the elements in this deque
- * @throws ArrayStoreException if the runtime type of the specified array
- * is not a supertype of the runtime type of every element in
- * this deque
- * @throws NullPointerException if the specified array is null
- */
- @SuppressWarnings("unchecked")
- public T[] toArray(T[] a) {
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- if (a.length < count)
- a = (T[])java.lang.reflect.Array.newInstance
- (a.getClass().getComponentType(), count);
-
- int k = 0;
- for (Node p = first; p != null; p = p.next)
- a[k++] = (T)p.item;
- if (a.length > k)
- a[k] = null;
- return a;
- } finally {
- lock.unlock();
- }
- }
-
- public String toString() {
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- Node p = first;
- if (p == null)
- return "[]";
-
- StringBuilder sb = new StringBuilder();
- sb.append('[');
- for (;;) {
- E e = p.item;
- sb.append(e == this ? "(this Collection)" : e);
- p = p.next;
- if (p == null)
- return sb.append(']').toString();
- sb.append(',').append(' ');
- }
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * Atomically removes all of the elements from this deque.
- * The deque will be empty after this call returns.
- */
- public void clear() {
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- for (Node f = first; f != null; ) {
- f.item = null;
- Node n = f.next;
- f.prev = null;
- f.next = null;
- f = n;
- }
- first = last = null;
- count = 0;
- notFull.signalAll();
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * Returns an iterator over the elements in this deque in proper sequence.
- * The elements will be returned in order from first (head) to last (tail).
- *
- * The returned iterator is a "weakly consistent" iterator that
- * will never throw {@link java.util.ConcurrentModificationException
- * ConcurrentModificationException}, and guarantees to traverse
- * elements as they existed upon construction of the iterator, and
- * may (but is not guaranteed to) reflect any modifications
- * subsequent to construction.
- *
- * @return an iterator over the elements in this deque in proper sequence
- */
- public Iterator iterator() {
- return new Itr();
- }
-
- /**
- * Returns an iterator over the elements in this deque in reverse
- * sequential order. The elements will be returned in order from
- * last (tail) to first (head).
- *
- * The returned iterator is a "weakly consistent" iterator that
- * will never throw {@link java.util.ConcurrentModificationException
- * ConcurrentModificationException}, and guarantees to traverse
- * elements as they existed upon construction of the iterator, and
- * may (but is not guaranteed to) reflect any modifications
- * subsequent to construction.
- *
- * @return an iterator over the elements in this deque in reverse order
- */
- public Iterator descendingIterator() {
- return new DescendingItr();
- }
-
- /**
- * Base class for Iterators for LinkedBlockingDeque
- */
- private abstract class AbstractItr implements Iterator {
- /**
- * The next node to return in next()
- */
- Node next;
-
- /**
- * nextItem holds on to item fields because once we claim that
- * an element exists in hasNext(), we must return item read
- * under lock (in advance()) even if it was in the process of
- * being removed when hasNext() was called.
- */
- E nextItem;
-
- /**
- * Node returned by most recent call to next. Needed by remove.
- * Reset to null if this element is deleted by a call to remove.
- */
- private Node lastRet;
-
- abstract Node firstNode();
- abstract Node nextNode(Node n);
-
- AbstractItr() {
- // set to initial position
- final ReentrantLock lock = LinkedBlockingDeque.this.lock;
- lock.lock();
- try {
- next = firstNode();
- nextItem = (next == null) ? null : next.item;
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * Returns the successor node of the given non-null, but
- * possibly previously deleted, node.
- */
- private Node succ(Node n) {
- // Chains of deleted nodes ending in null or self-links
- // are possible if multiple interior nodes are removed.
- for (;;) {
- Node s = nextNode(n);
- if (s == null)
- return null;
- else if (s.item != null)
- return s;
- else if (s == n)
- return firstNode();
- else
- n = s;
- }
- }
-
- /**
- * Advances next.
- */
- void advance() {
- final ReentrantLock lock = LinkedBlockingDeque.this.lock;
- lock.lock();
- try {
- // assert next != null;
- next = succ(next);
- nextItem = (next == null) ? null : next.item;
- } finally {
- lock.unlock();
- }
- }
-
- public boolean hasNext() {
- return next != null;
- }
-
- public E next() {
- if (next == null)
- throw new NoSuchElementException();
- lastRet = next;
- E x = nextItem;
- advance();
- return x;
- }
-
- public void remove() {
- Node n = lastRet;
- if (n == null)
- throw new IllegalStateException();
- lastRet = null;
- final ReentrantLock lock = LinkedBlockingDeque.this.lock;
- lock.lock();
- try {
- if (n.item != null)
- unlink(n);
- } finally {
- lock.unlock();
- }
- }
- }
-
- /** Forward iterator */
- private class Itr extends AbstractItr {
- Node firstNode() { return first; }
- Node nextNode(Node n) { return n.next; }
- }
-
- /** Descending iterator */
- private class DescendingItr extends AbstractItr {
- Node firstNode() { return last; }
- Node nextNode(Node n) { return n.prev; }
- }
-
- /**
- * Save the state of this deque to a stream (that is, serialize it).
- *
- * @serialData The capacity (int), followed by elements (each an
- * {@code Object}) in the proper order, followed by a null
- * @param s the stream
- */
- private void writeObject(java.io.ObjectOutputStream s)
- throws java.io.IOException {
- final ReentrantLock lock = this.lock;
- lock.lock();
- try {
- // Write out capacity and any hidden stuff
- s.defaultWriteObject();
- // Write out all elements in the proper order.
- for (Node p = first; p != null; p = p.next)
- s.writeObject(p.item);
- // Use trailing null as sentinel
- s.writeObject(null);
- } finally {
- lock.unlock();
- }
- }
-
- /**
- * Reconstitute this deque from a stream (that is,
- * deserialize it).
- * @param s the stream
- */
- private void readObject(java.io.ObjectInputStream s)
- throws java.io.IOException, ClassNotFoundException {
- s.defaultReadObject();
- count = 0;
- first = null;
- last = null;
- // Read in all elements and place in queue
- for (;;) {
- @SuppressWarnings("unchecked")
- E item = (E)s.readObject();
- if (item == null)
- break;
- add(item);
- }
- }
-
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/decode/BaseImageDecoder.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/decode/BaseImageDecoder.java
deleted file mode 100644
index 7b82ba689..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/decode/BaseImageDecoder.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.decode;
-
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.BitmapFactory.Options;
-import android.graphics.Matrix;
-import android.media.ExifInterface;
-import com.nostra13.universalimageloader.core.assist.ImageScaleType;
-import com.nostra13.universalimageloader.core.assist.ImageSize;
-import com.nostra13.universalimageloader.core.download.ImageDownloader.Scheme;
-import com.nostra13.universalimageloader.utils.ImageSizeUtils;
-import com.nostra13.universalimageloader.utils.IoUtils;
-import com.nostra13.universalimageloader.utils.L;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Decodes images to {@link Bitmap}, scales them to needed size
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @see ImageDecodingInfo
- * @since 1.8.3
- */
-public class BaseImageDecoder implements ImageDecoder {
-
- protected static final String LOG_SUBSAMPLE_IMAGE = "Subsample original image (%1$s) to %2$s (scale = %3$d) [%4$s]";
- protected static final String LOG_SCALE_IMAGE = "Scale subsampled image (%1$s) to %2$s (scale = %3$.5f) [%4$s]";
- protected static final String LOG_ROTATE_IMAGE = "Rotate image on %1$d\u00B0 [%2$s]";
- protected static final String LOG_FLIP_IMAGE = "Flip image horizontally [%s]";
- protected static final String ERROR_NO_IMAGE_STREAM = "No stream for image [%s]";
- protected static final String ERROR_CANT_DECODE_IMAGE = "Image can't be decoded [%s]";
-
- protected final boolean loggingEnabled;
-
- /**
- * @param loggingEnabled Whether debug logs will be written to LogCat. Usually should match {@link
- * com.nostra13.universalimageloader.core.ImageLoaderConfiguration.Builder#writeDebugLogs()
- * ImageLoaderConfiguration.writeDebugLogs()}
- */
- public BaseImageDecoder(boolean loggingEnabled) {
- this.loggingEnabled = loggingEnabled;
- }
-
- /**
- * Decodes image from URI into {@link Bitmap}. Image is scaled close to incoming {@linkplain ImageSize target size}
- * during decoding (depend on incoming parameters).
- *
- * @param decodingInfo Needed data for decoding image
- * @return Decoded bitmap
- * @throws IOException if some I/O exception occurs during image reading
- * @throws UnsupportedOperationException if image URI has unsupported scheme(protocol)
- */
- @Override
- public Bitmap decode(ImageDecodingInfo decodingInfo) throws IOException {
- Bitmap decodedBitmap;
- ImageFileInfo imageInfo;
-
- InputStream imageStream = getImageStream(decodingInfo);
- if (imageStream == null) {
- L.e(ERROR_NO_IMAGE_STREAM, decodingInfo.getImageKey());
- return null;
- }
- try {
- imageInfo = defineImageSizeAndRotation(imageStream, decodingInfo);
- imageStream = resetStream(imageStream, decodingInfo);
- Options decodingOptions = prepareDecodingOptions(imageInfo.imageSize, decodingInfo);
- decodedBitmap = BitmapFactory.decodeStream(imageStream, null, decodingOptions);
- } finally {
- IoUtils.closeSilently(imageStream);
- }
-
- if (decodedBitmap == null) {
- L.e(ERROR_CANT_DECODE_IMAGE, decodingInfo.getImageKey());
- } else {
- decodedBitmap = considerExactScaleAndOrientatiton(decodedBitmap, decodingInfo, imageInfo.exif.rotation,
- imageInfo.exif.flipHorizontal);
- }
- return decodedBitmap;
- }
-
- protected InputStream getImageStream(ImageDecodingInfo decodingInfo) throws IOException {
- return decodingInfo.getDownloader().getStream(decodingInfo.getImageUri(), decodingInfo.getExtraForDownloader());
- }
-
- protected ImageFileInfo defineImageSizeAndRotation(InputStream imageStream, ImageDecodingInfo decodingInfo)
- throws IOException {
- Options options = new Options();
- options.inJustDecodeBounds = true;
- BitmapFactory.decodeStream(imageStream, null, options);
-
- ExifInfo exif;
- String imageUri = decodingInfo.getImageUri();
- if (decodingInfo.shouldConsiderExifParams() && canDefineExifParams(imageUri, options.outMimeType)) {
- exif = defineExifOrientation(imageUri);
- } else {
- exif = new ExifInfo();
- }
- return new ImageFileInfo(new ImageSize(options.outWidth, options.outHeight, exif.rotation), exif);
- }
-
- private boolean canDefineExifParams(String imageUri, String mimeType) {
- return "image/jpeg".equalsIgnoreCase(mimeType) && (Scheme.ofUri(imageUri) == Scheme.FILE);
- }
-
- protected ExifInfo defineExifOrientation(String imageUri) {
- int rotation = 0;
- boolean flip = false;
- try {
- ExifInterface exif = new ExifInterface(Scheme.FILE.crop(imageUri));
- int exifOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL);
- switch (exifOrientation) {
- case ExifInterface.ORIENTATION_FLIP_HORIZONTAL:
- flip = true;
- case ExifInterface.ORIENTATION_NORMAL:
- rotation = 0;
- break;
- case ExifInterface.ORIENTATION_TRANSVERSE:
- flip = true;
- case ExifInterface.ORIENTATION_ROTATE_90:
- rotation = 90;
- break;
- case ExifInterface.ORIENTATION_FLIP_VERTICAL:
- flip = true;
- case ExifInterface.ORIENTATION_ROTATE_180:
- rotation = 180;
- break;
- case ExifInterface.ORIENTATION_TRANSPOSE:
- flip = true;
- case ExifInterface.ORIENTATION_ROTATE_270:
- rotation = 270;
- break;
- }
- } catch (IOException e) {
- L.w("Can't read EXIF tags from file [%s]", imageUri);
- }
- return new ExifInfo(rotation, flip);
- }
-
- protected Options prepareDecodingOptions(ImageSize imageSize, ImageDecodingInfo decodingInfo) {
- ImageScaleType scaleType = decodingInfo.getImageScaleType();
- int scale;
- if (scaleType == ImageScaleType.NONE) {
- scale = 1;
- } else if (scaleType == ImageScaleType.NONE_SAFE) {
- scale = ImageSizeUtils.computeMinImageSampleSize(imageSize);
- } else {
- ImageSize targetSize = decodingInfo.getTargetSize();
- boolean powerOf2 = scaleType == ImageScaleType.IN_SAMPLE_POWER_OF_2;
- scale = ImageSizeUtils.computeImageSampleSize(imageSize, targetSize, decodingInfo.getViewScaleType(), powerOf2);
- }
- if (scale > 1 && loggingEnabled) {
- L.d(LOG_SUBSAMPLE_IMAGE, imageSize, imageSize.scaleDown(scale), scale, decodingInfo.getImageKey());
- }
-
- Options decodingOptions = decodingInfo.getDecodingOptions();
- decodingOptions.inSampleSize = scale;
- return decodingOptions;
- }
-
- protected InputStream resetStream(InputStream imageStream, ImageDecodingInfo decodingInfo) throws IOException {
- try {
- imageStream.reset();
- } catch (IOException e) {
- IoUtils.closeSilently(imageStream);
- imageStream = getImageStream(decodingInfo);
- }
- return imageStream;
- }
-
- protected Bitmap considerExactScaleAndOrientatiton(Bitmap subsampledBitmap, ImageDecodingInfo decodingInfo,
- int rotation, boolean flipHorizontal) {
- Matrix m = new Matrix();
- // Scale to exact size if need
- ImageScaleType scaleType = decodingInfo.getImageScaleType();
- if (scaleType == ImageScaleType.EXACTLY || scaleType == ImageScaleType.EXACTLY_STRETCHED) {
- ImageSize srcSize = new ImageSize(subsampledBitmap.getWidth(), subsampledBitmap.getHeight(), rotation);
- float scale = ImageSizeUtils.computeImageScale(srcSize, decodingInfo.getTargetSize(), decodingInfo
- .getViewScaleType(), scaleType == ImageScaleType.EXACTLY_STRETCHED);
- if (Float.compare(scale, 1f) != 0) {
- m.setScale(scale, scale);
-
- if (loggingEnabled) {
- L.d(LOG_SCALE_IMAGE, srcSize, srcSize.scale(scale), scale, decodingInfo.getImageKey());
- }
- }
- }
- // Flip bitmap if need
- if (flipHorizontal) {
- m.postScale(-1, 1);
-
- if (loggingEnabled) L.d(LOG_FLIP_IMAGE, decodingInfo.getImageKey());
- }
- // Rotate bitmap if need
- if (rotation != 0) {
- m.postRotate(rotation);
-
- if (loggingEnabled) L.d(LOG_ROTATE_IMAGE, rotation, decodingInfo.getImageKey());
- }
-
- Bitmap finalBitmap = Bitmap.createBitmap(subsampledBitmap, 0, 0, subsampledBitmap.getWidth(), subsampledBitmap
- .getHeight(), m, true);
- if (finalBitmap != subsampledBitmap) {
- subsampledBitmap.recycle();
- }
- return finalBitmap;
- }
-
- protected static class ExifInfo {
-
- public final int rotation;
- public final boolean flipHorizontal;
-
- protected ExifInfo() {
- this.rotation = 0;
- this.flipHorizontal = false;
- }
-
- protected ExifInfo(int rotation, boolean flipHorizontal) {
- this.rotation = rotation;
- this.flipHorizontal = flipHorizontal;
- }
- }
-
- protected static class ImageFileInfo {
-
- public final ImageSize imageSize;
- public final ExifInfo exif;
-
- protected ImageFileInfo(ImageSize imageSize, ExifInfo exif) {
- this.imageSize = imageSize;
- this.exif = exif;
- }
- }
-}
\ No newline at end of file
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/decode/ImageDecoder.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/decode/ImageDecoder.java
deleted file mode 100644
index 69fb01842..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/decode/ImageDecoder.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright 2013 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.decode;
-
-import android.graphics.Bitmap;
-
-import java.io.IOException;
-
-/**
- * Provide decoding image to result {@link Bitmap}.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @see ImageDecodingInfo
- * @since 1.8.3
- */
-public interface ImageDecoder {
-
- /**
- * Decodes image to {@link Bitmap} according target size and other parameters.
- *
- * @param imageDecodingInfo
- * @return
- * @throws IOException
- */
- Bitmap decode(ImageDecodingInfo imageDecodingInfo) throws IOException;
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/decode/ImageDecodingInfo.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/decode/ImageDecodingInfo.java
deleted file mode 100644
index 9a9ca04a1..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/decode/ImageDecodingInfo.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright 2013-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.decode;
-
-import android.annotation.TargetApi;
-import android.graphics.BitmapFactory.Options;
-import android.os.Build;
-
-import com.nostra13.universalimageloader.core.DisplayImageOptions;
-import com.nostra13.universalimageloader.core.assist.ImageScaleType;
-import com.nostra13.universalimageloader.core.assist.ImageSize;
-import com.nostra13.universalimageloader.core.assist.ViewScaleType;
-import com.nostra13.universalimageloader.core.download.ImageDownloader;
-
-/**
- * Contains needed information for decoding image to Bitmap
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.8.3
- */
-public class ImageDecodingInfo {
-
- private final String imageKey;
- private final String imageUri;
- private final String originalImageUri;
- private final ImageSize targetSize;
-
- private final ImageScaleType imageScaleType;
- private final ViewScaleType viewScaleType;
-
- private final ImageDownloader downloader;
- private final Object extraForDownloader;
-
- private final boolean considerExifParams;
- private final Options decodingOptions;
-
- public ImageDecodingInfo(String imageKey, String imageUri, String originalImageUri, ImageSize targetSize, ViewScaleType viewScaleType,
- ImageDownloader downloader, DisplayImageOptions displayOptions) {
- this.imageKey = imageKey;
- this.imageUri = imageUri;
- this.originalImageUri = originalImageUri;
- this.targetSize = targetSize;
-
- this.imageScaleType = displayOptions.getImageScaleType();
- this.viewScaleType = viewScaleType;
-
- this.downloader = downloader;
- this.extraForDownloader = displayOptions.getExtraForDownloader();
-
- considerExifParams = displayOptions.isConsiderExifParams();
- decodingOptions = new Options();
- copyOptions(displayOptions.getDecodingOptions(), decodingOptions);
- }
-
- private void copyOptions(Options srcOptions, Options destOptions) {
- destOptions.inDensity = srcOptions.inDensity;
- destOptions.inDither = srcOptions.inDither;
- destOptions.inInputShareable = srcOptions.inInputShareable;
- destOptions.inJustDecodeBounds = srcOptions.inJustDecodeBounds;
- destOptions.inPreferredConfig = srcOptions.inPreferredConfig;
- destOptions.inPurgeable = srcOptions.inPurgeable;
- destOptions.inSampleSize = srcOptions.inSampleSize;
- destOptions.inScaled = srcOptions.inScaled;
- destOptions.inScreenDensity = srcOptions.inScreenDensity;
- destOptions.inTargetDensity = srcOptions.inTargetDensity;
- destOptions.inTempStorage = srcOptions.inTempStorage;
- if (Build.VERSION.SDK_INT >= 10) copyOptions10(srcOptions, destOptions);
- if (Build.VERSION.SDK_INT >= 11) copyOptions11(srcOptions, destOptions);
- }
-
- @TargetApi(10)
- private void copyOptions10(Options srcOptions, Options destOptions) {
- destOptions.inPreferQualityOverSpeed = srcOptions.inPreferQualityOverSpeed;
- }
-
- @TargetApi(11)
- private void copyOptions11(Options srcOptions, Options destOptions) {
- destOptions.inBitmap = srcOptions.inBitmap;
- destOptions.inMutable = srcOptions.inMutable;
- }
-
- /** @return Original {@linkplain com.nostra13.universalimageloader.utils.MemoryCacheUtils#generateKey(String, ImageSize) image key} (used in memory cache). */
- public String getImageKey() {
- return imageKey;
- }
-
- /** @return Image URI for decoding (usually image from disk cache) */
- public String getImageUri() {
- return imageUri;
- }
-
- /** @return The original image URI which was passed to ImageLoader */
- public String getOriginalImageUri() {
- return originalImageUri;
- }
-
- /**
- * @return Target size for image. Decoded bitmap should close to this size according to {@linkplain ImageScaleType
- * image scale type} and {@linkplain ViewScaleType view scale type}.
- */
- public ImageSize getTargetSize() {
- return targetSize;
- }
-
- /**
- * @return {@linkplain ImageScaleType Scale type for image sampling and scaling}. This parameter affects result size
- * of decoded bitmap.
- */
- public ImageScaleType getImageScaleType() {
- return imageScaleType;
- }
-
- /** @return {@linkplain ViewScaleType View scale type}. This parameter affects result size of decoded bitmap. */
- public ViewScaleType getViewScaleType() {
- return viewScaleType;
- }
-
- /** @return Downloader for image loading */
- public ImageDownloader getDownloader() {
- return downloader;
- }
-
- /** @return Auxiliary object for downloader */
- public Object getExtraForDownloader() {
- return extraForDownloader;
- }
-
- /** @return true - if EXIF params of image should be considered; false - otherwise */
- public boolean shouldConsiderExifParams() {
- return considerExifParams;
- }
-
- /** @return Decoding options */
- public Options getDecodingOptions() {
- return decodingOptions;
- }
-}
\ No newline at end of file
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/display/BitmapDisplayer.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/display/BitmapDisplayer.java
deleted file mode 100644
index 1149111ec..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/display/BitmapDisplayer.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.display;
-
-import android.graphics.Bitmap;
-import com.nostra13.universalimageloader.core.assist.LoadedFrom;
-import com.nostra13.universalimageloader.core.imageaware.ImageAware;
-
-/**
- * Displays {@link Bitmap} in {@link com.nostra13.universalimageloader.core.imageaware.ImageAware}. Implementations can
- * apply some changes to Bitmap or any animation for displaying Bitmap.
- * Implementations have to be thread-safe.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @see com.nostra13.universalimageloader.core.imageaware.ImageAware
- * @see com.nostra13.universalimageloader.core.assist.LoadedFrom
- * @since 1.5.6
- */
-public interface BitmapDisplayer {
- /**
- * Displays bitmap in {@link com.nostra13.universalimageloader.core.imageaware.ImageAware}.
- * NOTE: This method is called on UI thread so it's strongly recommended not to do any heavy work in it.
- *
- * @param bitmap Source bitmap
- * @param imageAware {@linkplain com.nostra13.universalimageloader.core.imageaware.ImageAware Image aware view} to
- * display Bitmap
- * @param loadedFrom Source of loaded image
- */
- void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom);
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/display/FadeInBitmapDisplayer.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/display/FadeInBitmapDisplayer.java
deleted file mode 100644
index 686f0fd1f..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/display/FadeInBitmapDisplayer.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich, Daniel MartÃ
- *
- * Licensed 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 com.nostra13.universalimageloader.core.display;
-
-import android.graphics.Bitmap;
-import android.view.View;
-import android.view.animation.AlphaAnimation;
-import android.view.animation.DecelerateInterpolator;
-import android.widget.ImageView;
-import com.nostra13.universalimageloader.core.assist.LoadedFrom;
-import com.nostra13.universalimageloader.core.imageaware.ImageAware;
-
-/**
- * Displays image with "fade in" animation
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com), Daniel MartÃ
- * @since 1.6.4
- */
-public class FadeInBitmapDisplayer implements BitmapDisplayer {
-
- private final int durationMillis;
-
- private final boolean animateFromNetwork;
- private final boolean animateFromDisk;
- private final boolean animateFromMemory;
-
- /**
- * @param durationMillis Duration of "fade-in" animation (in milliseconds)
- */
- public FadeInBitmapDisplayer(int durationMillis) {
- this(durationMillis, true, true, true);
- }
-
- /**
- * @param durationMillis Duration of "fade-in" animation (in milliseconds)
- * @param animateFromNetwork Whether animation should be played if image is loaded from network
- * @param animateFromDisk Whether animation should be played if image is loaded from disk cache
- * @param animateFromMemory Whether animation should be played if image is loaded from memory cache
- */
- public FadeInBitmapDisplayer(int durationMillis, boolean animateFromNetwork, boolean animateFromDisk,
- boolean animateFromMemory) {
- this.durationMillis = durationMillis;
- this.animateFromNetwork = animateFromNetwork;
- this.animateFromDisk = animateFromDisk;
- this.animateFromMemory = animateFromMemory;
- }
-
- @Override
- public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) {
- imageAware.setImageBitmap(bitmap);
-
- if ((animateFromNetwork && loadedFrom == LoadedFrom.NETWORK) ||
- (animateFromDisk && loadedFrom == LoadedFrom.DISC_CACHE) ||
- (animateFromMemory && loadedFrom == LoadedFrom.MEMORY_CACHE)) {
- animate(imageAware.getWrappedView(), durationMillis);
- }
- }
-
- /**
- * Animates {@link ImageView} with "fade-in" effect
- *
- * @param imageView {@link ImageView} which display image in
- * @param durationMillis The length of the animation in milliseconds
- */
- public static void animate(View imageView, int durationMillis) {
- if (imageView != null) {
- AlphaAnimation fadeImage = new AlphaAnimation(0, 1);
- fadeImage.setDuration(durationMillis);
- fadeImage.setInterpolator(new DecelerateInterpolator());
- imageView.startAnimation(fadeImage);
- }
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/display/RoundedBitmapDisplayer.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/display/RoundedBitmapDisplayer.java
deleted file mode 100644
index c4dd8d5f8..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/display/RoundedBitmapDisplayer.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.display;
-
-import android.graphics.*;
-import android.graphics.drawable.Drawable;
-
-import com.nostra13.universalimageloader.core.assist.LoadedFrom;
-import com.nostra13.universalimageloader.core.imageaware.ImageAware;
-import com.nostra13.universalimageloader.core.imageaware.ImageViewAware;
-
-/**
- * Can display bitmap with rounded corners. This implementation works only with ImageViews wrapped
- * in ImageViewAware.
- *
- * This implementation is inspired by
- *
- * Romain Guy's article. It rounds images using custom drawable drawing. Original bitmap isn't changed.
- *
- *
- * If this implementation doesn't meet your needs then consider
- * RoundedImageView or
- * CircularImageView projects for usage.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.5.6
- */
-public class RoundedBitmapDisplayer implements BitmapDisplayer {
-
- protected final int cornerRadius;
- protected final int margin;
-
- public RoundedBitmapDisplayer(int cornerRadiusPixels) {
- this(cornerRadiusPixels, 0);
- }
-
- public RoundedBitmapDisplayer(int cornerRadiusPixels, int marginPixels) {
- this.cornerRadius = cornerRadiusPixels;
- this.margin = marginPixels;
- }
-
- @Override
- public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) {
- if (!(imageAware instanceof ImageViewAware)) {
- throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is expected.");
- }
-
- imageAware.setImageDrawable(new RoundedDrawable(bitmap, cornerRadius, margin));
- }
-
- public static class RoundedDrawable extends Drawable {
-
- protected final float cornerRadius;
- protected final int margin;
-
- protected final RectF mRect = new RectF(),
- mBitmapRect;
- protected final BitmapShader bitmapShader;
- protected final Paint paint;
-
- public RoundedDrawable(Bitmap bitmap, int cornerRadius, int margin) {
- this.cornerRadius = cornerRadius;
- this.margin = margin;
-
- bitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
- mBitmapRect = new RectF (margin, margin, bitmap.getWidth() - margin, bitmap.getHeight() - margin);
-
- paint = new Paint();
- paint.setAntiAlias(true);
- paint.setShader(bitmapShader);
- }
-
- @Override
- protected void onBoundsChange(Rect bounds) {
- super.onBoundsChange(bounds);
- mRect.set(margin, margin, bounds.width() - margin, bounds.height() - margin);
-
- // Resize the original bitmap to fit the new bound
- Matrix shaderMatrix = new Matrix();
- shaderMatrix.setRectToRect(mBitmapRect, mRect, Matrix.ScaleToFit.FILL);
- bitmapShader.setLocalMatrix(shaderMatrix);
-
- }
-
- @Override
- public void draw(Canvas canvas) {
- canvas.drawRoundRect(mRect, cornerRadius, cornerRadius, paint);
- }
-
- @Override
- public int getOpacity() {
- return PixelFormat.TRANSLUCENT;
- }
-
- @Override
- public void setAlpha(int alpha) {
- paint.setAlpha(alpha);
- }
-
- @Override
- public void setColorFilter(ColorFilter cf) {
- paint.setColorFilter(cf);
- }
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/display/RoundedVignetteBitmapDisplayer.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/display/RoundedVignetteBitmapDisplayer.java
deleted file mode 100644
index bea59d354..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/display/RoundedVignetteBitmapDisplayer.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright 2013 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.display;
-
-import android.graphics.*;
-import com.nostra13.universalimageloader.core.assist.LoadedFrom;
-import com.nostra13.universalimageloader.core.imageaware.ImageAware;
-import com.nostra13.universalimageloader.core.imageaware.ImageViewAware;
-
-/**
- * Can display bitmap with rounded corners and vignette effect. This implementation works only with ImageViews wrapped
- * in ImageViewAware.
- *
- * This implementation is inspired by
- *
- * Romain Guy's article. It rounds images using custom drawable drawing. Original bitmap isn't changed.
- *
- *
- * If this implementation doesn't meet your needs then consider
- * this project for usage.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.9.1
- */
-public class RoundedVignetteBitmapDisplayer extends RoundedBitmapDisplayer {
-
- public RoundedVignetteBitmapDisplayer(int cornerRadiusPixels, int marginPixels) {
- super(cornerRadiusPixels, marginPixels);
- }
-
- @Override
- public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) {
- if (!(imageAware instanceof ImageViewAware)) {
- throw new IllegalArgumentException("ImageAware should wrap ImageView. ImageViewAware is expected.");
- }
-
- imageAware.setImageDrawable(new RoundedVignetteDrawable(bitmap, cornerRadius, margin));
- }
-
- protected static class RoundedVignetteDrawable extends RoundedDrawable {
-
- RoundedVignetteDrawable(Bitmap bitmap, int cornerRadius, int margin) {
- super(bitmap, cornerRadius, margin);
- }
-
- @Override
- protected void onBoundsChange(Rect bounds) {
- super.onBoundsChange(bounds);
- RadialGradient vignette = new RadialGradient(
- mRect.centerX(), mRect.centerY() * 1.0f / 0.7f, mRect.centerX() * 1.3f,
- new int[]{0, 0, 0x7f000000}, new float[]{0.0f, 0.7f, 1.0f},
- Shader.TileMode.CLAMP);
-
- Matrix oval = new Matrix();
- oval.setScale(1.0f, 0.7f);
- vignette.setLocalMatrix(oval);
-
- paint.setShader(new ComposeShader(bitmapShader, vignette, PorterDuff.Mode.SRC_OVER));
- }
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/display/SimpleBitmapDisplayer.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/display/SimpleBitmapDisplayer.java
deleted file mode 100644
index 8aae7de6b..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/display/SimpleBitmapDisplayer.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2013 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.display;
-
-import android.graphics.Bitmap;
-import com.nostra13.universalimageloader.core.assist.LoadedFrom;
-import com.nostra13.universalimageloader.core.imageaware.ImageAware;
-
-/**
- * Just displays {@link Bitmap} in {@link com.nostra13.universalimageloader.core.imageaware.ImageAware}
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.5.6
- */
-public final class SimpleBitmapDisplayer implements BitmapDisplayer {
- @Override
- public void display(Bitmap bitmap, ImageAware imageAware, LoadedFrom loadedFrom) {
- imageAware.setImageBitmap(bitmap);
- }
-}
\ No newline at end of file
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/download/BaseImageDownloader.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/download/BaseImageDownloader.java
deleted file mode 100644
index f050eebc6..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/download/BaseImageDownloader.java
+++ /dev/null
@@ -1,293 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.download;
-
-import android.annotation.TargetApi;
-import android.content.ContentResolver;
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.Bitmap.CompressFormat;
-import android.media.ThumbnailUtils;
-import android.net.Uri;
-import android.os.Build;
-import android.provider.ContactsContract;
-import android.provider.MediaStore;
-import android.webkit.MimeTypeMap;
-import com.nostra13.universalimageloader.core.DisplayImageOptions;
-import com.nostra13.universalimageloader.core.assist.ContentLengthInputStream;
-import com.nostra13.universalimageloader.utils.IoUtils;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-
-/**
- * Provides retrieving of {@link InputStream} of image by URI from network or file system or app resources.
- * {@link URLConnection} is used to retrieve image stream from network.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.8.0
- */
-public class BaseImageDownloader implements ImageDownloader {
- /** {@value} */
- public static final int DEFAULT_HTTP_CONNECT_TIMEOUT = 5 * 1000; // milliseconds
- /** {@value} */
- public static final int DEFAULT_HTTP_READ_TIMEOUT = 20 * 1000; // milliseconds
-
- /** {@value} */
- protected static final int BUFFER_SIZE = 32 * 1024; // 32 Kb
- /** {@value} */
- protected static final String ALLOWED_URI_CHARS = "@#&=*+-_.,:!?()/~'%";
-
- protected static final int MAX_REDIRECT_COUNT = 5;
-
- protected static final String CONTENT_CONTACTS_URI_PREFIX = "content://com.android.contacts/";
-
- private static final String ERROR_UNSUPPORTED_SCHEME = "UIL doesn't support scheme(protocol) by default [%s]. " + "You should implement this support yourself (BaseImageDownloader.getStreamFromOtherSource(...))";
-
- protected final Context context;
- protected final int connectTimeout;
- protected final int readTimeout;
-
- public BaseImageDownloader(Context context) {
- this(context, DEFAULT_HTTP_CONNECT_TIMEOUT, DEFAULT_HTTP_READ_TIMEOUT);
- }
-
- public BaseImageDownloader(Context context, int connectTimeout, int readTimeout) {
- this.context = context.getApplicationContext();
- this.connectTimeout = connectTimeout;
- this.readTimeout = readTimeout;
- }
-
- @Override
- public InputStream getStream(String imageUri, Object extra) throws IOException {
- switch (Scheme.ofUri(imageUri)) {
- case HTTP:
- case HTTPS:
- return getStreamFromNetwork(imageUri, extra);
- case FILE:
- return getStreamFromFile(imageUri, extra);
- case CONTENT:
- return getStreamFromContent(imageUri, extra);
- case ASSETS:
- return getStreamFromAssets(imageUri, extra);
- case DRAWABLE:
- return getStreamFromDrawable(imageUri, extra);
- case UNKNOWN:
- default:
- return getStreamFromOtherSource(imageUri, extra);
- }
- }
-
- /**
- * Retrieves {@link InputStream} of image by URI (image is located in the network).
- *
- * @param imageUri Image URI
- * @param extra Auxiliary object which was passed to {@link DisplayImageOptions.Builder#extraForDownloader(Object)
- * DisplayImageOptions.extraForDownloader(Object)}; can be null
- * @return {@link InputStream} of image
- * @throws IOException if some I/O error occurs during network request or if no InputStream could be created for
- * URL.
- */
- protected InputStream getStreamFromNetwork(String imageUri, Object extra) throws IOException {
- HttpURLConnection conn = createConnection(imageUri, extra);
-
- int redirectCount = 0;
- while (conn.getResponseCode() / 100 == 3 && redirectCount < MAX_REDIRECT_COUNT) {
- conn = createConnection(conn.getHeaderField("Location"), extra);
- redirectCount++;
- }
-
- InputStream imageStream;
- try {
- imageStream = conn.getInputStream();
- } catch (IOException e) {
- // Read all data to allow reuse connection (http://bit.ly/1ad35PY)
- IoUtils.readAndCloseStream(conn.getErrorStream());
- throw e;
- }
- if (!shouldBeProcessed(conn)) {
- IoUtils.closeSilently(imageStream);
- throw new IOException("Image request failed with response code " + conn.getResponseCode());
- }
-
- return new ContentLengthInputStream(new BufferedInputStream(imageStream, BUFFER_SIZE), conn.getContentLength());
- }
-
- /**
- * @param conn Opened request connection (response code is available)
- * @return true - if data from connection is correct and should be read and processed;
- * false - if response contains irrelevant data and shouldn't be processed
- * @throws IOException
- */
- protected boolean shouldBeProcessed(HttpURLConnection conn) throws IOException {
- return conn.getResponseCode() == 200;
- }
-
- /**
- * Create {@linkplain HttpURLConnection HTTP connection} for incoming URL
- *
- * @param url URL to connect to
- * @param extra Auxiliary object which was passed to {@link DisplayImageOptions.Builder#extraForDownloader(Object)
- * DisplayImageOptions.extraForDownloader(Object)}; can be null
- * @return {@linkplain HttpURLConnection Connection} for incoming URL. Connection isn't established so it still configurable.
- * @throws IOException if some I/O error occurs during network request or if no InputStream could be created for
- * URL.
- */
- protected HttpURLConnection createConnection(String url, Object extra) throws IOException {
- String encodedUrl = Uri.encode(url, ALLOWED_URI_CHARS);
- HttpURLConnection conn = (HttpURLConnection) new URL(encodedUrl).openConnection();
- conn.setConnectTimeout(connectTimeout);
- conn.setReadTimeout(readTimeout);
- return conn;
- }
-
- /**
- * Retrieves {@link InputStream} of image by URI (image is located on the local file system or SD card).
- *
- * @param imageUri Image URI
- * @param extra Auxiliary object which was passed to {@link DisplayImageOptions.Builder#extraForDownloader(Object)
- * DisplayImageOptions.extraForDownloader(Object)}; can be null
- * @return {@link InputStream} of image
- * @throws IOException if some I/O error occurs reading from file system
- */
- protected InputStream getStreamFromFile(String imageUri, Object extra) throws IOException {
- String filePath = Scheme.FILE.crop(imageUri);
- if (isVideoFileUri(imageUri)) {
- return getVideoThumbnailStream(filePath);
- } else {
- BufferedInputStream imageStream = new BufferedInputStream(new FileInputStream(filePath), BUFFER_SIZE);
- return new ContentLengthInputStream(imageStream, (int) new File(filePath).length());
- }
- }
-
- @TargetApi(Build.VERSION_CODES.FROYO)
- private InputStream getVideoThumbnailStream(String filePath) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) {
- Bitmap bitmap = ThumbnailUtils
- .createVideoThumbnail(filePath, MediaStore.Images.Thumbnails.FULL_SCREEN_KIND);
- if (bitmap != null) {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- bitmap.compress(CompressFormat.PNG, 0, bos);
- return new ByteArrayInputStream(bos.toByteArray());
- }
- }
- return null;
- }
-
- /**
- * Retrieves {@link InputStream} of image by URI (image is accessed using {@link ContentResolver}).
- *
- * @param imageUri Image URI
- * @param extra Auxiliary object which was passed to {@link DisplayImageOptions.Builder#extraForDownloader(Object)
- * DisplayImageOptions.extraForDownloader(Object)}; can be null
- * @return {@link InputStream} of image
- * @throws FileNotFoundException if the provided URI could not be opened
- */
- protected InputStream getStreamFromContent(String imageUri, Object extra) throws FileNotFoundException {
- ContentResolver res = context.getContentResolver();
-
- Uri uri = Uri.parse(imageUri);
- if (isVideoContentUri(uri)) { // video thumbnail
- Long origId = Long.valueOf(uri.getLastPathSegment());
- Bitmap bitmap = MediaStore.Video.Thumbnails
- .getThumbnail(res, origId, MediaStore.Images.Thumbnails.MINI_KIND, null);
- if (bitmap != null) {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- bitmap.compress(CompressFormat.PNG, 0, bos);
- return new ByteArrayInputStream(bos.toByteArray());
- }
- } else if (imageUri.startsWith(CONTENT_CONTACTS_URI_PREFIX)) { // contacts photo
- return getContactPhotoStream(uri);
- }
-
- return res.openInputStream(uri);
- }
-
- @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
- protected InputStream getContactPhotoStream(Uri uri) {
- ContentResolver res = context.getContentResolver();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- return ContactsContract.Contacts.openContactPhotoInputStream(res, uri, true);
- } else {
- return ContactsContract.Contacts.openContactPhotoInputStream(res, uri);
- }
- }
-
- /**
- * Retrieves {@link InputStream} of image by URI (image is located in assets of application).
- *
- * @param imageUri Image URI
- * @param extra Auxiliary object which was passed to {@link DisplayImageOptions.Builder#extraForDownloader(Object)
- * DisplayImageOptions.extraForDownloader(Object)}; can be null
- * @return {@link InputStream} of image
- * @throws IOException if some I/O error occurs file reading
- */
- protected InputStream getStreamFromAssets(String imageUri, Object extra) throws IOException {
- String filePath = Scheme.ASSETS.crop(imageUri);
- return context.getAssets().open(filePath);
- }
-
- /**
- * Retrieves {@link InputStream} of image by URI (image is located in drawable resources of application).
- *
- * @param imageUri Image URI
- * @param extra Auxiliary object which was passed to {@link DisplayImageOptions.Builder#extraForDownloader(Object)
- * DisplayImageOptions.extraForDownloader(Object)}; can be null
- * @return {@link InputStream} of image
- */
- protected InputStream getStreamFromDrawable(String imageUri, Object extra) {
- String drawableIdString = Scheme.DRAWABLE.crop(imageUri);
- int drawableId = Integer.parseInt(drawableIdString);
- return context.getResources().openRawResource(drawableId);
- }
-
- /**
- * Retrieves {@link InputStream} of image by URI from other source with unsupported scheme. Should be overriden by
- * successors to implement image downloading from special sources.
- * This method is called only if image URI has unsupported scheme. Throws {@link UnsupportedOperationException} by
- * default.
- *
- * @param imageUri Image URI
- * @param extra Auxiliary object which was passed to {@link DisplayImageOptions.Builder#extraForDownloader(Object)
- * DisplayImageOptions.extraForDownloader(Object)}; can be null
- * @return {@link InputStream} of image
- * @throws IOException if some I/O error occurs
- * @throws UnsupportedOperationException if image URI has unsupported scheme(protocol)
- */
- protected InputStream getStreamFromOtherSource(String imageUri, Object extra) throws IOException {
- throw new UnsupportedOperationException(String.format(ERROR_UNSUPPORTED_SCHEME, imageUri));
- }
-
- private boolean isVideoContentUri(Uri uri) {
- String mimeType = context.getContentResolver().getType(uri);
- return mimeType != null && mimeType.startsWith("video/");
- }
-
- private boolean isVideoFileUri(String uri) {
- String extension = MimeTypeMap.getFileExtensionFromUrl(uri);
- String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
- return mimeType != null && mimeType.startsWith("video/");
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/download/ImageDownloader.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/download/ImageDownloader.java
deleted file mode 100644
index 3fa0fb5cc..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/download/ImageDownloader.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2013 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.download;
-
-import com.nostra13.universalimageloader.core.DisplayImageOptions;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Locale;
-
-/**
- * Provides retrieving of {@link InputStream} of image by URI.
- * Implementations have to be thread-safe.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.4.0
- */
-public interface ImageDownloader {
- /**
- * Retrieves {@link InputStream} of image by URI.
- *
- * @param imageUri Image URI
- * @param extra Auxiliary object which was passed to {@link DisplayImageOptions.Builder#extraForDownloader(Object)
- * DisplayImageOptions.extraForDownloader(Object)}; can be null
- * @return {@link InputStream} of image
- * @throws IOException if some I/O error occurs during getting image stream
- * @throws UnsupportedOperationException if image URI has unsupported scheme(protocol)
- */
- InputStream getStream(String imageUri, Object extra) throws IOException;
-
- /** Represents supported schemes(protocols) of URI. Provides convenient methods for work with schemes and URIs. */
- public enum Scheme {
- HTTP("http"), HTTPS("https"), FILE("file"), CONTENT("content"), ASSETS("assets"), DRAWABLE("drawable"), UNKNOWN("");
-
- private String scheme;
- private String uriPrefix;
-
- Scheme(String scheme) {
- this.scheme = scheme;
- uriPrefix = scheme + "://";
- }
-
- /**
- * Defines scheme of incoming URI
- *
- * @param uri URI for scheme detection
- * @return Scheme of incoming URI
- */
- public static Scheme ofUri(String uri) {
- if (uri != null) {
- for (Scheme s : values()) {
- if (s.belongsTo(uri)) {
- return s;
- }
- }
- }
- return UNKNOWN;
- }
-
- private boolean belongsTo(String uri) {
- return uri.toLowerCase(Locale.US).startsWith(uriPrefix);
- }
-
- /** Appends scheme to incoming path */
- public String wrap(String path) {
- return uriPrefix + path;
- }
-
- /** Removed scheme part ("scheme://") from incoming URI */
- public String crop(String uri) {
- if (!belongsTo(uri)) {
- throw new IllegalArgumentException(String.format("URI [%1$s] doesn't have expected scheme [%2$s]", uri, scheme));
- }
- return uri.substring(uriPrefix.length());
- }
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/imageaware/ImageAware.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/imageaware/ImageAware.java
deleted file mode 100644
index ba1f4cb83..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/imageaware/ImageAware.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright 2013-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.imageaware;
-
-import android.graphics.Bitmap;
-import android.graphics.drawable.Drawable;
-import android.view.View;
-import com.nostra13.universalimageloader.core.assist.ViewScaleType;
-
-/**
- * Represents image aware view which provides all needed properties and behavior for image processing and displaying
- * through {@link com.nostra13.universalimageloader.core.ImageLoader ImageLoader}.
- * It can wrap any Android {@link android.view.View View} which can be accessed by {@link #getWrappedView()}. Wrapped
- * view is returned in {@link com.nostra13.universalimageloader.core.listener.ImageLoadingListener ImageLoadingListener}'s
- * callbacks.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @see ViewAware
- * @see ImageViewAware
- * @see NonViewAware
- * @since 1.9.0
- */
-public interface ImageAware {
- /**
- * Returns width of image aware view. This value is used to define scale size for original image.
- * Can return 0 if width is undefined.
- * Is called on UI thread if ImageLoader was called on UI thread. Otherwise - on background thread.
- */
- int getWidth();
-
- /**
- * Returns height of image aware view. This value is used to define scale size for original image.
- * Can return 0 if height is undefined.
- * Is called on UI thread if ImageLoader was called on UI thread. Otherwise - on background thread.
- */
- int getHeight();
-
- /**
- * Returns {@linkplain com.nostra13.universalimageloader.core.assist.ViewScaleType scale type} which is used for
- * scaling image for this image aware view. Must NOT return null.
- */
- ViewScaleType getScaleType();
-
- /**
- * Returns wrapped Android {@link android.view.View View}. Can return null if no view is wrapped or view was
- * collected by GC.
- * Is called on UI thread if ImageLoader was called on UI thread. Otherwise - on background thread.
- */
- View getWrappedView();
-
- /**
- * Returns a flag whether image aware view is collected by GC or whatsoever. If so then ImageLoader stop processing
- * of task for this image aware view and fires
- * {@link com.nostra13.universalimageloader.core.listener.ImageLoadingListener#onLoadingCancelled(String,
- * android.view.View) ImageLoadingListener#onLoadingCancelled(String, View)} callback.
- * Mey be called on UI thread if ImageLoader was called on UI thread. Otherwise - on background thread.
- *
- * @return true - if view is collected by GC and ImageLoader should stop processing this image aware view;
- * false - otherwise
- */
- boolean isCollected();
-
- /**
- * Returns ID of image aware view. Point of ID is similar to Object's hashCode. This ID should be unique for every
- * image view instance and should be the same for same instances. This ID identifies processing task in ImageLoader
- * so ImageLoader won't process two image aware views with the same ID in one time. When ImageLoader get new task
- * it cancels old task with this ID (if any) and starts new task.
- *
- * It's reasonable to return hash code of wrapped view (if any) to prevent displaying non-actual images in view
- * because of view re-using.
- */
- int getId();
-
- /**
- * Sets image drawable into this image aware view.
- * Displays drawable in this image aware view
- * {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions.Builder#showImageForEmptyUri(
- *android.graphics.drawable.Drawable) for empty Uri},
- * {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions.Builder#showImageOnLoading(
- *android.graphics.drawable.Drawable) on loading} or
- * {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions.Builder#showImageOnFail(
- *android.graphics.drawable.Drawable) on loading fail}. These drawables can be specified in
- * {@linkplain com.nostra13.universalimageloader.core.DisplayImageOptions display options}.
- * Also can be called in {@link com.nostra13.universalimageloader.core.display.BitmapDisplayer BitmapDisplayer}.< br />
- * Is called on UI thread if ImageLoader was called on UI thread. Otherwise - on background thread.
- *
- * @return true if drawable was set successfully; false - otherwise
- */
- boolean setImageDrawable(Drawable drawable);
-
- /**
- * Sets image bitmap into this image aware view.
- * Displays loaded and decoded image {@link android.graphics.Bitmap} in this image view aware.
- * Actually it's used only in
- * {@link com.nostra13.universalimageloader.core.display.BitmapDisplayer BitmapDisplayer}.< br />
- * Is called on UI thread if ImageLoader was called on UI thread. Otherwise - on background thread.
- *
- * @return true if bitmap was set successfully; false - otherwise
- */
- boolean setImageBitmap(Bitmap bitmap);
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/imageaware/ImageViewAware.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/imageaware/ImageViewAware.java
deleted file mode 100644
index 418f6b0a4..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/imageaware/ImageViewAware.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*******************************************************************************
- * Copyright 2013-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.imageaware;
-
-import android.graphics.Bitmap;
-import android.graphics.drawable.AnimationDrawable;
-import android.graphics.drawable.Drawable;
-import android.view.View;
-import android.widget.ImageView;
-import com.nostra13.universalimageloader.core.assist.ViewScaleType;
-import com.nostra13.universalimageloader.utils.L;
-
-import java.lang.reflect.Field;
-
-/**
- * Wrapper for Android {@link android.widget.ImageView ImageView}. Keeps weak reference of ImageView to prevent memory
- * leaks.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.9.0
- */
-public class ImageViewAware extends ViewAware {
-
- /**
- * Constructor.
- * References {@link #ImageViewAware(android.widget.ImageView, boolean) ImageViewAware(imageView, true)}.
- *
- * @param imageView {@link android.widget.ImageView ImageView} to work with
- */
- public ImageViewAware(ImageView imageView) {
- super(imageView);
- }
-
- /**
- * Constructor
- *
- * @param imageView {@link android.widget.ImageView ImageView} to work with
- * @param checkActualViewSize true - then {@link #getWidth()} and {@link #getHeight()} will check actual
- * size of ImageView. It can cause known issues like
- * this.
- * But it helps to save memory because memory cache keeps bitmaps of actual (less in
- * general) size.
- *
- * false - then {@link #getWidth()} and {@link #getHeight()} will NOT
- * consider actual size of ImageView, just layout parameters.
If you set 'false'
- * it's recommended 'android:layout_width' and 'android:layout_height' (or
- * 'android:maxWidth' and 'android:maxHeight') are set with concrete values. It helps to
- * save memory.
- *
- */
- public ImageViewAware(ImageView imageView, boolean checkActualViewSize) {
- super(imageView, checkActualViewSize);
- }
-
- /**
- * {@inheritDoc}
- *
- * 3) Get maxWidth.
- */
- @Override
- public int getWidth() {
- int width = super.getWidth();
- if (width <= 0) {
- ImageView imageView = (ImageView) viewRef.get();
- if (imageView != null) {
- width = getImageViewFieldValue(imageView, "mMaxWidth"); // Check maxWidth parameter
- }
- }
- return width;
- }
-
- /**
- * {@inheritDoc}
- *
- * 3) Get maxHeight
- */
- @Override
- public int getHeight() {
- int height = super.getHeight();
- if (height <= 0) {
- ImageView imageView = (ImageView) viewRef.get();
- if (imageView != null) {
- height = getImageViewFieldValue(imageView, "mMaxHeight"); // Check maxHeight parameter
- }
- }
- return height;
- }
-
- @Override
- public ViewScaleType getScaleType() {
- ImageView imageView = (ImageView) viewRef.get();
- if (imageView != null) {
- return ViewScaleType.fromImageView(imageView);
- }
- return super.getScaleType();
- }
-
- @Override
- public ImageView getWrappedView() {
- return (ImageView) super.getWrappedView();
- }
-
- @Override
- protected void setImageDrawableInto(Drawable drawable, View view) {
- ((ImageView) view).setImageDrawable(drawable);
- if (drawable instanceof AnimationDrawable) {
- ((AnimationDrawable)drawable).start();
- }
- }
-
- @Override
- protected void setImageBitmapInto(Bitmap bitmap, View view) {
- ((ImageView) view).setImageBitmap(bitmap);
- }
-
- private static int getImageViewFieldValue(Object object, String fieldName) {
- int value = 0;
- try {
- Field field = ImageView.class.getDeclaredField(fieldName);
- field.setAccessible(true);
- int fieldValue = (Integer) field.get(object);
- if (fieldValue > 0 && fieldValue < Integer.MAX_VALUE) {
- value = fieldValue;
- }
- } catch (Exception e) {
- L.e(e);
- }
- return value;
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/imageaware/NonViewAware.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/imageaware/NonViewAware.java
deleted file mode 100644
index 1975bdfa3..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/imageaware/NonViewAware.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright 2013-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.imageaware;
-
-import android.graphics.Bitmap;
-import android.graphics.drawable.Drawable;
-import android.text.TextUtils;
-import android.view.View;
-import com.nostra13.universalimageloader.core.assist.ImageSize;
-import com.nostra13.universalimageloader.core.assist.ViewScaleType;
-
-/**
- * ImageAware which provides needed info for processing of original image but do nothing for displaying image. It's
- * used when user need just load and decode image and get it in {@linkplain
- * com.nostra13.universalimageloader.core.listener.ImageLoadingListener#onLoadingComplete(String, android.view.View,
- * android.graphics.Bitmap) callback}.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.9.0
- */
-public class NonViewAware implements ImageAware {
-
- protected final String imageUri;
- protected final ImageSize imageSize;
- protected final ViewScaleType scaleType;
-
- public NonViewAware(ImageSize imageSize, ViewScaleType scaleType) {
- this(null, imageSize, scaleType);
- }
-
- public NonViewAware(String imageUri, ImageSize imageSize, ViewScaleType scaleType) {
- if (imageSize == null) throw new IllegalArgumentException("imageSize must not be null");
- if (scaleType == null) throw new IllegalArgumentException("scaleType must not be null");
-
- this.imageUri = imageUri;
- this.imageSize = imageSize;
- this.scaleType = scaleType;
- }
-
- @Override
- public int getWidth() {
- return imageSize.getWidth();
- }
-
- @Override
- public int getHeight() {
- return imageSize.getHeight();
- }
-
- @Override
- public ViewScaleType getScaleType() {
- return scaleType;
- }
-
- @Override
- public View getWrappedView() {
- return null;
- }
-
- @Override
- public boolean isCollected() {
- return false;
- }
-
- @Override
- public int getId() {
- return TextUtils.isEmpty(imageUri) ? super.hashCode() : imageUri.hashCode();
- }
-
- @Override
- public boolean setImageDrawable(Drawable drawable) { // Do nothing
- return true;
- }
-
- @Override
- public boolean setImageBitmap(Bitmap bitmap) { // Do nothing
- return true;
- }
-}
\ No newline at end of file
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/imageaware/ViewAware.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/imageaware/ViewAware.java
deleted file mode 100644
index af6871531..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/imageaware/ViewAware.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright 2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.imageaware;
-
-import android.graphics.Bitmap;
-import android.graphics.drawable.Drawable;
-import android.os.Looper;
-import android.view.View;
-import android.view.ViewGroup;
-import com.nostra13.universalimageloader.core.assist.ViewScaleType;
-import com.nostra13.universalimageloader.utils.L;
-
-import java.lang.ref.Reference;
-import java.lang.ref.WeakReference;
-
-/**
- * Wrapper for Android {@link android.view.View View}. Keeps weak reference of View to prevent memory leaks.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.9.2
- */
-public abstract class ViewAware implements ImageAware {
-
- public static final String WARN_CANT_SET_DRAWABLE = "Can't set a drawable into view. You should call ImageLoader on UI thread for it.";
- public static final String WARN_CANT_SET_BITMAP = "Can't set a bitmap into view. You should call ImageLoader on UI thread for it.";
-
- protected Reference viewRef;
- protected boolean checkActualViewSize;
-
- /**
- * Constructor.
- * References {@link #ViewAware(android.view.View, boolean) ImageViewAware(imageView, true)}.
- *
- * @param view {@link android.view.View View} to work with
- */
- public ViewAware(View view) {
- this(view, true);
- }
-
- /**
- * Constructor
- *
- * @param view {@link android.view.View View} to work with
- * @param checkActualViewSize true - then {@link #getWidth()} and {@link #getHeight()} will check actual
- * size of View. It can cause known issues like
- * this.
- * But it helps to save memory because memory cache keeps bitmaps of actual (less in
- * general) size.
- *
- * false - then {@link #getWidth()} and {@link #getHeight()} will NOT
- * consider actual size of View, just layout parameters.
If you set 'false'
- * it's recommended 'android:layout_width' and 'android:layout_height' (or
- * 'android:maxWidth' and 'android:maxHeight') are set with concrete values. It helps to
- * save memory.
- */
- public ViewAware(View view, boolean checkActualViewSize) {
- if (view == null) throw new IllegalArgumentException("view must not be null");
-
- this.viewRef = new WeakReference(view);
- this.checkActualViewSize = checkActualViewSize;
- }
-
- /**
- * {@inheritDoc}
- *
- * Width is defined by target {@link android.view.View view} parameters, configuration
- * parameters or device display dimensions.
- * Size computing algorithm (go by steps until get non-zero value):
- * 1) Get the actual drawn getWidth() of the View
- * 2) Get layout_width
- */
- @Override
- public int getWidth() {
- View view = viewRef.get();
- if (view != null) {
- final ViewGroup.LayoutParams params = view.getLayoutParams();
- int width = 0;
- if (checkActualViewSize && params != null && params.width != ViewGroup.LayoutParams.WRAP_CONTENT) {
- width = view.getWidth(); // Get actual image width
- }
- if (width <= 0 && params != null) width = params.width; // Get layout width parameter
- return width;
- }
- return 0;
- }
-
- /**
- * {@inheritDoc}
- *
- * Height is defined by target {@link android.view.View view} parameters, configuration
- * parameters or device display dimensions.
- * Size computing algorithm (go by steps until get non-zero value):
- * 1) Get the actual drawn getHeight() of the View
- * 2) Get layout_height
- */
- @Override
- public int getHeight() {
- View view = viewRef.get();
- if (view != null) {
- final ViewGroup.LayoutParams params = view.getLayoutParams();
- int height = 0;
- if (checkActualViewSize && params != null && params.height != ViewGroup.LayoutParams.WRAP_CONTENT) {
- height = view.getHeight(); // Get actual image height
- }
- if (height <= 0 && params != null) height = params.height; // Get layout height parameter
- return height;
- }
- return 0;
- }
-
- @Override
- public ViewScaleType getScaleType() {
- return ViewScaleType.CROP;
- }
-
- @Override
- public View getWrappedView() {
- return viewRef.get();
- }
-
- @Override
- public boolean isCollected() {
- return viewRef.get() == null;
- }
-
- @Override
- public int getId() {
- View view = viewRef.get();
- return view == null ? super.hashCode() : view.hashCode();
- }
-
- @Override
- public boolean setImageDrawable(Drawable drawable) {
- if (Looper.myLooper() == Looper.getMainLooper()) {
- View view = viewRef.get();
- if (view != null) {
- setImageDrawableInto(drawable, view);
- return true;
- }
- } else {
- L.w(WARN_CANT_SET_DRAWABLE);
- }
- return false;
- }
-
- @Override
- public boolean setImageBitmap(Bitmap bitmap) {
- if (Looper.myLooper() == Looper.getMainLooper()) {
- View view = viewRef.get();
- if (view != null) {
- setImageBitmapInto(bitmap, view);
- return true;
- }
- } else {
- L.w(WARN_CANT_SET_BITMAP);
- }
- return false;
- }
-
- /**
- * Should set drawable into incoming view. Incoming view is guaranteed not null.
- * This method is called on UI thread.
- */
- protected abstract void setImageDrawableInto(Drawable drawable, View view);
-
- /**
- * Should set Bitmap into incoming view. Incoming view is guaranteed not null.< br />
- * This method is called on UI thread.
- */
- protected abstract void setImageBitmapInto(Bitmap bitmap, View view);
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/listener/ImageLoadingListener.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/listener/ImageLoadingListener.java
deleted file mode 100644
index 7be04fbcf..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/listener/ImageLoadingListener.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2013 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.listener;
-
-import android.graphics.Bitmap;
-import android.view.View;
-import com.nostra13.universalimageloader.core.assist.FailReason;
-
-/**
- * Listener for image loading process.
- * You can use {@link SimpleImageLoadingListener} for implementing only needed methods.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @see SimpleImageLoadingListener
- * @see com.nostra13.universalimageloader.core.assist.FailReason
- * @since 1.0.0
- */
-public interface ImageLoadingListener {
-
- /**
- * Is called when image loading task was started
- *
- * @param imageUri Loading image URI
- * @param view View for image
- */
- void onLoadingStarted(String imageUri, View view);
-
- /**
- * Is called when an error was occurred during image loading
- *
- * @param imageUri Loading image URI
- * @param view View for image. Can be null.
- * @param failReason {@linkplain com.nostra13.universalimageloader.core.assist.FailReason The reason} why image
- * loading was failed
- */
- void onLoadingFailed(String imageUri, View view, FailReason failReason);
-
- /**
- * Is called when image is loaded successfully (and displayed in View if one was specified)
- *
- * @param imageUri Loaded image URI
- * @param view View for image. Can be null.
- * @param loadedImage Bitmap of loaded and decoded image
- */
- void onLoadingComplete(String imageUri, View view, Bitmap loadedImage);
-
- /**
- * Is called when image loading task was cancelled because View for image was reused in newer task
- *
- * @param imageUri Loading image URI
- * @param view View for image. Can be null.
- */
- void onLoadingCancelled(String imageUri, View view);
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/listener/ImageLoadingProgressListener.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/listener/ImageLoadingProgressListener.java
deleted file mode 100644
index c9ce6848c..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/listener/ImageLoadingProgressListener.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright 2013 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.listener;
-
-import android.view.View;
-
-/**
- * Listener for image loading progress.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.9.1
- */
-public interface ImageLoadingProgressListener {
-
- /**
- * Is called when image loading progress changed.
- *
- * @param imageUri Image URI
- * @param view View for image. Can be null.
- * @param current Downloaded size in bytes
- * @param total Total size in bytes
- */
- void onProgressUpdate(String imageUri, View view, int current, int total);
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/listener/PauseOnScrollListener.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/listener/PauseOnScrollListener.java
deleted file mode 100644
index 870822f65..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/listener/PauseOnScrollListener.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2013 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.listener;
-
-import android.widget.AbsListView;
-import android.widget.AbsListView.OnScrollListener;
-import android.widget.GridView;
-import android.widget.ListView;
-import com.nostra13.universalimageloader.core.ImageLoader;
-
-/**
- * Listener-helper for {@linkplain AbsListView list views} ({@link ListView}, {@link GridView}) which can
- * {@linkplain ImageLoader#pause() pause ImageLoader's tasks} while list view is scrolling (touch scrolling and/or
- * fling). It prevents redundant loadings.
- * Set it to your list view's {@link AbsListView#setOnScrollListener(OnScrollListener) setOnScrollListener(...)}.
- * This listener can wrap your custom {@linkplain OnScrollListener listener}.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.7.0
- */
-public class PauseOnScrollListener implements OnScrollListener {
-
- private ImageLoader imageLoader;
-
- private final boolean pauseOnScroll;
- private final boolean pauseOnFling;
- private final OnScrollListener externalListener;
-
- /**
- * Constructor
- *
- * @param imageLoader {@linkplain ImageLoader} instance for controlling
- * @param pauseOnScroll Whether {@linkplain ImageLoader#pause() pause ImageLoader} during touch scrolling
- * @param pauseOnFling Whether {@linkplain ImageLoader#pause() pause ImageLoader} during fling
- */
- public PauseOnScrollListener(ImageLoader imageLoader, boolean pauseOnScroll, boolean pauseOnFling) {
- this(imageLoader, pauseOnScroll, pauseOnFling, null);
- }
-
- /**
- * Constructor
- *
- * @param imageLoader {@linkplain ImageLoader} instance for controlling
- * @param pauseOnScroll Whether {@linkplain ImageLoader#pause() pause ImageLoader} during touch scrolling
- * @param pauseOnFling Whether {@linkplain ImageLoader#pause() pause ImageLoader} during fling
- * @param customListener Your custom {@link OnScrollListener} for {@linkplain AbsListView list view} which also
- * will be get scroll events
- */
- public PauseOnScrollListener(ImageLoader imageLoader, boolean pauseOnScroll, boolean pauseOnFling,
- OnScrollListener customListener) {
- this.imageLoader = imageLoader;
- this.pauseOnScroll = pauseOnScroll;
- this.pauseOnFling = pauseOnFling;
- externalListener = customListener;
- }
-
- @Override
- public void onScrollStateChanged(AbsListView view, int scrollState) {
- switch (scrollState) {
- case OnScrollListener.SCROLL_STATE_IDLE:
- imageLoader.resume();
- break;
- case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
- if (pauseOnScroll) {
- imageLoader.pause();
- }
- break;
- case OnScrollListener.SCROLL_STATE_FLING:
- if (pauseOnFling) {
- imageLoader.pause();
- }
- break;
- }
- if (externalListener != null) {
- externalListener.onScrollStateChanged(view, scrollState);
- }
- }
-
- @Override
- public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
- if (externalListener != null) {
- externalListener.onScroll(view, firstVisibleItem, visibleItemCount, totalItemCount);
- }
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/listener/SimpleImageLoadingListener.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/listener/SimpleImageLoadingListener.java
deleted file mode 100644
index 3e42223d5..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/listener/SimpleImageLoadingListener.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2013 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.listener;
-
-import android.graphics.Bitmap;
-import android.view.View;
-import com.nostra13.universalimageloader.core.assist.FailReason;
-
-/**
- * A convenient class to extend when you only want to listen for a subset of all the image loading events. This
- * implements all methods in the {@link com.nostra13.universalimageloader.core.listener.ImageLoadingListener} but does
- * nothing.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.4.0
- */
-public class SimpleImageLoadingListener implements ImageLoadingListener {
- @Override
- public void onLoadingStarted(String imageUri, View view) {
- // Empty implementation
- }
-
- @Override
- public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
- // Empty implementation
- }
-
- @Override
- public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
- // Empty implementation
- }
-
- @Override
- public void onLoadingCancelled(String imageUri, View view) {
- // Empty implementation
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/process/BitmapProcessor.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/process/BitmapProcessor.java
deleted file mode 100644
index 962605dbd..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/core/process/BitmapProcessor.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2013 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.core.process;
-
-import android.graphics.Bitmap;
-import com.nostra13.universalimageloader.core.DisplayImageOptions;
-
-/**
- * Makes some processing on {@link Bitmap}. Implementations can apply any changes to original {@link Bitmap}.
- * Implementations have to be thread-safe.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.8.0
- */
-public interface BitmapProcessor {
- /**
- * Makes some processing of incoming bitmap.
- * This method is executing on additional thread (not on UI thread).
- * Note: If this processor is used as {@linkplain DisplayImageOptions.Builder#preProcessor(BitmapProcessor)
- * pre-processor} then don't forget {@linkplain Bitmap#recycle() to recycle} incoming bitmap if you return a new
- * created one.
- *
- * @param bitmap Original {@linkplain Bitmap bitmap}
- * @return Processed {@linkplain Bitmap bitmap}
- */
- Bitmap process(Bitmap bitmap);
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/utils/DiskCacheUtils.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/utils/DiskCacheUtils.java
deleted file mode 100644
index 3b17fd7d4..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/utils/DiskCacheUtils.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.utils;
-
-import com.nostra13.universalimageloader.cache.disc.DiskCache;
-
-import java.io.File;
-
-/**
- * Utility for convenient work with disk cache.
- * NOTE: This utility works with file system so avoid using it on application main thread.
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.8.0
- */
-public final class DiskCacheUtils {
-
- private DiskCacheUtils() {
- }
-
- /** Returns {@link File} of cached image or null if image was not cached in disk cache */
- public static File findInCache(String imageUri, DiskCache diskCache) {
- File image = diskCache.get(imageUri);
- return image != null && image.exists() ? image : null;
- }
-
- /**
- * Removed cached image file from disk cache (if image was cached in disk cache before)
- *
- * @return true - if cached image file existed and was deleted; false - otherwise.
- */
- public static boolean removeFromCache(String imageUri, DiskCache diskCache) {
- File image = diskCache.get(imageUri);
- return image != null && image.exists() && image.delete();
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/utils/ImageSizeUtils.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/utils/ImageSizeUtils.java
deleted file mode 100644
index d899b8d83..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/utils/ImageSizeUtils.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*******************************************************************************
- * Copyright 2013-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.utils;
-
-import android.graphics.BitmapFactory;
-import android.opengl.GLES10;
-import com.nostra13.universalimageloader.core.assist.ImageSize;
-import com.nostra13.universalimageloader.core.assist.ViewScaleType;
-import com.nostra13.universalimageloader.core.imageaware.ImageAware;
-
-import javax.microedition.khronos.opengles.GL10;
-
-/**
- * Provides calculations with image sizes, scales
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.8.3
- */
-public final class ImageSizeUtils {
-
- private static final int DEFAULT_MAX_BITMAP_DIMENSION = 2048;
-
- private static ImageSize maxBitmapSize;
-
- static {
- int[] maxTextureSize = new int[1];
- GLES10.glGetIntegerv(GL10.GL_MAX_TEXTURE_SIZE, maxTextureSize, 0);
- int maxBitmapDimension = Math.max(maxTextureSize[0], DEFAULT_MAX_BITMAP_DIMENSION);
- maxBitmapSize = new ImageSize(maxBitmapDimension, maxBitmapDimension);
- }
-
- private ImageSizeUtils() {
- }
-
- /**
- * Defines target size for image aware view. Size is defined by target
- * {@link com.nostra13.universalimageloader.core.imageaware.ImageAware view} parameters, configuration
- * parameters or device display dimensions.
- */
- public static ImageSize defineTargetSizeForView(ImageAware imageAware, ImageSize maxImageSize) {
- int width = imageAware.getWidth();
- if (width <= 0) width = maxImageSize.getWidth();
-
- int height = imageAware.getHeight();
- if (height <= 0) height = maxImageSize.getHeight();
-
- return new ImageSize(width, height);
- }
-
- /**
- * Computes sample size for downscaling image size (srcSize) to view size (targetSize). This sample
- * size is used during
- * {@linkplain BitmapFactory#decodeStream(java.io.InputStream, android.graphics.Rect, android.graphics.BitmapFactory.Options)
- * decoding image} to bitmap.
- *
- * Examples:
- *
- *
- * srcSize(100x100), targetSize(10x10), powerOf2Scale = true -> sampleSize = 8
- * srcSize(100x100), targetSize(10x10), powerOf2Scale = false -> sampleSize = 10
- *
- * srcSize(100x100), targetSize(20x40), viewScaleType = FIT_INSIDE -> sampleSize = 5
- * srcSize(100x100), targetSize(20x40), viewScaleType = CROP -> sampleSize = 2
- *
- *
- *
- * The sample size is the number of pixels in either dimension that correspond to a single pixel in the decoded
- * bitmap. For example, inSampleSize == 4 returns an image that is 1/4 the width/height of the original, and 1/16
- * the number of pixels. Any value <= 1 is treated the same as 1.
- *
- * @param srcSize Original (image) size
- * @param targetSize Target (view) size
- * @param viewScaleType {@linkplain ViewScaleType Scale type} for placing image in view
- * @param powerOf2Scale true - if sample size be a power of 2 (1, 2, 4, 8, ...)
- * @return Computed sample size
- */
- public static int computeImageSampleSize(ImageSize srcSize, ImageSize targetSize, ViewScaleType viewScaleType,
- boolean powerOf2Scale) {
- final int srcWidth = srcSize.getWidth();
- final int srcHeight = srcSize.getHeight();
- final int targetWidth = targetSize.getWidth();
- final int targetHeight = targetSize.getHeight();
-
- int scale = 1;
-
- switch (viewScaleType) {
- case FIT_INSIDE:
- if (powerOf2Scale) {
- final int halfWidth = srcWidth / 2;
- final int halfHeight = srcHeight / 2;
- while ((halfWidth / scale) > targetWidth || (halfHeight / scale) > targetHeight) { // ||
- scale *= 2;
- }
- } else {
- scale = Math.max(srcWidth / targetWidth, srcHeight / targetHeight); // max
- }
- break;
- case CROP:
- if (powerOf2Scale) {
- final int halfWidth = srcWidth / 2;
- final int halfHeight = srcHeight / 2;
- while ((halfWidth / scale) > targetWidth && (halfHeight / scale) > targetHeight) { // &&
- scale *= 2;
- }
- } else {
- scale = Math.min(srcWidth / targetWidth, srcHeight / targetHeight); // min
- }
- break;
- }
-
- if (scale < 1) {
- scale = 1;
- }
- scale = considerMaxTextureSize(srcWidth, srcHeight, scale, powerOf2Scale);
-
- return scale;
- }
-
- private static int considerMaxTextureSize(int srcWidth, int srcHeight, int scale, boolean powerOf2) {
- final int maxWidth = maxBitmapSize.getWidth();
- final int maxHeight = maxBitmapSize.getHeight();
- while ((srcWidth / scale) > maxWidth || (srcHeight / scale) > maxHeight) {
- if (powerOf2) {
- scale *= 2;
- } else {
- scale++;
- }
- }
- return scale;
- }
-
- /**
- * Computes minimal sample size for downscaling image so result image size won't exceed max acceptable OpenGL
- * texture size.
- * We can't create Bitmap in memory with size exceed max texture size (usually this is 2048x2048) so this method
- * calculate minimal sample size which should be applied to image to fit into these limits.
- *
- * @param srcSize Original image size
- * @return Minimal sample size
- */
- public static int computeMinImageSampleSize(ImageSize srcSize) {
- final int srcWidth = srcSize.getWidth();
- final int srcHeight = srcSize.getHeight();
- final int targetWidth = maxBitmapSize.getWidth();
- final int targetHeight = maxBitmapSize.getHeight();
-
- final int widthScale = (int) Math.ceil((float) srcWidth / targetWidth);
- final int heightScale = (int) Math.ceil((float) srcHeight / targetHeight);
-
- return Math.max(widthScale, heightScale); // max
- }
-
- /**
- * Computes scale of target size (targetSize) to source size (srcSize).
- *
- * Examples:
- *
- *
- * srcSize(40x40), targetSize(10x10) -> scale = 0.25
- *
- * srcSize(10x10), targetSize(20x20), stretch = false -> scale = 1
- * srcSize(10x10), targetSize(20x20), stretch = true -> scale = 2
- *
- * srcSize(100x100), targetSize(20x40), viewScaleType = FIT_INSIDE -> scale = 0.2
- * srcSize(100x100), targetSize(20x40), viewScaleType = CROP -> scale = 0.4
- *
- *
- * @param srcSize Source (image) size
- * @param targetSize Target (view) size
- * @param viewScaleType {@linkplain ViewScaleType Scale type} for placing image in view
- * @param stretch Whether source size should be stretched if target size is larger than source size. If false
- * then result scale value can't be greater than 1.
- * @return Computed scale
- */
- public static float computeImageScale(ImageSize srcSize, ImageSize targetSize, ViewScaleType viewScaleType,
- boolean stretch) {
- final int srcWidth = srcSize.getWidth();
- final int srcHeight = srcSize.getHeight();
- final int targetWidth = targetSize.getWidth();
- final int targetHeight = targetSize.getHeight();
-
- final float widthScale = (float) srcWidth / targetWidth;
- final float heightScale = (float) srcHeight / targetHeight;
-
- final int destWidth;
- final int destHeight;
- if ((viewScaleType == ViewScaleType.FIT_INSIDE && widthScale >= heightScale) || (viewScaleType == ViewScaleType.CROP && widthScale < heightScale)) {
- destWidth = targetWidth;
- destHeight = (int) (srcHeight / widthScale);
- } else {
- destWidth = (int) (srcWidth / heightScale);
- destHeight = targetHeight;
- }
-
- float scale = 1;
- if ((!stretch && destWidth < srcWidth && destHeight < srcHeight) || (stretch && destWidth != srcWidth && destHeight != srcHeight)) {
- scale = (float) destWidth / srcWidth;
- }
-
- return scale;
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/utils/IoUtils.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/utils/IoUtils.java
deleted file mode 100644
index 498f3c2fc..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/utils/IoUtils.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.utils;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * Provides I/O operations
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.0.0
- */
-public final class IoUtils {
-
- /** {@value} */
- public static final int DEFAULT_BUFFER_SIZE = 32 * 1024; // 32 KB
- /** {@value} */
- public static final int DEFAULT_IMAGE_TOTAL_SIZE = 500 * 1024; // 500 Kb
- /** {@value} */
- public static final int CONTINUE_LOADING_PERCENTAGE = 75;
-
- private IoUtils() {
- }
-
- /**
- * Copies stream, fires progress events by listener, can be interrupted by listener. Uses buffer size =
- * {@value #DEFAULT_BUFFER_SIZE} bytes.
- *
- * @param is Input stream
- * @param os Output stream
- * @param listener null-ok; Listener of copying progress and controller of copying interrupting
- * @return true - if stream copied successfully; false - if copying was interrupted by listener
- * @throws IOException
- */
- public static boolean copyStream(InputStream is, OutputStream os, CopyListener listener) throws IOException {
- return copyStream(is, os, listener, DEFAULT_BUFFER_SIZE);
- }
-
- /**
- * Copies stream, fires progress events by listener, can be interrupted by listener.
- *
- * @param is Input stream
- * @param os Output stream
- * @param listener null-ok; Listener of copying progress and controller of copying interrupting
- * @param bufferSize Buffer size for copying, also represents a step for firing progress listener callback, i.e.
- * progress event will be fired after every copied bufferSize bytes
- * @return true - if stream copied successfully; false - if copying was interrupted by listener
- * @throws IOException
- */
- public static boolean copyStream(InputStream is, OutputStream os, CopyListener listener, int bufferSize)
- throws IOException {
- int current = 0;
- int total = is.available();
- if (total <= 0) {
- total = DEFAULT_IMAGE_TOTAL_SIZE;
- }
-
- final byte[] bytes = new byte[bufferSize];
- int count;
- if (shouldStopLoading(listener, current, total)) return false;
- while ((count = is.read(bytes, 0, bufferSize)) != -1) {
- os.write(bytes, 0, count);
- current += count;
- if (shouldStopLoading(listener, current, total)) return false;
- }
- os.flush();
- return true;
- }
-
- private static boolean shouldStopLoading(CopyListener listener, int current, int total) {
- if (listener != null) {
- boolean shouldContinue = listener.onBytesCopied(current, total);
- if (!shouldContinue) {
- if (100 * current / total < CONTINUE_LOADING_PERCENTAGE) {
- return true; // if loaded more than 75% then continue loading anyway
- }
- }
- }
- return false;
- }
-
- /**
- * Reads all data from stream and close it silently
- *
- * @param is Input stream
- */
- public static void readAndCloseStream(InputStream is) {
- final byte[] bytes = new byte[DEFAULT_BUFFER_SIZE];
- try {
- while (is.read(bytes, 0, DEFAULT_BUFFER_SIZE) != -1);
- } catch (IOException ignored) {
- } finally {
- closeSilently(is);
- }
- }
-
- public static void closeSilently(Closeable closeable) {
- if (closeable != null) {
- try {
- closeable.close();
- } catch (Exception ignored) {
- }
- }
- }
-
- /** Listener and controller for copy process */
- public static interface CopyListener {
- /**
- * @param current Loaded bytes
- * @param total Total bytes for loading
- * @return true - if copying should be continued; false - if copying should be interrupted
- */
- boolean onBytesCopied(int current, int total);
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/utils/L.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/utils/L.java
deleted file mode 100644
index 427b8671e..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/utils/L.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.utils;
-
-import android.util.Log;
-import com.nostra13.universalimageloader.core.ImageLoader;
-
-/**
- * "Less-word" analog of Android {@link android.util.Log logger}
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.6.4
- */
-public final class L {
-
- private static final String LOG_FORMAT = "%1$s\n%2$s";
- private static volatile boolean writeDebugLogs = false;
- private static volatile boolean writeLogs = true;
-
- private L() {
- }
-
- /**
- * Enables logger (if {@link #disableLogging()} was called before)
- *
- * @deprecated Use {@link #writeLogs(boolean) writeLogs(true)} instead
- */
- @Deprecated
- public static void enableLogging() {
- writeLogs(true);
- }
-
- /**
- * Disables logger, no logs will be passed to LogCat, all log methods will do nothing
- *
- * @deprecated Use {@link #writeLogs(boolean) writeLogs(false)} instead
- */
- @Deprecated
- public static void disableLogging() {
- writeLogs(false);
- }
-
- /**
- * Enables/disables detail logging of {@link ImageLoader} work.
- * Consider {@link com.nostra13.universalimageloader.utils.L#disableLogging()} to disable
- * ImageLoader logging completely (even error logs)
- * Debug logs are disabled by default.
- */
- public static void writeDebugLogs(boolean writeDebugLogs) {
- L.writeDebugLogs = writeDebugLogs;
- }
-
- /** Enables/disables logging of {@link ImageLoader} completely (even error logs). */
- public static void writeLogs(boolean writeLogs) {
- L.writeLogs = writeLogs;
- }
-
- public static void d(String message, Object... args) {
- if (writeDebugLogs) {
- log(Log.DEBUG, null, message, args);
- }
- }
-
- public static void i(String message, Object... args) {
- log(Log.INFO, null, message, args);
- }
-
- public static void w(String message, Object... args) {
- log(Log.WARN, null, message, args);
- }
-
- public static void e(Throwable ex) {
- log(Log.ERROR, ex, null);
- }
-
- public static void e(String message, Object... args) {
- log(Log.ERROR, null, message, args);
- }
-
- public static void e(Throwable ex, String message, Object... args) {
- log(Log.ERROR, ex, message, args);
- }
-
- private static void log(int priority, Throwable ex, String message, Object... args) {
- if (!writeLogs) return;
- if (args.length > 0) {
- message = String.format(message, args);
- }
-
- String log;
- if (ex == null) {
- log = message;
- } else {
- String logMessage = message == null ? ex.getMessage() : message;
- String logBody = Log.getStackTraceString(ex);
- log = String.format(LOG_FORMAT, logMessage, logBody);
- }
- Log.println(priority, ImageLoader.TAG, log);
- }
-}
\ No newline at end of file
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/utils/MemoryCacheUtils.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/utils/MemoryCacheUtils.java
deleted file mode 100644
index 39bed8799..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/utils/MemoryCacheUtils.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.utils;
-
-import android.graphics.Bitmap;
-
-import com.nostra13.universalimageloader.cache.memory.MemoryCache;
-import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;
-import com.nostra13.universalimageloader.core.assist.ImageSize;
-
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.List;
-
-/**
- * Utility for generating of keys for memory cache, key comparing and other work with memory cache
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.6.3
- */
-public final class MemoryCacheUtils {
-
- private static final String URI_AND_SIZE_SEPARATOR = "_";
- private static final String WIDTH_AND_HEIGHT_SEPARATOR = "x";
-
- private MemoryCacheUtils() {
- }
-
- /**
- * Generates key for memory cache for incoming image (URI + size).
- * Pattern for cache key - [imageUri]_[width]x[height].
- */
- public static String generateKey(String imageUri, ImageSize targetSize) {
- return new StringBuilder(imageUri).append(URI_AND_SIZE_SEPARATOR).append(targetSize.getWidth()).append(WIDTH_AND_HEIGHT_SEPARATOR).append(targetSize.getHeight()).toString();
- }
-
- public static Comparator createFuzzyKeyComparator() {
- return new Comparator() {
- @Override
- public int compare(String key1, String key2) {
- String imageUri1 = key1.substring(0, key1.lastIndexOf(URI_AND_SIZE_SEPARATOR));
- String imageUri2 = key2.substring(0, key2.lastIndexOf(URI_AND_SIZE_SEPARATOR));
- return imageUri1.compareTo(imageUri2);
- }
- };
- }
-
- /**
- * Searches all bitmaps in memory cache which are corresponded to incoming URI.
- * Note: Memory cache can contain multiple sizes of the same image if only you didn't set
- * {@link ImageLoaderConfiguration.Builder#denyCacheImageMultipleSizesInMemory()
- * denyCacheImageMultipleSizesInMemory()} option in {@linkplain ImageLoaderConfiguration configuration}
- */
- public static List findCachedBitmapsForImageUri(String imageUri, MemoryCache memoryCache) {
- List values = new ArrayList();
- for (String key : memoryCache.keys()) {
- if (key.startsWith(imageUri)) {
- values.add(memoryCache.get(key));
- }
- }
- return values;
- }
-
- /**
- * Searches all keys in memory cache which are corresponded to incoming URI.
- * Note: Memory cache can contain multiple sizes of the same image if only you didn't set
- * {@link ImageLoaderConfiguration.Builder#denyCacheImageMultipleSizesInMemory()
- * denyCacheImageMultipleSizesInMemory()} option in {@linkplain ImageLoaderConfiguration configuration}
- */
- public static List findCacheKeysForImageUri(String imageUri, MemoryCache memoryCache) {
- List values = new ArrayList();
- for (String key : memoryCache.keys()) {
- if (key.startsWith(imageUri)) {
- values.add(key);
- }
- }
- return values;
- }
-
- /**
- * Removes from memory cache all images for incoming URI.
- * Note: Memory cache can contain multiple sizes of the same image if only you didn't set
- * {@link ImageLoaderConfiguration.Builder#denyCacheImageMultipleSizesInMemory()
- * denyCacheImageMultipleSizesInMemory()} option in {@linkplain ImageLoaderConfiguration configuration}
- */
- public static void removeFromCache(String imageUri, MemoryCache memoryCache) {
- List keysToRemove = new ArrayList();
- for (String key : memoryCache.keys()) {
- if (key.startsWith(imageUri)) {
- keysToRemove.add(key);
- }
- }
- for (String keyToRemove : keysToRemove) {
- memoryCache.remove(keyToRemove);
- }
- }
-}
diff --git a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/utils/StorageUtils.java b/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/utils/StorageUtils.java
deleted file mode 100644
index 13026495f..000000000
--- a/extern/UniversalImageLoader/library/src/com/nostra13/universalimageloader/utils/StorageUtils.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*******************************************************************************
- * Copyright 2011-2014 Sergey Tarasevich
- *
- * Licensed 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 com.nostra13.universalimageloader.utils;
-
-import android.content.Context;
-import android.content.pm.PackageManager;
-import android.os.Environment;
-
-import java.io.File;
-import java.io.IOException;
-
-import static android.os.Environment.MEDIA_MOUNTED;
-
-/**
- * Provides application storage paths
- *
- * @author Sergey Tarasevich (nostra13[at]gmail[dot]com)
- * @since 1.0.0
- */
-public final class StorageUtils {
-
- private static final String EXTERNAL_STORAGE_PERMISSION = "android.permission.WRITE_EXTERNAL_STORAGE";
- private static final String INDIVIDUAL_DIR_NAME = "uil-images";
-
- private StorageUtils() {
- }
-
- /**
- * Returns application cache directory. Cache directory will be created on SD card
- * ("/Android/data/[app_package_name]/cache") if card is mounted and app has appropriate permission. Else -
- * Android defines cache directory on device's file system.
- *
- * @param context Application context
- * @return Cache {@link File directory}.
- * NOTE: Can be null in some unpredictable cases (if SD card is unmounted and
- * {@link android.content.Context#getCacheDir() Context.getCacheDir()} returns null).
- */
- public static File getCacheDirectory(Context context) {
- return getCacheDirectory(context, true);
- }
-
- /**
- * Returns application cache directory. Cache directory will be created on SD card
- * ("/Android/data/[app_package_name]/cache") (if card is mounted and app has appropriate permission) or
- * on device's file system depending incoming parameters.
- *
- * @param context Application context
- * @param preferExternal Whether prefer external location for cache
- * @return Cache {@link File directory}.
- * NOTE: Can be null in some unpredictable cases (if SD card is unmounted and
- * {@link android.content.Context#getCacheDir() Context.getCacheDir()} returns null).
- */
- public static File getCacheDirectory(Context context, boolean preferExternal) {
- File appCacheDir = null;
- String externalStorageState;
- try {
- externalStorageState = Environment.getExternalStorageState();
- } catch (NullPointerException e) { // (sh)it happens (Issue #660)
- externalStorageState = "";
- } catch (IncompatibleClassChangeError e) { // (sh)it happens too (Issue #989)
- externalStorageState = "";
- }
- if (preferExternal && MEDIA_MOUNTED.equals(externalStorageState) && hasExternalStoragePermission(context)) {
- appCacheDir = getExternalCacheDir(context);
- }
- if (appCacheDir == null) {
- appCacheDir = context.getCacheDir();
- }
- if (appCacheDir == null) {
- String cacheDirPath = "/data/data/" + context.getPackageName() + "/cache/";
- L.w("Can't define system cache directory! '%s' will be used.", cacheDirPath);
- appCacheDir = new File(cacheDirPath);
- }
- return appCacheDir;
- }
-
- /**
- * Returns individual application cache directory (for only image caching from ImageLoader). Cache directory will be
- * created on SD card ("/Android/data/[app_package_name]/cache/uil-images") if card is mounted and app has
- * appropriate permission. Else - Android defines cache directory on device's file system.
- *
- * @param context Application context
- * @return Cache {@link File directory}
- */
- public static File getIndividualCacheDirectory(Context context) {
- return getIndividualCacheDirectory(context, INDIVIDUAL_DIR_NAME);
- }
-
- /**
- * Returns individual application cache directory (for only image caching from ImageLoader). Cache directory will be
- * created on SD card ("/Android/data/[app_package_name]/cache/uil-images") if card is mounted and app has
- * appropriate permission. Else - Android defines cache directory on device's file system.
- *
- * @param context Application context
- * @param cacheDir Cache directory path (e.g.: "AppCacheDir", "AppDir/cache/images")
- * @return Cache {@link File directory}
- */
- public static File getIndividualCacheDirectory(Context context, String cacheDir) {
- File appCacheDir = getCacheDirectory(context);
- File individualCacheDir = new File(appCacheDir, cacheDir);
- if (!individualCacheDir.exists()) {
- if (!individualCacheDir.mkdir()) {
- individualCacheDir = appCacheDir;
- }
- }
- return individualCacheDir;
- }
-
- /**
- * Returns specified application cache directory. Cache directory will be created on SD card by defined path if card
- * is mounted and app has appropriate permission. Else - Android defines cache directory on device's file system.
- *
- * @param context Application context
- * @param cacheDir Cache directory path (e.g.: "AppCacheDir", "AppDir/cache/images")
- * @return Cache {@link File directory}
- */
- public static File getOwnCacheDirectory(Context context, String cacheDir) {
- File appCacheDir = null;
- if (MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) && hasExternalStoragePermission(context)) {
- appCacheDir = new File(Environment.getExternalStorageDirectory(), cacheDir);
- }
- if (appCacheDir == null || (!appCacheDir.exists() && !appCacheDir.mkdirs())) {
- appCacheDir = context.getCacheDir();
- }
- return appCacheDir;
- }
-
- /**
- * Returns specified application cache directory. Cache directory will be created on SD card by defined path if card
- * is mounted and app has appropriate permission. Else - Android defines cache directory on device's file system.
- *
- * @param context Application context
- * @param cacheDir Cache directory path (e.g.: "AppCacheDir", "AppDir/cache/images")
- * @return Cache {@link File directory}
- */
- public static File getOwnCacheDirectory(Context context, String cacheDir, boolean preferExternal) {
- File appCacheDir = null;
- if (preferExternal && MEDIA_MOUNTED.equals(Environment.getExternalStorageState()) && hasExternalStoragePermission(context)) {
- appCacheDir = new File(Environment.getExternalStorageDirectory(), cacheDir);
- }
- if (appCacheDir == null || (!appCacheDir.exists() && !appCacheDir.mkdirs())) {
- appCacheDir = context.getCacheDir();
- }
- return appCacheDir;
- }
-
- private static File getExternalCacheDir(Context context) {
- File dataDir = new File(new File(Environment.getExternalStorageDirectory(), "Android"), "data");
- File appCacheDir = new File(new File(dataDir, context.getPackageName()), "cache");
- if (!appCacheDir.exists()) {
- if (!appCacheDir.mkdirs()) {
- L.w("Unable to create external cache directory");
- return null;
- }
- try {
- new File(appCacheDir, ".nomedia").createNewFile();
- } catch (IOException e) {
- L.i("Can't create \".nomedia\" file in application external cache directory");
- }
- }
- return appCacheDir;
- }
-
- private static boolean hasExternalStoragePermission(Context context) {
- int perm = context.checkCallingOrSelfPermission(EXTERNAL_STORAGE_PERMISSION);
- return perm == PackageManager.PERMISSION_GRANTED;
- }
-}
diff --git a/extern/UniversalImageLoader/settings.gradle b/extern/UniversalImageLoader/settings.gradle
deleted file mode 100644
index d8f14a134..000000000
--- a/extern/UniversalImageLoader/settings.gradle
+++ /dev/null
@@ -1 +0,0 @@
-include ':library'
diff --git a/extern/libsuperuser/LICENSE b/extern/libsuperuser/LICENSE
deleted file mode 100644
index ade750b16..000000000
--- a/extern/libsuperuser/LICENSE
+++ /dev/null
@@ -1,177 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
diff --git a/extern/libsuperuser/build.gradle b/extern/libsuperuser/build.gradle
deleted file mode 100644
index f3de435d5..000000000
--- a/extern/libsuperuser/build.gradle
+++ /dev/null
@@ -1,15 +0,0 @@
-buildscript {
- repositories {
- jcenter()
- }
-
- dependencies {
- classpath 'com.android.tools.build:gradle:1.0.0'
- }
-}
-
-allprojects {
- repositories {
- jcenter()
- }
-}
diff --git a/extern/libsuperuser/libsuperuser/.classpath b/extern/libsuperuser/libsuperuser/.classpath
deleted file mode 100644
index b76ec6cd4..000000000
--- a/extern/libsuperuser/libsuperuser/.classpath
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
diff --git a/extern/libsuperuser/libsuperuser/.project b/extern/libsuperuser/libsuperuser/.project
deleted file mode 100644
index 8f20a24e9..000000000
--- a/extern/libsuperuser/libsuperuser/.project
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
- libsuperuser
-
-
-
-
-
- com.android.ide.eclipse.adt.ResourceManagerBuilder
-
-
-
-
- com.android.ide.eclipse.adt.PreCompilerBuilder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
- com.saikoa.dexguard.eclipse.adt.ApkBuilder
-
-
-
-
- com.android.ide.eclipse.adt.ApkBuilder
-
-
-
-
-
- com.android.ide.eclipse.adt.AndroidNature
- org.eclipse.jdt.core.javanature
-
-
diff --git a/extern/libsuperuser/libsuperuser/AndroidManifest.xml b/extern/libsuperuser/libsuperuser/AndroidManifest.xml
deleted file mode 100644
index 2a7f3830e..000000000
--- a/extern/libsuperuser/libsuperuser/AndroidManifest.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
diff --git a/extern/libsuperuser/libsuperuser/build.gradle b/extern/libsuperuser/libsuperuser/build.gradle
deleted file mode 100644
index 8987b1ebe..000000000
--- a/extern/libsuperuser/libsuperuser/build.gradle
+++ /dev/null
@@ -1,56 +0,0 @@
-apply plugin: 'com.android.library'
-
-android {
- compileSdkVersion 21
- buildToolsVersion "23.0.1"
-
- defaultConfig {
- minSdkVersion 4
- targetSdkVersion 21
- }
-
- sourceSets {
- main {
- manifest.srcFile 'AndroidManifest.xml'
- java.srcDirs = ['src']
- resources.srcDirs = ['src']
- aidl.srcDirs = ['src']
- renderscript.srcDirs = ['src']
- res.srcDirs = ['res']
- assets.srcDirs = ['assets']
- }
- }
- compileOptions {
- sourceCompatibility JavaVersion.VERSION_1_6
- }
-}
-
-version = "1.0.0." + (new Date()).format('yyyyMMddHHmm')
-group = "eu.chainfire"
-
-dependencies {
-}
-
-task sourcesJar(type: Jar) {
- from android.sourceSets.main.java.srcDirs
- classifier = 'sources'
-}
-
-task javadoc(type: Javadoc) {
- source = android.sourceSets.main.java.srcDirs
- classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
-}
-
-task javadocJar(type: Jar, dependsOn: javadoc) {
- classifier = 'javadoc'
- from javadoc.destinationDir
-}
-
-artifacts {
- archives javadocJar
- archives sourcesJar
-}
-
-task findConventions << {
- println project.getConvention()
-}
diff --git a/extern/libsuperuser/libsuperuser/project.properties b/extern/libsuperuser/libsuperuser/project.properties
deleted file mode 100644
index 93c8c3c08..000000000
--- a/extern/libsuperuser/libsuperuser/project.properties
+++ /dev/null
@@ -1,15 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
-#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
-
-# Project target.
-target=android-21
-android.library=true
diff --git a/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/Application.java b/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/Application.java
deleted file mode 100644
index 095c7209b..000000000
--- a/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/Application.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Jorrit "Chainfire" Jongma
- *
- * Licensed 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 eu.chainfire.libsuperuser;
-
-import android.content.Context;
-import android.os.Handler;
-import android.widget.Toast;
-
-/**
- * Base application class to extend from, solving some issues with
- * toasts and AsyncTasks you are likely to run into
- */
-public class Application extends android.app.Application {
- /**
- * Shows a toast message
- *
- * @param context Any context belonging to this application
- * @param message The message to show
- */
- public static void toast(Context context, String message) {
- // this is a static method so it is easier to call,
- // as the context checking and casting is done for you
-
- if (context == null) return;
-
- if (!(context instanceof Application)) {
- context = context.getApplicationContext();
- }
-
- if (context instanceof Application) {
- final Context c = context;
- final String m = message;
-
- ((Application)context).runInApplicationThread(new Runnable() {
- @Override
- public void run() {
- Toast.makeText(c, m, Toast.LENGTH_LONG).show();
- }
- });
- }
- }
-
- private static Handler mApplicationHandler = new Handler();
-
- /**
- * Run a runnable in the main application thread
- *
- * @param r Runnable to run
- */
- public void runInApplicationThread(Runnable r) {
- mApplicationHandler.post(r);
- }
-
- @Override
- public void onCreate() {
- super.onCreate();
-
- try {
- // workaround bug in AsyncTask, can show up (for example) when you toast from a service
- // this makes sure AsyncTask's internal handler is created from the right (main) thread
- Class.forName("android.os.AsyncTask");
- } catch (ClassNotFoundException e) {
- // will never happen
- }
- }
-}
diff --git a/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/Debug.java b/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/Debug.java
deleted file mode 100644
index 6116c9abb..000000000
--- a/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/Debug.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Jorrit "Chainfire" Jongma
- *
- * Licensed 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 eu.chainfire.libsuperuser;
-
-import android.os.Looper;
-import android.util.Log;
-
-/**
- * Utility class for logging and debug features that (by default) does nothing when not in debug mode
- */
-public class Debug {
-
- // ----- DEBUGGING -----
-
- private static boolean debug = BuildConfig.DEBUG;
-
- /**
- * Enable or disable debug mode
- *
- * By default, debug mode is enabled for development
- * builds and disabled for exported APKs - see
- * BuildConfig.DEBUG
- *
- * @param enable Enable debug mode ?
- */
- public static void setDebug(boolean enable) {
- debug = enable;
- }
-
- /**
- * Is debug mode enabled ?
- *
- * @return Debug mode enabled
- */
- public static boolean getDebug() {
- return debug;
- }
-
- // ----- LOGGING -----
-
- public interface OnLogListener {
- void onLog(int type, String typeIndicator, String message);
- }
-
- public static final String TAG = "libsuperuser";
-
- public static final int LOG_GENERAL = 0x0001;
- public static final int LOG_COMMAND = 0x0002;
- public static final int LOG_OUTPUT = 0x0004;
-
- public static final int LOG_NONE = 0x0000;
- public static final int LOG_ALL = 0xFFFF;
-
- private static int logTypes = LOG_ALL;
-
- private static OnLogListener logListener = null;
-
- /**
- * Log a message (internal)
- *
- * Current debug and enabled logtypes decide what gets logged -
- * even if a custom callback is registered
- *
- * @param type Type of message to log
- * @param typeIndicator String indicator for message type
- * @param message The message to log
- */
- private static void logCommon(int type, String typeIndicator, String message) {
- if (debug && ((logTypes & type) == type)) {
- if (logListener != null) {
- logListener.onLog(type, typeIndicator, message);
- } else {
- Log.d(TAG, "[" + TAG + "][" + typeIndicator + "]" + (!message.startsWith("[") && !message.startsWith(" ") ? " " : "") + message);
- }
- }
- }
-
- /**
- * Log a "general" message
- *
- * These messages are infrequent and mostly occur at startup/shutdown or on error
- *
- * @param message The message to log
- */
- public static void log(String message) {
- logCommon(LOG_GENERAL, "G", message);
- }
-
- /**
- * Log a "per-command" message
- *
- * This could produce a lot of output if the client runs many commands in the session
- *
- * @param message The message to log
- */
- public static void logCommand(String message) {
- logCommon(LOG_COMMAND, "C", message);
- }
-
- /**
- * Log a line of stdout/stderr output
- *
- * This could produce a lot of output if the shell commands are noisy
- *
- * @param message The message to log
- */
- public static void logOutput(String message) {
- logCommon(LOG_OUTPUT, "O", message);
- }
-
- /**
- * Enable or disable logging specific types of message
- *
- * You may | (or) LOG_* constants together. Note that
- * debug mode must also be enabled for actual logging to
- * occur.
- *
- * @param type LOG_* constants
- * @param enable Enable or disable
- */
- public static void setLogTypeEnabled(int type, boolean enable) {
- if (enable) {
- logTypes |= type;
- } else {
- logTypes &= ~type;
- }
- }
-
- /**
- * Is logging for specific types of messages enabled ?
- *
- * You may | (or) LOG_* constants together, to learn if
- * all passed message types are enabled for logging. Note
- * that debug mode must also be enabled for actual logging
- * to occur.
- *
- * @param type LOG_* constants
- */
- public static boolean getLogTypeEnabled(int type) {
- return ((logTypes & type) == type);
- }
-
- /**
- * Is logging for specific types of messages enabled ?
- *
- * You may | (or) LOG_* constants together, to learn if
- * all message types are enabled for logging. Takes
- * debug mode into account for the result.
- *
- * @param type LOG_* constants
- */
- public static boolean getLogTypeEnabledEffective(int type) {
- return getDebug() && getLogTypeEnabled(type);
- }
-
- /**
- * Register a custom log handler
- *
- * Replaces the log method (write to logcat) with your own
- * handler. Whether your handler gets called is still dependent
- * on debug mode and message types being enabled for logging.
- *
- * @param onLogListener Custom log listener or NULL to revert to default
- */
- public static void setOnLogListener(OnLogListener onLogListener) {
- logListener = onLogListener;
- }
-
- /**
- * Get the currently registered custom log handler
- *
- * @return Current custom log handler or NULL if none is present
- */
- public static OnLogListener getOnLogListener() {
- return logListener;
- }
-
- // ----- SANITY CHECKS -----
-
- private static boolean sanityChecks = true;
-
- /**
- * Enable or disable sanity checks
- *
- * Enables or disables the library crashing when su is called
- * from the main thread.
- *
- * @param enable Enable or disable
- */
- public static void setSanityChecksEnabled(boolean enable) {
- sanityChecks = enable;
- }
-
- /**
- * Are sanity checks enabled ?
- *
- * Note that debug mode must also be enabled for actual
- * sanity checks to occur.
- *
- * @return True if enabled
- */
- public static boolean getSanityChecksEnabled() {
- return sanityChecks;
- }
-
- /**
- * Are sanity checks enabled ?
- *
- * Takes debug mode into account for the result.
- *
- * @return True if enabled
- */
- public static boolean getSanityChecksEnabledEffective() {
- return getDebug() && getSanityChecksEnabled();
- }
-
- /**
- * Are we running on the main thread ?
- *
- * @return Running on main thread ?
- */
- public static boolean onMainThread() {
- return ((Looper.myLooper() != null) && (Looper.myLooper() == Looper.getMainLooper()));
- }
-
-}
diff --git a/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/HideOverlaysReceiver.java b/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/HideOverlaysReceiver.java
deleted file mode 100644
index 4b4ce5a8d..000000000
--- a/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/HideOverlaysReceiver.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Jorrit "Chainfire" Jongma
- *
- * Licensed 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 eu.chainfire.libsuperuser;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-
-/**
- *
- * Base receiver to extend to catch notifications when overlays should be
- * hidden.
- *
- *
- * Tapjacking protection in SuperSU prevents some dialogs from receiving user
- * input when overlays are present. For security reasons this notification is
- * only sent to apps that have previously been granted root access, so even if
- * your app does not require root, you still need to request
- * it, and the user must grant it.
- *
- *
- * Note that the word overlay as used here should be interpreted as "any view or
- * window possibly obscuring SuperSU dialogs".
- *
- */
-public abstract class HideOverlaysReceiver extends BroadcastReceiver {
- public static final String ACTION_HIDE_OVERLAYS = "eu.chainfire.supersu.action.HIDE_OVERLAYS";
- public static final String CATEGORY_HIDE_OVERLAYS = Intent.CATEGORY_INFO;
- public static final String EXTRA_HIDE_OVERLAYS = "eu.chainfire.supersu.extra.HIDE";
-
- @Override
- public final void onReceive(Context context, Intent intent) {
- if (intent.hasExtra(EXTRA_HIDE_OVERLAYS)) {
- onHideOverlays(intent.getBooleanExtra(EXTRA_HIDE_OVERLAYS, false));
- }
- }
-
- /**
- * Called when overlays should be hidden or may be shown
- * again.
- *
- * @param hide Should overlays be hidden?
- */
- public abstract void onHideOverlays(boolean hide);
-}
diff --git a/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/Shell.java b/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/Shell.java
deleted file mode 100644
index 742363a87..000000000
--- a/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/Shell.java
+++ /dev/null
@@ -1,1756 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Jorrit "Chainfire" Jongma
- *
- * Licensed 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 eu.chainfire.libsuperuser;
-
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-import android.os.Handler;
-import android.os.Looper;
-
-import eu.chainfire.libsuperuser.StreamGobbler.OnLineListener;
-
-/**
- * Class providing functionality to execute commands in a (root) shell
- */
-public class Shell {
- /**
- *
- * Runs commands using the supplied shell, and returns the output, or null
- * in case of errors.
- *
- *
- * This method is deprecated and only provided for backwards compatibility.
- * Use {@link #run(String, String[], String[], boolean)} instead, and see
- * that same method for usage notes.
- *
- *
- * @param shell The shell to use for executing the commands
- * @param commands The commands to execute
- * @param wantSTDERR Return STDERR in the output ?
- * @return Output of the commands, or null in case of an error
- */
- @Deprecated
- public static List run(String shell, String[] commands, boolean wantSTDERR) {
- return run(shell, commands, null, wantSTDERR);
- }
-
- /**
- *
- * Runs commands using the supplied shell, and returns the output, or null
- * in case of errors.
- *
- *
- * Note that due to compatibility with older Android versions, wantSTDERR is
- * not implemented using redirectErrorStream, but rather appended to the
- * output. STDOUT and STDERR are thus not guaranteed to be in the correct
- * order in the output.
- *
- *
- * Note as well that this code will intentionally crash when run in debug
- * mode from the main thread of the application. You should always execute
- * shell commands from a background thread.
- *
- *
- * When in debug mode, the code will also excessively log the commands
- * passed to and the output returned from the shell.
- *
- *
- * Though this function uses background threads to gobble STDOUT and STDERR
- * so a deadlock does not occur if the shell produces massive output, the
- * output is still stored in a List<String>, and as such doing
- * something like 'ls -lR /' will probably have you run out of
- * memory.
- *
- *
- * @param shell The shell to use for executing the commands
- * @param commands The commands to execute
- * @param environment List of all environment variables (in 'key=value'
- * format) or null for defaults
- * @param wantSTDERR Return STDERR in the output ?
- * @return Output of the commands, or null in case of an error
- */
- public static List run(String shell, String[] commands, String[] environment,
- boolean wantSTDERR) {
- String shellUpper = shell.toUpperCase(Locale.ENGLISH);
-
- if (Debug.getSanityChecksEnabledEffective() && Debug.onMainThread()) {
- // check if we're running in the main thread, and if so, crash if
- // we're in debug mode, to let the developer know attention is
- // needed here.
-
- Debug.log(ShellOnMainThreadException.EXCEPTION_COMMAND);
- throw new ShellOnMainThreadException(ShellOnMainThreadException.EXCEPTION_COMMAND);
- }
- Debug.logCommand(String.format("[%s%%] START", shellUpper));
-
- List res = Collections.synchronizedList(new ArrayList());
-
- try {
- // Combine passed environment with system environment
- if (environment != null) {
- Map newEnvironment = new HashMap();
- newEnvironment.putAll(System.getenv());
- int split;
- for (String entry : environment) {
- if ((split = entry.indexOf("=")) >= 0) {
- newEnvironment.put(entry.substring(0, split), entry.substring(split + 1));
- }
- }
- int i = 0;
- environment = new String[newEnvironment.size()];
- for (Map.Entry entry : newEnvironment.entrySet()) {
- environment[i] = entry.getKey() + "=" + entry.getValue();
- i++;
- }
- }
-
- // setup our process, retrieve STDIN stream, and STDOUT/STDERR
- // gobblers
- Process process = Runtime.getRuntime().exec(shell, environment);
- DataOutputStream STDIN = new DataOutputStream(process.getOutputStream());
- StreamGobbler STDOUT = new StreamGobbler(shellUpper + "-", process.getInputStream(),
- res);
- StreamGobbler STDERR = new StreamGobbler(shellUpper + "*", process.getErrorStream(),
- wantSTDERR ? res : null);
-
- // start gobbling and write our commands to the shell
- STDOUT.start();
- STDERR.start();
- try {
- for (String write : commands) {
- Debug.logCommand(String.format("[%s+] %s", shellUpper, write));
- STDIN.write((write + "\n").getBytes("UTF-8"));
- STDIN.flush();
- }
- STDIN.write("exit\n".getBytes("UTF-8"));
- STDIN.flush();
- } catch (IOException e) {
- if (e.getMessage().contains("EPIPE")) {
- // method most horrid to catch broken pipe, in which case we
- // do nothing. the command is not a shell, the shell closed
- // STDIN, the script already contained the exit command, etc.
- // these cases we want the output instead of returning null
- } else {
- // other issues we don't know how to handle, leads to
- // returning null
- throw e;
- }
- }
-
- // wait for our process to finish, while we gobble away in the
- // background
- process.waitFor();
-
- // make sure our threads are done gobbling, our streams are closed,
- // and the process is destroyed - while the latter two shouldn't be
- // needed in theory, and may even produce warnings, in "normal" Java
- // they are required for guaranteed cleanup of resources, so lets be
- // safe and do this on Android as well
- try {
- STDIN.close();
- } catch (IOException e) {
- // might be closed already
- }
- STDOUT.join();
- STDERR.join();
- process.destroy();
-
- // in case of su, 255 usually indicates access denied
- if (SU.isSU(shell) && (process.exitValue() == 255)) {
- res = null;
- }
- } catch (IOException e) {
- // shell probably not found
- res = null;
- } catch (InterruptedException e) {
- // this should really be re-thrown
- res = null;
- }
-
- Debug.logCommand(String.format("[%s%%] END", shell.toUpperCase(Locale.ENGLISH)));
- return res;
- }
-
- protected static String[] availableTestCommands = new String[] {
- "echo -BOC-",
- "id"
- };
-
- /**
- * See if the shell is alive, and if so, check the UID
- *
- * @param ret Standard output from running availableTestCommands
- * @param checkForRoot true if we are expecting this shell to be running as
- * root
- * @return true on success, false on error
- */
- protected static boolean parseAvailableResult(List ret, boolean checkForRoot) {
- if (ret == null)
- return false;
-
- // this is only one of many ways this can be done
- boolean echo_seen = false;
-
- for (String line : ret) {
- if (line.contains("uid=")) {
- // id command is working, let's see if we are actually root
- return !checkForRoot || line.contains("uid=0");
- } else if (line.contains("-BOC-")) {
- // if we end up here, at least the su command starts some kind
- // of shell,
- // let's hope it has root privileges - no way to know without
- // additional
- // native binaries
- echo_seen = true;
- }
- }
-
- return echo_seen;
- }
-
- /**
- * This class provides utility functions to easily execute commands using SH
- */
- public static class SH {
- /**
- * Runs command and return output
- *
- * @param command The command to run
- * @return Output of the command, or null in case of an error
- */
- public static List run(String command) {
- return Shell.run("sh", new String[] {
- command
- }, null, false);
- }
-
- /**
- * Runs commands and return output
- *
- * @param commands The commands to run
- * @return Output of the commands, or null in case of an error
- */
- public static List run(List commands) {
- return Shell.run("sh", commands.toArray(new String[commands.size()]), null, false);
- }
-
- /**
- * Runs commands and return output
- *
- * @param commands The commands to run
- * @return Output of the commands, or null in case of an error
- */
- public static List run(String[] commands) {
- return Shell.run("sh", commands, null, false);
- }
- }
-
- /**
- * This class provides utility functions to easily execute commands using SU
- * (root shell), as well as detecting whether or not root is available, and
- * if so which version.
- */
- public static class SU {
- private static Boolean isSELinuxEnforcing = null;
- private static String[] suVersion = new String[] {
- null, null
- };
-
- /**
- * Runs command as root (if available) and return output
- *
- * @param command The command to run
- * @return Output of the command, or null if root isn't available or in
- * case of an error
- */
- public static List run(String command) {
- return Shell.run("su", new String[] {
- command
- }, null, false);
- }
-
- /**
- * Runs commands as root (if available) and return output
- *
- * @param commands The commands to run
- * @return Output of the commands, or null if root isn't available or in
- * case of an error
- */
- public static List run(List commands) {
- return Shell.run("su", commands.toArray(new String[commands.size()]), null, false);
- }
-
- /**
- * Runs commands as root (if available) and return output
- *
- * @param commands The commands to run
- * @return Output of the commands, or null if root isn't available or in
- * case of an error
- */
- public static List run(String[] commands) {
- return Shell.run("su", commands, null, false);
- }
-
- /**
- * Detects whether or not superuser access is available, by checking the
- * output of the "id" command if available, checking if a shell runs at
- * all otherwise
- *
- * @return True if superuser access available
- */
- public static boolean available() {
- // this is only one of many ways this can be done
-
- List ret = run(Shell.availableTestCommands);
- return Shell.parseAvailableResult(ret, true);
- }
-
- /**
- *
- * Detects the version of the su binary installed (if any), if supported
- * by the binary. Most binaries support two different version numbers,
- * the public version that is displayed to users, and an internal
- * version number that is used for version number comparisons. Returns
- * null if su not available or retrieving the version isn't supported.
- *
- *
- * Note that su binary version and GUI (APK) version can be completely
- * different.
- *
- *
- * This function caches its result to improve performance on multiple
- * calls
- *
- *
- * @param internal Request human-readable version or application
- * internal version
- * @return String containing the su version or null
- */
- public static synchronized String version(boolean internal) {
- int idx = internal ? 0 : 1;
- if (suVersion[idx] == null) {
- String version = null;
-
- List ret = Shell.run(
- internal ? "su -V" : "su -v",
- new String[] { "exit" },
- null,
- false
- );
-
- if (ret != null) {
- for (String line : ret) {
- if (!internal) {
- if (!line.trim().equals("")) {
- version = line;
- break;
- }
- } else {
- try {
- if (Integer.parseInt(line) > 0) {
- version = line;
- break;
- }
- } catch (NumberFormatException e) {
- // should be parsable, try next line otherwise
- }
- }
- }
- }
-
- suVersion[idx] = version;
- }
- return suVersion[idx];
- }
-
- /**
- * Attempts to deduce if the shell command refers to a su shell
- *
- * @param shell Shell command to run
- * @return Shell command appears to be su
- */
- public static boolean isSU(String shell) {
- // Strip parameters
- int pos = shell.indexOf(' ');
- if (pos >= 0) {
- shell = shell.substring(0, pos);
- }
-
- // Strip path
- pos = shell.lastIndexOf('/');
- if (pos >= 0) {
- shell = shell.substring(pos + 1);
- }
-
- return shell.equals("su");
- }
-
- /**
- * Constructs a shell command to start a su shell using the supplied uid
- * and SELinux context. This is can be an expensive operation, consider
- * caching the result.
- *
- * @param uid Uid to use (0 == root)
- * @param context (SELinux) context name to use or null
- * @return Shell command
- */
- public static String shell(int uid, String context) {
- // su[ --context ][ ]
- String shell = "su";
-
- if ((context != null) && isSELinuxEnforcing()) {
- String display = version(false);
- String internal = version(true);
-
- // We only know the format for SuperSU v1.90+ right now
- if ((display != null) &&
- (internal != null) &&
- (display.endsWith("SUPERSU")) &&
- (Integer.valueOf(internal) >= 190)) {
- shell = String.format(Locale.ENGLISH, "%s --context %s", shell, context);
- }
- }
-
- // Most su binaries support the "su " format, but in case
- // they don't, lets skip it for the default 0 (root) case
- if (uid > 0) {
- shell = String.format(Locale.ENGLISH, "%s %d", shell, uid);
- }
-
- return shell;
- }
-
- /**
- * Constructs a shell command to start a su shell connected to mount
- * master daemon, to perform public mounts on Android 4.3+ (or 4.2+ in
- * SELinux enforcing mode)
- *
- * @return Shell command
- */
- public static String shellMountMaster() {
- if (android.os.Build.VERSION.SDK_INT >= 17) {
- return "su --mount-master";
- }
- return "su";
- }
-
- /**
- * Detect if SELinux is set to enforcing, caches result
- *
- * @return true if SELinux set to enforcing, or false in the case of
- * permissive or not present
- */
- public static synchronized boolean isSELinuxEnforcing() {
- if (isSELinuxEnforcing == null) {
- Boolean enforcing = null;
-
- // First known firmware with SELinux built-in was a 4.2 (17)
- // leak
- if (android.os.Build.VERSION.SDK_INT >= 17) {
- // Detect enforcing through sysfs, not always present
- File f = new File("/sys/fs/selinux/enforce");
- if (f.exists()) {
- try {
- InputStream is = new FileInputStream("/sys/fs/selinux/enforce");
- try {
- enforcing = (is.read() == '1');
- } finally {
- is.close();
- }
- } catch (Exception e) {
- // we might not be allowed to read, thanks SELinux
- }
- }
-
- // 4.4+ builds are enforcing by default, take the gamble
- if (enforcing == null) {
- enforcing = (android.os.Build.VERSION.SDK_INT >= 19);
- }
- }
-
- if (enforcing == null) {
- enforcing = false;
- }
-
- isSELinuxEnforcing = enforcing;
- }
- return isSELinuxEnforcing;
- }
-
- /**
- *
- * Clears results cached by isSELinuxEnforcing() and version(boolean
- * internal) calls.
- *
- *
- * Most apps should never need to call this, as neither enforcing status
- * nor su version is likely to change on a running device - though it is
- * not impossible.
- *
- */
- public static synchronized void clearCachedResults() {
- isSELinuxEnforcing = null;
- suVersion[0] = null;
- suVersion[1] = null;
- }
- }
-
- private interface OnResult {
- // for any onCommandResult callback
- int WATCHDOG_EXIT = -1;
- int SHELL_DIED = -2;
-
- // for Interactive.open() callbacks only
- int SHELL_EXEC_FAILED = -3;
- int SHELL_WRONG_UID = -4;
- int SHELL_RUNNING = 0;
- }
-
- /**
- * Command result callback, notifies the recipient of the completion of a
- * command block, including the (last) exit code, and the full output
- */
- public interface OnCommandResultListener extends OnResult {
- /**
- *
- * Command result callback
- *
- *
- * Depending on how and on which thread the shell was created, this
- * callback may be executed on one of the gobbler threads. In that case,
- * it is important the callback returns as quickly as possible, as
- * delays in this callback may pause the native process or even result
- * in a deadlock
- *
- *
- * See {@link Shell.Interactive} for threading details
- *
- *
- * @param commandCode Value previously supplied to addCommand
- * @param exitCode Exit code of the last command in the block
- * @param output All output generated by the command block
- */
- void onCommandResult(int commandCode, int exitCode, List output);
- }
-
- /**
- * Command per line callback for parsing the output line by line without
- * buffering It also notifies the recipient of the completion of a command
- * block, including the (last) exit code.
- */
- public interface OnCommandLineListener extends OnResult, OnLineListener {
- /**
- *
- * Command result callback
- *
- *
- * Depending on how and on which thread the shell was created, this
- * callback may be executed on one of the gobbler threads. In that case,
- * it is important the callback returns as quickly as possible, as
- * delays in this callback may pause the native process or even result
- * in a deadlock
- *
- *
- * See {@link Shell.Interactive} for threading details
- *
- *
- * @param commandCode Value previously supplied to addCommand
- * @param exitCode Exit code of the last command in the block
- */
- void onCommandResult(int commandCode, int exitCode);
- }
-
- /**
- * Internal class to store command block properties
- */
- private static class Command {
- private static int commandCounter = 0;
-
- private final String[] commands;
- private final int code;
- private final OnCommandResultListener onCommandResultListener;
- private final OnCommandLineListener onCommandLineListener;
- private final String marker;
-
- public Command(String[] commands, int code,
- OnCommandResultListener onCommandResultListener,
- OnCommandLineListener onCommandLineListener) {
- this.commands = commands;
- this.code = code;
- this.onCommandResultListener = onCommandResultListener;
- this.onCommandLineListener = onCommandLineListener;
- this.marker = UUID.randomUUID().toString() + String.format("-%08x", ++commandCounter);
- }
- }
-
- /**
- * Builder class for {@link Shell.Interactive}
- */
- public static class Builder {
- private Handler handler = null;
- private boolean autoHandler = true;
- private String shell = "sh";
- private boolean wantSTDERR = false;
- private List commands = new LinkedList();
- private Map environment = new HashMap();
- private OnLineListener onSTDOUTLineListener = null;
- private OnLineListener onSTDERRLineListener = null;
- private int watchdogTimeout = 0;
-
- /**
- *
- * Set a custom handler that will be used to post all callbacks to
- *
- *
- * See {@link Shell.Interactive} for further details on threading and
- * handlers
- *
- *
- * @param handler Handler to use
- * @return This Builder object for method chaining
- */
- public Builder setHandler(Handler handler) {
- this.handler = handler;
- return this;
- }
-
- /**
- *
- * Automatically create a handler if possible ? Default to true
- *
- *
- * See {@link Shell.Interactive} for further details on threading and
- * handlers
- *
- *
- * @param autoHandler Auto-create handler ?
- * @return This Builder object for method chaining
- */
- public Builder setAutoHandler(boolean autoHandler) {
- this.autoHandler = autoHandler;
- return this;
- }
-
- /**
- * Set shell binary to use. Usually "sh" or "su", do not use a full path
- * unless you have a good reason to
- *
- * @param shell Shell to use
- * @return This Builder object for method chaining
- */
- public Builder setShell(String shell) {
- this.shell = shell;
- return this;
- }
-
- /**
- * Convenience function to set "sh" as used shell
- *
- * @return This Builder object for method chaining
- */
- public Builder useSH() {
- return setShell("sh");
- }
-
- /**
- * Convenience function to set "su" as used shell
- *
- * @return This Builder object for method chaining
- */
- public Builder useSU() {
- return setShell("su");
- }
-
- /**
- * Set if error output should be appended to command block result output
- *
- * @param wantSTDERR Want error output ?
- * @return This Builder object for method chaining
- */
- public Builder setWantSTDERR(boolean wantSTDERR) {
- this.wantSTDERR = wantSTDERR;
- return this;
- }
-
- /**
- * Add or update an environment variable
- *
- * @param key Key of the environment variable
- * @param value Value of the environment variable
- * @return This Builder object for method chaining
- */
- public Builder addEnvironment(String key, String value) {
- environment.put(key, value);
- return this;
- }
-
- /**
- * Add or update environment variables
- *
- * @param addEnvironment Map of environment variables
- * @return This Builder object for method chaining
- */
- public Builder addEnvironment(Map addEnvironment) {
- environment.putAll(addEnvironment);
- return this;
- }
-
- /**
- * Add a command to execute
- *
- * @param command Command to execute
- * @return This Builder object for method chaining
- */
- public Builder addCommand(String command) {
- return addCommand(command, 0, null);
- }
-
- /**
- *
- * Add a command to execute, with a callback to be called on completion
- *
- *
- * The thread on which the callback executes is dependent on various
- * factors, see {@link Shell.Interactive} for further details
- *
- *
- * @param command Command to execute
- * @param code User-defined value passed back to the callback
- * @param onCommandResultListener Callback to be called on completion
- * @return This Builder object for method chaining
- */
- public Builder addCommand(String command, int code,
- OnCommandResultListener onCommandResultListener) {
- return addCommand(new String[] {
- command
- }, code, onCommandResultListener);
- }
-
- /**
- * Add commands to execute
- *
- * @param commands Commands to execute
- * @return This Builder object for method chaining
- */
- public Builder addCommand(List commands) {
- return addCommand(commands, 0, null);
- }
-
- /**
- *
- * Add commands to execute, with a callback to be called on completion
- * (of all commands)
- *
- *
- * The thread on which the callback executes is dependent on various
- * factors, see {@link Shell.Interactive} for further details
- *
- *
- * @param commands Commands to execute
- * @param code User-defined value passed back to the callback
- * @param onCommandResultListener Callback to be called on completion
- * (of all commands)
- * @return This Builder object for method chaining
- */
- public Builder addCommand(List commands, int code,
- OnCommandResultListener onCommandResultListener) {
- return addCommand(commands.toArray(new String[commands.size()]), code,
- onCommandResultListener);
- }
-
- /**
- * Add commands to execute
- *
- * @param commands Commands to execute
- * @return This Builder object for method chaining
- */
- public Builder addCommand(String[] commands) {
- return addCommand(commands, 0, null);
- }
-
- /**
- *
- * Add commands to execute, with a callback to be called on completion
- * (of all commands)
- *
- *
- * The thread on which the callback executes is dependent on various
- * factors, see {@link Shell.Interactive} for further details
- *
- *
- * @param commands Commands to execute
- * @param code User-defined value passed back to the callback
- * @param onCommandResultListener Callback to be called on completion
- * (of all commands)
- * @return This Builder object for method chaining
- */
- public Builder addCommand(String[] commands, int code,
- OnCommandResultListener onCommandResultListener) {
- this.commands.add(new Command(commands, code, onCommandResultListener, null));
- return this;
- }
-
- /**
- *
- * Set a callback called for every line output to STDOUT by the shell
- *
- *
- * The thread on which the callback executes is dependent on various
- * factors, see {@link Shell.Interactive} for further details
- *
- *
- * @param onLineListener Callback to be called for each line
- * @return This Builder object for method chaining
- */
- public Builder setOnSTDOUTLineListener(OnLineListener onLineListener) {
- this.onSTDOUTLineListener = onLineListener;
- return this;
- }
-
- /**
- *
- * Set a callback called for every line output to STDERR by the shell
- *
- *
- * The thread on which the callback executes is dependent on various
- * factors, see {@link Shell.Interactive} for further details
- *
- *
- * @param onLineListener Callback to be called for each line
- * @return This Builder object for method chaining
- */
- public Builder setOnSTDERRLineListener(OnLineListener onLineListener) {
- this.onSTDERRLineListener = onLineListener;
- return this;
- }
-
- /**
- *
- * Enable command timeout callback
- *
- *
- * This will invoke the onCommandResult() callback with exitCode
- * WATCHDOG_EXIT if a command takes longer than watchdogTimeout seconds
- * to complete.
- *
- *
- * If a watchdog timeout occurs, it generally means that the Interactive
- * session is out of sync with the shell process. The caller should
- * close the current session and open a new one.
- *
- *
- * @param watchdogTimeout Timeout, in seconds; 0 to disable
- * @return This Builder object for method chaining
- */
- public Builder setWatchdogTimeout(int watchdogTimeout) {
- this.watchdogTimeout = watchdogTimeout;
- return this;
- }
-
- /**
- *
- * Enable/disable reduced logcat output
- *
- *
- * Note that this is a global setting
- *
- *
- * @param useMinimal true for reduced output, false for full output
- * @return This Builder object for method chaining
- */
- public Builder setMinimalLogging(boolean useMinimal) {
- Debug.setLogTypeEnabled(Debug.LOG_COMMAND | Debug.LOG_OUTPUT, !useMinimal);
- return this;
- }
-
- /**
- * Construct a {@link Shell.Interactive} instance, and start the shell
- */
- public Interactive open() {
- return new Interactive(this, null);
- }
-
- /**
- * Construct a {@link Shell.Interactive} instance, try to start the
- * shell, and call onCommandResultListener to report success or failure
- *
- * @param onCommandResultListener Callback to return shell open status
- */
- public Interactive open(OnCommandResultListener onCommandResultListener) {
- return new Interactive(this, onCommandResultListener);
- }
- }
-
- /**
- *
- * An interactive shell - initially created with {@link Shell.Builder} -
- * that executes blocks of commands you supply in the background, optionally
- * calling callbacks as each block completes.
- *
- *
- * STDERR output can be supplied as well, but due to compatibility with
- * older Android versions, wantSTDERR is not implemented using
- * redirectErrorStream, but rather appended to the output. STDOUT and STDERR
- * are thus not guaranteed to be in the correct order in the output.
- *
- *
- * Note as well that the close() and waitForIdle() methods will
- * intentionally crash when run in debug mode from the main thread of the
- * application. Any blocking call should be run from a background thread.
- *
- *
- * When in debug mode, the code will also excessively log the commands
- * passed to and the output returned from the shell.
- *
- *
- * Though this function uses background threads to gobble STDOUT and STDERR
- * so a deadlock does not occur if the shell produces massive output, the
- * output is still stored in a List<String>, and as such doing
- * something like 'ls -lR /' will probably have you run out of
- * memory when using a {@link Shell.OnCommandResultListener}. A work-around
- * is to not supply this callback, but using (only)
- * {@link Shell.Builder#setOnSTDOUTLineListener(OnLineListener)}. This way,
- * an internal buffer will not be created and wasting your memory.
- *
- * Callbacks, threads and handlers
- *
- * On which thread the callbacks execute is dependent on your
- * initialization. You can supply a custom Handler using
- * {@link Shell.Builder#setHandler(Handler)} if needed. If you do not supply
- * a custom Handler - unless you set
- * {@link Shell.Builder#setAutoHandler(boolean)} to false - a Handler will
- * be auto-created if the thread used for instantiation of the object has a
- * Looper.
- *
- *
- * If no Handler was supplied and it was also not auto-created, all
- * callbacks will be called from either the STDOUT or STDERR gobbler
- * threads. These are important threads that should be blocked as little as
- * possible, as blocking them may in rare cases pause the native process or
- * even create a deadlock.
- *
- *
- * The main thread must certainly have a Looper, thus if you call
- * {@link Shell.Builder#open()} from the main thread, a handler will (by
- * default) be auto-created, and all the callbacks will be called on the
- * main thread. While this is often convenient and easy to code with, you
- * should be aware that if your callbacks are 'expensive' to execute, this
- * may negatively impact UI performance.
- *
- *
- * Background threads usually do not have a Looper, so calling
- * {@link Shell.Builder#open()} from such a background thread will (by
- * default) result in all the callbacks being executed in one of the gobbler
- * threads. You will have to make sure the code you execute in these
- * callbacks is thread-safe.
- *
- */
- public static class Interactive {
- private final Handler handler;
- private final boolean autoHandler;
- private final String shell;
- private final boolean wantSTDERR;
- private final List commands;
- private final Map environment;
- private final OnLineListener onSTDOUTLineListener;
- private final OnLineListener onSTDERRLineListener;
- private int watchdogTimeout;
-
- private Process process = null;
- private DataOutputStream STDIN = null;
- private StreamGobbler STDOUT = null;
- private StreamGobbler STDERR = null;
- private ScheduledThreadPoolExecutor watchdog = null;
-
- private volatile boolean running = false;
- private volatile boolean idle = true; // read/write only synchronized
- private volatile boolean closed = true;
- private volatile int callbacks = 0;
- private volatile int watchdogCount;
-
- private final Object idleSync = new Object();
- private final Object callbackSync = new Object();
-
- private volatile int lastExitCode = 0;
- private volatile String lastMarkerSTDOUT = null;
- private volatile String lastMarkerSTDERR = null;
- private volatile Command command = null;
- private volatile List buffer = null;
-
- /**
- * The only way to create an instance: Shell.Builder::open()
- *
- * @param builder Builder class to take values from
- */
- private Interactive(final Builder builder,
- final OnCommandResultListener onCommandResultListener) {
- autoHandler = builder.autoHandler;
- shell = builder.shell;
- wantSTDERR = builder.wantSTDERR;
- commands = builder.commands;
- environment = builder.environment;
- onSTDOUTLineListener = builder.onSTDOUTLineListener;
- onSTDERRLineListener = builder.onSTDERRLineListener;
- watchdogTimeout = builder.watchdogTimeout;
-
- // If a looper is available, we offload the callbacks from the
- // gobbling threads
- // to whichever thread created us. Would normally do this in open(),
- // but then we could not declare handler as final
- if ((Looper.myLooper() != null) && (builder.handler == null) && autoHandler) {
- handler = new Handler();
- } else {
- handler = builder.handler;
- }
-
- if (onCommandResultListener != null) {
- // Allow up to 60 seconds for SuperSU/Superuser dialog, then enable
- // the user-specified timeout for all subsequent operations
- watchdogTimeout = 60;
- commands.add(0, new Command(Shell.availableTestCommands, 0, new OnCommandResultListener() {
- public void onCommandResult(int commandCode, int exitCode, List output) {
- if ((exitCode == OnCommandResultListener.SHELL_RUNNING) &&
- !Shell.parseAvailableResult(output, Shell.SU.isSU(shell))) {
- // shell is up, but it's brain-damaged
- exitCode = OnCommandResultListener.SHELL_WRONG_UID;
- }
- watchdogTimeout = builder.watchdogTimeout;
- onCommandResultListener.onCommandResult(0, exitCode, output);
- }
- }, null));
- }
-
- if (!open() && (onCommandResultListener != null)) {
- onCommandResultListener.onCommandResult(0,
- OnCommandResultListener.SHELL_EXEC_FAILED, null);
- }
- }
-
- @Override
- protected void finalize() throws Throwable {
- if (!closed && Debug.getSanityChecksEnabledEffective()) {
- // waste of resources
- Debug.log(ShellNotClosedException.EXCEPTION_NOT_CLOSED);
- throw new ShellNotClosedException();
- }
- super.finalize();
- }
-
- /**
- * Add a command to execute
- *
- * @param command Command to execute
- */
- public void addCommand(String command) {
- addCommand(command, 0, (OnCommandResultListener) null);
- }
-
- /**
- *
- * Add a command to execute, with a callback to be called on completion
- *
- *
- * The thread on which the callback executes is dependent on various
- * factors, see {@link Shell.Interactive} for further details
- *
- *
- * @param command Command to execute
- * @param code User-defined value passed back to the callback
- * @param onCommandResultListener Callback to be called on completion
- */
- public void addCommand(String command, int code,
- OnCommandResultListener onCommandResultListener) {
- addCommand(new String[] {
- command
- }, code, onCommandResultListener);
- }
-
- /**
- *
- * Add a command to execute, with a callback. This callback gobbles the
- * output line by line without buffering it and also returns the result
- * code on completion.
- *
- *
- * The thread on which the callback executes is dependent on various
- * factors, see {@link Shell.Interactive} for further details
- *
- *
- * @param command Command to execute
- * @param code User-defined value passed back to the callback
- * @param onCommandLineListener Callback
- */
- public void addCommand(String command, int code, OnCommandLineListener onCommandLineListener) {
- addCommand(new String[] {
- command
- }, code, onCommandLineListener);
- }
-
- /**
- * Add commands to execute
- *
- * @param commands Commands to execute
- */
- public void addCommand(List commands) {
- addCommand(commands, 0, (OnCommandResultListener) null);
- }
-
- /**
- *
- * Add commands to execute, with a callback to be called on completion
- * (of all commands)
- *
- *
- * The thread on which the callback executes is dependent on various
- * factors, see {@link Shell.Interactive} for further details
- *
- *
- * @param commands Commands to execute
- * @param code User-defined value passed back to the callback
- * @param onCommandResultListener Callback to be called on completion
- * (of all commands)
- */
- public void addCommand(List commands, int code,
- OnCommandResultListener onCommandResultListener) {
- addCommand(commands.toArray(new String[commands.size()]), code, onCommandResultListener);
- }
-
- /**
- *
- * Add commands to execute, with a callback. This callback gobbles the
- * output line by line without buffering it and also returns the result
- * code on completion.
- *
- *
- * The thread on which the callback executes is dependent on various
- * factors, see {@link Shell.Interactive} for further details
- *
- *
- * @param commands Commands to execute
- * @param code User-defined value passed back to the callback
- * @param onCommandLineListener Callback
- */
- public void addCommand(List commands, int code,
- OnCommandLineListener onCommandLineListener) {
- addCommand(commands.toArray(new String[commands.size()]), code, onCommandLineListener);
- }
-
- /**
- * Add commands to execute
- *
- * @param commands Commands to execute
- */
- public void addCommand(String[] commands) {
- addCommand(commands, 0, (OnCommandResultListener) null);
- }
-
- /**
- *
- * Add commands to execute, with a callback to be called on completion
- * (of all commands)
- *
- *
- * The thread on which the callback executes is dependent on various
- * factors, see {@link Shell.Interactive} for further details
- *
- *
- * @param commands Commands to execute
- * @param code User-defined value passed back to the callback
- * @param onCommandResultListener Callback to be called on completion
- * (of all commands)
- */
- public synchronized void addCommand(String[] commands, int code,
- OnCommandResultListener onCommandResultListener) {
- this.commands.add(new Command(commands, code, onCommandResultListener, null));
- runNextCommand();
- }
-
- /**
- *
- * Add commands to execute, with a callback. This callback gobbles the
- * output line by line without buffering it and also returns the result
- * code on completion.
- *
- *
- * The thread on which the callback executes is dependent on various
- * factors, see {@link Shell.Interactive} for further details
- *
- *
- * @param commands Commands to execute
- * @param code User-defined value passed back to the callback
- * @param onCommandLineListener Callback
- */
- public synchronized void addCommand(String[] commands, int code,
- OnCommandLineListener onCommandLineListener) {
- this.commands.add(new Command(commands, code, null, onCommandLineListener));
- runNextCommand();
- }
-
- /**
- * Run the next command if any and if ready, signals idle state if no
- * commands left
- */
- private void runNextCommand() {
- runNextCommand(true);
- }
-
- /**
- * Called from a ScheduledThreadPoolExecutor timer thread every second
- * when there is an outstanding command
- */
- private synchronized void handleWatchdog() {
- final int exitCode;
-
- if (watchdog == null)
- return;
- if (watchdogTimeout == 0)
- return;
-
- if (!isRunning()) {
- exitCode = OnCommandResultListener.SHELL_DIED;
- Debug.log(String.format("[%s%%] SHELL_DIED", shell.toUpperCase(Locale.ENGLISH)));
- } else if (watchdogCount++ < watchdogTimeout) {
- return;
- } else {
- exitCode = OnCommandResultListener.WATCHDOG_EXIT;
- Debug.log(String.format("[%s%%] WATCHDOG_EXIT", shell.toUpperCase(Locale.ENGLISH)));
- }
-
- if (handler != null) {
- postCallback(command, exitCode, buffer);
- }
-
- // prevent multiple callbacks for the same command
- command = null;
- buffer = null;
- idle = true;
-
- watchdog.shutdown();
- watchdog = null;
- kill();
- }
-
- /**
- * Start the periodic timer when a command is submitted
- */
- private void startWatchdog() {
- if (watchdogTimeout == 0) {
- return;
- }
- watchdogCount = 0;
- watchdog = new ScheduledThreadPoolExecutor(1);
- watchdog.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- handleWatchdog();
- }
- }, 1, 1, TimeUnit.SECONDS);
- }
-
- /**
- * Disable the watchdog timer upon command completion
- */
- private void stopWatchdog() {
- if (watchdog != null) {
- watchdog.shutdownNow();
- watchdog = null;
- }
- }
-
- /**
- * Run the next command if any and if ready
- *
- * @param notifyIdle signals idle state if no commands left ?
- */
- private void runNextCommand(boolean notifyIdle) {
- // must always be called from a synchronized method
-
- boolean running = isRunning();
- if (!running)
- idle = true;
-
- if (running && idle && (commands.size() > 0)) {
- Command command = commands.get(0);
- commands.remove(0);
-
- buffer = null;
- lastExitCode = 0;
- lastMarkerSTDOUT = null;
- lastMarkerSTDERR = null;
-
- if (command.commands.length > 0) {
- try {
- if (command.onCommandResultListener != null) {
- // no reason to store the output if we don't have an
- // OnCommandResultListener
- // user should catch the output with an
- // OnLineListener in this case
- buffer = Collections.synchronizedList(new ArrayList());
- }
-
- idle = false;
- this.command = command;
- startWatchdog();
- for (String write : command.commands) {
- Debug.logCommand(String.format("[%s+] %s",
- shell.toUpperCase(Locale.ENGLISH), write));
- STDIN.write((write + "\n").getBytes("UTF-8"));
- }
- STDIN.write(("echo " + command.marker + " $?\n").getBytes("UTF-8"));
- STDIN.write(("echo " + command.marker + " >&2\n").getBytes("UTF-8"));
- STDIN.flush();
- } catch (IOException e) {
- // STDIN might have closed
- }
- } else {
- runNextCommand(false);
- }
- } else if (!running) {
- // our shell died for unknown reasons - abort all submissions
- while (commands.size() > 0) {
- postCallback(commands.remove(0), OnCommandResultListener.SHELL_DIED, null);
- }
- }
-
- if (idle && notifyIdle) {
- synchronized (idleSync) {
- idleSync.notifyAll();
- }
- }
- }
-
- /**
- * Processes a STDOUT/STDERR line containing an end/exitCode marker
- */
- private synchronized void processMarker() {
- if (command.marker.equals(lastMarkerSTDOUT)
- && (command.marker.equals(lastMarkerSTDERR))) {
- postCallback(command, lastExitCode, buffer);
- stopWatchdog();
- command = null;
- buffer = null;
- idle = true;
- runNextCommand();
- }
- }
-
- /**
- * Process a normal STDOUT/STDERR line
- *
- * @param line Line to process
- * @param listener Callback to call or null
- */
- private synchronized void processLine(String line, OnLineListener listener) {
- if (listener != null) {
- if (handler != null) {
- final String fLine = line;
- final OnLineListener fListener = listener;
-
- startCallback();
- handler.post(new Runnable() {
- @Override
- public void run() {
- try {
- fListener.onLine(fLine);
- } finally {
- endCallback();
- }
- }
- });
- } else {
- listener.onLine(line);
- }
- }
- }
-
- /**
- * Add line to internal buffer
- *
- * @param line Line to add
- */
- private synchronized void addBuffer(String line) {
- if (buffer != null) {
- buffer.add(line);
- }
- }
-
- /**
- * Increase callback counter
- */
- private void startCallback() {
- synchronized (callbackSync) {
- callbacks++;
- }
- }
-
- /**
- * Schedule a callback to run on the appropriate thread
- */
- private void postCallback(final Command fCommand, final int fExitCode,
- final List fOutput) {
- if (fCommand.onCommandResultListener == null && fCommand.onCommandLineListener == null) {
- return;
- }
- if (handler == null) {
- if ((fCommand.onCommandResultListener != null) && (fOutput != null))
- fCommand.onCommandResultListener.onCommandResult(fCommand.code, fExitCode,
- fOutput);
- if (fCommand.onCommandLineListener != null)
- fCommand.onCommandLineListener.onCommandResult(fCommand.code, fExitCode);
- return;
- }
- startCallback();
- handler.post(new Runnable() {
- @Override
- public void run() {
- try {
- if ((fCommand.onCommandResultListener != null) && (fOutput != null))
- fCommand.onCommandResultListener.onCommandResult(fCommand.code,
- fExitCode, fOutput);
- if (fCommand.onCommandLineListener != null)
- fCommand.onCommandLineListener
- .onCommandResult(fCommand.code, fExitCode);
- } finally {
- endCallback();
- }
- }
- });
- }
-
- /**
- * Decrease callback counter, signals callback complete state when
- * dropped to 0
- */
- private void endCallback() {
- synchronized (callbackSync) {
- callbacks--;
- if (callbacks == 0) {
- callbackSync.notifyAll();
- }
- }
- }
-
- /**
- * Internal call that launches the shell, starts gobbling, and starts
- * executing commands. See {@link Shell.Interactive}
- *
- * @return Opened successfully ?
- */
- private synchronized boolean open() {
- Debug.log(String.format("[%s%%] START", shell.toUpperCase(Locale.ENGLISH)));
-
- try {
- // setup our process, retrieve STDIN stream, and STDOUT/STDERR
- // gobblers
- if (environment.size() == 0) {
- process = Runtime.getRuntime().exec(shell);
- } else {
- Map newEnvironment = new HashMap();
- newEnvironment.putAll(System.getenv());
- newEnvironment.putAll(environment);
- int i = 0;
- String[] env = new String[newEnvironment.size()];
- for (Map.Entry entry : newEnvironment.entrySet()) {
- env[i] = entry.getKey() + "=" + entry.getValue();
- i++;
- }
- process = Runtime.getRuntime().exec(shell, env);
- }
-
- STDIN = new DataOutputStream(process.getOutputStream());
- STDOUT = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "-",
- process.getInputStream(), new OnLineListener() {
- @Override
- public void onLine(String line) {
- synchronized (Interactive.this) {
- if (command == null) {
- return;
- }
- if (line.startsWith(command.marker)) {
- try {
- lastExitCode = Integer.valueOf(
- line.substring(command.marker.length() + 1), 10);
- } catch (Exception e) {
- // this really shouldn't happen
- e.printStackTrace();
- }
- lastMarkerSTDOUT = command.marker;
- processMarker();
- } else {
- addBuffer(line);
- processLine(line, onSTDOUTLineListener);
- processLine(line, command.onCommandLineListener);
- }
- }
- }
- });
- STDERR = new StreamGobbler(shell.toUpperCase(Locale.ENGLISH) + "*",
- process.getErrorStream(), new OnLineListener() {
- @Override
- public void onLine(String line) {
- synchronized (Interactive.this) {
- if (command == null) {
- return;
- }
- if (line.startsWith(command.marker)) {
- lastMarkerSTDERR = command.marker;
- processMarker();
- } else {
- if (wantSTDERR)
- addBuffer(line);
- processLine(line, onSTDERRLineListener);
- }
- }
- }
- });
-
- // start gobbling and write our commands to the shell
- STDOUT.start();
- STDERR.start();
-
- running = true;
- closed = false;
-
- runNextCommand();
-
- return true;
- } catch (IOException e) {
- // shell probably not found
- return false;
- }
- }
-
- /**
- * Close shell and clean up all resources. Call this when you are done
- * with the shell. If the shell is not idle (all commands completed) you
- * should not call this method from the main UI thread because it may
- * block for a long time. This method will intentionally crash your app
- * (if in debug mode) if you try to do this anyway.
- */
- public void close() {
- boolean _idle = isIdle(); // idle must be checked synchronized
-
- synchronized (this) {
- if (!running)
- return;
- running = false;
- closed = true;
- }
-
- // This method should not be called from the main thread unless the
- // shell is idle and can be cleaned up with (minimal) waiting. Only
- // throw in debug mode.
- if (!_idle && Debug.getSanityChecksEnabledEffective() && Debug.onMainThread()) {
- Debug.log(ShellOnMainThreadException.EXCEPTION_NOT_IDLE);
- throw new ShellOnMainThreadException(ShellOnMainThreadException.EXCEPTION_NOT_IDLE);
- }
-
- if (!_idle)
- waitForIdle();
-
- try {
- try {
- STDIN.write(("exit\n").getBytes("UTF-8"));
- STDIN.flush();
- } catch (IOException e) {
- if (e.getMessage().contains("EPIPE")) {
- // we're not running a shell, the shell closed STDIN,
- // the script already contained the exit command, etc.
- } else {
- throw e;
- }
- }
-
- // wait for our process to finish, while we gobble away in the
- // background
- process.waitFor();
-
- // make sure our threads are done gobbling, our streams are
- // closed, and the process is destroyed - while the latter two
- // shouldn't be needed in theory, and may even produce warnings,
- // in "normal" Java they are required for guaranteed cleanup of
- // resources, so lets be safe and do this on Android as well
- try {
- STDIN.close();
- } catch (IOException e) {
- // STDIN going missing is no reason to abort
- }
- STDOUT.join();
- STDERR.join();
- stopWatchdog();
- process.destroy();
- } catch (IOException e) {
- // various unforseen IO errors may still occur
- } catch (InterruptedException e) {
- // this should really be re-thrown
- }
-
- Debug.log(String.format("[%s%%] END", shell.toUpperCase(Locale.ENGLISH)));
- }
-
- /**
- * Try to clean up as much as possible from a shell that's gotten itself
- * wedged. Hopefully the StreamGobblers will croak on their own when the
- * other side of the pipe is closed.
- */
- public synchronized void kill() {
- running = false;
- closed = true;
-
- try {
- STDIN.close();
- } catch (IOException e) {
- // in case it was closed
- }
- try {
- process.destroy();
- } catch (Exception e) {
- // in case it was already destroyed or can't be
- }
- }
-
- /**
- * Is our shell still running ?
- *
- * @return Shell running ?
- */
- public boolean isRunning() {
- if (process == null) {
- return false;
- }
- try {
- process.exitValue();
- return false;
- } catch (IllegalThreadStateException e) {
- // if this is thrown, we're still running
- }
- return true;
- }
-
- /**
- * Have all commands completed executing ?
- *
- * @return Shell idle ?
- */
- public synchronized boolean isIdle() {
- if (!isRunning()) {
- idle = true;
- synchronized (idleSync) {
- idleSync.notifyAll();
- }
- }
- return idle;
- }
-
- /**
- *
- * Wait for idle state. As this is a blocking call, you should not call
- * it from the main UI thread. If you do so and debug mode is enabled,
- * this method will intentionally crash your app.
- *
- *
- * If not interrupted, this method will not return until all commands
- * have finished executing. Note that this does not necessarily mean
- * that all the callbacks have fired yet.
- *
- *
- * If no Handler is used, all callbacks will have been executed when
- * this method returns. If a Handler is used, and this method is called
- * from a different thread than associated with the Handler's Looper,
- * all callbacks will have been executed when this method returns as
- * well. If however a Handler is used but this method is called from the
- * same thread as associated with the Handler's Looper, there is no way
- * to know.
- *
- *
- * In practice this means that in most simple cases all callbacks will
- * have completed when this method returns, but if you actually depend
- * on this behavior, you should make certain this is indeed the case.
- *
- *
- * See {@link Shell.Interactive} for further details on threading and
- * handlers
- *
- *
- * @return True if wait complete, false if wait interrupted
- */
- public boolean waitForIdle() {
- if (Debug.getSanityChecksEnabledEffective() && Debug.onMainThread()) {
- Debug.log(ShellOnMainThreadException.EXCEPTION_WAIT_IDLE);
- throw new ShellOnMainThreadException(ShellOnMainThreadException.EXCEPTION_WAIT_IDLE);
- }
-
- if (isRunning()) {
- synchronized (idleSync) {
- while (!idle) {
- try {
- idleSync.wait();
- } catch (InterruptedException e) {
- return false;
- }
- }
- }
-
- if ((handler != null) &&
- (handler.getLooper() != null) &&
- (handler.getLooper() != Looper.myLooper())) {
- // If the callbacks are posted to a different thread than
- // this one, we can wait until all callbacks have called
- // before returning. If we don't use a Handler at all, the
- // callbacks are already called before we get here. If we do
- // use a Handler but we use the same Looper, waiting here
- // would actually block the callbacks from being called
-
- synchronized (callbackSync) {
- while (callbacks > 0) {
- try {
- callbackSync.wait();
- } catch (InterruptedException e) {
- return false;
- }
- }
- }
- }
- }
-
- return true;
- }
-
- /**
- * Are we using a Handler to post callbacks ?
- *
- * @return Handler used ?
- */
- public boolean hasHandler() {
- return (handler != null);
- }
- }
-}
diff --git a/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/ShellNotClosedException.java b/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/ShellNotClosedException.java
deleted file mode 100644
index 2a44083ec..000000000
--- a/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/ShellNotClosedException.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Jorrit "Chainfire" Jongma
- *
- * Licensed 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 eu.chainfire.libsuperuser;
-
-/**
- * Exception class used to notify developer that a shell was not close()d
- */
-@SuppressWarnings("serial")
-public class ShellNotClosedException extends RuntimeException {
- public static final String EXCEPTION_NOT_CLOSED = "Application did not close() interactive shell";
-
- public ShellNotClosedException() {
- super(EXCEPTION_NOT_CLOSED);
- }
-}
diff --git a/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/ShellOnMainThreadException.java b/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/ShellOnMainThreadException.java
deleted file mode 100644
index 69732e3b3..000000000
--- a/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/ShellOnMainThreadException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Jorrit "Chainfire" Jongma
- *
- * Licensed 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 eu.chainfire.libsuperuser;
-
-/**
- * Exception class used to crash application when shell commands are executed
- * from the main thread, and we are in debug mode.
- */
-@SuppressWarnings("serial")
-public class ShellOnMainThreadException extends RuntimeException {
- public static final String EXCEPTION_COMMAND = "Application attempted to run a shell command from the main thread";
- public static final String EXCEPTION_NOT_IDLE = "Application attempted to wait for a non-idle shell to close on the main thread";
- public static final String EXCEPTION_WAIT_IDLE = "Application attempted to wait for a shell to become idle on the main thread";
-
- public ShellOnMainThreadException(String message) {
- super(message);
- }
-}
diff --git a/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/StreamGobbler.java b/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/StreamGobbler.java
deleted file mode 100644
index 4ce669742..000000000
--- a/extern/libsuperuser/libsuperuser/src/eu/chainfire/libsuperuser/StreamGobbler.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2012-2014 Jorrit "Chainfire" Jongma
- *
- * Licensed 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 eu.chainfire.libsuperuser;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.List;
-
-/**
- * Thread utility class continuously reading from an InputStream
- */
-public class StreamGobbler extends Thread {
- /**
- * Line callback interface
- */
- public interface OnLineListener {
- /**
- * Line callback
- *
- * This callback should process the line as quickly as possible.
- * Delays in this callback may pause the native process or even
- * result in a deadlock
- *
- * @param line String that was gobbled
- */
- void onLine(String line);
- }
-
- private String shell = null;
- private BufferedReader reader = null;
- private List writer = null;
- private OnLineListener listener = null;
-
- /**
- * StreamGobbler constructor
- *
- * We use this class because shell STDOUT and STDERR should be read as quickly as
- * possible to prevent a deadlock from occurring, or Process.waitFor() never
- * returning (as the buffer is full, pausing the native process)
- *
- * @param shell Name of the shell
- * @param inputStream InputStream to read from
- * @param outputList List to write to, or null
- */
- public StreamGobbler(String shell, InputStream inputStream, List outputList) {
- this.shell = shell;
- reader = new BufferedReader(new InputStreamReader(inputStream));
- writer = outputList;
- }
-
- /**
- * StreamGobbler constructor
- *
- * We use this class because shell STDOUT and STDERR should be read as quickly as
- * possible to prevent a deadlock from occurring, or Process.waitFor() never
- * returning (as the buffer is full, pausing the native process)
- *
- * @param shell Name of the shell
- * @param inputStream InputStream to read from
- * @param onLineListener OnLineListener callback
- */
- public StreamGobbler(String shell, InputStream inputStream, OnLineListener onLineListener) {
- this.shell = shell;
- reader = new BufferedReader(new InputStreamReader(inputStream));
- listener = onLineListener;
- }
-
- @Override
- public void run() {
- // keep reading the InputStream until it ends (or an error occurs)
- try {
- String line;
- while ((line = reader.readLine()) != null) {
- Debug.logOutput(String.format("[%s] %s", shell, line));
- if (writer != null) writer.add(line);
- if (listener != null) listener.onLine(line);
- }
- } catch (IOException e) {
- // reader probably closed, expected exit condition
- }
-
- // make sure our stream is closed and resources will be freed
- try {
- reader.close();
- } catch (IOException e) {
- // read already closed
- }
- }
-}
diff --git a/extern/libsuperuser/settings.gradle b/extern/libsuperuser/settings.gradle
deleted file mode 100644
index 32aef3ac0..000000000
--- a/extern/libsuperuser/settings.gradle
+++ /dev/null
@@ -1 +0,0 @@
-include ':libsuperuser', ':libsuperuser_example'
diff --git a/extern/zxing-core/build.gradle b/extern/zxing-core/build.gradle
deleted file mode 100644
index 4d4a19643..000000000
--- a/extern/zxing-core/build.gradle
+++ /dev/null
@@ -1,3 +0,0 @@
-apply plugin: 'java'
-
-sourceCompatibility = 1.7
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/BarcodeFormat.java b/extern/zxing-core/src/main/java/com/google/zxing/BarcodeFormat.java
deleted file mode 100644
index 7f6a0ef58..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/BarcodeFormat.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-/**
- * Enumerates barcode formats known to this package. Please keep alphabetized.
- *
- * @author Sean Owen
- */
-public enum BarcodeFormat {
-
- /** Aztec 2D barcode format. */
- AZTEC,
-
- /** CODABAR 1D format. */
- CODABAR,
-
- /** Code 39 1D format. */
- CODE_39,
-
- /** Code 93 1D format. */
- CODE_93,
-
- /** Code 128 1D format. */
- CODE_128,
-
- /** Data Matrix 2D barcode format. */
- DATA_MATRIX,
-
- /** EAN-8 1D format. */
- EAN_8,
-
- /** EAN-13 1D format. */
- EAN_13,
-
- /** ITF (Interleaved Two of Five) 1D format. */
- ITF,
-
- /** MaxiCode 2D barcode format. */
- MAXICODE,
-
- /** PDF417 format. */
- PDF_417,
-
- /** QR Code 2D barcode format. */
- QR_CODE,
-
- /** RSS 14 */
- RSS_14,
-
- /** RSS EXPANDED */
- RSS_EXPANDED,
-
- /** UPC-A 1D format. */
- UPC_A,
-
- /** UPC-E 1D format. */
- UPC_E,
-
- /** UPC/EAN extension format. Not a stand-alone format. */
- UPC_EAN_EXTENSION
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/Binarizer.java b/extern/zxing-core/src/main/java/com/google/zxing/Binarizer.java
deleted file mode 100644
index 02af0832f..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/Binarizer.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright 2009 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-import com.google.zxing.common.BitArray;
-import com.google.zxing.common.BitMatrix;
-
-/**
- * This class hierarchy provides a set of methods to convert luminance data to 1 bit data.
- * It allows the algorithm to vary polymorphically, for example allowing a very expensive
- * thresholding technique for servers and a fast one for mobile. It also permits the implementation
- * to vary, e.g. a JNI version for Android and a Java fallback version for other platforms.
- *
- * @author dswitkin@google.com (Daniel Switkin)
- */
-public abstract class Binarizer {
-
- private final LuminanceSource source;
-
- protected Binarizer(LuminanceSource source) {
- this.source = source;
- }
-
- public final LuminanceSource getLuminanceSource() {
- return source;
- }
-
- /**
- * Converts one row of luminance data to 1 bit data. May actually do the conversion, or return
- * cached data. Callers should assume this method is expensive and call it as seldom as possible.
- * This method is intended for decoding 1D barcodes and may choose to apply sharpening.
- * For callers which only examine one row of pixels at a time, the same BitArray should be reused
- * and passed in with each call for performance. However it is legal to keep more than one row
- * at a time if needed.
- *
- * @param y The row to fetch, which must be in [0, bitmap height)
- * @param row An optional preallocated array. If null or too small, it will be ignored.
- * If used, the Binarizer will call BitArray.clear(). Always use the returned object.
- * @return The array of bits for this row (true means black).
- * @throws NotFoundException if row can't be binarized
- */
- public abstract BitArray getBlackRow(int y, BitArray row) throws NotFoundException;
-
- /**
- * Converts a 2D array of luminance data to 1 bit data. As above, assume this method is expensive
- * and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or
- * may not apply sharpening. Therefore, a row from this matrix may not be identical to one
- * fetched using getBlackRow(), so don't mix and match between them.
- *
- * @return The 2D array of bits for the image (true means black).
- * @throws NotFoundException if image can't be binarized to make a matrix
- */
- public abstract BitMatrix getBlackMatrix() throws NotFoundException;
-
- /**
- * Creates a new object with the same type as this Binarizer implementation, but with pristine
- * state. This is needed because Binarizer implementations may be stateful, e.g. keeping a cache
- * of 1 bit data. See Effective Java for why we can't use Java's clone() method.
- *
- * @param source The LuminanceSource this Binarizer will operate on.
- * @return A new concrete Binarizer implementation object.
- */
- public abstract Binarizer createBinarizer(LuminanceSource source);
-
- public final int getWidth() {
- return source.getWidth();
- }
-
- public final int getHeight() {
- return source.getHeight();
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/BinaryBitmap.java b/extern/zxing-core/src/main/java/com/google/zxing/BinaryBitmap.java
deleted file mode 100644
index c1ef8a13e..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/BinaryBitmap.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright 2009 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-import com.google.zxing.common.BitArray;
-import com.google.zxing.common.BitMatrix;
-
-/**
- * This class is the core bitmap class used by ZXing to represent 1 bit data. Reader objects
- * accept a BinaryBitmap and attempt to decode it.
- *
- * @author dswitkin@google.com (Daniel Switkin)
- */
-public final class BinaryBitmap {
-
- private final Binarizer binarizer;
- private BitMatrix matrix;
-
- public BinaryBitmap(Binarizer binarizer) {
- if (binarizer == null) {
- throw new IllegalArgumentException("Binarizer must be non-null.");
- }
- this.binarizer = binarizer;
- }
-
- /**
- * @return The width of the bitmap.
- */
- public int getWidth() {
- return binarizer.getWidth();
- }
-
- /**
- * @return The height of the bitmap.
- */
- public int getHeight() {
- return binarizer.getHeight();
- }
-
- /**
- * Converts one row of luminance data to 1 bit data. May actually do the conversion, or return
- * cached data. Callers should assume this method is expensive and call it as seldom as possible.
- * This method is intended for decoding 1D barcodes and may choose to apply sharpening.
- *
- * @param y The row to fetch, which must be in [0, bitmap height)
- * @param row An optional preallocated array. If null or too small, it will be ignored.
- * If used, the Binarizer will call BitArray.clear(). Always use the returned object.
- * @return The array of bits for this row (true means black).
- * @throws NotFoundException if row can't be binarized
- */
- public BitArray getBlackRow(int y, BitArray row) throws NotFoundException {
- return binarizer.getBlackRow(y, row);
- }
-
- /**
- * Converts a 2D array of luminance data to 1 bit. As above, assume this method is expensive
- * and do not call it repeatedly. This method is intended for decoding 2D barcodes and may or
- * may not apply sharpening. Therefore, a row from this matrix may not be identical to one
- * fetched using getBlackRow(), so don't mix and match between them.
- *
- * @return The 2D array of bits for the image (true means black).
- * @throws NotFoundException if image can't be binarized to make a matrix
- */
- public BitMatrix getBlackMatrix() throws NotFoundException {
- // The matrix is created on demand the first time it is requested, then cached. There are two
- // reasons for this:
- // 1. This work will never be done if the caller only installs 1D Reader objects, or if a
- // 1D Reader finds a barcode before the 2D Readers run.
- // 2. This work will only be done once even if the caller installs multiple 2D Readers.
- if (matrix == null) {
- matrix = binarizer.getBlackMatrix();
- }
- return matrix;
- }
-
- /**
- * @return Whether this bitmap can be cropped.
- */
- public boolean isCropSupported() {
- return binarizer.getLuminanceSource().isCropSupported();
- }
-
- /**
- * Returns a new object with cropped image data. Implementations may keep a reference to the
- * original data rather than a copy. Only callable if isCropSupported() is true.
- *
- * @param left The left coordinate, which must be in [0,getWidth())
- * @param top The top coordinate, which must be in [0,getHeight())
- * @param width The width of the rectangle to crop.
- * @param height The height of the rectangle to crop.
- * @return A cropped version of this object.
- */
- public BinaryBitmap crop(int left, int top, int width, int height) {
- LuminanceSource newSource = binarizer.getLuminanceSource().crop(left, top, width, height);
- return new BinaryBitmap(binarizer.createBinarizer(newSource));
- }
-
- /**
- * @return Whether this bitmap supports counter-clockwise rotation.
- */
- public boolean isRotateSupported() {
- return binarizer.getLuminanceSource().isRotateSupported();
- }
-
- /**
- * Returns a new object with rotated image data by 90 degrees counterclockwise.
- * Only callable if {@link #isRotateSupported()} is true.
- *
- * @return A rotated version of this object.
- */
- public BinaryBitmap rotateCounterClockwise() {
- LuminanceSource newSource = binarizer.getLuminanceSource().rotateCounterClockwise();
- return new BinaryBitmap(binarizer.createBinarizer(newSource));
- }
-
- /**
- * Returns a new object with rotated image data by 45 degrees counterclockwise.
- * Only callable if {@link #isRotateSupported()} is true.
- *
- * @return A rotated version of this object.
- */
- public BinaryBitmap rotateCounterClockwise45() {
- LuminanceSource newSource = binarizer.getLuminanceSource().rotateCounterClockwise45();
- return new BinaryBitmap(binarizer.createBinarizer(newSource));
- }
-
- @Override
- public String toString() {
- try {
- return getBlackMatrix().toString();
- } catch (NotFoundException e) {
- return "";
- }
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/ChecksumException.java b/extern/zxing-core/src/main/java/com/google/zxing/ChecksumException.java
deleted file mode 100644
index c5acbe3ee..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/ChecksumException.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-/**
- * Thrown when a barcode was successfully detected and decoded, but
- * was not returned because its checksum feature failed.
- *
- * @author Sean Owen
- */
-public final class ChecksumException extends ReaderException {
-
- private static final ChecksumException INSTANCE = new ChecksumException();
- static {
- INSTANCE.setStackTrace(NO_TRACE); // since it's meaningless
- }
-
- private ChecksumException() {
- // do nothing
- }
-
- private ChecksumException(Throwable cause) {
- super(cause);
- }
-
- public static ChecksumException getChecksumInstance() {
- return isStackTrace ? new ChecksumException() : INSTANCE;
- }
-
- public static ChecksumException getChecksumInstance(Throwable cause) {
- return isStackTrace ? new ChecksumException(cause) : INSTANCE;
- }
-}
\ No newline at end of file
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/DecodeHintType.java b/extern/zxing-core/src/main/java/com/google/zxing/DecodeHintType.java
deleted file mode 100644
index a6658695e..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/DecodeHintType.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-import java.util.List;
-
-/**
- * Encapsulates a type of hint that a caller may pass to a barcode reader to help it
- * more quickly or accurately decode it. It is up to implementations to decide what,
- * if anything, to do with the information that is supplied.
- *
- * @author Sean Owen
- * @author dswitkin@google.com (Daniel Switkin)
- * @see Reader#decode(BinaryBitmap,java.util.Map)
- */
-public enum DecodeHintType {
-
- /**
- * Unspecified, application-specific hint. Maps to an unspecified {@link Object}.
- */
- OTHER(Object.class),
-
- /**
- * Image is a pure monochrome image of a barcode. Doesn't matter what it maps to;
- * use {@link Boolean#TRUE}.
- */
- PURE_BARCODE(Void.class),
-
- /**
- * Image is known to be of one of a few possible formats.
- * Maps to a {@link List} of {@link BarcodeFormat}s.
- */
- POSSIBLE_FORMATS(List.class),
-
- /**
- * Spend more time to try to find a barcode; optimize for accuracy, not speed.
- * Doesn't matter what it maps to; use {@link Boolean#TRUE}.
- */
- TRY_HARDER(Void.class),
-
- /**
- * Specifies what character encoding to use when decoding, where applicable (type String)
- */
- CHARACTER_SET(String.class),
-
- /**
- * Allowed lengths of encoded data -- reject anything else. Maps to an {@code int[]}.
- */
- ALLOWED_LENGTHS(int[].class),
-
- /**
- * Assume Code 39 codes employ a check digit. Doesn't matter what it maps to;
- * use {@link Boolean#TRUE}.
- */
- ASSUME_CODE_39_CHECK_DIGIT(Void.class),
-
- /**
- * Assume the barcode is being processed as a GS1 barcode, and modify behavior as needed.
- * For example this affects FNC1 handling for Code 128 (aka GS1-128). Doesn't matter what it maps to;
- * use {@link Boolean#TRUE}.
- */
- ASSUME_GS1(Void.class),
-
- /**
- * If true, return the start and end digits in a Codabar barcode instead of stripping them. They
- * are alpha, whereas the rest are numeric. By default, they are stripped, but this causes them
- * to not be. Doesn't matter what it maps to; use {@link Boolean#TRUE}.
- */
- RETURN_CODABAR_START_END(Void.class),
-
- /**
- * The caller needs to be notified via callback when a possible {@link ResultPoint}
- * is found. Maps to a {@link ResultPointCallback}.
- */
- NEED_RESULT_POINT_CALLBACK(ResultPointCallback.class),
-
-
- /**
- * Allowed extension lengths for EAN or UPC barcodes. Other formats will ignore this.
- * Maps to an {@code int[]} of the allowed extension lengths, for example [2], [5], or [2, 5].
- * If it is optional to have an extension, do not set this hint. If this is set,
- * and a UPC or EAN barcode is found but an extension is not, then no result will be returned
- * at all.
- */
- ALLOWED_EAN_EXTENSIONS(int[].class),
-
- // End of enumeration values.
- ;
-
- /**
- * Data type the hint is expecting.
- * Among the possible values the {@link Void} stands out as being used for
- * hints that do not expect a value to be supplied (flag hints). Such hints
- * will possibly have their value ignored, or replaced by a
- * {@link Boolean#TRUE}. Hint suppliers should probably use
- * {@link Boolean#TRUE} as directed by the actual hint documentation.
- */
- private final Class> valueType;
-
- DecodeHintType(Class> valueType) {
- this.valueType = valueType;
- }
-
- public Class> getValueType() {
- return valueType;
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/Dimension.java b/extern/zxing-core/src/main/java/com/google/zxing/Dimension.java
deleted file mode 100644
index b3a2486e6..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/Dimension.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2012 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-/**
- * Simply encapsulates a width and height.
- */
-public final class Dimension {
-
- private final int width;
- private final int height;
-
- public Dimension(int width, int height) {
- if (width < 0 || height < 0) {
- throw new IllegalArgumentException();
- }
- this.width = width;
- this.height = height;
- }
-
- public int getWidth() {
- return width;
- }
-
- public int getHeight() {
- return height;
- }
-
- @Override
- public boolean equals(Object other) {
- if (other instanceof Dimension) {
- Dimension d = (Dimension) other;
- return width == d.width && height == d.height;
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return width * 32713 + height;
- }
-
- @Override
- public String toString() {
- return width + "x" + height;
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/EncodeHintType.java b/extern/zxing-core/src/main/java/com/google/zxing/EncodeHintType.java
deleted file mode 100644
index ff97b21aa..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/EncodeHintType.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-/**
- * These are a set of hints that you may pass to Writers to specify their behavior.
- *
- * @author dswitkin@google.com (Daniel Switkin)
- */
-public enum EncodeHintType {
-
- /**
- * Specifies what degree of error correction to use, for example in QR Codes.
- * Type depends on the encoder. For example for QR codes it's type
- * {@link com.google.zxing.qrcode.decoder.ErrorCorrectionLevel ErrorCorrectionLevel}.
- * For Aztec it is of type {@link Integer}, representing the minimal percentage of error correction words.
- * For PDF417 it is of type {@link Integer}, valid values being 0 to 8.
- * Note: an Aztec symbol should have a minimum of 25% EC words.
- */
- ERROR_CORRECTION,
-
- /**
- * Specifies what character encoding to use where applicable (type {@link String})
- */
- CHARACTER_SET,
-
- /**
- * Specifies the matrix shape for Data Matrix (type {@link com.google.zxing.datamatrix.encoder.SymbolShapeHint})
- */
- DATA_MATRIX_SHAPE,
-
- /**
- * Specifies a minimum barcode size (type {@link Dimension}). Only applicable to Data Matrix now.
- *
- * @deprecated use width/height params in
- * {@link com.google.zxing.datamatrix.DataMatrixWriter#encode(String, BarcodeFormat, int, int)}
- */
- @Deprecated
- MIN_SIZE,
-
- /**
- * Specifies a maximum barcode size (type {@link Dimension}). Only applicable to Data Matrix now.
- *
- * @deprecated without replacement
- */
- @Deprecated
- MAX_SIZE,
-
- /**
- * Specifies margin, in pixels, to use when generating the barcode. The meaning can vary
- * by format; for example it controls margin before and after the barcode horizontally for
- * most 1D formats. (Type {@link Integer}).
- */
- MARGIN,
-
- /**
- * Specifies whether to use compact mode for PDF417 (type {@link Boolean}).
- */
- PDF417_COMPACT,
-
- /**
- * Specifies what compaction mode to use for PDF417 (type
- * {@link com.google.zxing.pdf417.encoder.Compaction Compaction}).
- */
- PDF417_COMPACTION,
-
- /**
- * Specifies the minimum and maximum number of rows and columns for PDF417 (type
- * {@link com.google.zxing.pdf417.encoder.Dimensions Dimensions}).
- */
- PDF417_DIMENSIONS,
-
- /**
- * Specifies the required number of layers for an Aztec code:
- * a negative number (-1, -2, -3, -4) specifies a compact Aztec code
- * 0 indicates to use the minimum number of layers (the default)
- * a positive number (1, 2, .. 32) specifies a normaol (non-compact) Aztec code
- */
- AZTEC_LAYERS,
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/FormatException.java b/extern/zxing-core/src/main/java/com/google/zxing/FormatException.java
deleted file mode 100644
index b046b822d..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/FormatException.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-/**
- * Thrown when a barcode was successfully detected, but some aspect of
- * the content did not conform to the barcode's format rules. This could have
- * been due to a mis-detection.
- *
- * @author Sean Owen
- */
-public final class FormatException extends ReaderException {
-
- private static final FormatException INSTANCE = new FormatException();
- static {
- INSTANCE.setStackTrace(NO_TRACE); // since it's meaningless
- }
-
- private FormatException() {
- }
-
- private FormatException(Throwable cause) {
- super(cause);
- }
-
- public static FormatException getFormatInstance() {
- return isStackTrace ? new FormatException() : INSTANCE;
- }
-
- public static FormatException getFormatInstance(Throwable cause) {
- return isStackTrace ? new FormatException(cause) : INSTANCE;
- }
-}
\ No newline at end of file
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/InvertedLuminanceSource.java b/extern/zxing-core/src/main/java/com/google/zxing/InvertedLuminanceSource.java
deleted file mode 100644
index edaa119bd..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/InvertedLuminanceSource.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2013 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-/**
- * A wrapper implementation of {@link LuminanceSource} which inverts the luminances it returns -- black becomes
- * white and vice versa, and each value becomes (255-value).
- *
- * @author Sean Owen
- */
-public final class InvertedLuminanceSource extends LuminanceSource {
-
- private final LuminanceSource delegate;
-
- public InvertedLuminanceSource(LuminanceSource delegate) {
- super(delegate.getWidth(), delegate.getHeight());
- this.delegate = delegate;
- }
-
- @Override
- public byte[] getRow(int y, byte[] row) {
- row = delegate.getRow(y, row);
- int width = getWidth();
- for (int i = 0; i < width; i++) {
- row[i] = (byte) (255 - (row[i] & 0xFF));
- }
- return row;
- }
-
- @Override
- public byte[] getMatrix() {
- byte[] matrix = delegate.getMatrix();
- int length = getWidth() * getHeight();
- byte[] invertedMatrix = new byte[length];
- for (int i = 0; i < length; i++) {
- invertedMatrix[i] = (byte) (255 - (matrix[i] & 0xFF));
- }
- return invertedMatrix;
- }
-
- @Override
- public boolean isCropSupported() {
- return delegate.isCropSupported();
- }
-
- @Override
- public LuminanceSource crop(int left, int top, int width, int height) {
- return new InvertedLuminanceSource(delegate.crop(left, top, width, height));
- }
-
- @Override
- public boolean isRotateSupported() {
- return delegate.isRotateSupported();
- }
-
- /**
- * @return original delegate {@link LuminanceSource} since invert undoes itself
- */
- @Override
- public LuminanceSource invert() {
- return delegate;
- }
-
- @Override
- public LuminanceSource rotateCounterClockwise() {
- return new InvertedLuminanceSource(delegate.rotateCounterClockwise());
- }
-
- @Override
- public LuminanceSource rotateCounterClockwise45() {
- return new InvertedLuminanceSource(delegate.rotateCounterClockwise45());
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/LuminanceSource.java b/extern/zxing-core/src/main/java/com/google/zxing/LuminanceSource.java
deleted file mode 100644
index 1946d023c..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/LuminanceSource.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 2009 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-/**
- * The purpose of this class hierarchy is to abstract different bitmap implementations across
- * platforms into a standard interface for requesting greyscale luminance values. The interface
- * only provides immutable methods; therefore crop and rotation create copies. This is to ensure
- * that one Reader does not modify the original luminance source and leave it in an unknown state
- * for other Readers in the chain.
- *
- * @author dswitkin@google.com (Daniel Switkin)
- */
-public abstract class LuminanceSource {
-
- private final int width;
- private final int height;
-
- protected LuminanceSource(int width, int height) {
- this.width = width;
- this.height = height;
- }
-
- /**
- * Fetches one row of luminance data from the underlying platform's bitmap. Values range from
- * 0 (black) to 255 (white). Because Java does not have an unsigned byte type, callers will have
- * to bitwise and with 0xff for each value. It is preferable for implementations of this method
- * to only fetch this row rather than the whole image, since no 2D Readers may be installed and
- * getMatrix() may never be called.
- *
- * @param y The row to fetch, which must be in [0,getHeight())
- * @param row An optional preallocated array. If null or too small, it will be ignored.
- * Always use the returned object, and ignore the .length of the array.
- * @return An array containing the luminance data.
- */
- public abstract byte[] getRow(int y, byte[] row);
-
- /**
- * Fetches luminance data for the underlying bitmap. Values should be fetched using:
- * {@code int luminance = array[y * width + x] & 0xff}
- *
- * @return A row-major 2D array of luminance values. Do not use result.length as it may be
- * larger than width * height bytes on some platforms. Do not modify the contents
- * of the result.
- */
- public abstract byte[] getMatrix();
-
- /**
- * @return The width of the bitmap.
- */
- public final int getWidth() {
- return width;
- }
-
- /**
- * @return The height of the bitmap.
- */
- public final int getHeight() {
- return height;
- }
-
- /**
- * @return Whether this subclass supports cropping.
- */
- public boolean isCropSupported() {
- return false;
- }
-
- /**
- * Returns a new object with cropped image data. Implementations may keep a reference to the
- * original data rather than a copy. Only callable if isCropSupported() is true.
- *
- * @param left The left coordinate, which must be in [0,getWidth())
- * @param top The top coordinate, which must be in [0,getHeight())
- * @param width The width of the rectangle to crop.
- * @param height The height of the rectangle to crop.
- * @return A cropped version of this object.
- */
- public LuminanceSource crop(int left, int top, int width, int height) {
- throw new UnsupportedOperationException("This luminance source does not support cropping.");
- }
-
- /**
- * @return Whether this subclass supports counter-clockwise rotation.
- */
- public boolean isRotateSupported() {
- return false;
- }
-
- /**
- * @return a wrapper of this {@code LuminanceSource} which inverts the luminances it returns -- black becomes
- * white and vice versa, and each value becomes (255-value).
- */
- public LuminanceSource invert() {
- return new InvertedLuminanceSource(this);
- }
-
- /**
- * Returns a new object with rotated image data by 90 degrees counterclockwise.
- * Only callable if {@link #isRotateSupported()} is true.
- *
- * @return A rotated version of this object.
- */
- public LuminanceSource rotateCounterClockwise() {
- throw new UnsupportedOperationException("This luminance source does not support rotation by 90 degrees.");
- }
-
- /**
- * Returns a new object with rotated image data by 45 degrees counterclockwise.
- * Only callable if {@link #isRotateSupported()} is true.
- *
- * @return A rotated version of this object.
- */
- public LuminanceSource rotateCounterClockwise45() {
- throw new UnsupportedOperationException("This luminance source does not support rotation by 45 degrees.");
- }
-
- @Override
- public final String toString() {
- byte[] row = new byte[width];
- StringBuilder result = new StringBuilder(height * (width + 1));
- for (int y = 0; y < height; y++) {
- row = getRow(y, row);
- for (int x = 0; x < width; x++) {
- int luminance = row[x] & 0xFF;
- char c;
- if (luminance < 0x40) {
- c = '#';
- } else if (luminance < 0x80) {
- c = '+';
- } else if (luminance < 0xC0) {
- c = '.';
- } else {
- c = ' ';
- }
- result.append(c);
- }
- result.append('\n');
- }
- return result.toString();
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/MultiFormatReader.java b/extern/zxing-core/src/main/java/com/google/zxing/MultiFormatReader.java
deleted file mode 100644
index fe6f4ce5a..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/MultiFormatReader.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-import com.google.zxing.aztec.AztecReader;
-import com.google.zxing.datamatrix.DataMatrixReader;
-import com.google.zxing.maxicode.MaxiCodeReader;
-import com.google.zxing.oned.MultiFormatOneDReader;
-import com.google.zxing.pdf417.PDF417Reader;
-import com.google.zxing.qrcode.QRCodeReader;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-
-/**
- * MultiFormatReader is a convenience class and the main entry point into the library for most uses.
- * By default it attempts to decode all barcode formats that the library supports. Optionally, you
- * can provide a hints object to request different behavior, for example only decoding QR codes.
- *
- * @author Sean Owen
- * @author dswitkin@google.com (Daniel Switkin)
- */
-public final class MultiFormatReader implements Reader {
-
- private Map hints;
- private Reader[] readers;
-
- /**
- * This version of decode honors the intent of Reader.decode(BinaryBitmap) in that it
- * passes null as a hint to the decoders. However, that makes it inefficient to call repeatedly.
- * Use setHints() followed by decodeWithState() for continuous scan applications.
- *
- * @param image The pixel data to decode
- * @return The contents of the image
- * @throws NotFoundException Any errors which occurred
- */
- @Override
- public Result decode(BinaryBitmap image) throws NotFoundException {
- setHints(null);
- return decodeInternal(image);
- }
-
- /**
- * Decode an image using the hints provided. Does not honor existing state.
- *
- * @param image The pixel data to decode
- * @param hints The hints to use, clearing the previous state.
- * @return The contents of the image
- * @throws NotFoundException Any errors which occurred
- */
- @Override
- public Result decode(BinaryBitmap image, Map hints) throws NotFoundException {
- setHints(hints);
- return decodeInternal(image);
- }
-
- /**
- * Decode an image using the state set up by calling setHints() previously. Continuous scan
- * clients will get a large speed increase by using this instead of decode().
- *
- * @param image The pixel data to decode
- * @return The contents of the image
- * @throws NotFoundException Any errors which occurred
- */
- public Result decodeWithState(BinaryBitmap image) throws NotFoundException {
- // Make sure to set up the default state so we don't crash
- if (readers == null) {
- setHints(null);
- }
- return decodeInternal(image);
- }
-
- /**
- * This method adds state to the MultiFormatReader. By setting the hints once, subsequent calls
- * to decodeWithState(image) can reuse the same set of readers without reallocating memory. This
- * is important for performance in continuous scan clients.
- *
- * @param hints The set of hints to use for subsequent calls to decode(image)
- */
- public void setHints(Map hints) {
- this.hints = hints;
-
- boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
- @SuppressWarnings("unchecked")
- Collection formats =
- hints == null ? null : (Collection) hints.get(DecodeHintType.POSSIBLE_FORMATS);
- Collection readers = new ArrayList<>();
- if (formats != null) {
- boolean addOneDReader =
- formats.contains(BarcodeFormat.UPC_A) ||
- formats.contains(BarcodeFormat.UPC_E) ||
- formats.contains(BarcodeFormat.EAN_13) ||
- formats.contains(BarcodeFormat.EAN_8) ||
- formats.contains(BarcodeFormat.CODABAR) ||
- formats.contains(BarcodeFormat.CODE_39) ||
- formats.contains(BarcodeFormat.CODE_93) ||
- formats.contains(BarcodeFormat.CODE_128) ||
- formats.contains(BarcodeFormat.ITF) ||
- formats.contains(BarcodeFormat.RSS_14) ||
- formats.contains(BarcodeFormat.RSS_EXPANDED);
- // Put 1D readers upfront in "normal" mode
- if (addOneDReader && !tryHarder) {
- readers.add(new MultiFormatOneDReader(hints));
- }
- if (formats.contains(BarcodeFormat.QR_CODE)) {
- readers.add(new QRCodeReader());
- }
- if (formats.contains(BarcodeFormat.DATA_MATRIX)) {
- readers.add(new DataMatrixReader());
- }
- if (formats.contains(BarcodeFormat.AZTEC)) {
- readers.add(new AztecReader());
- }
- if (formats.contains(BarcodeFormat.PDF_417)) {
- readers.add(new PDF417Reader());
- }
- if (formats.contains(BarcodeFormat.MAXICODE)) {
- readers.add(new MaxiCodeReader());
- }
- // At end in "try harder" mode
- if (addOneDReader && tryHarder) {
- readers.add(new MultiFormatOneDReader(hints));
- }
- }
- if (readers.isEmpty()) {
- if (!tryHarder) {
- readers.add(new MultiFormatOneDReader(hints));
- }
-
- readers.add(new QRCodeReader());
- readers.add(new DataMatrixReader());
- readers.add(new AztecReader());
- readers.add(new PDF417Reader());
- readers.add(new MaxiCodeReader());
-
- if (tryHarder) {
- readers.add(new MultiFormatOneDReader(hints));
- }
- }
- this.readers = readers.toArray(new Reader[readers.size()]);
- }
-
- @Override
- public void reset() {
- if (readers != null) {
- for (Reader reader : readers) {
- reader.reset();
- }
- }
- }
-
- private Result decodeInternal(BinaryBitmap image) throws NotFoundException {
- if (readers != null) {
- for (Reader reader : readers) {
- try {
- return reader.decode(image, hints);
- } catch (ReaderException re) {
- // continue
- }
- }
- }
- throw NotFoundException.getNotFoundInstance();
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/MultiFormatWriter.java b/extern/zxing-core/src/main/java/com/google/zxing/MultiFormatWriter.java
deleted file mode 100644
index c980eb666..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/MultiFormatWriter.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-import com.google.zxing.aztec.AztecWriter;
-import com.google.zxing.common.BitMatrix;
-import com.google.zxing.datamatrix.DataMatrixWriter;
-import com.google.zxing.oned.CodaBarWriter;
-import com.google.zxing.oned.Code128Writer;
-import com.google.zxing.oned.Code39Writer;
-import com.google.zxing.oned.EAN13Writer;
-import com.google.zxing.oned.EAN8Writer;
-import com.google.zxing.oned.ITFWriter;
-import com.google.zxing.oned.UPCAWriter;
-import com.google.zxing.pdf417.PDF417Writer;
-import com.google.zxing.qrcode.QRCodeWriter;
-
-import java.util.Map;
-
-/**
- * This is a factory class which finds the appropriate Writer subclass for the BarcodeFormat
- * requested and encodes the barcode with the supplied contents.
- *
- * @author dswitkin@google.com (Daniel Switkin)
- */
-public final class MultiFormatWriter implements Writer {
-
- @Override
- public BitMatrix encode(String contents,
- BarcodeFormat format,
- int width,
- int height) throws WriterException {
- return encode(contents, format, width, height, null);
- }
-
- @Override
- public BitMatrix encode(String contents,
- BarcodeFormat format,
- int width, int height,
- Map hints) throws WriterException {
-
- Writer writer;
- switch (format) {
- case EAN_8:
- writer = new EAN8Writer();
- break;
- case EAN_13:
- writer = new EAN13Writer();
- break;
- case UPC_A:
- writer = new UPCAWriter();
- break;
- case QR_CODE:
- writer = new QRCodeWriter();
- break;
- case CODE_39:
- writer = new Code39Writer();
- break;
- case CODE_128:
- writer = new Code128Writer();
- break;
- case ITF:
- writer = new ITFWriter();
- break;
- case PDF_417:
- writer = new PDF417Writer();
- break;
- case CODABAR:
- writer = new CodaBarWriter();
- break;
- case DATA_MATRIX:
- writer = new DataMatrixWriter();
- break;
- case AZTEC:
- writer = new AztecWriter();
- break;
- default:
- throw new IllegalArgumentException("No encoder available for format " + format);
- }
- return writer.encode(contents, format, width, height, hints);
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/NotFoundException.java b/extern/zxing-core/src/main/java/com/google/zxing/NotFoundException.java
deleted file mode 100644
index 863526af4..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/NotFoundException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-/**
- * Thrown when a barcode was not found in the image. It might have been
- * partially detected but could not be confirmed.
- *
- * @author Sean Owen
- */
-public final class NotFoundException extends ReaderException {
-
- private static final NotFoundException INSTANCE = new NotFoundException();
- static {
- INSTANCE.setStackTrace(NO_TRACE); // since it's meaningless
- }
-
- private NotFoundException() {
- // do nothing
- }
-
- public static NotFoundException getNotFoundInstance() {
- return INSTANCE;
- }
-
-}
\ No newline at end of file
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/PlanarYUVLuminanceSource.java b/extern/zxing-core/src/main/java/com/google/zxing/PlanarYUVLuminanceSource.java
deleted file mode 100644
index 2049e5930..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/PlanarYUVLuminanceSource.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright 2009 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-/**
- * This object extends LuminanceSource around an array of YUV data returned from the camera driver,
- * with the option to crop to a rectangle within the full data. This can be used to exclude
- * superfluous pixels around the perimeter and speed up decoding.
- *
- * It works for any pixel format where the Y channel is planar and appears first, including
- * YCbCr_420_SP and YCbCr_422_SP.
- *
- * @author dswitkin@google.com (Daniel Switkin)
- */
-public final class PlanarYUVLuminanceSource extends LuminanceSource {
-
- private static final int THUMBNAIL_SCALE_FACTOR = 2;
-
- private final byte[] yuvData;
- private final int dataWidth;
- private final int dataHeight;
- private final int left;
- private final int top;
-
- public PlanarYUVLuminanceSource(byte[] yuvData,
- int dataWidth,
- int dataHeight,
- int left,
- int top,
- int width,
- int height,
- boolean reverseHorizontal) {
- super(width, height);
-
- if (left + width > dataWidth || top + height > dataHeight) {
- throw new IllegalArgumentException("Crop rectangle does not fit within image data.");
- }
-
- this.yuvData = yuvData;
- this.dataWidth = dataWidth;
- this.dataHeight = dataHeight;
- this.left = left;
- this.top = top;
- if (reverseHorizontal) {
- reverseHorizontal(width, height);
- }
- }
-
- @Override
- public byte[] getRow(int y, byte[] row) {
- if (y < 0 || y >= getHeight()) {
- throw new IllegalArgumentException("Requested row is outside the image: " + y);
- }
- int width = getWidth();
- if (row == null || row.length < width) {
- row = new byte[width];
- }
- int offset = (y + top) * dataWidth + left;
- System.arraycopy(yuvData, offset, row, 0, width);
- return row;
- }
-
- @Override
- public byte[] getMatrix() {
- int width = getWidth();
- int height = getHeight();
-
- // If the caller asks for the entire underlying image, save the copy and give them the
- // original data. The docs specifically warn that result.length must be ignored.
- if (width == dataWidth && height == dataHeight) {
- return yuvData;
- }
-
- int area = width * height;
- byte[] matrix = new byte[area];
- int inputOffset = top * dataWidth + left;
-
- // If the width matches the full width of the underlying data, perform a single copy.
- if (width == dataWidth) {
- System.arraycopy(yuvData, inputOffset, matrix, 0, area);
- return matrix;
- }
-
- // Otherwise copy one cropped row at a time.
- byte[] yuv = yuvData;
- for (int y = 0; y < height; y++) {
- int outputOffset = y * width;
- System.arraycopy(yuv, inputOffset, matrix, outputOffset, width);
- inputOffset += dataWidth;
- }
- return matrix;
- }
-
- @Override
- public boolean isCropSupported() {
- return true;
- }
-
- @Override
- public LuminanceSource crop(int left, int top, int width, int height) {
- return new PlanarYUVLuminanceSource(yuvData,
- dataWidth,
- dataHeight,
- this.left + left,
- this.top + top,
- width,
- height,
- false);
- }
-
- public int[] renderThumbnail() {
- int width = getWidth() / THUMBNAIL_SCALE_FACTOR;
- int height = getHeight() / THUMBNAIL_SCALE_FACTOR;
- int[] pixels = new int[width * height];
- byte[] yuv = yuvData;
- int inputOffset = top * dataWidth + left;
-
- for (int y = 0; y < height; y++) {
- int outputOffset = y * width;
- for (int x = 0; x < width; x++) {
- int grey = yuv[inputOffset + x * THUMBNAIL_SCALE_FACTOR] & 0xff;
- pixels[outputOffset + x] = 0xFF000000 | (grey * 0x00010101);
- }
- inputOffset += dataWidth * THUMBNAIL_SCALE_FACTOR;
- }
- return pixels;
- }
-
- /**
- * @return width of image from {@link #renderThumbnail()}
- */
- public int getThumbnailWidth() {
- return getWidth() / THUMBNAIL_SCALE_FACTOR;
- }
-
- /**
- * @return height of image from {@link #renderThumbnail()}
- */
- public int getThumbnailHeight() {
- return getHeight() / THUMBNAIL_SCALE_FACTOR;
- }
-
- private void reverseHorizontal(int width, int height) {
- byte[] yuvData = this.yuvData;
- for (int y = 0, rowStart = top * dataWidth + left; y < height; y++, rowStart += dataWidth) {
- int middle = rowStart + width / 2;
- for (int x1 = rowStart, x2 = rowStart + width - 1; x1 < middle; x1++, x2--) {
- byte temp = yuvData[x1];
- yuvData[x1] = yuvData[x2];
- yuvData[x2] = temp;
- }
- }
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/RGBLuminanceSource.java b/extern/zxing-core/src/main/java/com/google/zxing/RGBLuminanceSource.java
deleted file mode 100644
index 7c70b35ca..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/RGBLuminanceSource.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright 2009 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-/**
- * This class is used to help decode images from files which arrive as RGB data from
- * an ARGB pixel array. It does not support rotation.
- *
- * @author dswitkin@google.com (Daniel Switkin)
- * @author Betaminos
- */
-public final class RGBLuminanceSource extends LuminanceSource {
-
- private final byte[] luminances;
- private final int dataWidth;
- private final int dataHeight;
- private final int left;
- private final int top;
-
- public RGBLuminanceSource(int width, int height, int[] pixels) {
- super(width, height);
-
- dataWidth = width;
- dataHeight = height;
- left = 0;
- top = 0;
-
- // In order to measure pure decoding speed, we convert the entire image to a greyscale array
- // up front, which is the same as the Y channel of the YUVLuminanceSource in the real app.
- luminances = new byte[width * height];
- for (int y = 0; y < height; y++) {
- int offset = y * width;
- for (int x = 0; x < width; x++) {
- int pixel = pixels[offset + x];
- int r = (pixel >> 16) & 0xff;
- int g = (pixel >> 8) & 0xff;
- int b = pixel & 0xff;
- if (r == g && g == b) {
- // Image is already greyscale, so pick any channel.
- luminances[offset + x] = (byte) r;
- } else {
- // Calculate luminance cheaply, favoring green.
- luminances[offset + x] = (byte) ((r + 2 * g + b) / 4);
- }
- }
- }
- }
-
- private RGBLuminanceSource(byte[] pixels,
- int dataWidth,
- int dataHeight,
- int left,
- int top,
- int width,
- int height) {
- super(width, height);
- if (left + width > dataWidth || top + height > dataHeight) {
- throw new IllegalArgumentException("Crop rectangle does not fit within image data.");
- }
- this.luminances = pixels;
- this.dataWidth = dataWidth;
- this.dataHeight = dataHeight;
- this.left = left;
- this.top = top;
- }
-
- @Override
- public byte[] getRow(int y, byte[] row) {
- if (y < 0 || y >= getHeight()) {
- throw new IllegalArgumentException("Requested row is outside the image: " + y);
- }
- int width = getWidth();
- if (row == null || row.length < width) {
- row = new byte[width];
- }
- int offset = (y + top) * dataWidth + left;
- System.arraycopy(luminances, offset, row, 0, width);
- return row;
- }
-
- @Override
- public byte[] getMatrix() {
- int width = getWidth();
- int height = getHeight();
-
- // If the caller asks for the entire underlying image, save the copy and give them the
- // original data. The docs specifically warn that result.length must be ignored.
- if (width == dataWidth && height == dataHeight) {
- return luminances;
- }
-
- int area = width * height;
- byte[] matrix = new byte[area];
- int inputOffset = top * dataWidth + left;
-
- // If the width matches the full width of the underlying data, perform a single copy.
- if (width == dataWidth) {
- System.arraycopy(luminances, inputOffset, matrix, 0, area);
- return matrix;
- }
-
- // Otherwise copy one cropped row at a time.
- byte[] rgb = luminances;
- for (int y = 0; y < height; y++) {
- int outputOffset = y * width;
- System.arraycopy(rgb, inputOffset, matrix, outputOffset, width);
- inputOffset += dataWidth;
- }
- return matrix;
- }
-
- @Override
- public boolean isCropSupported() {
- return true;
- }
-
- @Override
- public LuminanceSource crop(int left, int top, int width, int height) {
- return new RGBLuminanceSource(luminances,
- dataWidth,
- dataHeight,
- this.left + left,
- this.top + top,
- width,
- height);
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/Reader.java b/extern/zxing-core/src/main/java/com/google/zxing/Reader.java
deleted file mode 100644
index bd3732e02..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/Reader.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-import java.util.Map;
-
-/**
- * Implementations of this interface can decode an image of a barcode in some format into
- * the String it encodes. For example, {@link com.google.zxing.qrcode.QRCodeReader} can
- * decode a QR code. The decoder may optionally receive hints from the caller which may help
- * it decode more quickly or accurately.
- *
- * See {@link com.google.zxing.MultiFormatReader}, which attempts to determine what barcode
- * format is present within the image as well, and then decodes it accordingly.
- *
- * @author Sean Owen
- * @author dswitkin@google.com (Daniel Switkin)
- */
-public interface Reader {
-
- /**
- * Locates and decodes a barcode in some format within an image.
- *
- * @param image image of barcode to decode
- * @return String which the barcode encodes
- * @throws NotFoundException if no potential barcode is found
- * @throws ChecksumException if a potential barcode is found but does not pass its checksum
- * @throws FormatException if a potential barcode is found but format is invalid
- */
- Result decode(BinaryBitmap image) throws NotFoundException, ChecksumException, FormatException;
-
- /**
- * Locates and decodes a barcode in some format within an image. This method also accepts
- * hints, each possibly associated to some data, which may help the implementation decode.
- *
- * @param image image of barcode to decode
- * @param hints passed as a {@link java.util.Map} from {@link com.google.zxing.DecodeHintType}
- * to arbitrary data. The
- * meaning of the data depends upon the hint type. The implementation may or may not do
- * anything with these hints.
- * @return String which the barcode encodes
- * @throws NotFoundException if no potential barcode is found
- * @throws ChecksumException if a potential barcode is found but does not pass its checksum
- * @throws FormatException if a potential barcode is found but format is invalid
- */
- Result decode(BinaryBitmap image, Map hints)
- throws NotFoundException, ChecksumException, FormatException;
-
- /**
- * Resets any internal state the implementation has after a decode, to prepare it
- * for reuse.
- */
- void reset();
-
-}
\ No newline at end of file
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/ReaderException.java b/extern/zxing-core/src/main/java/com/google/zxing/ReaderException.java
deleted file mode 100644
index 5f2c12e43..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/ReaderException.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-/**
- * The general exception class throw when something goes wrong during decoding of a barcode.
- * This includes, but is not limited to, failing checksums / error correction algorithms, being
- * unable to locate finder timing patterns, and so on.
- *
- * @author Sean Owen
- */
-public abstract class ReaderException extends Exception {
-
- // disable stack traces when not running inside test units
- protected static final boolean isStackTrace =
- System.getProperty("surefire.test.class.path") != null;
- protected static final StackTraceElement[] NO_TRACE = new StackTraceElement[0];
-
- ReaderException() {
- // do nothing
- }
-
- ReaderException(Throwable cause) {
- super(cause);
- }
-
- // Prevent stack traces from being taken
- // srowen says: huh, my IDE is saying this is not an override. native methods can't be overridden?
- // This, at least, does not hurt. Because we use a singleton pattern here, it doesn't matter anyhow.
- @Override
- public final Throwable fillInStackTrace() {
- return null;
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/Result.java b/extern/zxing-core/src/main/java/com/google/zxing/Result.java
deleted file mode 100644
index 7c98006de..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/Result.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-import java.util.EnumMap;
-import java.util.Map;
-
-/**
- * Encapsulates the result of decoding a barcode within an image.
- *
- * @author Sean Owen
- */
-public final class Result {
-
- private final String text;
- private final byte[] rawBytes;
- private ResultPoint[] resultPoints;
- private final BarcodeFormat format;
- private Map resultMetadata;
- private final long timestamp;
-
- public Result(String text,
- byte[] rawBytes,
- ResultPoint[] resultPoints,
- BarcodeFormat format) {
- this(text, rawBytes, resultPoints, format, System.currentTimeMillis());
- }
-
- public Result(String text,
- byte[] rawBytes,
- ResultPoint[] resultPoints,
- BarcodeFormat format,
- long timestamp) {
- this.text = text;
- this.rawBytes = rawBytes;
- this.resultPoints = resultPoints;
- this.format = format;
- this.resultMetadata = null;
- this.timestamp = timestamp;
- }
-
- /**
- * @return raw text encoded by the barcode
- */
- public String getText() {
- return text;
- }
-
- /**
- * @return raw bytes encoded by the barcode, if applicable, otherwise {@code null}
- */
- public byte[] getRawBytes() {
- return rawBytes;
- }
-
- /**
- * @return points related to the barcode in the image. These are typically points
- * identifying finder patterns or the corners of the barcode. The exact meaning is
- * specific to the type of barcode that was decoded.
- */
- public ResultPoint[] getResultPoints() {
- return resultPoints;
- }
-
- /**
- * @return {@link BarcodeFormat} representing the format of the barcode that was decoded
- */
- public BarcodeFormat getBarcodeFormat() {
- return format;
- }
-
- /**
- * @return {@link Map} mapping {@link ResultMetadataType} keys to values. May be
- * {@code null}. This contains optional metadata about what was detected about the barcode,
- * like orientation.
- */
- public Map getResultMetadata() {
- return resultMetadata;
- }
-
- public void putMetadata(ResultMetadataType type, Object value) {
- if (resultMetadata == null) {
- resultMetadata = new EnumMap<>(ResultMetadataType.class);
- }
- resultMetadata.put(type, value);
- }
-
- public void putAllMetadata(Map metadata) {
- if (metadata != null) {
- if (resultMetadata == null) {
- resultMetadata = metadata;
- } else {
- resultMetadata.putAll(metadata);
- }
- }
- }
-
- public void addResultPoints(ResultPoint[] newPoints) {
- ResultPoint[] oldPoints = resultPoints;
- if (oldPoints == null) {
- resultPoints = newPoints;
- } else if (newPoints != null && newPoints.length > 0) {
- ResultPoint[] allPoints = new ResultPoint[oldPoints.length + newPoints.length];
- System.arraycopy(oldPoints, 0, allPoints, 0, oldPoints.length);
- System.arraycopy(newPoints, 0, allPoints, oldPoints.length, newPoints.length);
- resultPoints = allPoints;
- }
- }
-
- public long getTimestamp() {
- return timestamp;
- }
-
- @Override
- public String toString() {
- return text;
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/ResultMetadataType.java b/extern/zxing-core/src/main/java/com/google/zxing/ResultMetadataType.java
deleted file mode 100644
index eac968b1e..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/ResultMetadataType.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-/**
- * Represents some type of metadata about the result of the decoding that the decoder
- * wishes to communicate back to the caller.
- *
- * @author Sean Owen
- */
-public enum ResultMetadataType {
-
- /**
- * Unspecified, application-specific metadata. Maps to an unspecified {@link Object}.
- */
- OTHER,
-
- /**
- * Denotes the likely approximate orientation of the barcode in the image. This value
- * is given as degrees rotated clockwise from the normal, upright orientation.
- * For example a 1D barcode which was found by reading top-to-bottom would be
- * said to have orientation "90". This key maps to an {@link Integer} whose
- * value is in the range [0,360).
- */
- ORIENTATION,
-
- /**
- * 2D barcode formats typically encode text, but allow for a sort of 'byte mode'
- * which is sometimes used to encode binary data. While {@link Result} makes available
- * the complete raw bytes in the barcode for these formats, it does not offer the bytes
- * from the byte segments alone.
- *
- * This maps to a {@link java.util.List} of byte arrays corresponding to the
- * raw bytes in the byte segments in the barcode, in order.
- */
- BYTE_SEGMENTS,
-
- /**
- * Error correction level used, if applicable. The value type depends on the
- * format, but is typically a String.
- */
- ERROR_CORRECTION_LEVEL,
-
- /**
- * For some periodicals, indicates the issue number as an {@link Integer}.
- */
- ISSUE_NUMBER,
-
- /**
- * For some products, indicates the suggested retail price in the barcode as a
- * formatted {@link String}.
- */
- SUGGESTED_PRICE ,
-
- /**
- * For some products, the possible country of manufacture as a {@link String} denoting the
- * ISO country code. Some map to multiple possible countries, like "US/CA".
- */
- POSSIBLE_COUNTRY,
-
- /**
- * For some products, the extension text
- */
- UPC_EAN_EXTENSION,
-
- /**
- * PDF417-specific metadata
- */
- PDF417_EXTRA_METADATA,
-
- /**
- * If the code format supports structured append and the current scanned code is part of one then the
- * sequence number is given with it.
- */
- STRUCTURED_APPEND_SEQUENCE,
-
- /**
- * If the code format supports structured append and the current scanned code is part of one then the
- * parity is given with it.
- */
- STRUCTURED_APPEND_PARITY,
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/ResultPoint.java b/extern/zxing-core/src/main/java/com/google/zxing/ResultPoint.java
deleted file mode 100644
index 920cd24c5..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/ResultPoint.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-import com.google.zxing.common.detector.MathUtils;
-
-/**
- * Encapsulates a point of interest in an image containing a barcode. Typically, this
- * would be the location of a finder pattern or the corner of the barcode, for example.
- *
- * @author Sean Owen
- */
-public class ResultPoint {
-
- private final float x;
- private final float y;
-
- public ResultPoint(float x, float y) {
- this.x = x;
- this.y = y;
- }
-
- public final float getX() {
- return x;
- }
-
- public final float getY() {
- return y;
- }
-
- @Override
- public final boolean equals(Object other) {
- if (other instanceof ResultPoint) {
- ResultPoint otherPoint = (ResultPoint) other;
- return x == otherPoint.x && y == otherPoint.y;
- }
- return false;
- }
-
- @Override
- public final int hashCode() {
- return 31 * Float.floatToIntBits(x) + Float.floatToIntBits(y);
- }
-
- @Override
- public final String toString() {
- StringBuilder result = new StringBuilder(25);
- result.append('(');
- result.append(x);
- result.append(',');
- result.append(y);
- result.append(')');
- return result.toString();
- }
-
- /**
- * Orders an array of three ResultPoints in an order [A,B,C] such that AB is less than AC
- * and BC is less than AC, and the angle between BC and BA is less than 180 degrees.
- *
- * @param patterns array of three {@code ResultPoint} to order
- */
- public static void orderBestPatterns(ResultPoint[] patterns) {
-
- // Find distances between pattern centers
- float zeroOneDistance = distance(patterns[0], patterns[1]);
- float oneTwoDistance = distance(patterns[1], patterns[2]);
- float zeroTwoDistance = distance(patterns[0], patterns[2]);
-
- ResultPoint pointA;
- ResultPoint pointB;
- ResultPoint pointC;
- // Assume one closest to other two is B; A and C will just be guesses at first
- if (oneTwoDistance >= zeroOneDistance && oneTwoDistance >= zeroTwoDistance) {
- pointB = patterns[0];
- pointA = patterns[1];
- pointC = patterns[2];
- } else if (zeroTwoDistance >= oneTwoDistance && zeroTwoDistance >= zeroOneDistance) {
- pointB = patterns[1];
- pointA = patterns[0];
- pointC = patterns[2];
- } else {
- pointB = patterns[2];
- pointA = patterns[0];
- pointC = patterns[1];
- }
-
- // Use cross product to figure out whether A and C are correct or flipped.
- // This asks whether BC x BA has a positive z component, which is the arrangement
- // we want for A, B, C. If it's negative, then we've got it flipped around and
- // should swap A and C.
- if (crossProductZ(pointA, pointB, pointC) < 0.0f) {
- ResultPoint temp = pointA;
- pointA = pointC;
- pointC = temp;
- }
-
- patterns[0] = pointA;
- patterns[1] = pointB;
- patterns[2] = pointC;
- }
-
-
- /**
- * @param pattern1 first pattern
- * @param pattern2 second pattern
- * @return distance between two points
- */
- public static float distance(ResultPoint pattern1, ResultPoint pattern2) {
- return MathUtils.distance(pattern1.x, pattern1.y, pattern2.x, pattern2.y);
- }
-
- /**
- * Returns the z component of the cross product between vectors BC and BA.
- */
- private static float crossProductZ(ResultPoint pointA,
- ResultPoint pointB,
- ResultPoint pointC) {
- float bX = pointB.x;
- float bY = pointB.y;
- return ((pointC.x - bX) * (pointA.y - bY)) - ((pointC.y - bY) * (pointA.x - bX));
- }
-
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/ResultPointCallback.java b/extern/zxing-core/src/main/java/com/google/zxing/ResultPointCallback.java
deleted file mode 100644
index 0c85410bc..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/ResultPointCallback.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright 2009 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-/**
- * Callback which is invoked when a possible result point (significant
- * point in the barcode image such as a corner) is found.
- *
- * @see DecodeHintType#NEED_RESULT_POINT_CALLBACK
- */
-public interface ResultPointCallback {
-
- void foundPossibleResultPoint(ResultPoint point);
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/Writer.java b/extern/zxing-core/src/main/java/com/google/zxing/Writer.java
deleted file mode 100644
index f405fd844..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/Writer.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-import com.google.zxing.common.BitMatrix;
-
-import java.util.Map;
-
-/**
- * The base class for all objects which encode/generate a barcode image.
- *
- * @author dswitkin@google.com (Daniel Switkin)
- */
-public interface Writer {
-
- /**
- * Encode a barcode using the default settings.
- *
- * @param contents The contents to encode in the barcode
- * @param format The barcode format to generate
- * @param width The preferred width in pixels
- * @param height The preferred height in pixels
- * @return {@link BitMatrix} representing encoded barcode image
- * @throws WriterException if contents cannot be encoded legally in a format
- */
- BitMatrix encode(String contents, BarcodeFormat format, int width, int height)
- throws WriterException;
-
- /**
- * @param contents The contents to encode in the barcode
- * @param format The barcode format to generate
- * @param width The preferred width in pixels
- * @param height The preferred height in pixels
- * @param hints Additional parameters to supply to the encoder
- * @return {@link BitMatrix} representing encoded barcode image
- * @throws WriterException if contents cannot be encoded legally in a format
- */
- BitMatrix encode(String contents,
- BarcodeFormat format,
- int width,
- int height,
- Map hints)
- throws WriterException;
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/WriterException.java b/extern/zxing-core/src/main/java/com/google/zxing/WriterException.java
deleted file mode 100644
index c61800b93..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/WriterException.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed 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 com.google.zxing;
-
-/**
- * A base class which covers the range of exceptions which may occur when encoding a barcode using
- * the Writer framework.
- *
- * @author dswitkin@google.com (Daniel Switkin)
- */
-public final class WriterException extends Exception {
-
- public WriterException() {
- }
-
- public WriterException(String message) {
- super(message);
- }
-
- public WriterException(Throwable cause) {
- super(cause);
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/aztec/AztecDetectorResult.java b/extern/zxing-core/src/main/java/com/google/zxing/aztec/AztecDetectorResult.java
deleted file mode 100644
index f262e0e6d..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/aztec/AztecDetectorResult.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2010 ZXing authors
- *
- * Licensed 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 com.google.zxing.aztec;
-
-import com.google.zxing.ResultPoint;
-import com.google.zxing.common.BitMatrix;
-import com.google.zxing.common.DetectorResult;
-
-public final class AztecDetectorResult extends DetectorResult {
-
- private final boolean compact;
- private final int nbDatablocks;
- private final int nbLayers;
-
- public AztecDetectorResult(BitMatrix bits,
- ResultPoint[] points,
- boolean compact,
- int nbDatablocks,
- int nbLayers) {
- super(bits, points);
- this.compact = compact;
- this.nbDatablocks = nbDatablocks;
- this.nbLayers = nbLayers;
- }
-
- public int getNbLayers() {
- return nbLayers;
- }
-
- public int getNbDatablocks() {
- return nbDatablocks;
- }
-
- public boolean isCompact() {
- return compact;
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/aztec/AztecReader.java b/extern/zxing-core/src/main/java/com/google/zxing/aztec/AztecReader.java
deleted file mode 100644
index d56e3f6c6..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/aztec/AztecReader.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright 2010 ZXing authors
- *
- * Licensed 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 com.google.zxing.aztec;
-
-import com.google.zxing.BarcodeFormat;
-import com.google.zxing.BinaryBitmap;
-import com.google.zxing.DecodeHintType;
-import com.google.zxing.FormatException;
-import com.google.zxing.NotFoundException;
-import com.google.zxing.Reader;
-import com.google.zxing.Result;
-import com.google.zxing.ResultMetadataType;
-import com.google.zxing.ResultPoint;
-import com.google.zxing.ResultPointCallback;
-import com.google.zxing.aztec.decoder.Decoder;
-import com.google.zxing.aztec.detector.Detector;
-import com.google.zxing.common.DecoderResult;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * This implementation can detect and decode Aztec codes in an image.
- *
- * @author David Olivier
- */
-public final class AztecReader implements Reader {
-
- /**
- * Locates and decodes a Data Matrix code in an image.
- *
- * @return a String representing the content encoded by the Data Matrix code
- * @throws NotFoundException if a Data Matrix code cannot be found
- * @throws FormatException if a Data Matrix code cannot be decoded
- */
- @Override
- public Result decode(BinaryBitmap image) throws NotFoundException, FormatException {
- return decode(image, null);
- }
-
- @Override
- public Result decode(BinaryBitmap image, Map hints)
- throws NotFoundException, FormatException {
-
- NotFoundException notFoundException = null;
- FormatException formatException = null;
- Detector detector = new Detector(image.getBlackMatrix());
- ResultPoint[] points = null;
- DecoderResult decoderResult = null;
- try {
- AztecDetectorResult detectorResult = detector.detect(false);
- points = detectorResult.getPoints();
- decoderResult = new Decoder().decode(detectorResult);
- } catch (NotFoundException e) {
- notFoundException = e;
- } catch (FormatException e) {
- formatException = e;
- }
- if (decoderResult == null) {
- try {
- AztecDetectorResult detectorResult = detector.detect(true);
- points = detectorResult.getPoints();
- decoderResult = new Decoder().decode(detectorResult);
- } catch (NotFoundException | FormatException e) {
- if (notFoundException != null) {
- throw notFoundException;
- }
- if (formatException != null) {
- throw formatException;
- }
- throw e;
- }
- }
-
- if (hints != null) {
- ResultPointCallback rpcb = (ResultPointCallback) hints.get(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
- if (rpcb != null) {
- for (ResultPoint point : points) {
- rpcb.foundPossibleResultPoint(point);
- }
- }
- }
-
- Result result = new Result(decoderResult.getText(), decoderResult.getRawBytes(), points, BarcodeFormat.AZTEC);
-
- List byteSegments = decoderResult.getByteSegments();
- if (byteSegments != null) {
- result.putMetadata(ResultMetadataType.BYTE_SEGMENTS, byteSegments);
- }
- String ecLevel = decoderResult.getECLevel();
- if (ecLevel != null) {
- result.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, ecLevel);
- }
-
- return result;
- }
-
- @Override
- public void reset() {
- // do nothing
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/aztec/AztecWriter.java b/extern/zxing-core/src/main/java/com/google/zxing/aztec/AztecWriter.java
deleted file mode 100644
index afa73ef83..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/aztec/AztecWriter.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2013 ZXing authors
- *
- * Licensed 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 com.google.zxing.aztec;
-
-import com.google.zxing.BarcodeFormat;
-import com.google.zxing.EncodeHintType;
-import com.google.zxing.Writer;
-import com.google.zxing.aztec.encoder.AztecCode;
-import com.google.zxing.aztec.encoder.Encoder;
-import com.google.zxing.common.BitMatrix;
-
-import java.nio.charset.Charset;
-import java.util.Map;
-
-public final class AztecWriter implements Writer {
-
- private static final Charset DEFAULT_CHARSET = Charset.forName("ISO-8859-1");
-
- @Override
- public BitMatrix encode(String contents, BarcodeFormat format, int width, int height) {
- return encode(contents, format, width, height, null);
- }
-
- @Override
- public BitMatrix encode(String contents, BarcodeFormat format, int width, int height, Map hints) {
- String charset = hints == null ? null : (String) hints.get(EncodeHintType.CHARACTER_SET);
- Number eccPercent = hints == null ? null : (Number) hints.get(EncodeHintType.ERROR_CORRECTION);
- Number layers = hints == null ? null : (Number) hints.get(EncodeHintType.AZTEC_LAYERS);
- return encode(contents,
- format,
- width,
- height,
- charset == null ? DEFAULT_CHARSET : Charset.forName(charset),
- eccPercent == null ? Encoder.DEFAULT_EC_PERCENT : eccPercent.intValue(),
- layers == null ? Encoder.DEFAULT_AZTEC_LAYERS : layers.intValue());
- }
-
- private static BitMatrix encode(String contents, BarcodeFormat format,
- int width, int height,
- Charset charset, int eccPercent, int layers) {
- if (format != BarcodeFormat.AZTEC) {
- throw new IllegalArgumentException("Can only encode AZTEC, but got " + format);
- }
- AztecCode aztec = Encoder.encode(contents.getBytes(charset), eccPercent, layers);
- return renderResult(aztec, width, height);
- }
-
- private static BitMatrix renderResult(AztecCode code, int width, int height) {
- BitMatrix input = code.getMatrix();
- if (input == null) {
- throw new IllegalStateException();
- }
- int inputWidth = input.getWidth();
- int inputHeight = input.getHeight();
- int outputWidth = Math.max(width, inputWidth);
- int outputHeight = Math.max(height, inputHeight);
-
- int multiple = Math.min(outputWidth / inputWidth, outputHeight / inputHeight);
- int leftPadding = (outputWidth - (inputWidth * multiple)) / 2;
- int topPadding = (outputHeight - (inputHeight * multiple)) / 2;
-
- BitMatrix output = new BitMatrix(outputWidth, outputHeight);
-
- for (int inputY = 0, outputY = topPadding; inputY < inputHeight; inputY++, outputY += multiple) {
- // Write the contents of this row of the barcode
- for (int inputX = 0, outputX = leftPadding; inputX < inputWidth; inputX++, outputX += multiple) {
- if (input.get(inputX, inputY)) {
- output.setRegion(outputX, outputY, multiple, multiple);
- }
- }
- }
- return output;
- }
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/aztec/decoder/Decoder.java b/extern/zxing-core/src/main/java/com/google/zxing/aztec/decoder/Decoder.java
deleted file mode 100644
index d0304a9a1..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/aztec/decoder/Decoder.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * Copyright 2010 ZXing authors
- *
- * Licensed 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 com.google.zxing.aztec.decoder;
-
-import com.google.zxing.FormatException;
-import com.google.zxing.aztec.AztecDetectorResult;
-import com.google.zxing.common.BitMatrix;
-import com.google.zxing.common.DecoderResult;
-import com.google.zxing.common.reedsolomon.GenericGF;
-import com.google.zxing.common.reedsolomon.ReedSolomonDecoder;
-import com.google.zxing.common.reedsolomon.ReedSolomonException;
-
-import java.util.Arrays;
-
-/**
- * The main class which implements Aztec Code decoding -- as opposed to locating and extracting
- * the Aztec Code from an image.
- *
- * @author David Olivier
- */
-public final class Decoder {
-
- private enum Table {
- UPPER,
- LOWER,
- MIXED,
- DIGIT,
- PUNCT,
- BINARY
- }
-
- private static final String[] UPPER_TABLE = {
- "CTRL_PS", " ", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P",
- "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "CTRL_LL", "CTRL_ML", "CTRL_DL", "CTRL_BS"
- };
-
- private static final String[] LOWER_TABLE = {
- "CTRL_PS", " ", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p",
- "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "CTRL_US", "CTRL_ML", "CTRL_DL", "CTRL_BS"
- };
-
- private static final String[] MIXED_TABLE = {
- "CTRL_PS", " ", "\1", "\2", "\3", "\4", "\5", "\6", "\7", "\b", "\t", "\n",
- "\13", "\f", "\r", "\33", "\34", "\35", "\36", "\37", "@", "\\", "^", "_",
- "`", "|", "~", "\177", "CTRL_LL", "CTRL_UL", "CTRL_PL", "CTRL_BS"
- };
-
- private static final String[] PUNCT_TABLE = {
- "", "\r", "\r\n", ". ", ", ", ": ", "!", "\"", "#", "$", "%", "&", "'", "(", ")",
- "*", "+", ",", "-", ".", "/", ":", ";", "<", "=", ">", "?", "[", "]", "{", "}", "CTRL_UL"
- };
-
- private static final String[] DIGIT_TABLE = {
- "CTRL_PS", " ", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", ",", ".", "CTRL_UL", "CTRL_US"
- };
-
- private AztecDetectorResult ddata;
-
- public DecoderResult decode(AztecDetectorResult detectorResult) throws FormatException {
- ddata = detectorResult;
- BitMatrix matrix = detectorResult.getBits();
- boolean[] rawbits = extractBits(matrix);
- boolean[] correctedBits = correctBits(rawbits);
- String result = getEncodedData(correctedBits);
- return new DecoderResult(null, result, null, null);
- }
-
- // This method is used for testing the high-level encoder
- public static String highLevelDecode(boolean[] correctedBits) {
- return getEncodedData(correctedBits);
- }
-
- /**
- * Gets the string encoded in the aztec code bits
- *
- * @return the decoded string
- */
- private static String getEncodedData(boolean[] correctedBits) {
- int endIndex = correctedBits.length;
- Table latchTable = Table.UPPER; // table most recently latched to
- Table shiftTable = Table.UPPER; // table to use for the next read
- StringBuilder result = new StringBuilder(20);
- int index = 0;
- while (index < endIndex) {
- if (shiftTable == Table.BINARY) {
- if (endIndex - index < 5) {
- break;
- }
- int length = readCode(correctedBits, index, 5);
- index += 5;
- if (length == 0) {
- if (endIndex - index < 11) {
- break;
- }
- length = readCode(correctedBits, index, 11) + 31;
- index += 11;
- }
- for (int charCount = 0; charCount < length; charCount++) {
- if (endIndex - index < 8) {
- index = endIndex; // Force outer loop to exit
- break;
- }
- int code = readCode(correctedBits, index, 8);
- result.append((char) code);
- index += 8;
- }
- // Go back to whatever mode we had been in
- shiftTable = latchTable;
- } else {
- int size = shiftTable == Table.DIGIT ? 4 : 5;
- if (endIndex - index < size) {
- break;
- }
- int code = readCode(correctedBits, index, size);
- index += size;
- String str = getCharacter(shiftTable, code);
- if (str.startsWith("CTRL_")) {
- // Table changes
- shiftTable = getTable(str.charAt(5));
- if (str.charAt(6) == 'L') {
- latchTable = shiftTable;
- }
- } else {
- result.append(str);
- // Go back to whatever mode we had been in
- shiftTable = latchTable;
- }
- }
- }
- return result.toString();
- }
-
- /**
- * gets the table corresponding to the char passed
- */
- private static Table getTable(char t) {
- switch (t) {
- case 'L':
- return Table.LOWER;
- case 'P':
- return Table.PUNCT;
- case 'M':
- return Table.MIXED;
- case 'D':
- return Table.DIGIT;
- case 'B':
- return Table.BINARY;
- case 'U':
- default:
- return Table.UPPER;
- }
- }
-
- /**
- * Gets the character (or string) corresponding to the passed code in the given table
- *
- * @param table the table used
- * @param code the code of the character
- */
- private static String getCharacter(Table table, int code) {
- switch (table) {
- case UPPER:
- return UPPER_TABLE[code];
- case LOWER:
- return LOWER_TABLE[code];
- case MIXED:
- return MIXED_TABLE[code];
- case PUNCT:
- return PUNCT_TABLE[code];
- case DIGIT:
- return DIGIT_TABLE[code];
- default:
- // Should not reach here.
- throw new IllegalStateException("Bad table");
- }
- }
-
- /**
- * Performs RS error correction on an array of bits.
- *
- * @return the corrected array
- * @throws FormatException if the input contains too many errors
- */
- private boolean[] correctBits(boolean[] rawbits) throws FormatException {
- GenericGF gf;
- int codewordSize;
-
- if (ddata.getNbLayers() <= 2) {
- codewordSize = 6;
- gf = GenericGF.AZTEC_DATA_6;
- } else if (ddata.getNbLayers() <= 8) {
- codewordSize = 8;
- gf = GenericGF.AZTEC_DATA_8;
- } else if (ddata.getNbLayers() <= 22) {
- codewordSize = 10;
- gf = GenericGF.AZTEC_DATA_10;
- } else {
- codewordSize = 12;
- gf = GenericGF.AZTEC_DATA_12;
- }
-
- int numDataCodewords = ddata.getNbDatablocks();
- int numCodewords = rawbits.length / codewordSize;
- if (numCodewords < numDataCodewords) {
- throw FormatException.getFormatInstance();
- }
- int offset = rawbits.length % codewordSize;
- int numECCodewords = numCodewords - numDataCodewords;
-
- int[] dataWords = new int[numCodewords];
- for (int i = 0; i < numCodewords; i++, offset += codewordSize) {
- dataWords[i] = readCode(rawbits, offset, codewordSize);
- }
-
- try {
- ReedSolomonDecoder rsDecoder = new ReedSolomonDecoder(gf);
- rsDecoder.decode(dataWords, numECCodewords);
- } catch (ReedSolomonException ex) {
- throw FormatException.getFormatInstance(ex);
- }
-
- // Now perform the unstuffing operation.
- // First, count how many bits are going to be thrown out as stuffing
- int mask = (1 << codewordSize) - 1;
- int stuffedBits = 0;
- for (int i = 0; i < numDataCodewords; i++) {
- int dataWord = dataWords[i];
- if (dataWord == 0 || dataWord == mask) {
- throw FormatException.getFormatInstance();
- } else if (dataWord == 1 || dataWord == mask - 1) {
- stuffedBits++;
- }
- }
- // Now, actually unpack the bits and remove the stuffing
- boolean[] correctedBits = new boolean[numDataCodewords * codewordSize - stuffedBits];
- int index = 0;
- for (int i = 0; i < numDataCodewords; i++) {
- int dataWord = dataWords[i];
- if (dataWord == 1 || dataWord == mask - 1) {
- // next codewordSize-1 bits are all zeros or all ones
- Arrays.fill(correctedBits, index, index + codewordSize - 1, dataWord > 1);
- index += codewordSize - 1;
- } else {
- for (int bit = codewordSize - 1; bit >= 0; --bit) {
- correctedBits[index++] = (dataWord & (1 << bit)) != 0;
- }
- }
- }
- return correctedBits;
- }
-
- /**
- * Gets the array of bits from an Aztec Code matrix
- *
- * @return the array of bits
- */
- boolean[] extractBits(BitMatrix matrix) {
- boolean compact = ddata.isCompact();
- int layers = ddata.getNbLayers();
- int baseMatrixSize = compact ? 11 + layers * 4 : 14 + layers * 4; // not including alignment lines
- int[] alignmentMap = new int[baseMatrixSize];
- boolean[] rawbits = new boolean[totalBitsInLayer(layers, compact)];
-
- if (compact) {
- for (int i = 0; i < alignmentMap.length; i++) {
- alignmentMap[i] = i;
- }
- } else {
- int matrixSize = baseMatrixSize + 1 + 2 * ((baseMatrixSize / 2 - 1) / 15);
- int origCenter = baseMatrixSize / 2;
- int center = matrixSize / 2;
- for (int i = 0; i < origCenter; i++) {
- int newOffset = i + i / 15;
- alignmentMap[origCenter - i - 1] = center - newOffset - 1;
- alignmentMap[origCenter + i] = center + newOffset + 1;
- }
- }
- for (int i = 0, rowOffset = 0; i < layers; i++) {
- int rowSize = compact ? (layers - i) * 4 + 9 : (layers - i) * 4 + 12;
- // The top-left most point of this layer is (not including alignment lines)
- int low = i * 2;
- // The bottom-right most point of this layer is (not including alignment lines)
- int high = baseMatrixSize - 1 - low;
- // We pull bits from the two 2 x rowSize columns and two rowSize x 2 rows
- for (int j = 0; j < rowSize; j++) {
- int columnOffset = j * 2;
- for (int k = 0; k < 2; k++) {
- // left column
- rawbits[rowOffset + columnOffset + k] =
- matrix.get(alignmentMap[low + k], alignmentMap[low + j]);
- // bottom row
- rawbits[rowOffset + 2 * rowSize + columnOffset + k] =
- matrix.get(alignmentMap[low + j], alignmentMap[high - k]);
- // right column
- rawbits[rowOffset + 4 * rowSize + columnOffset + k] =
- matrix.get(alignmentMap[high - k], alignmentMap[high - j]);
- // top row
- rawbits[rowOffset + 6 * rowSize + columnOffset + k] =
- matrix.get(alignmentMap[high - j], alignmentMap[low + k]);
- }
- }
- rowOffset += rowSize * 8;
- }
- return rawbits;
- }
-
- /**
- * Reads a code of given length and at given index in an array of bits
- */
- private static int readCode(boolean[] rawbits, int startIndex, int length) {
- int res = 0;
- for (int i = startIndex; i < startIndex + length; i++) {
- res <<= 1;
- if (rawbits[i]) {
- res |= 0x01;
- }
- }
- return res;
- }
-
- private static int totalBitsInLayer(int layers, boolean compact) {
- return ((compact ? 88 : 112) + 16 * layers) * layers;
- }
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/aztec/detector/Detector.java b/extern/zxing-core/src/main/java/com/google/zxing/aztec/detector/Detector.java
deleted file mode 100644
index 5cc5c3669..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/aztec/detector/Detector.java
+++ /dev/null
@@ -1,600 +0,0 @@
-/*
- * Copyright 2010 ZXing authors
- *
- * Licensed 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 com.google.zxing.aztec.detector;
-
-import com.google.zxing.NotFoundException;
-import com.google.zxing.ResultPoint;
-import com.google.zxing.aztec.AztecDetectorResult;
-import com.google.zxing.common.BitMatrix;
-import com.google.zxing.common.GridSampler;
-import com.google.zxing.common.detector.MathUtils;
-import com.google.zxing.common.detector.WhiteRectangleDetector;
-import com.google.zxing.common.reedsolomon.GenericGF;
-import com.google.zxing.common.reedsolomon.ReedSolomonDecoder;
-import com.google.zxing.common.reedsolomon.ReedSolomonException;
-
-/**
- * Encapsulates logic that can detect an Aztec Code in an image, even if the Aztec Code
- * is rotated or skewed, or partially obscured.
- *
- * @author David Olivier
- * @author Frank Yellin
- */
-public final class Detector {
-
- private final BitMatrix image;
-
- private boolean compact;
- private int nbLayers;
- private int nbDataBlocks;
- private int nbCenterLayers;
- private int shift;
-
- public Detector(BitMatrix image) {
- this.image = image;
- }
-
- public AztecDetectorResult detect() throws NotFoundException {
- return detect(false);
- }
-
- /**
- * Detects an Aztec Code in an image.
- *
- * @param isMirror if true, image is a mirror-image of original
- * @return {@link AztecDetectorResult} encapsulating results of detecting an Aztec Code
- * @throws NotFoundException if no Aztec Code can be found
- */
- public AztecDetectorResult detect(boolean isMirror) throws NotFoundException {
-
- // 1. Get the center of the aztec matrix
- Point pCenter = getMatrixCenter();
-
- // 2. Get the center points of the four diagonal points just outside the bull's eye
- // [topRight, bottomRight, bottomLeft, topLeft]
- ResultPoint[] bullsEyeCorners = getBullsEyeCorners(pCenter);
-
- if (isMirror) {
- ResultPoint temp = bullsEyeCorners[0];
- bullsEyeCorners[0] = bullsEyeCorners[2];
- bullsEyeCorners[2] = temp;
- }
-
- // 3. Get the size of the matrix and other parameters from the bull's eye
- extractParameters(bullsEyeCorners);
-
- // 4. Sample the grid
- BitMatrix bits = sampleGrid(image,
- bullsEyeCorners[shift % 4],
- bullsEyeCorners[(shift + 1) % 4],
- bullsEyeCorners[(shift + 2) % 4],
- bullsEyeCorners[(shift + 3) % 4]);
-
- // 5. Get the corners of the matrix.
- ResultPoint[] corners = getMatrixCornerPoints(bullsEyeCorners);
-
- return new AztecDetectorResult(bits, corners, compact, nbDataBlocks, nbLayers);
- }
-
- /**
- * Extracts the number of data layers and data blocks from the layer around the bull's eye.
- *
- * @param bullsEyeCorners the array of bull's eye corners
- * @throws NotFoundException in case of too many errors or invalid parameters
- */
- private void extractParameters(ResultPoint[] bullsEyeCorners) throws NotFoundException {
- if (!isValid(bullsEyeCorners[0]) || !isValid(bullsEyeCorners[1]) ||
- !isValid(bullsEyeCorners[2]) || !isValid(bullsEyeCorners[3])) {
- throw NotFoundException.getNotFoundInstance();
- }
- int length = 2 * nbCenterLayers;
- // Get the bits around the bull's eye
- int[] sides = {
- sampleLine(bullsEyeCorners[0], bullsEyeCorners[1], length), // Right side
- sampleLine(bullsEyeCorners[1], bullsEyeCorners[2], length), // Bottom
- sampleLine(bullsEyeCorners[2], bullsEyeCorners[3], length), // Left side
- sampleLine(bullsEyeCorners[3], bullsEyeCorners[0], length) // Top
- };
-
- // bullsEyeCorners[shift] is the corner of the bulls'eye that has three
- // orientation marks.
- // sides[shift] is the row/column that goes from the corner with three
- // orientation marks to the corner with two.
- shift = getRotation(sides, length);
-
- // Flatten the parameter bits into a single 28- or 40-bit long
- long parameterData = 0;
- for (int i = 0; i < 4; i++) {
- int side = sides[(shift + i) % 4];
- if (compact) {
- // Each side of the form ..XXXXXXX. where Xs are parameter data
- parameterData <<= 7;
- parameterData += (side >> 1) & 0x7F;
- } else {
- // Each side of the form ..XXXXX.XXXXX. where Xs are parameter data
- parameterData <<= 10;
- parameterData += ((side >> 2) & (0x1f << 5)) + ((side >> 1) & 0x1F);
- }
- }
-
- // Corrects parameter data using RS. Returns just the data portion
- // without the error correction.
- int correctedData = getCorrectedParameterData(parameterData, compact);
-
- if (compact) {
- // 8 bits: 2 bits layers and 6 bits data blocks
- nbLayers = (correctedData >> 6) + 1;
- nbDataBlocks = (correctedData & 0x3F) + 1;
- } else {
- // 16 bits: 5 bits layers and 11 bits data blocks
- nbLayers = (correctedData >> 11) + 1;
- nbDataBlocks = (correctedData & 0x7FF) + 1;
- }
- }
-
- private static final int[] EXPECTED_CORNER_BITS = {
- 0xee0, // 07340 XXX .XX X.. ...
- 0x1dc, // 00734 ... XXX .XX X..
- 0x83b, // 04073 X.. ... XXX .XX
- 0x707, // 03407 .XX X.. ... XXX
- };
-
- private static int getRotation(int[] sides, int length) throws NotFoundException {
- // In a normal pattern, we expect to See
- // ** .* D A
- // * *
- //
- // . *
- // .. .. C B
- //
- // Grab the 3 bits from each of the sides the form the locator pattern and concatenate
- // into a 12-bit integer. Start with the bit at A
- int cornerBits = 0;
- for (int side : sides) {
- // XX......X where X's are orientation marks
- int t = ((side >> (length - 2)) << 1) + (side & 1);
- cornerBits = (cornerBits << 3) + t;
- }
- // Mov the bottom bit to the top, so that the three bits of the locator pattern at A are
- // together. cornerBits is now:
- // 3 orientation bits at A || 3 orientation bits at B || ... || 3 orientation bits at D
- cornerBits = ((cornerBits & 1) << 11) + (cornerBits >> 1);
- // The result shift indicates which element of BullsEyeCorners[] goes into the top-left
- // corner. Since the four rotation values have a Hamming distance of 8, we
- // can easily tolerate two errors.
- for (int shift = 0; shift < 4; shift++) {
- if (Integer.bitCount(cornerBits ^ EXPECTED_CORNER_BITS[shift]) <= 2) {
- return shift;
- }
- }
- throw NotFoundException.getNotFoundInstance();
- }
-
- /**
- * Corrects the parameter bits using Reed-Solomon algorithm.
- *
- * @param parameterData parameter bits
- * @param compact true if this is a compact Aztec code
- * @throws NotFoundException if the array contains too many errors
- */
- private static int getCorrectedParameterData(long parameterData, boolean compact) throws NotFoundException {
- int numCodewords;
- int numDataCodewords;
-
- if (compact) {
- numCodewords = 7;
- numDataCodewords = 2;
- } else {
- numCodewords = 10;
- numDataCodewords = 4;
- }
-
- int numECCodewords = numCodewords - numDataCodewords;
- int[] parameterWords = new int[numCodewords];
- for (int i = numCodewords - 1; i >= 0; --i) {
- parameterWords[i] = (int) parameterData & 0xF;
- parameterData >>= 4;
- }
- try {
- ReedSolomonDecoder rsDecoder = new ReedSolomonDecoder(GenericGF.AZTEC_PARAM);
- rsDecoder.decode(parameterWords, numECCodewords);
- } catch (ReedSolomonException ignored) {
- throw NotFoundException.getNotFoundInstance();
- }
- // Toss the error correction. Just return the data as an integer
- int result = 0;
- for (int i = 0; i < numDataCodewords; i++) {
- result = (result << 4) + parameterWords[i];
- }
- return result;
- }
-
- /**
- * Finds the corners of a bull-eye centered on the passed point.
- * This returns the centers of the diagonal points just outside the bull's eye
- * Returns [topRight, bottomRight, bottomLeft, topLeft]
- *
- * @param pCenter Center point
- * @return The corners of the bull-eye
- * @throws NotFoundException If no valid bull-eye can be found
- */
- private ResultPoint[] getBullsEyeCorners(Point pCenter) throws NotFoundException {
-
- Point pina = pCenter;
- Point pinb = pCenter;
- Point pinc = pCenter;
- Point pind = pCenter;
-
- boolean color = true;
-
- for (nbCenterLayers = 1; nbCenterLayers < 9; nbCenterLayers++) {
- Point pouta = getFirstDifferent(pina, color, 1, -1);
- Point poutb = getFirstDifferent(pinb, color, 1, 1);
- Point poutc = getFirstDifferent(pinc, color, -1, 1);
- Point poutd = getFirstDifferent(pind, color, -1, -1);
-
- //d a
- //
- //c b
-
- if (nbCenterLayers > 2) {
- float q = distance(poutd, pouta) * nbCenterLayers / (distance(pind, pina) * (nbCenterLayers + 2));
- if (q < 0.75 || q > 1.25 || !isWhiteOrBlackRectangle(pouta, poutb, poutc, poutd)) {
- break;
- }
- }
-
- pina = pouta;
- pinb = poutb;
- pinc = poutc;
- pind = poutd;
-
- color = !color;
- }
-
- if (nbCenterLayers != 5 && nbCenterLayers != 7) {
- throw NotFoundException.getNotFoundInstance();
- }
-
- compact = nbCenterLayers == 5;
-
- // Expand the square by .5 pixel in each direction so that we're on the border
- // between the white square and the black square
- ResultPoint pinax = new ResultPoint(pina.getX() + 0.5f, pina.getY() - 0.5f);
- ResultPoint pinbx = new ResultPoint(pinb.getX() + 0.5f, pinb.getY() + 0.5f);
- ResultPoint pincx = new ResultPoint(pinc.getX() - 0.5f, pinc.getY() + 0.5f);
- ResultPoint pindx = new ResultPoint(pind.getX() - 0.5f, pind.getY() - 0.5f);
-
- // Expand the square so that its corners are the centers of the points
- // just outside the bull's eye.
- return expandSquare(new ResultPoint[]{pinax, pinbx, pincx, pindx},
- 2 * nbCenterLayers - 3,
- 2 * nbCenterLayers);
- }
-
- /**
- * Finds a candidate center point of an Aztec code from an image
- *
- * @return the center point
- */
- private Point getMatrixCenter() {
-
- ResultPoint pointA;
- ResultPoint pointB;
- ResultPoint pointC;
- ResultPoint pointD;
-
- //Get a white rectangle that can be the border of the matrix in center bull's eye or
- try {
-
- ResultPoint[] cornerPoints = new WhiteRectangleDetector(image).detect();
- pointA = cornerPoints[0];
- pointB = cornerPoints[1];
- pointC = cornerPoints[2];
- pointD = cornerPoints[3];
-
- } catch (NotFoundException e) {
-
- // This exception can be in case the initial rectangle is white
- // In that case, surely in the bull's eye, we try to expand the rectangle.
- int cx = image.getWidth() / 2;
- int cy = image.getHeight() / 2;
- pointA = getFirstDifferent(new Point(cx + 7, cy - 7), false, 1, -1).toResultPoint();
- pointB = getFirstDifferent(new Point(cx + 7, cy + 7), false, 1, 1).toResultPoint();
- pointC = getFirstDifferent(new Point(cx - 7, cy + 7), false, -1, 1).toResultPoint();
- pointD = getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toResultPoint();
-
- }
-
- //Compute the center of the rectangle
- int cx = MathUtils.round((pointA.getX() + pointD.getX() + pointB.getX() + pointC.getX()) / 4.0f);
- int cy = MathUtils.round((pointA.getY() + pointD.getY() + pointB.getY() + pointC.getY()) / 4.0f);
-
- // Redetermine the white rectangle starting from previously computed center.
- // This will ensure that we end up with a white rectangle in center bull's eye
- // in order to compute a more accurate center.
- try {
- ResultPoint[] cornerPoints = new WhiteRectangleDetector(image, 15, cx, cy).detect();
- pointA = cornerPoints[0];
- pointB = cornerPoints[1];
- pointC = cornerPoints[2];
- pointD = cornerPoints[3];
- } catch (NotFoundException e) {
- // This exception can be in case the initial rectangle is white
- // In that case we try to expand the rectangle.
- pointA = getFirstDifferent(new Point(cx + 7, cy - 7), false, 1, -1).toResultPoint();
- pointB = getFirstDifferent(new Point(cx + 7, cy + 7), false, 1, 1).toResultPoint();
- pointC = getFirstDifferent(new Point(cx - 7, cy + 7), false, -1, 1).toResultPoint();
- pointD = getFirstDifferent(new Point(cx - 7, cy - 7), false, -1, -1).toResultPoint();
- }
-
- // Recompute the center of the rectangle
- cx = MathUtils.round((pointA.getX() + pointD.getX() + pointB.getX() + pointC.getX()) / 4.0f);
- cy = MathUtils.round((pointA.getY() + pointD.getY() + pointB.getY() + pointC.getY()) / 4.0f);
-
- return new Point(cx, cy);
- }
-
- /**
- * Gets the Aztec code corners from the bull's eye corners and the parameters.
- *
- * @param bullsEyeCorners the array of bull's eye corners
- * @return the array of aztec code corners
- */
- private ResultPoint[] getMatrixCornerPoints(ResultPoint[] bullsEyeCorners) {
- return expandSquare(bullsEyeCorners, 2 * nbCenterLayers, getDimension());
- }
-
- /**
- * Creates a BitMatrix by sampling the provided image.
- * topLeft, topRight, bottomRight, and bottomLeft are the centers of the squares on the
- * diagonal just outside the bull's eye.
- */
- private BitMatrix sampleGrid(BitMatrix image,
- ResultPoint topLeft,
- ResultPoint topRight,
- ResultPoint bottomRight,
- ResultPoint bottomLeft) throws NotFoundException {
-
- GridSampler sampler = GridSampler.getInstance();
- int dimension = getDimension();
-
- float low = dimension / 2.0f - nbCenterLayers;
- float high = dimension / 2.0f + nbCenterLayers;
-
- return sampler.sampleGrid(image,
- dimension,
- dimension,
- low, low, // topleft
- high, low, // topright
- high, high, // bottomright
- low, high, // bottomleft
- topLeft.getX(), topLeft.getY(),
- topRight.getX(), topRight.getY(),
- bottomRight.getX(), bottomRight.getY(),
- bottomLeft.getX(), bottomLeft.getY());
- }
-
- /**
- * Samples a line.
- *
- * @param p1 start point (inclusive)
- * @param p2 end point (exclusive)
- * @param size number of bits
- * @return the array of bits as an int (first bit is high-order bit of result)
- */
- private int sampleLine(ResultPoint p1, ResultPoint p2, int size) {
- int result = 0;
-
- float d = distance(p1, p2);
- float moduleSize = d / size;
- float px = p1.getX();
- float py = p1.getY();
- float dx = moduleSize * (p2.getX() - p1.getX()) / d;
- float dy = moduleSize * (p2.getY() - p1.getY()) / d;
- for (int i = 0; i < size; i++) {
- if (image.get(MathUtils.round(px + i * dx), MathUtils.round(py + i * dy))) {
- result |= 1 << (size - i - 1);
- }
- }
- return result;
- }
-
- /**
- * @return true if the border of the rectangle passed in parameter is compound of white points only
- * or black points only
- */
- private boolean isWhiteOrBlackRectangle(Point p1,
- Point p2,
- Point p3,
- Point p4) {
-
- int corr = 3;
-
- p1 = new Point(p1.getX() - corr, p1.getY() + corr);
- p2 = new Point(p2.getX() - corr, p2.getY() - corr);
- p3 = new Point(p3.getX() + corr, p3.getY() - corr);
- p4 = new Point(p4.getX() + corr, p4.getY() + corr);
-
- int cInit = getColor(p4, p1);
-
- if (cInit == 0) {
- return false;
- }
-
- int c = getColor(p1, p2);
-
- if (c != cInit) {
- return false;
- }
-
- c = getColor(p2, p3);
-
- if (c != cInit) {
- return false;
- }
-
- c = getColor(p3, p4);
-
- return c == cInit;
-
- }
-
- /**
- * Gets the color of a segment
- *
- * @return 1 if segment more than 90% black, -1 if segment is more than 90% white, 0 else
- */
- private int getColor(Point p1, Point p2) {
- float d = distance(p1, p2);
- float dx = (p2.getX() - p1.getX()) / d;
- float dy = (p2.getY() - p1.getY()) / d;
- int error = 0;
-
- float px = p1.getX();
- float py = p1.getY();
-
- boolean colorModel = image.get(p1.getX(), p1.getY());
-
- for (int i = 0; i < d; i++) {
- px += dx;
- py += dy;
- if (image.get(MathUtils.round(px), MathUtils.round(py)) != colorModel) {
- error++;
- }
- }
-
- float errRatio = error / d;
-
- if (errRatio > 0.1f && errRatio < 0.9f) {
- return 0;
- }
-
- return (errRatio <= 0.1f) == colorModel ? 1 : -1;
- }
-
- /**
- * Gets the coordinate of the first point with a different color in the given direction
- */
- private Point getFirstDifferent(Point init, boolean color, int dx, int dy) {
- int x = init.getX() + dx;
- int y = init.getY() + dy;
-
- while (isValid(x, y) && image.get(x, y) == color) {
- x += dx;
- y += dy;
- }
-
- x -= dx;
- y -= dy;
-
- while (isValid(x, y) && image.get(x, y) == color) {
- x += dx;
- }
- x -= dx;
-
- while (isValid(x, y) && image.get(x, y) == color) {
- y += dy;
- }
- y -= dy;
-
- return new Point(x, y);
- }
-
- /**
- * Expand the square represented by the corner points by pushing out equally in all directions
- *
- * @param cornerPoints the corners of the square, which has the bull's eye at its center
- * @param oldSide the original length of the side of the square in the target bit matrix
- * @param newSide the new length of the size of the square in the target bit matrix
- * @return the corners of the expanded square
- */
- private static ResultPoint[] expandSquare(ResultPoint[] cornerPoints, float oldSide, float newSide) {
- float ratio = newSide / (2 * oldSide);
- float dx = cornerPoints[0].getX() - cornerPoints[2].getX();
- float dy = cornerPoints[0].getY() - cornerPoints[2].getY();
- float centerx = (cornerPoints[0].getX() + cornerPoints[2].getX()) / 2.0f;
- float centery = (cornerPoints[0].getY() + cornerPoints[2].getY()) / 2.0f;
-
- ResultPoint result0 = new ResultPoint(centerx + ratio * dx, centery + ratio * dy);
- ResultPoint result2 = new ResultPoint(centerx - ratio * dx, centery - ratio * dy);
-
- dx = cornerPoints[1].getX() - cornerPoints[3].getX();
- dy = cornerPoints[1].getY() - cornerPoints[3].getY();
- centerx = (cornerPoints[1].getX() + cornerPoints[3].getX()) / 2.0f;
- centery = (cornerPoints[1].getY() + cornerPoints[3].getY()) / 2.0f;
- ResultPoint result1 = new ResultPoint(centerx + ratio * dx, centery + ratio * dy);
- ResultPoint result3 = new ResultPoint(centerx - ratio * dx, centery - ratio * dy);
-
- return new ResultPoint[]{result0, result1, result2, result3};
- }
-
- private boolean isValid(int x, int y) {
- return x >= 0 && x < image.getWidth() && y > 0 && y < image.getHeight();
- }
-
- private boolean isValid(ResultPoint point) {
- int x = MathUtils.round(point.getX());
- int y = MathUtils.round(point.getY());
- return isValid(x, y);
- }
-
- private static float distance(Point a, Point b) {
- return MathUtils.distance(a.getX(), a.getY(), b.getX(), b.getY());
- }
-
- private static float distance(ResultPoint a, ResultPoint b) {
- return MathUtils.distance(a.getX(), a.getY(), b.getX(), b.getY());
- }
-
- private int getDimension() {
- if (compact) {
- return 4 * nbLayers + 11;
- }
- if (nbLayers <= 4) {
- return 4 * nbLayers + 15;
- }
- return 4 * nbLayers + 2 * ((nbLayers - 4) / 8 + 1) + 15;
- }
-
- static final class Point {
- private final int x;
- private final int y;
-
- ResultPoint toResultPoint() {
- return new ResultPoint(getX(), getY());
- }
-
- Point(int x, int y) {
- this.x = x;
- this.y = y;
- }
-
- int getX() {
- return x;
- }
-
- int getY() {
- return y;
- }
-
- @Override
- public String toString() {
- return "<" + x + ' ' + y + '>';
- }
- }
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/AztecCode.java b/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/AztecCode.java
deleted file mode 100644
index e813b6bfa..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/AztecCode.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 2013 ZXing authors
- *
- * Licensed 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 com.google.zxing.aztec.encoder;
-
-import com.google.zxing.common.BitMatrix;
-
-/**
- * Aztec 2D code representation
- *
- * @author Rustam Abdullaev
- */
-public final class AztecCode {
-
- private boolean compact;
- private int size;
- private int layers;
- private int codeWords;
- private BitMatrix matrix;
-
- /**
- * @return {@code true} if compact instead of full mode
- */
- public boolean isCompact() {
- return compact;
- }
-
- public void setCompact(boolean compact) {
- this.compact = compact;
- }
-
- /**
- * @return size in pixels (width and height)
- */
- public int getSize() {
- return size;
- }
-
- public void setSize(int size) {
- this.size = size;
- }
-
- /**
- * @return number of levels
- */
- public int getLayers() {
- return layers;
- }
-
- public void setLayers(int layers) {
- this.layers = layers;
- }
-
- /**
- * @return number of data codewords
- */
- public int getCodeWords() {
- return codeWords;
- }
-
- public void setCodeWords(int codeWords) {
- this.codeWords = codeWords;
- }
-
- /**
- * @return the symbol image
- */
- public BitMatrix getMatrix() {
- return matrix;
- }
-
- public void setMatrix(BitMatrix matrix) {
- this.matrix = matrix;
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/BinaryShiftToken.java b/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/BinaryShiftToken.java
deleted file mode 100644
index 637ba63a5..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/BinaryShiftToken.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2013 ZXing authors
- *
- * Licensed 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 com.google.zxing.aztec.encoder;
-
-import com.google.zxing.common.BitArray;
-
-final class BinaryShiftToken extends Token {
-
- private final short binaryShiftStart;
- private final short binaryShiftByteCount;
-
- BinaryShiftToken(Token previous,
- int binaryShiftStart,
- int binaryShiftByteCount) {
- super(previous);
- this.binaryShiftStart = (short) binaryShiftStart;
- this.binaryShiftByteCount = (short) binaryShiftByteCount;
- }
-
- @Override
- public void appendTo(BitArray bitArray, byte[] text) {
- for (int i = 0; i < binaryShiftByteCount; i++) {
- if (i == 0 || (i == 31 && binaryShiftByteCount <= 62)) {
- // We need a header before the first character, and before
- // character 31 when the total byte code is <= 62
- bitArray.appendBits(31, 5); // BINARY_SHIFT
- if (binaryShiftByteCount > 62) {
- bitArray.appendBits(binaryShiftByteCount - 31, 16);
- } else if (i == 0) {
- // 1 <= binaryShiftByteCode <= 62
- bitArray.appendBits(Math.min(binaryShiftByteCount, 31), 5);
- } else {
- // 32 <= binaryShiftCount <= 62 and i == 31
- bitArray.appendBits(binaryShiftByteCount - 31, 5);
- }
- }
- bitArray.appendBits(text[binaryShiftStart + i], 8);
- }
- }
-
- @Override
- public String toString() {
- return "<" + binaryShiftStart + "::" + (binaryShiftStart + binaryShiftByteCount - 1) + '>';
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/Encoder.java b/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/Encoder.java
deleted file mode 100644
index 3a3655411..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/Encoder.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/*
- * Copyright 2013 ZXing authors
- *
- * Licensed 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 com.google.zxing.aztec.encoder;
-
-import com.google.zxing.common.BitArray;
-import com.google.zxing.common.BitMatrix;
-import com.google.zxing.common.reedsolomon.GenericGF;
-import com.google.zxing.common.reedsolomon.ReedSolomonEncoder;
-
-/**
- * Generates Aztec 2D barcodes.
- *
- * @author Rustam Abdullaev
- */
-public final class Encoder {
-
- public static final int DEFAULT_EC_PERCENT = 33; // default minimal percentage of error check words
- public static final int DEFAULT_AZTEC_LAYERS = 0;
- private static final int MAX_NB_BITS = 32;
- private static final int MAX_NB_BITS_COMPACT = 4;
-
- private static final int[] WORD_SIZE = {
- 4, 6, 6, 8, 8, 8, 8, 8, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
- 12, 12, 12, 12, 12, 12, 12, 12, 12, 12
- };
-
- private Encoder() {
- }
-
- /**
- * Encodes the given binary content as an Aztec symbol
- *
- * @param data input data string
- * @return Aztec symbol matrix with metadata
- */
- public static AztecCode encode(byte[] data) {
- return encode(data, DEFAULT_EC_PERCENT, DEFAULT_AZTEC_LAYERS);
- }
-
- /**
- * Encodes the given binary content as an Aztec symbol
- *
- * @param data input data string
- * @param minECCPercent minimal percentage of error check words (According to ISO/IEC 24778:2008,
- * a minimum of 23% + 3 words is recommended)
- * @param userSpecifiedLayers if non-zero, a user-specified value for the number of layers
- * @return Aztec symbol matrix with metadata
- */
- public static AztecCode encode(byte[] data, int minECCPercent, int userSpecifiedLayers) {
- // High-level encode
- BitArray bits = new HighLevelEncoder(data).encode();
-
- // stuff bits and choose symbol size
- int eccBits = bits.getSize() * minECCPercent / 100 + 11;
- int totalSizeBits = bits.getSize() + eccBits;
- boolean compact;
- int layers;
- int totalBitsInLayer;
- int wordSize;
- BitArray stuffedBits;
- if (userSpecifiedLayers != DEFAULT_AZTEC_LAYERS) {
- compact = userSpecifiedLayers < 0;
- layers = Math.abs(userSpecifiedLayers);
- if (layers > (compact ? MAX_NB_BITS_COMPACT : MAX_NB_BITS)) {
- throw new IllegalArgumentException(
- String.format("Illegal value %s for layers", userSpecifiedLayers));
- }
- totalBitsInLayer = totalBitsInLayer(layers, compact);
- wordSize = WORD_SIZE[layers];
- int usableBitsInLayers = totalBitsInLayer - (totalBitsInLayer % wordSize);
- stuffedBits = stuffBits(bits, wordSize);
- if (stuffedBits.getSize() + eccBits > usableBitsInLayers) {
- throw new IllegalArgumentException("Data to large for user specified layer");
- }
- if (compact && stuffedBits.getSize() > wordSize * 64) {
- // Compact format only allows 64 data words, though C4 can hold more words than that
- throw new IllegalArgumentException("Data to large for user specified layer");
- }
- } else {
- wordSize = 0;
- stuffedBits = null;
- // We look at the possible table sizes in the order Compact1, Compact2, Compact3,
- // Compact4, Normal4,... Normal(i) for i < 4 isn't typically used since Compact(i+1)
- // is the same size, but has more data.
- for (int i = 0; ; i++) {
- if (i > MAX_NB_BITS) {
- throw new IllegalArgumentException("Data too large for an Aztec code");
- }
- compact = i <= 3;
- layers = compact ? i + 1 : i;
- totalBitsInLayer = totalBitsInLayer(layers, compact);
- if (totalSizeBits > totalBitsInLayer) {
- continue;
- }
- // [Re]stuff the bits if this is the first opportunity, or if the
- // wordSize has changed
- if (wordSize != WORD_SIZE[layers]) {
- wordSize = WORD_SIZE[layers];
- stuffedBits = stuffBits(bits, wordSize);
- }
- int usableBitsInLayers = totalBitsInLayer - (totalBitsInLayer % wordSize);
- if (compact && stuffedBits.getSize() > wordSize * 64) {
- // Compact format only allows 64 data words, though C4 can hold more words than that
- continue;
- }
- if (stuffedBits.getSize() + eccBits <= usableBitsInLayers) {
- break;
- }
- }
- }
- BitArray messageBits = generateCheckWords(stuffedBits, totalBitsInLayer, wordSize);
-
- // generate mode message
- int messageSizeInWords = stuffedBits.getSize() / wordSize;
- BitArray modeMessage = generateModeMessage(compact, layers, messageSizeInWords);
-
- // allocate symbol
- int baseMatrixSize = compact ? 11 + layers * 4 : 14 + layers * 4; // not including alignment lines
- int[] alignmentMap = new int[baseMatrixSize];
- int matrixSize;
- if (compact) {
- // no alignment marks in compact mode, alignmentMap is a no-op
- matrixSize = baseMatrixSize;
- for (int i = 0; i < alignmentMap.length; i++) {
- alignmentMap[i] = i;
- }
- } else {
- matrixSize = baseMatrixSize + 1 + 2 * ((baseMatrixSize / 2 - 1) / 15);
- int origCenter = baseMatrixSize / 2;
- int center = matrixSize / 2;
- for (int i = 0; i < origCenter; i++) {
- int newOffset = i + i / 15;
- alignmentMap[origCenter - i - 1] = center - newOffset - 1;
- alignmentMap[origCenter + i] = center + newOffset + 1;
- }
- }
- BitMatrix matrix = new BitMatrix(matrixSize);
-
- // draw data bits
- for (int i = 0, rowOffset = 0; i < layers; i++) {
- int rowSize = compact ? (layers - i) * 4 + 9 : (layers - i) * 4 + 12;
- for (int j = 0; j < rowSize; j++) {
- int columnOffset = j * 2;
- for (int k = 0; k < 2; k++) {
- if (messageBits.get(rowOffset + columnOffset + k)) {
- matrix.set(alignmentMap[i * 2 + k], alignmentMap[i * 2 + j]);
- }
- if (messageBits.get(rowOffset + rowSize * 2 + columnOffset + k)) {
- matrix.set(alignmentMap[i * 2 + j], alignmentMap[baseMatrixSize - 1 - i * 2 - k]);
- }
- if (messageBits.get(rowOffset + rowSize * 4 + columnOffset + k)) {
- matrix.set(alignmentMap[baseMatrixSize - 1 - i * 2 - k], alignmentMap[baseMatrixSize - 1 - i * 2 - j]);
- }
- if (messageBits.get(rowOffset + rowSize * 6 + columnOffset + k)) {
- matrix.set(alignmentMap[baseMatrixSize - 1 - i * 2 - j], alignmentMap[i * 2 + k]);
- }
- }
- }
- rowOffset += rowSize * 8;
- }
-
- // draw mode message
- drawModeMessage(matrix, compact, matrixSize, modeMessage);
-
- // draw alignment marks
- if (compact) {
- drawBullsEye(matrix, matrixSize / 2, 5);
- } else {
- drawBullsEye(matrix, matrixSize / 2, 7);
- for (int i = 0, j = 0; i < baseMatrixSize / 2 - 1; i += 15, j += 16) {
- for (int k = (matrixSize / 2) & 1; k < matrixSize; k += 2) {
- matrix.set(matrixSize / 2 - j, k);
- matrix.set(matrixSize / 2 + j, k);
- matrix.set(k, matrixSize / 2 - j);
- matrix.set(k, matrixSize / 2 + j);
- }
- }
- }
-
- AztecCode aztec = new AztecCode();
- aztec.setCompact(compact);
- aztec.setSize(matrixSize);
- aztec.setLayers(layers);
- aztec.setCodeWords(messageSizeInWords);
- aztec.setMatrix(matrix);
- return aztec;
- }
-
- private static void drawBullsEye(BitMatrix matrix, int center, int size) {
- for (int i = 0; i < size; i += 2) {
- for (int j = center - i; j <= center + i; j++) {
- matrix.set(j, center - i);
- matrix.set(j, center + i);
- matrix.set(center - i, j);
- matrix.set(center + i, j);
- }
- }
- matrix.set(center - size, center - size);
- matrix.set(center - size + 1, center - size);
- matrix.set(center - size, center - size + 1);
- matrix.set(center + size, center - size);
- matrix.set(center + size, center - size + 1);
- matrix.set(center + size, center + size - 1);
- }
-
- static BitArray generateModeMessage(boolean compact, int layers, int messageSizeInWords) {
- BitArray modeMessage = new BitArray();
- if (compact) {
- modeMessage.appendBits(layers - 1, 2);
- modeMessage.appendBits(messageSizeInWords - 1, 6);
- modeMessage = generateCheckWords(modeMessage, 28, 4);
- } else {
- modeMessage.appendBits(layers - 1, 5);
- modeMessage.appendBits(messageSizeInWords - 1, 11);
- modeMessage = generateCheckWords(modeMessage, 40, 4);
- }
- return modeMessage;
- }
-
- private static void drawModeMessage(BitMatrix matrix, boolean compact, int matrixSize, BitArray modeMessage) {
- int center = matrixSize / 2;
- if (compact) {
- for (int i = 0; i < 7; i++) {
- int offset = center - 3 + i;
- if (modeMessage.get(i)) {
- matrix.set(offset, center - 5);
- }
- if (modeMessage.get(i + 7)) {
- matrix.set(center + 5, offset);
- }
- if (modeMessage.get(20 - i)) {
- matrix.set(offset, center + 5);
- }
- if (modeMessage.get(27 - i)) {
- matrix.set(center - 5, offset);
- }
- }
- } else {
- for (int i = 0; i < 10; i++) {
- int offset = center - 5 + i + i / 5;
- if (modeMessage.get(i)) {
- matrix.set(offset, center - 7);
- }
- if (modeMessage.get(i + 10)) {
- matrix.set(center + 7, offset);
- }
- if (modeMessage.get(29 - i)) {
- matrix.set(offset, center + 7);
- }
- if (modeMessage.get(39 - i)) {
- matrix.set(center - 7, offset);
- }
- }
- }
- }
-
- private static BitArray generateCheckWords(BitArray bitArray, int totalBits, int wordSize) {
- // bitArray is guaranteed to be a multiple of the wordSize, so no padding needed
- int messageSizeInWords = bitArray.getSize() / wordSize;
- ReedSolomonEncoder rs = new ReedSolomonEncoder(getGF(wordSize));
- int totalWords = totalBits / wordSize;
- int[] messageWords = bitsToWords(bitArray, wordSize, totalWords);
- rs.encode(messageWords, totalWords - messageSizeInWords);
- int startPad = totalBits % wordSize;
- BitArray messageBits = new BitArray();
- messageBits.appendBits(0, startPad);
- for (int messageWord : messageWords) {
- messageBits.appendBits(messageWord, wordSize);
- }
- return messageBits;
- }
-
- private static int[] bitsToWords(BitArray stuffedBits, int wordSize, int totalWords) {
- int[] message = new int[totalWords];
- int i;
- int n;
- for (i = 0, n = stuffedBits.getSize() / wordSize; i < n; i++) {
- int value = 0;
- for (int j = 0; j < wordSize; j++) {
- value |= stuffedBits.get(i * wordSize + j) ? (1 << wordSize - j - 1) : 0;
- }
- message[i] = value;
- }
- return message;
- }
-
- private static GenericGF getGF(int wordSize) {
- switch (wordSize) {
- case 4:
- return GenericGF.AZTEC_PARAM;
- case 6:
- return GenericGF.AZTEC_DATA_6;
- case 8:
- return GenericGF.AZTEC_DATA_8;
- case 10:
- return GenericGF.AZTEC_DATA_10;
- case 12:
- return GenericGF.AZTEC_DATA_12;
- default:
- throw new IllegalArgumentException("Unsupported word size " + wordSize);
- }
- }
-
- static BitArray stuffBits(BitArray bits, int wordSize) {
- BitArray out = new BitArray();
-
- int n = bits.getSize();
- int mask = (1 << wordSize) - 2;
- for (int i = 0; i < n; i += wordSize) {
- int word = 0;
- for (int j = 0; j < wordSize; j++) {
- if (i + j >= n || bits.get(i + j)) {
- word |= 1 << (wordSize - 1 - j);
- }
- }
- if ((word & mask) == mask) {
- out.appendBits(word & mask, wordSize);
- i--;
- } else if ((word & mask) == 0) {
- out.appendBits(word | 1, wordSize);
- i--;
- } else {
- out.appendBits(word, wordSize);
- }
- }
- return out;
- }
-
- private static int totalBitsInLayer(int layers, boolean compact) {
- return ((compact ? 88 : 112) + 16 * layers) * layers;
- }
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/HighLevelEncoder.java b/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/HighLevelEncoder.java
deleted file mode 100644
index bd867e31c..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/HighLevelEncoder.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * Copyright 2013 ZXing authors
- *
- * Licensed 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 com.google.zxing.aztec.encoder;
-
-import com.google.zxing.common.BitArray;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * This produces nearly optimal encodings of text into the first-level of
- * encoding used by Aztec code.
- *
- * It uses a dynamic algorithm. For each prefix of the string, it determines
- * a set of encodings that could lead to this prefix. We repeatedly add a
- * character and generate a new set of optimal encodings until we have read
- * through the entire input.
- *
- * @author Frank Yellin
- * @author Rustam Abdullaev
- */
-public final class HighLevelEncoder {
-
- static final String[] MODE_NAMES = {"UPPER", "LOWER", "DIGIT", "MIXED", "PUNCT"};
-
- static final int MODE_UPPER = 0; // 5 bits
- static final int MODE_LOWER = 1; // 5 bits
- static final int MODE_DIGIT = 2; // 4 bits
- static final int MODE_MIXED = 3; // 5 bits
- static final int MODE_PUNCT = 4; // 5 bits
-
- // The Latch Table shows, for each pair of Modes, the optimal method for
- // getting from one mode to another. In the worst possible case, this can
- // be up to 14 bits. In the best possible case, we are already there!
- // The high half-word of each entry gives the number of bits.
- // The low half-word of each entry are the actual bits necessary to change
- static final int[][] LATCH_TABLE = {
- {
- 0,
- (5 << 16) + 28, // UPPER -> LOWER
- (5 << 16) + 30, // UPPER -> DIGIT
- (5 << 16) + 29, // UPPER -> MIXED
- (10 << 16) + (29 << 5) + 30, // UPPER -> MIXED -> PUNCT
- },
- {
- (9 << 16) + (30 << 4) + 14, // LOWER -> DIGIT -> UPPER
- 0,
- (5 << 16) + 30, // LOWER -> DIGIT
- (5 << 16) + 29, // LOWER -> MIXED
- (10 << 16) + (29 << 5) + 30, // LOWER -> MIXED -> PUNCT
- },
- {
- (4 << 16) + 14, // DIGIT -> UPPER
- (9 << 16) + (14 << 5) + 28, // DIGIT -> UPPER -> LOWER
- 0,
- (9 << 16) + (14 << 5) + 29, // DIGIT -> UPPER -> MIXED
- (14 << 16) + (14 << 10) + (29 << 5) + 30,
- // DIGIT -> UPPER -> MIXED -> PUNCT
- },
- {
- (5 << 16) + 29, // MIXED -> UPPER
- (5 << 16) + 28, // MIXED -> LOWER
- (10 << 16) + (29 << 5) + 30, // MIXED -> UPPER -> DIGIT
- 0,
- (5 << 16) + 30, // MIXED -> PUNCT
- },
- {
- (5 << 16) + 31, // PUNCT -> UPPER
- (10 << 16) + (31 << 5) + 28, // PUNCT -> UPPER -> LOWER
- (10 << 16) + (31 << 5) + 30, // PUNCT -> UPPER -> DIGIT
- (10 << 16) + (31 << 5) + 29, // PUNCT -> UPPER -> MIXED
- 0,
- },
- };
-
- // A reverse mapping from [mode][char] to the encoding for that character
- // in that mode. An entry of 0 indicates no mapping exists.
- private static final int[][] CHAR_MAP = new int[5][256];
- static {
- CHAR_MAP[MODE_UPPER][' '] = 1;
- for (int c = 'A'; c <= 'Z'; c++) {
- CHAR_MAP[MODE_UPPER][c] = c - 'A' + 2;
- }
- CHAR_MAP[MODE_LOWER][' '] = 1;
- for (int c = 'a'; c <= 'z'; c++) {
- CHAR_MAP[MODE_LOWER][c] = c - 'a' + 2;
- }
- CHAR_MAP[MODE_DIGIT][' '] = 1;
- for (int c = '0'; c <= '9'; c++) {
- CHAR_MAP[MODE_DIGIT][c] = c - '0' + 2;
- }
- CHAR_MAP[MODE_DIGIT][','] = 12;
- CHAR_MAP[MODE_DIGIT]['.'] = 13;
- int[] mixedTable = {
- '\0', ' ', '\1', '\2', '\3', '\4', '\5', '\6', '\7', '\b', '\t', '\n',
- '\13', '\f', '\r', '\33', '\34', '\35', '\36', '\37', '@', '\\', '^',
- '_', '`', '|', '~', '\177'
- };
- for (int i = 0; i < mixedTable.length; i++) {
- CHAR_MAP[MODE_MIXED][mixedTable[i]] = i;
- }
- int[] punctTable = {
- '\0', '\r', '\0', '\0', '\0', '\0', '!', '\'', '#', '$', '%', '&', '\'',
- '(', ')', '*', '+', ',', '-', '.', '/', ':', ';', '<', '=', '>', '?',
- '[', ']', '{', '}'
- };
- for (int i = 0; i < punctTable.length; i++) {
- if (punctTable[i] > 0) {
- CHAR_MAP[MODE_PUNCT][punctTable[i]] = i;
- }
- }
- }
-
- // A map showing the available shift codes. (The shifts to BINARY are not
- // shown
- static final int[][] SHIFT_TABLE = new int[6][6]; // mode shift codes, per table
- static {
- for (int[] table : SHIFT_TABLE) {
- Arrays.fill(table, -1);
- }
- SHIFT_TABLE[MODE_UPPER][MODE_PUNCT] = 0;
-
- SHIFT_TABLE[MODE_LOWER][MODE_PUNCT] = 0;
- SHIFT_TABLE[MODE_LOWER][MODE_UPPER] = 28;
-
- SHIFT_TABLE[MODE_MIXED][MODE_PUNCT] = 0;
-
- SHIFT_TABLE[MODE_DIGIT][MODE_PUNCT] = 0;
- SHIFT_TABLE[MODE_DIGIT][MODE_UPPER] = 15;
- }
-
- private final byte[] text;
-
- public HighLevelEncoder(byte[] text) {
- this.text = text;
- }
-
- /**
- * @return text represented by this encoder encoded as a {@link BitArray}
- */
- public BitArray encode() {
- Collection states = Collections.singletonList(State.INITIAL_STATE);
- for (int index = 0; index < text.length; index++) {
- int pairCode;
- int nextChar = index + 1 < text.length ? text[index + 1] : 0;
- switch (text[index]) {
- case '\r':
- pairCode = nextChar == '\n' ? 2 : 0;
- break;
- case '.' :
- pairCode = nextChar == ' ' ? 3 : 0;
- break;
- case ',' :
- pairCode = nextChar == ' ' ? 4 : 0;
- break;
- case ':' :
- pairCode = nextChar == ' ' ? 5 : 0;
- break;
- default:
- pairCode = 0;
- }
- if (pairCode > 0) {
- // We have one of the four special PUNCT pairs. Treat them specially.
- // Get a new set of states for the two new characters.
- states = updateStateListForPair(states, index, pairCode);
- index++;
- } else {
- // Get a new set of states for the new character.
- states = updateStateListForChar(states, index);
- }
- }
- // We are left with a set of states. Find the shortest one.
- State minState = Collections.min(states, new Comparator() {
- @Override
- public int compare(State a, State b) {
- return a.getBitCount() - b.getBitCount();
- }
- });
- // Convert it to a bit array, and return.
- return minState.toBitArray(text);
- }
-
- // We update a set of states for a new character by updating each state
- // for the new character, merging the results, and then removing the
- // non-optimal states.
- private Collection updateStateListForChar(Iterable states, int index) {
- Collection result = new LinkedList<>();
- for (State state : states) {
- updateStateForChar(state, index, result);
- }
- return simplifyStates(result);
- }
-
- // Return a set of states that represent the possible ways of updating this
- // state for the next character. The resulting set of states are added to
- // the "result" list.
- private void updateStateForChar(State state, int index, Collection result) {
- char ch = (char) (text[index] & 0xFF);
- boolean charInCurrentTable = CHAR_MAP[state.getMode()][ch] > 0;
- State stateNoBinary = null;
- for (int mode = 0; mode <= MODE_PUNCT; mode++) {
- int charInMode = CHAR_MAP[mode][ch];
- if (charInMode > 0) {
- if (stateNoBinary == null) {
- // Only create stateNoBinary the first time it's required.
- stateNoBinary = state.endBinaryShift(index);
- }
- // Try generating the character by latching to its mode
- if (!charInCurrentTable || mode == state.getMode() || mode == MODE_DIGIT) {
- // If the character is in the current table, we don't want to latch to
- // any other mode except possibly digit (which uses only 4 bits). Any
- // other latch would be equally successful *after* this character, and
- // so wouldn't save any bits.
- State latchState = stateNoBinary.latchAndAppend(mode, charInMode);
- result.add(latchState);
- }
- // Try generating the character by switching to its mode.
- if (!charInCurrentTable && SHIFT_TABLE[state.getMode()][mode] >= 0) {
- // It never makes sense to temporarily shift to another mode if the
- // character exists in the current mode. That can never save bits.
- State shiftState = stateNoBinary.shiftAndAppend(mode, charInMode);
- result.add(shiftState);
- }
- }
- }
- if (state.getBinaryShiftByteCount() > 0 || CHAR_MAP[state.getMode()][ch] == 0) {
- // It's never worthwhile to go into binary shift mode if you're not already
- // in binary shift mode, and the character exists in your current mode.
- // That can never save bits over just outputting the char in the current mode.
- State binaryState = state.addBinaryShiftChar(index);
- result.add(binaryState);
- }
- }
-
- private static Collection updateStateListForPair(Iterable states, int index, int pairCode) {
- Collection result = new LinkedList<>();
- for (State state : states) {
- updateStateForPair(state, index, pairCode, result);
- }
- return simplifyStates(result);
- }
-
- private static void updateStateForPair(State state, int index, int pairCode, Collection result) {
- State stateNoBinary = state.endBinaryShift(index);
- // Possibility 1. Latch to MODE_PUNCT, and then append this code
- result.add(stateNoBinary.latchAndAppend(MODE_PUNCT, pairCode));
- if (state.getMode() != MODE_PUNCT) {
- // Possibility 2. Shift to MODE_PUNCT, and then append this code.
- // Every state except MODE_PUNCT (handled above) can shift
- result.add(stateNoBinary.shiftAndAppend(MODE_PUNCT, pairCode));
- }
- if (pairCode == 3 || pairCode == 4) {
- // both characters are in DIGITS. Sometimes better to just add two digits
- State digitState = stateNoBinary
- .latchAndAppend(MODE_DIGIT, 16 - pairCode) // period or comma in DIGIT
- .latchAndAppend(MODE_DIGIT, 1); // space in DIGIT
- result.add(digitState);
- }
- if (state.getBinaryShiftByteCount() > 0) {
- // It only makes sense to do the characters as binary if we're already
- // in binary mode.
- State binaryState = state.addBinaryShiftChar(index).addBinaryShiftChar(index + 1);
- result.add(binaryState);
- }
- }
-
- private static Collection simplifyStates(Iterable states) {
- List result = new LinkedList<>();
- for (State newState : states) {
- boolean add = true;
- for (Iterator iterator = result.iterator(); iterator.hasNext();) {
- State oldState = iterator.next();
- if (oldState.isBetterThanOrEqualTo(newState)) {
- add = false;
- break;
- }
- if (newState.isBetterThanOrEqualTo(oldState)) {
- iterator.remove();
- }
- }
- if (add) {
- result.add(newState);
- }
- }
- return result;
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/SimpleToken.java b/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/SimpleToken.java
deleted file mode 100644
index 047d962ad..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/SimpleToken.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2013 ZXing authors
- *
- * Licensed 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 com.google.zxing.aztec.encoder;
-
-import com.google.zxing.common.BitArray;
-
-final class SimpleToken extends Token {
-
- // For normal words, indicates value and bitCount
- private final short value;
- private final short bitCount;
-
- SimpleToken(Token previous, int value, int bitCount) {
- super(previous);
- this.value = (short) value;
- this.bitCount = (short) bitCount;
- }
-
- @Override
- void appendTo(BitArray bitArray, byte[] text) {
- bitArray.appendBits(value, bitCount);
- }
-
- @Override
- public String toString() {
- int value = this.value & ((1 << bitCount) - 1);
- value |= 1 << bitCount;
- return '<' + Integer.toBinaryString(value | (1 << bitCount)).substring(1) + '>';
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/State.java b/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/State.java
deleted file mode 100644
index 927da63a9..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/State.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright 2013 ZXing authors
- *
- * Licensed 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 com.google.zxing.aztec.encoder;
-
-import java.util.Deque;
-import java.util.LinkedList;
-
-import com.google.zxing.common.BitArray;
-
-/**
- * State represents all information about a sequence necessary to generate the current output.
- * Note that a state is immutable.
- */
-final class State {
-
- static final State INITIAL_STATE = new State(Token.EMPTY, HighLevelEncoder.MODE_UPPER, 0, 0);
-
- // The current mode of the encoding (or the mode to which we'll return if
- // we're in Binary Shift mode.
- private final int mode;
- // The list of tokens that we output. If we are in Binary Shift mode, this
- // token list does *not* yet included the token for those bytes
- private final Token token;
- // If non-zero, the number of most recent bytes that should be output
- // in Binary Shift mode.
- private final int binaryShiftByteCount;
- // The total number of bits generated (including Binary Shift).
- private final int bitCount;
-
- private State(Token token, int mode, int binaryBytes, int bitCount) {
- this.token = token;
- this.mode = mode;
- this.binaryShiftByteCount = binaryBytes;
- this.bitCount = bitCount;
- // Make sure we match the token
- //int binaryShiftBitCount = (binaryShiftByteCount * 8) +
- // (binaryShiftByteCount == 0 ? 0 :
- // binaryShiftByteCount <= 31 ? 10 :
- // binaryShiftByteCount <= 62 ? 20 : 21);
- //assert this.bitCount == token.getTotalBitCount() + binaryShiftBitCount;
- }
-
- int getMode() {
- return mode;
- }
-
- Token getToken() {
- return token;
- }
-
- int getBinaryShiftByteCount() {
- return binaryShiftByteCount;
- }
-
- int getBitCount() {
- return bitCount;
- }
-
- // Create a new state representing this state with a latch to a (not
- // necessary different) mode, and then a code.
- State latchAndAppend(int mode, int value) {
- //assert binaryShiftByteCount == 0;
- int bitCount = this.bitCount;
- Token token = this.token;
- if (mode != this.mode) {
- int latch = HighLevelEncoder.LATCH_TABLE[this.mode][mode];
- token = token.add(latch & 0xFFFF, latch >> 16);
- bitCount += latch >> 16;
- }
- int latchModeBitCount = mode == HighLevelEncoder.MODE_DIGIT ? 4 : 5;
- token = token.add(value, latchModeBitCount);
- return new State(token, mode, 0, bitCount + latchModeBitCount);
- }
-
- // Create a new state representing this state, with a temporary shift
- // to a different mode to output a single value.
- State shiftAndAppend(int mode, int value) {
- //assert binaryShiftByteCount == 0 && this.mode != mode;
- Token token = this.token;
- int thisModeBitCount = this.mode == HighLevelEncoder.MODE_DIGIT ? 4 : 5;
- // Shifts exist only to UPPER and PUNCT, both with tokens size 5.
- token = token.add(HighLevelEncoder.SHIFT_TABLE[this.mode][mode], thisModeBitCount);
- token = token.add(value, 5);
- return new State(token, this.mode, 0, this.bitCount + thisModeBitCount + 5);
- }
-
- // Create a new state representing this state, but an additional character
- // output in Binary Shift mode.
- State addBinaryShiftChar(int index) {
- Token token = this.token;
- int mode = this.mode;
- int bitCount = this.bitCount;
- if (this.mode == HighLevelEncoder.MODE_PUNCT || this.mode == HighLevelEncoder.MODE_DIGIT) {
- //assert binaryShiftByteCount == 0;
- int latch = HighLevelEncoder.LATCH_TABLE[mode][HighLevelEncoder.MODE_UPPER];
- token = token.add(latch & 0xFFFF, latch >> 16);
- bitCount += latch >> 16;
- mode = HighLevelEncoder.MODE_UPPER;
- }
- int deltaBitCount =
- (binaryShiftByteCount == 0 || binaryShiftByteCount == 31) ? 18 :
- (binaryShiftByteCount == 62) ? 9 : 8;
- State result = new State(token, mode, binaryShiftByteCount + 1, bitCount + deltaBitCount);
- if (result.binaryShiftByteCount == 2047 + 31) {
- // The string is as long as it's allowed to be. We should end it.
- result = result.endBinaryShift(index + 1);
- }
- return result;
- }
-
- // Create the state identical to this one, but we are no longer in
- // Binary Shift mode.
- State endBinaryShift(int index) {
- if (binaryShiftByteCount == 0) {
- return this;
- }
- Token token = this.token;
- token = token.addBinaryShift(index - binaryShiftByteCount, binaryShiftByteCount);
- //assert token.getTotalBitCount() == this.bitCount;
- return new State(token, mode, 0, this.bitCount);
- }
-
- // Returns true if "this" state is better (or equal) to be in than "that"
- // state under all possible circumstances.
- boolean isBetterThanOrEqualTo(State other) {
- int mySize = this.bitCount + (HighLevelEncoder.LATCH_TABLE[this.mode][other.mode] >> 16);
- if (other.binaryShiftByteCount > 0 &&
- (this.binaryShiftByteCount == 0 || this.binaryShiftByteCount > other.binaryShiftByteCount)) {
- mySize += 10; // Cost of entering Binary Shift mode.
- }
- return mySize <= other.bitCount;
- }
-
- BitArray toBitArray(byte[] text) {
- // Reverse the tokens, so that they are in the order that they should
- // be output
- Deque symbols = new LinkedList<>();
- for (Token token = endBinaryShift(text.length).token; token != null; token = token.getPrevious()) {
- symbols.addFirst(token);
- }
- BitArray bitArray = new BitArray();
- // Add each token to the result.
- for (Token symbol : symbols) {
- symbol.appendTo(bitArray, text);
- }
- //assert bitArray.getSize() == this.bitCount;
- return bitArray;
- }
-
- @Override
- public String toString() {
- return String.format("%s bits=%d bytes=%d", HighLevelEncoder.MODE_NAMES[mode], bitCount, binaryShiftByteCount);
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/Token.java b/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/Token.java
deleted file mode 100644
index 62d336e9c..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/aztec/encoder/Token.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2013 ZXing authors
- *
- * Licensed 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 com.google.zxing.aztec.encoder;
-
-import com.google.zxing.common.BitArray;
-
-abstract class Token {
-
- static final Token EMPTY = new SimpleToken(null, 0, 0);
-
- private final Token previous;
-
- Token(Token previous) {
- this.previous = previous;
- }
-
- final Token getPrevious() {
- return previous;
- }
-
- final Token add(int value, int bitCount) {
- return new SimpleToken(this, value, bitCount);
- }
-
- final Token addBinaryShift(int start, int byteCount) {
- //int bitCount = (byteCount * 8) + (byteCount <= 31 ? 10 : byteCount <= 62 ? 20 : 21);
- return new BinaryShiftToken(this, start, byteCount);
- }
-
- abstract void appendTo(BitArray bitArray, byte[] text);
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/AbstractDoCoMoResultParser.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/AbstractDoCoMoResultParser.java
deleted file mode 100644
index 3d2c1d2a7..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/AbstractDoCoMoResultParser.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing.client.result;
-
-/**
- * See
- *
- * DoCoMo's documentation about the result types represented by subclasses of this class.
- *
- * Thanks to Jeff Griffin for proposing rewrite of these classes that relies less
- * on exception-based mechanisms during parsing.
- *
- * @author Sean Owen
- */
-abstract class AbstractDoCoMoResultParser extends ResultParser {
-
- static String[] matchDoCoMoPrefixedField(String prefix, String rawText, boolean trim) {
- return matchPrefixedField(prefix, rawText, ';', trim);
- }
-
- static String matchSingleDoCoMoPrefixedField(String prefix, String rawText, boolean trim) {
- return matchSinglePrefixedField(prefix, rawText, ';', trim);
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/AddressBookAUResultParser.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/AddressBookAUResultParser.java
deleted file mode 100644
index cf7f96e87..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/AddressBookAUResultParser.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed 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 com.google.zxing.client.result;
-
-import com.google.zxing.Result;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Implements KDDI AU's address book format. See
- *
- * http://www.au.kddi.com/ezfactory/tec/two_dimensions/index.html.
- * (Thanks to Yuzo for translating!)
- *
- * @author Sean Owen
- */
-public final class AddressBookAUResultParser extends ResultParser {
-
- @Override
- public AddressBookParsedResult parse(Result result) {
- String rawText = getMassagedText(result);
- // MEMORY is mandatory; seems like a decent indicator, as does end-of-record separator CR/LF
- if (!rawText.contains("MEMORY") || !rawText.contains("\r\n")) {
- return null;
- }
-
- // NAME1 and NAME2 have specific uses, namely written name and pronunciation, respectively.
- // Therefore we treat them specially instead of as an array of names.
- String name = matchSinglePrefixedField("NAME1:", rawText, '\r', true);
- String pronunciation = matchSinglePrefixedField("NAME2:", rawText, '\r', true);
-
- String[] phoneNumbers = matchMultipleValuePrefix("TEL", 3, rawText, true);
- String[] emails = matchMultipleValuePrefix("MAIL", 3, rawText, true);
- String note = matchSinglePrefixedField("MEMORY:", rawText, '\r', false);
- String address = matchSinglePrefixedField("ADD:", rawText, '\r', true);
- String[] addresses = address == null ? null : new String[] {address};
- return new AddressBookParsedResult(maybeWrap(name),
- null,
- pronunciation,
- phoneNumbers,
- null,
- emails,
- null,
- null,
- note,
- addresses,
- null,
- null,
- null,
- null,
- null,
- null);
- }
-
- private static String[] matchMultipleValuePrefix(String prefix,
- int max,
- String rawText,
- boolean trim) {
- List values = null;
- for (int i = 1; i <= max; i++) {
- String value = matchSinglePrefixedField(prefix + i + ':', rawText, '\r', trim);
- if (value == null) {
- break;
- }
- if (values == null) {
- values = new ArrayList<>(max); // lazy init
- }
- values.add(value);
- }
- if (values == null) {
- return null;
- }
- return values.toArray(new String[values.size()]);
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/AddressBookDoCoMoResultParser.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/AddressBookDoCoMoResultParser.java
deleted file mode 100644
index cb2e19b26..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/AddressBookDoCoMoResultParser.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing.client.result;
-
-import com.google.zxing.Result;
-
-/**
- * Implements the "MECARD" address book entry format.
- *
- * Supported keys: N, SOUND, TEL, EMAIL, NOTE, ADR, BDAY, URL, plus ORG
- * Unsupported keys: TEL-AV, NICKNAME
- *
- * Except for TEL, multiple values for keys are also not supported;
- * the first one found takes precedence.
- *
- * Our understanding of the MECARD format is based on this document:
- *
- * http://www.mobicode.org.tw/files/OMIA%20Mobile%20Bar%20Code%20Standard%20v3.2.1.doc
- *
- * @author Sean Owen
- */
-public final class AddressBookDoCoMoResultParser extends AbstractDoCoMoResultParser {
-
- @Override
- public AddressBookParsedResult parse(Result result) {
- String rawText = getMassagedText(result);
- if (!rawText.startsWith("MECARD:")) {
- return null;
- }
- String[] rawName = matchDoCoMoPrefixedField("N:", rawText, true);
- if (rawName == null) {
- return null;
- }
- String name = parseName(rawName[0]);
- String pronunciation = matchSingleDoCoMoPrefixedField("SOUND:", rawText, true);
- String[] phoneNumbers = matchDoCoMoPrefixedField("TEL:", rawText, true);
- String[] emails = matchDoCoMoPrefixedField("EMAIL:", rawText, true);
- String note = matchSingleDoCoMoPrefixedField("NOTE:", rawText, false);
- String[] addresses = matchDoCoMoPrefixedField("ADR:", rawText, true);
- String birthday = matchSingleDoCoMoPrefixedField("BDAY:", rawText, true);
- if (!isStringOfDigits(birthday, 8)) {
- // No reason to throw out the whole card because the birthday is formatted wrong.
- birthday = null;
- }
- String[] urls = matchDoCoMoPrefixedField("URL:", rawText, true);
-
- // Although ORG may not be strictly legal in MECARD, it does exist in VCARD and we might as well
- // honor it when found in the wild.
- String org = matchSingleDoCoMoPrefixedField("ORG:", rawText, true);
-
- return new AddressBookParsedResult(maybeWrap(name),
- null,
- pronunciation,
- phoneNumbers,
- null,
- emails,
- null,
- null,
- note,
- addresses,
- null,
- org,
- birthday,
- null,
- urls,
- null);
- }
-
- private static String parseName(String name) {
- int comma = name.indexOf((int) ',');
- if (comma >= 0) {
- // Format may be last,first; switch it around
- return name.substring(comma + 1) + ' ' + name.substring(0, comma);
- }
- return name;
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/AddressBookParsedResult.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/AddressBookParsedResult.java
deleted file mode 100644
index 291ebfccf..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/AddressBookParsedResult.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing.client.result;
-
-/**
- * @author Sean Owen
- */
-public final class AddressBookParsedResult extends ParsedResult {
-
- private final String[] names;
- private final String[] nicknames;
- private final String pronunciation;
- private final String[] phoneNumbers;
- private final String[] phoneTypes;
- private final String[] emails;
- private final String[] emailTypes;
- private final String instantMessenger;
- private final String note;
- private final String[] addresses;
- private final String[] addressTypes;
- private final String org;
- private final String birthday;
- private final String title;
- private final String[] urls;
- private final String[] geo;
-
- public AddressBookParsedResult(String[] names,
- String[] phoneNumbers,
- String[] phoneTypes,
- String[] emails,
- String[] emailTypes,
- String[] addresses,
- String[] addressTypes) {
- this(names,
- null,
- null,
- phoneNumbers,
- phoneTypes,
- emails,
- emailTypes,
- null,
- null,
- addresses,
- addressTypes,
- null,
- null,
- null,
- null,
- null);
- }
-
- public AddressBookParsedResult(String[] names,
- String[] nicknames,
- String pronunciation,
- String[] phoneNumbers,
- String[] phoneTypes,
- String[] emails,
- String[] emailTypes,
- String instantMessenger,
- String note,
- String[] addresses,
- String[] addressTypes,
- String org,
- String birthday,
- String title,
- String[] urls,
- String[] geo) {
- super(ParsedResultType.ADDRESSBOOK);
- this.names = names;
- this.nicknames = nicknames;
- this.pronunciation = pronunciation;
- this.phoneNumbers = phoneNumbers;
- this.phoneTypes = phoneTypes;
- this.emails = emails;
- this.emailTypes = emailTypes;
- this.instantMessenger = instantMessenger;
- this.note = note;
- this.addresses = addresses;
- this.addressTypes = addressTypes;
- this.org = org;
- this.birthday = birthday;
- this.title = title;
- this.urls = urls;
- this.geo = geo;
- }
-
- public String[] getNames() {
- return names;
- }
-
- public String[] getNicknames() {
- return nicknames;
- }
-
- /**
- * In Japanese, the name is written in kanji, which can have multiple readings. Therefore a hint
- * is often provided, called furigana, which spells the name phonetically.
- *
- * @return The pronunciation of the getNames() field, often in hiragana or katakana.
- */
- public String getPronunciation() {
- return pronunciation;
- }
-
- public String[] getPhoneNumbers() {
- return phoneNumbers;
- }
-
- /**
- * @return optional descriptions of the type of each phone number. It could be like "HOME", but,
- * there is no guaranteed or standard format.
- */
- public String[] getPhoneTypes() {
- return phoneTypes;
- }
-
- public String[] getEmails() {
- return emails;
- }
-
- /**
- * @return optional descriptions of the type of each e-mail. It could be like "WORK", but,
- * there is no guaranteed or standard format.
- */
- public String[] getEmailTypes() {
- return emailTypes;
- }
-
- public String getInstantMessenger() {
- return instantMessenger;
- }
-
- public String getNote() {
- return note;
- }
-
- public String[] getAddresses() {
- return addresses;
- }
-
- /**
- * @return optional descriptions of the type of each e-mail. It could be like "WORK", but,
- * there is no guaranteed or standard format.
- */
- public String[] getAddressTypes() {
- return addressTypes;
- }
-
- public String getTitle() {
- return title;
- }
-
- public String getOrg() {
- return org;
- }
-
- public String[] getURLs() {
- return urls;
- }
-
- /**
- * @return birthday formatted as yyyyMMdd (e.g. 19780917)
- */
- public String getBirthday() {
- return birthday;
- }
-
- /**
- * @return a location as a latitude/longitude pair
- */
- public String[] getGeo() {
- return geo;
- }
-
- @Override
- public String getDisplayResult() {
- StringBuilder result = new StringBuilder(100);
- maybeAppend(names, result);
- maybeAppend(nicknames, result);
- maybeAppend(pronunciation, result);
- maybeAppend(title, result);
- maybeAppend(org, result);
- maybeAppend(addresses, result);
- maybeAppend(phoneNumbers, result);
- maybeAppend(emails, result);
- maybeAppend(instantMessenger, result);
- maybeAppend(urls, result);
- maybeAppend(birthday, result);
- maybeAppend(geo, result);
- maybeAppend(note, result);
- return result.toString();
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/BizcardResultParser.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/BizcardResultParser.java
deleted file mode 100644
index 1d588d4c2..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/BizcardResultParser.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed 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 com.google.zxing.client.result;
-
-import com.google.zxing.Result;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Implements the "BIZCARD" address book entry format, though this has been
- * largely reverse-engineered from examples observed in the wild -- still
- * looking for a definitive reference.
- *
- * @author Sean Owen
- */
-public final class BizcardResultParser extends AbstractDoCoMoResultParser {
-
- // Yes, we extend AbstractDoCoMoResultParser since the format is very much
- // like the DoCoMo MECARD format, but this is not technically one of
- // DoCoMo's proposed formats
-
- @Override
- public AddressBookParsedResult parse(Result result) {
- String rawText = getMassagedText(result);
- if (!rawText.startsWith("BIZCARD:")) {
- return null;
- }
- String firstName = matchSingleDoCoMoPrefixedField("N:", rawText, true);
- String lastName = matchSingleDoCoMoPrefixedField("X:", rawText, true);
- String fullName = buildName(firstName, lastName);
- String title = matchSingleDoCoMoPrefixedField("T:", rawText, true);
- String org = matchSingleDoCoMoPrefixedField("C:", rawText, true);
- String[] addresses = matchDoCoMoPrefixedField("A:", rawText, true);
- String phoneNumber1 = matchSingleDoCoMoPrefixedField("B:", rawText, true);
- String phoneNumber2 = matchSingleDoCoMoPrefixedField("M:", rawText, true);
- String phoneNumber3 = matchSingleDoCoMoPrefixedField("F:", rawText, true);
- String email = matchSingleDoCoMoPrefixedField("E:", rawText, true);
-
- return new AddressBookParsedResult(maybeWrap(fullName),
- null,
- null,
- buildPhoneNumbers(phoneNumber1, phoneNumber2, phoneNumber3),
- null,
- maybeWrap(email),
- null,
- null,
- null,
- addresses,
- null,
- org,
- null,
- title,
- null,
- null);
- }
-
- private static String[] buildPhoneNumbers(String number1,
- String number2,
- String number3) {
- List numbers = new ArrayList<>(3);
- if (number1 != null) {
- numbers.add(number1);
- }
- if (number2 != null) {
- numbers.add(number2);
- }
- if (number3 != null) {
- numbers.add(number3);
- }
- int size = numbers.size();
- if (size == 0) {
- return null;
- }
- return numbers.toArray(new String[size]);
- }
-
- private static String buildName(String firstName, String lastName) {
- if (firstName == null) {
- return lastName;
- } else {
- return lastName == null ? firstName : firstName + ' ' + lastName;
- }
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/BookmarkDoCoMoResultParser.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/BookmarkDoCoMoResultParser.java
deleted file mode 100644
index a729239d8..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/BookmarkDoCoMoResultParser.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing.client.result;
-
-import com.google.zxing.Result;
-
-/**
- * @author Sean Owen
- */
-public final class BookmarkDoCoMoResultParser extends AbstractDoCoMoResultParser {
-
- @Override
- public URIParsedResult parse(Result result) {
- String rawText = result.getText();
- if (!rawText.startsWith("MEBKM:")) {
- return null;
- }
- String title = matchSingleDoCoMoPrefixedField("TITLE:", rawText, true);
- String[] rawUri = matchDoCoMoPrefixedField("URL:", rawText, true);
- if (rawUri == null) {
- return null;
- }
- String uri = rawUri[0];
- return URIResultParser.isBasicallyValidURI(uri) ? new URIParsedResult(uri, title) : null;
- }
-
-}
\ No newline at end of file
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/CalendarParsedResult.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/CalendarParsedResult.java
deleted file mode 100644
index 48b92a6bc..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/CalendarParsedResult.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed 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 com.google.zxing.client.result;
-
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Locale;
-import java.util.TimeZone;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * @author Sean Owen
- */
-public final class CalendarParsedResult extends ParsedResult {
-
- private static final Pattern RFC2445_DURATION =
- Pattern.compile("P(?:(\\d+)W)?(?:(\\d+)D)?(?:T(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)S)?)?");
- private static final long[] RFC2445_DURATION_FIELD_UNITS = {
- 7 * 24 * 60 * 60 * 1000L, // 1 week
- 24 * 60 * 60 * 1000L, // 1 day
- 60 * 60 * 1000L, // 1 hour
- 60 * 1000L, // 1 minute
- 1000L, // 1 second
- };
-
- private static final Pattern DATE_TIME = Pattern.compile("[0-9]{8}(T[0-9]{6}Z?)?");
-
- private final String summary;
- private final Date start;
- private final boolean startAllDay;
- private final Date end;
- private final boolean endAllDay;
- private final String location;
- private final String organizer;
- private final String[] attendees;
- private final String description;
- private final double latitude;
- private final double longitude;
-
- public CalendarParsedResult(String summary,
- String startString,
- String endString,
- String durationString,
- String location,
- String organizer,
- String[] attendees,
- String description,
- double latitude,
- double longitude) {
- super(ParsedResultType.CALENDAR);
- this.summary = summary;
-
- try {
- this.start = parseDate(startString);
- } catch (ParseException pe) {
- throw new IllegalArgumentException(pe.toString());
- }
-
- if (endString == null) {
- long durationMS = parseDurationMS(durationString);
- end = durationMS < 0L ? null : new Date(start.getTime() + durationMS);
- } else {
- try {
- this.end = parseDate(endString);
- } catch (ParseException pe) {
- throw new IllegalArgumentException(pe.toString());
- }
- }
-
- this.startAllDay = startString.length() == 8;
- this.endAllDay = endString != null && endString.length() == 8;
-
- this.location = location;
- this.organizer = organizer;
- this.attendees = attendees;
- this.description = description;
- this.latitude = latitude;
- this.longitude = longitude;
- }
-
- public String getSummary() {
- return summary;
- }
-
- /**
- * @return start time
- */
- public Date getStart() {
- return start;
- }
-
- /**
- * @return true if start time was specified as a whole day
- */
- public boolean isStartAllDay() {
- return startAllDay;
- }
-
- /**
- * @return event end {@link Date}, or {@code null} if event has no duration
- * @see #getStart()
- */
- public Date getEnd() {
- return end;
- }
-
- /**
- * @return true if end time was specified as a whole day
- */
- public boolean isEndAllDay() {
- return endAllDay;
- }
-
- public String getLocation() {
- return location;
- }
-
- public String getOrganizer() {
- return organizer;
- }
-
- public String[] getAttendees() {
- return attendees;
- }
-
- public String getDescription() {
- return description;
- }
-
- public double getLatitude() {
- return latitude;
- }
-
- public double getLongitude() {
- return longitude;
- }
-
- @Override
- public String getDisplayResult() {
- StringBuilder result = new StringBuilder(100);
- maybeAppend(summary, result);
- maybeAppend(format(startAllDay, start), result);
- maybeAppend(format(endAllDay, end), result);
- maybeAppend(location, result);
- maybeAppend(organizer, result);
- maybeAppend(attendees, result);
- maybeAppend(description, result);
- return result.toString();
- }
-
- /**
- * Parses a string as a date. RFC 2445 allows the start and end fields to be of type DATE (e.g. 20081021)
- * or DATE-TIME (e.g. 20081021T123000 for local time, or 20081021T123000Z for UTC).
- *
- * @param when The string to parse
- * @throws ParseException if not able to parse as a date
- */
- private static Date parseDate(String when) throws ParseException {
- if (!DATE_TIME.matcher(when).matches()) {
- throw new ParseException(when, 0);
- }
- if (when.length() == 8) {
- // Show only year/month/day
- return buildDateFormat().parse(when);
- } else {
- // The when string can be local time, or UTC if it ends with a Z
- Date date;
- if (when.length() == 16 && when.charAt(15) == 'Z') {
- date = buildDateTimeFormat().parse(when.substring(0, 15));
- Calendar calendar = new GregorianCalendar();
- long milliseconds = date.getTime();
- // Account for time zone difference
- milliseconds += calendar.get(Calendar.ZONE_OFFSET);
- // Might need to correct for daylight savings time, but use target time since
- // now might be in DST but not then, or vice versa
- calendar.setTime(new Date(milliseconds));
- milliseconds += calendar.get(Calendar.DST_OFFSET);
- date = new Date(milliseconds);
- } else {
- date = buildDateTimeFormat().parse(when);
- }
- return date;
- }
- }
-
- private static String format(boolean allDay, Date date) {
- if (date == null) {
- return null;
- }
- DateFormat format = allDay
- ? DateFormat.getDateInstance(DateFormat.MEDIUM)
- : DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
- return format.format(date);
- }
-
- private static long parseDurationMS(CharSequence durationString) {
- if (durationString == null) {
- return -1L;
- }
- Matcher m = RFC2445_DURATION.matcher(durationString);
- if (!m.matches()) {
- return -1L;
- }
- long durationMS = 0L;
- for (int i = 0; i < RFC2445_DURATION_FIELD_UNITS.length; i++) {
- String fieldValue = m.group(i + 1);
- if (fieldValue != null) {
- durationMS += RFC2445_DURATION_FIELD_UNITS[i] * Integer.parseInt(fieldValue);
- }
- }
- return durationMS;
- }
-
- private static DateFormat buildDateFormat() {
- DateFormat format = new SimpleDateFormat("yyyyMMdd", Locale.ENGLISH);
- // For dates without a time, for purposes of interacting with Android, the resulting timestamp
- // needs to be midnight of that day in GMT. See:
- // http://code.google.com/p/android/issues/detail?id=8330
- format.setTimeZone(TimeZone.getTimeZone("GMT"));
- return format;
- }
-
- private static DateFormat buildDateTimeFormat() {
- return new SimpleDateFormat("yyyyMMdd'T'HHmmss", Locale.ENGLISH);
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/EmailAddressParsedResult.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/EmailAddressParsedResult.java
deleted file mode 100644
index 06c4075a4..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/EmailAddressParsedResult.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing.client.result;
-
-/**
- * @author Sean Owen
- */
-public final class EmailAddressParsedResult extends ParsedResult {
-
- private final String[] tos;
- private final String[] ccs;
- private final String[] bccs;
- private final String subject;
- private final String body;
-
- EmailAddressParsedResult(String to) {
- this(new String[] {to}, null, null, null, null);
- }
-
- EmailAddressParsedResult(String[] tos,
- String[] ccs,
- String[] bccs,
- String subject,
- String body) {
- super(ParsedResultType.EMAIL_ADDRESS);
- this.tos = tos;
- this.ccs = ccs;
- this.bccs = bccs;
- this.subject = subject;
- this.body = body;
- }
-
- /**
- * @return first elements of {@link #getTos()} or {@code null} if none
- * @deprecated use {@link #getTos()}
- */
- @Deprecated
- public String getEmailAddress() {
- return tos == null || tos.length == 0 ? null : tos[0];
- }
-
- public String[] getTos() {
- return tos;
- }
-
- public String[] getCCs() {
- return ccs;
- }
-
- public String[] getBCCs() {
- return bccs;
- }
-
- public String getSubject() {
- return subject;
- }
-
- public String getBody() {
- return body;
- }
-
- /**
- * @return "mailto:"
- * @deprecated without replacement
- */
- @Deprecated
- public String getMailtoURI() {
- return "mailto:";
- }
-
- @Override
- public String getDisplayResult() {
- StringBuilder result = new StringBuilder(30);
- maybeAppend(tos, result);
- maybeAppend(ccs, result);
- maybeAppend(bccs, result);
- maybeAppend(subject, result);
- maybeAppend(body, result);
- return result.toString();
- }
-
-}
\ No newline at end of file
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/EmailAddressResultParser.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/EmailAddressResultParser.java
deleted file mode 100644
index d66adf1dd..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/EmailAddressResultParser.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing.client.result;
-
-import com.google.zxing.Result;
-
-import java.util.Map;
-import java.util.regex.Pattern;
-
-/**
- * Represents a result that encodes an e-mail address, either as a plain address
- * like "joe@example.org" or a mailto: URL like "mailto:joe@example.org".
- *
- * @author Sean Owen
- */
-public final class EmailAddressResultParser extends ResultParser {
-
- private static final Pattern COMMA = Pattern.compile(",");
-
- @Override
- public EmailAddressParsedResult parse(Result result) {
- String rawText = getMassagedText(result);
- if (rawText.startsWith("mailto:") || rawText.startsWith("MAILTO:")) {
- // If it starts with mailto:, assume it is definitely trying to be an email address
- String hostEmail = rawText.substring(7);
- int queryStart = hostEmail.indexOf('?');
- if (queryStart >= 0) {
- hostEmail = hostEmail.substring(0, queryStart);
- }
- hostEmail = urlDecode(hostEmail);
- String[] tos = null;
- if (!hostEmail.isEmpty()) {
- tos = COMMA.split(hostEmail);
- }
- Map nameValues = parseNameValuePairs(rawText);
- String[] ccs = null;
- String[] bccs = null;
- String subject = null;
- String body = null;
- if (nameValues != null) {
- if (tos == null) {
- String tosString = nameValues.get("to");
- if (tosString != null) {
- tos = COMMA.split(tosString);
- }
- }
- String ccString = nameValues.get("cc");
- if (ccString != null) {
- ccs = COMMA.split(ccString);
- }
- String bccString = nameValues.get("bcc");
- if (bccString != null) {
- bccs = COMMA.split(bccString);
- }
- subject = nameValues.get("subject");
- body = nameValues.get("body");
- }
- return new EmailAddressParsedResult(tos, ccs, bccs, subject, body);
- } else {
- if (!EmailDoCoMoResultParser.isBasicallyValidEmailAddress(rawText)) {
- return null;
- }
- return new EmailAddressParsedResult(rawText);
- }
- }
-
-}
\ No newline at end of file
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/EmailDoCoMoResultParser.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/EmailDoCoMoResultParser.java
deleted file mode 100644
index fc4c28485..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/EmailDoCoMoResultParser.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing.client.result;
-
-import com.google.zxing.Result;
-
-import java.util.regex.Pattern;
-
-/**
- * Implements the "MATMSG" email message entry format.
- *
- * Supported keys: TO, SUB, BODY
- *
- * @author Sean Owen
- */
-public final class EmailDoCoMoResultParser extends AbstractDoCoMoResultParser {
-
- private static final Pattern ATEXT_ALPHANUMERIC = Pattern.compile("[a-zA-Z0-9@.!#$%&'*+\\-/=?^_`{|}~]+");
-
- @Override
- public EmailAddressParsedResult parse(Result result) {
- String rawText = getMassagedText(result);
- if (!rawText.startsWith("MATMSG:")) {
- return null;
- }
- String[] tos = matchDoCoMoPrefixedField("TO:", rawText, true);
- if (tos == null) {
- return null;
- }
- for (String to : tos) {
- if (!isBasicallyValidEmailAddress(to)) {
- return null;
- }
- }
- String subject = matchSingleDoCoMoPrefixedField("SUB:", rawText, false);
- String body = matchSingleDoCoMoPrefixedField("BODY:", rawText, false);
- return new EmailAddressParsedResult(tos, null, null, subject, body);
- }
-
- /**
- * This implements only the most basic checking for an email address's validity -- that it contains
- * an '@' and contains no characters disallowed by RFC 2822. This is an overly lenient definition of
- * validity. We want to generally be lenient here since this class is only intended to encapsulate what's
- * in a barcode, not "judge" it.
- */
- static boolean isBasicallyValidEmailAddress(String email) {
- return email != null && ATEXT_ALPHANUMERIC.matcher(email).matches() && email.indexOf('@') >= 0;
- }
-
-}
\ No newline at end of file
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/ExpandedProductParsedResult.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/ExpandedProductParsedResult.java
deleted file mode 100644
index 6053100d4..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/ExpandedProductParsedResult.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * Copyright (C) 2010 ZXing authors
- *
- * Licensed 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.
- */
-
-/*
- * These authors would like to acknowledge the Spanish Ministry of Industry,
- * Tourism and Trade, for the support in the project TSI020301-2008-2
- * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
- * Mobile Dynamic Environments", led by Treelogic
- * ( http://www.treelogic.com/ ):
- *
- * http://www.piramidepse.com/
- */
-
-package com.google.zxing.client.result;
-
-import java.util.Map;
-
-/**
- * @author Antonio Manuel Benjumea Conde, Servinform, S.A.
- * @author AgustÃn Delgado, Servinform, S.A.
- */
-public final class ExpandedProductParsedResult extends ParsedResult {
-
- public static final String KILOGRAM = "KG";
- public static final String POUND = "LB";
-
- private final String rawText;
- private final String productID;
- private final String sscc;
- private final String lotNumber;
- private final String productionDate;
- private final String packagingDate;
- private final String bestBeforeDate;
- private final String expirationDate;
- private final String weight;
- private final String weightType;
- private final String weightIncrement;
- private final String price;
- private final String priceIncrement;
- private final String priceCurrency;
- // For AIS that not exist in this object
- private final Map uncommonAIs;
-
- public ExpandedProductParsedResult(String rawText,
- String productID,
- String sscc,
- String lotNumber,
- String productionDate,
- String packagingDate,
- String bestBeforeDate,
- String expirationDate,
- String weight,
- String weightType,
- String weightIncrement,
- String price,
- String priceIncrement,
- String priceCurrency,
- Map uncommonAIs) {
- super(ParsedResultType.PRODUCT);
- this.rawText = rawText;
- this.productID = productID;
- this.sscc = sscc;
- this.lotNumber = lotNumber;
- this.productionDate = productionDate;
- this.packagingDate = packagingDate;
- this.bestBeforeDate = bestBeforeDate;
- this.expirationDate = expirationDate;
- this.weight = weight;
- this.weightType = weightType;
- this.weightIncrement = weightIncrement;
- this.price = price;
- this.priceIncrement = priceIncrement;
- this.priceCurrency = priceCurrency;
- this.uncommonAIs = uncommonAIs;
- }
-
- @Override
- public boolean equals(Object o){
- if (!(o instanceof ExpandedProductParsedResult)) {
- return false;
- }
-
- ExpandedProductParsedResult other = (ExpandedProductParsedResult)o;
-
- return equalsOrNull(productID, other.productID)
- && equalsOrNull(sscc, other.sscc)
- && equalsOrNull(lotNumber, other.lotNumber)
- && equalsOrNull(productionDate, other.productionDate)
- && equalsOrNull(bestBeforeDate, other.bestBeforeDate)
- && equalsOrNull(expirationDate, other.expirationDate)
- && equalsOrNull(weight, other.weight)
- && equalsOrNull(weightType, other.weightType)
- && equalsOrNull(weightIncrement, other.weightIncrement)
- && equalsOrNull(price, other.price)
- && equalsOrNull(priceIncrement, other.priceIncrement)
- && equalsOrNull(priceCurrency, other.priceCurrency)
- && equalsOrNull(uncommonAIs, other.uncommonAIs);
- }
-
- private static boolean equalsOrNull(Object o1, Object o2) {
- return o1 == null ? o2 == null : o1.equals(o2);
- }
-
- @Override
- public int hashCode(){
- int hash = 0;
- hash ^= hashNotNull(productID);
- hash ^= hashNotNull(sscc);
- hash ^= hashNotNull(lotNumber);
- hash ^= hashNotNull(productionDate);
- hash ^= hashNotNull(bestBeforeDate);
- hash ^= hashNotNull(expirationDate);
- hash ^= hashNotNull(weight);
- hash ^= hashNotNull(weightType);
- hash ^= hashNotNull(weightIncrement);
- hash ^= hashNotNull(price);
- hash ^= hashNotNull(priceIncrement);
- hash ^= hashNotNull(priceCurrency);
- hash ^= hashNotNull(uncommonAIs);
- return hash;
- }
-
- private static int hashNotNull(Object o) {
- return o == null ? 0 : o.hashCode();
- }
-
- public String getRawText() {
- return rawText;
- }
-
- public String getProductID() {
- return productID;
- }
-
- public String getSscc() {
- return sscc;
- }
-
- public String getLotNumber() {
- return lotNumber;
- }
-
- public String getProductionDate() {
- return productionDate;
- }
-
- public String getPackagingDate() {
- return packagingDate;
- }
-
- public String getBestBeforeDate() {
- return bestBeforeDate;
- }
-
- public String getExpirationDate() {
- return expirationDate;
- }
-
- public String getWeight() {
- return weight;
- }
-
- public String getWeightType() {
- return weightType;
- }
-
- public String getWeightIncrement() {
- return weightIncrement;
- }
-
- public String getPrice() {
- return price;
- }
-
- public String getPriceIncrement() {
- return priceIncrement;
- }
-
- public String getPriceCurrency() {
- return priceCurrency;
- }
-
- public Map getUncommonAIs() {
- return uncommonAIs;
- }
-
- @Override
- public String getDisplayResult() {
- return String.valueOf(rawText);
- }
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/ExpandedProductResultParser.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/ExpandedProductResultParser.java
deleted file mode 100644
index a64aec275..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/ExpandedProductResultParser.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Copyright (C) 2010 ZXing authors
- *
- * Licensed 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.
- */
-
-/*
- * These authors would like to acknowledge the Spanish Ministry of Industry,
- * Tourism and Trade, for the support in the project TSI020301-2008-2
- * "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
- * Mobile Dynamic Environments", led by Treelogic
- * ( http://www.treelogic.com/ ):
- *
- * http://www.piramidepse.com/
- */
-
-package com.google.zxing.client.result;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import com.google.zxing.BarcodeFormat;
-import com.google.zxing.Result;
-
-/**
- * Parses strings of digits that represent a RSS Extended code.
- *
- * @author Antonio Manuel Benjumea Conde, Servinform, S.A.
- * @author AgustÃn Delgado, Servinform, S.A.
- */
-public final class ExpandedProductResultParser extends ResultParser {
-
- @Override
- public ExpandedProductParsedResult parse(Result result) {
- BarcodeFormat format = result.getBarcodeFormat();
- if (format != BarcodeFormat.RSS_EXPANDED) {
- // ExtendedProductParsedResult NOT created. Not a RSS Expanded barcode
- return null;
- }
- String rawText = getMassagedText(result);
-
- String productID = null;
- String sscc = null;
- String lotNumber = null;
- String productionDate = null;
- String packagingDate = null;
- String bestBeforeDate = null;
- String expirationDate = null;
- String weight = null;
- String weightType = null;
- String weightIncrement = null;
- String price = null;
- String priceIncrement = null;
- String priceCurrency = null;
- Map uncommonAIs = new HashMap<>();
-
- int i = 0;
-
- while (i < rawText.length()) {
- String ai = findAIvalue(i, rawText);
- if (ai == null) {
- // Error. Code doesn't match with RSS expanded pattern
- // ExtendedProductParsedResult NOT created. Not match with RSS Expanded pattern
- return null;
- }
- i += ai.length() + 2;
- String value = findValue(i, rawText);
- i += value.length();
-
- switch (ai) {
- case "00":
- sscc = value;
- break;
- case "01":
- productID = value;
- break;
- case "10":
- lotNumber = value;
- break;
- case "11":
- productionDate = value;
- break;
- case "13":
- packagingDate = value;
- break;
- case "15":
- bestBeforeDate = value;
- break;
- case "17":
- expirationDate = value;
- break;
- case "3100":
- case "3101":
- case "3102":
- case "3103":
- case "3104":
- case "3105":
- case "3106":
- case "3107":
- case "3108":
- case "3109":
- weight = value;
- weightType = ExpandedProductParsedResult.KILOGRAM;
- weightIncrement = ai.substring(3);
- break;
- case "3200":
- case "3201":
- case "3202":
- case "3203":
- case "3204":
- case "3205":
- case "3206":
- case "3207":
- case "3208":
- case "3209":
- weight = value;
- weightType = ExpandedProductParsedResult.POUND;
- weightIncrement = ai.substring(3);
- break;
- case "3920":
- case "3921":
- case "3922":
- case "3923":
- price = value;
- priceIncrement = ai.substring(3);
- break;
- case "3930":
- case "3931":
- case "3932":
- case "3933":
- if (value.length() < 4) {
- // The value must have more of 3 symbols (3 for currency and
- // 1 at least for the price)
- // ExtendedProductParsedResult NOT created. Not match with RSS Expanded pattern
- return null;
- }
- price = value.substring(3);
- priceCurrency = value.substring(0, 3);
- priceIncrement = ai.substring(3);
- break;
- default:
- // No match with common AIs
- uncommonAIs.put(ai, value);
- break;
- }
- }
-
- return new ExpandedProductParsedResult(rawText,
- productID,
- sscc,
- lotNumber,
- productionDate,
- packagingDate,
- bestBeforeDate,
- expirationDate,
- weight,
- weightType,
- weightIncrement,
- price,
- priceIncrement,
- priceCurrency,
- uncommonAIs);
- }
-
- private static String findAIvalue(int i, String rawText) {
- char c = rawText.charAt(i);
- // First character must be a open parenthesis.If not, ERROR
- if (c != '(') {
- return null;
- }
-
- CharSequence rawTextAux = rawText.substring(i + 1);
-
- StringBuilder buf = new StringBuilder();
- for (int index = 0; index < rawTextAux.length(); index++) {
- char currentChar = rawTextAux.charAt(index);
- if (currentChar == ')') {
- return buf.toString();
- } else if (currentChar >= '0' && currentChar <= '9') {
- buf.append(currentChar);
- } else {
- return null;
- }
- }
- return buf.toString();
- }
-
- private static String findValue(int i, String rawText) {
- StringBuilder buf = new StringBuilder();
- String rawTextAux = rawText.substring(i);
-
- for (int index = 0; index < rawTextAux.length(); index++) {
- char c = rawTextAux.charAt(index);
- if (c == '(') {
- // We look for a new AI. If it doesn't exist (ERROR), we coninue
- // with the iteration
- if (findAIvalue(index, rawTextAux) == null) {
- buf.append('(');
- } else {
- break;
- }
- } else {
- buf.append(c);
- }
- }
- return buf.toString();
- }
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/GeoParsedResult.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/GeoParsedResult.java
deleted file mode 100644
index 6eaad1ebb..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/GeoParsedResult.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed 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 com.google.zxing.client.result;
-
-/**
- * @author Sean Owen
- */
-public final class GeoParsedResult extends ParsedResult {
-
- private final double latitude;
- private final double longitude;
- private final double altitude;
- private final String query;
-
- GeoParsedResult(double latitude, double longitude, double altitude, String query) {
- super(ParsedResultType.GEO);
- this.latitude = latitude;
- this.longitude = longitude;
- this.altitude = altitude;
- this.query = query;
- }
-
- public String getGeoURI() {
- StringBuilder result = new StringBuilder();
- result.append("geo:");
- result.append(latitude);
- result.append(',');
- result.append(longitude);
- if (altitude > 0) {
- result.append(',');
- result.append(altitude);
- }
- if (query != null) {
- result.append('?');
- result.append(query);
- }
- return result.toString();
- }
-
- /**
- * @return latitude in degrees
- */
- public double getLatitude() {
- return latitude;
- }
-
- /**
- * @return longitude in degrees
- */
- public double getLongitude() {
- return longitude;
- }
-
- /**
- * @return altitude in meters. If not specified, in the geo URI, returns 0.0
- */
- public double getAltitude() {
- return altitude;
- }
-
- /**
- * @return query string associated with geo URI or null if none exists
- */
- public String getQuery() {
- return query;
- }
-
- @Override
- public String getDisplayResult() {
- StringBuilder result = new StringBuilder(20);
- result.append(latitude);
- result.append(", ");
- result.append(longitude);
- if (altitude > 0.0) {
- result.append(", ");
- result.append(altitude);
- result.append('m');
- }
- if (query != null) {
- result.append(" (");
- result.append(query);
- result.append(')');
- }
- return result.toString();
- }
-
-}
\ No newline at end of file
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/GeoResultParser.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/GeoResultParser.java
deleted file mode 100644
index fb9cb07d4..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/GeoResultParser.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed 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 com.google.zxing.client.result;
-
-import com.google.zxing.Result;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Parses a "geo:" URI result, which specifies a location on the surface of
- * the Earth as well as an optional altitude above the surface. See
- *
- * http://tools.ietf.org/html/draft-mayrhofer-geo-uri-00.
- *
- * @author Sean Owen
- */
-public final class GeoResultParser extends ResultParser {
-
- private static final Pattern GEO_URL_PATTERN =
- Pattern.compile("geo:([\\-0-9.]+),([\\-0-9.]+)(?:,([\\-0-9.]+))?(?:\\?(.*))?", Pattern.CASE_INSENSITIVE);
-
- @Override
- public GeoParsedResult parse(Result result) {
- CharSequence rawText = getMassagedText(result);
- Matcher matcher = GEO_URL_PATTERN.matcher(rawText);
- if (!matcher.matches()) {
- return null;
- }
-
- String query = matcher.group(4);
-
- double latitude;
- double longitude;
- double altitude;
- try {
- latitude = Double.parseDouble(matcher.group(1));
- if (latitude > 90.0 || latitude < -90.0) {
- return null;
- }
- longitude = Double.parseDouble(matcher.group(2));
- if (longitude > 180.0 || longitude < -180.0) {
- return null;
- }
- if (matcher.group(3) == null) {
- altitude = 0.0;
- } else {
- altitude = Double.parseDouble(matcher.group(3));
- if (altitude < 0.0) {
- return null;
- }
- }
- } catch (NumberFormatException ignored) {
- return null;
- }
- return new GeoParsedResult(latitude, longitude, altitude, query);
- }
-
-}
\ No newline at end of file
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/ISBNParsedResult.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/ISBNParsedResult.java
deleted file mode 100644
index 51b63ff82..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/ISBNParsedResult.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed 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 com.google.zxing.client.result;
-
-/**
- * @author jbreiden@google.com (Jeff Breidenbach)
- */
-public final class ISBNParsedResult extends ParsedResult {
-
- private final String isbn;
-
- ISBNParsedResult(String isbn) {
- super(ParsedResultType.ISBN);
- this.isbn = isbn;
- }
-
- public String getISBN() {
- return isbn;
- }
-
- @Override
- public String getDisplayResult() {
- return isbn;
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/ISBNResultParser.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/ISBNResultParser.java
deleted file mode 100644
index e957dd02b..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/ISBNResultParser.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed 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 com.google.zxing.client.result;
-
-import com.google.zxing.BarcodeFormat;
-import com.google.zxing.Result;
-
-/**
- * Parses strings of digits that represent a ISBN.
- *
- * @author jbreiden@google.com (Jeff Breidenbach)
- */
-public final class ISBNResultParser extends ResultParser {
-
- /**
- * See ISBN-13 For Dummies
- */
- @Override
- public ISBNParsedResult parse(Result result) {
- BarcodeFormat format = result.getBarcodeFormat();
- if (format != BarcodeFormat.EAN_13) {
- return null;
- }
- String rawText = getMassagedText(result);
- int length = rawText.length();
- if (length != 13) {
- return null;
- }
- if (!rawText.startsWith("978") && !rawText.startsWith("979")) {
- return null;
- }
-
- return new ISBNParsedResult(rawText);
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/ParsedResult.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/ParsedResult.java
deleted file mode 100644
index 17660e2e6..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/ParsedResult.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing.client.result;
-
-/**
- * Abstract class representing the result of decoding a barcode, as more than
- * a String -- as some type of structured data. This might be a subclass which represents
- * a URL, or an e-mail address. {@link ResultParser#parseResult(com.google.zxing.Result)} will turn a raw
- * decoded string into the most appropriate type of structured representation.
- *
- * Thanks to Jeff Griffin for proposing rewrite of these classes that relies less
- * on exception-based mechanisms during parsing.
- *
- * @author Sean Owen
- */
-public abstract class ParsedResult {
-
- private final ParsedResultType type;
-
- protected ParsedResult(ParsedResultType type) {
- this.type = type;
- }
-
- public final ParsedResultType getType() {
- return type;
- }
-
- public abstract String getDisplayResult();
-
- @Override
- public final String toString() {
- return getDisplayResult();
- }
-
- public static void maybeAppend(String value, StringBuilder result) {
- if (value != null && !value.isEmpty()) {
- // Don't add a newline before the first value
- if (result.length() > 0) {
- result.append('\n');
- }
- result.append(value);
- }
- }
-
- public static void maybeAppend(String[] values, StringBuilder result) {
- if (values != null) {
- for (String value : values) {
- maybeAppend(value, result);
- }
- }
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/ParsedResultType.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/ParsedResultType.java
deleted file mode 100644
index c74d54594..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/ParsedResultType.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2010 ZXing authors
- *
- * Licensed 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 com.google.zxing.client.result;
-
-/**
- * Represents the type of data encoded by a barcode -- from plain text, to a
- * URI, to an e-mail address, etc.
- *
- * @author Sean Owen
- */
-public enum ParsedResultType {
-
- ADDRESSBOOK,
- EMAIL_ADDRESS,
- PRODUCT,
- URI,
- TEXT,
- GEO,
- TEL,
- SMS,
- CALENDAR,
- WIFI,
- ISBN,
- VIN,
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/ProductParsedResult.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/ProductParsedResult.java
deleted file mode 100644
index 95cfad016..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/ProductParsedResult.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing.client.result;
-
-/**
- * @author dswitkin@google.com (Daniel Switkin)
- */
-public final class ProductParsedResult extends ParsedResult {
-
- private final String productID;
- private final String normalizedProductID;
-
- ProductParsedResult(String productID) {
- this(productID, productID);
- }
-
- ProductParsedResult(String productID, String normalizedProductID) {
- super(ParsedResultType.PRODUCT);
- this.productID = productID;
- this.normalizedProductID = normalizedProductID;
- }
-
- public String getProductID() {
- return productID;
- }
-
- public String getNormalizedProductID() {
- return normalizedProductID;
- }
-
- @Override
- public String getDisplayResult() {
- return productID;
- }
-
-}
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/ProductResultParser.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/ProductResultParser.java
deleted file mode 100644
index bed1a7dc1..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/ProductResultParser.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing.client.result;
-
-import com.google.zxing.BarcodeFormat;
-import com.google.zxing.Result;
-import com.google.zxing.oned.UPCEReader;
-
-/**
- * Parses strings of digits that represent a UPC code.
- *
- * @author dswitkin@google.com (Daniel Switkin)
- */
-public final class ProductResultParser extends ResultParser {
-
- // Treat all UPC and EAN variants as UPCs, in the sense that they are all product barcodes.
- @Override
- public ProductParsedResult parse(Result result) {
- BarcodeFormat format = result.getBarcodeFormat();
- if (!(format == BarcodeFormat.UPC_A || format == BarcodeFormat.UPC_E ||
- format == BarcodeFormat.EAN_8 || format == BarcodeFormat.EAN_13)) {
- return null;
- }
- String rawText = getMassagedText(result);
- if (!isStringOfDigits(rawText, rawText.length())) {
- return null;
- }
- // Not actually checking the checksum again here
-
- String normalizedProductID;
- // Expand UPC-E for purposes of searching
- if (format == BarcodeFormat.UPC_E && rawText.length() == 8) {
- normalizedProductID = UPCEReader.convertUPCEtoUPCA(rawText);
- } else {
- normalizedProductID = rawText;
- }
-
- return new ProductParsedResult(rawText, normalizedProductID);
- }
-
-}
\ No newline at end of file
diff --git a/extern/zxing-core/src/main/java/com/google/zxing/client/result/ResultParser.java b/extern/zxing-core/src/main/java/com/google/zxing/client/result/ResultParser.java
deleted file mode 100644
index c86f1f7fc..000000000
--- a/extern/zxing-core/src/main/java/com/google/zxing/client/result/ResultParser.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Copyright 2007 ZXing authors
- *
- * Licensed 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 com.google.zxing.client.result;
-
-import com.google.zxing.Result;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-/**
- * Abstract class representing the result of decoding a barcode, as more than
- * a String -- as some type of structured data. This might be a subclass which represents
- * a URL, or an e-mail address. {@link #parseResult(Result)} will turn a raw
- * decoded string into the most appropriate type of structured representation.
- *
- * Thanks to Jeff Griffin for proposing rewrite of these classes that relies less
- * on exception-based mechanisms during parsing.
- *
- * @author Sean Owen
- */
-public abstract class ResultParser {
-
- private static final ResultParser[] PARSERS = {
- new BookmarkDoCoMoResultParser(),
- new AddressBookDoCoMoResultParser(),
- new EmailDoCoMoResultParser(),
- new AddressBookAUResultParser(),
- new VCardResultParser(),
- new BizcardResultParser(),
- new VEventResultParser(),
- new EmailAddressResultParser(),
- new SMTPResultParser(),
- new TelResultParser(),
- new SMSMMSResultParser(),
- new SMSTOMMSTOResultParser(),
- new GeoResultParser(),
- new WifiResultParser(),
- new URLTOResultParser(),
- new URIResultParser(),
- new ISBNResultParser(),
- new ProductResultParser(),
- new ExpandedProductResultParser(),
- new VINResultParser(),
- };
-
- private static final Pattern DIGITS = Pattern.compile("\\d+");
- private static final Pattern AMPERSAND = Pattern.compile("&");
- private static final Pattern EQUALS = Pattern.compile("=");
- private static final String BYTE_ORDER_MARK = "\ufeff";
-
- /**
- * Attempts to parse the raw {@link Result}'s contents as a particular type
- * of information (email, URL, etc.) and return a {@link ParsedResult} encapsulating
- * the result of parsing.
- *
- * @param theResult the raw {@link Result} to parse
- * @return {@link ParsedResult} encapsulating the parsing result
- */
- public abstract ParsedResult parse(Result theResult);
-
- protected static String getMassagedText(Result result) {
- String text = result.getText();
- if (text.startsWith(BYTE_ORDER_MARK)) {
- text = text.substring(1);
- }
- return text;
- }
-
- public static ParsedResult parseResult(Result theResult) {
- for (ResultParser parser : PARSERS) {
- ParsedResult result = parser.parse(theResult);
- if (result != null) {
- return result;
- }
- }
- return new TextParsedResult(theResult.getText(), null);
- }
-
- protected static void maybeAppend(String value, StringBuilder result) {
- if (value != null) {
- result.append('\n');
- result.append(value);
- }
- }
-
- protected static void maybeAppend(String[] value, StringBuilder result) {
- if (value != null) {
- for (String s : value) {
- result.append('\n');
- result.append(s);
- }
- }
- }
-
- protected static String[] maybeWrap(String value) {
- return value == null ? null : new String[] { value };
- }
-
- protected static String unescapeBackslash(String escaped) {
- int backslash = escaped.indexOf('\\');
- if (backslash < 0) {
- return escaped;
- }
- int max = escaped.length();
- StringBuilder unescaped = new StringBuilder(max - 1);
- unescaped.append(escaped.toCharArray(), 0, backslash);
- boolean nextIsEscaped = false;
- for (int i = backslash; i < max; i++) {
- char c = escaped.charAt(i);
- if (nextIsEscaped || c != '\\') {
- unescaped.append(c);
- nextIsEscaped = false;
- } else {
- nextIsEscaped = true;
- }
- }
- return unescaped.toString();
- }
-
- protected static int parseHexDigit(char c) {
- if (c >= '0' && c <= '9') {
- return c - '0';
- }
- if (c >= 'a' && c <= 'f') {
- return 10 + (c - 'a');
- }
- if (c >= 'A' && c <= 'F') {
- return 10 + (c - 'A');
- }
- return -1;
- }
-
- protected static boolean isStringOfDigits(CharSequence value, int length) {
- return value != null && length > 0 && length == value.length() && DIGITS.matcher(value).matches();
- }
-
- protected static boolean isSubstringOfDigits(CharSequence value, int offset, int length) {
- if (value == null || length <= 0) {
- return false;
- }
- int max = offset + length;
- return value.length() >= max && DIGITS.matcher(value.subSequence(offset, max)).matches();
- }
-
- static Map parseNameValuePairs(String uri) {
- int paramStart = uri.indexOf('?');
- if (paramStart < 0) {
- return null;
- }
- Map result = new HashMap<>(3);
- for (String keyValue : AMPERSAND.split(uri.substring(paramStart + 1))) {
- appendKeyValue(keyValue, result);
- }
- return result;
- }
-
- private static void appendKeyValue(CharSequence keyValue, Map result) {
- String[] keyValueTokens = EQUALS.split(keyValue, 2);
- if (keyValueTokens.length == 2) {
- String key = keyValueTokens[0];
- String value = keyValueTokens[1];
- try {
- value = urlDecode(value);
- result.put(key, value);
- } catch (IllegalArgumentException iae) {
- // continue; invalid data such as an escape like %0t
- }
- }
- }
-
- static String urlDecode(String encoded) {
- try {
- return URLDecoder.decode(encoded, "UTF-8");
- } catch (UnsupportedEncodingException uee) {
- throw new IllegalStateException(uee); // can't happen
- }
- }
-
- static String[] matchPrefixedField(String prefix, String rawText, char endChar, boolean trim) {
- List