Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes bug on Android 4.x where finished document downloads wouldn't a…

…ppear under my documents.
  • Loading branch information...
commit 0c88fa6bee6373ec2008a69ed4be20d3f52818cd 1 parent ca8a0ec
@gubatron gubatron authored
View
2  changelog.txt
@@ -17,6 +17,8 @@ FrostWire 1.0.6 - 03/28/2013
which pass filepath uris instead of android provider uris.
- Fixes double audio playback issue with third party media playing apps.
- Fixes bug where the app would force close and restart on phones without SD cards.
+ - Fixes bug on Android 4.x where finished document downloads wouldn't appear under
+ documents.
FrostWire 1.0.5
- Kindle Fire HD Compatible.
View
30 src/gui/com/frostwire/android/gui/UniversalScanner.java
@@ -21,8 +21,9 @@
import java.io.File;
import java.util.Arrays;
import java.util.Collection;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import android.content.ContentResolver;
import android.content.ContentValues;
@@ -36,6 +37,7 @@
import com.frostwire.android.core.ConfigurationManager;
import com.frostwire.android.core.Constants;
import com.frostwire.android.core.FileDescriptor;
+import com.frostwire.android.core.MediaType;
import com.frostwire.android.core.providers.UniversalStore;
import com.frostwire.android.core.providers.UniversalStore.Documents;
import com.frostwire.android.core.providers.UniversalStore.Documents.DocumentsColumns;
@@ -50,7 +52,7 @@
*/
final class UniversalScanner {
- private static final Logger LOG = Logger.getLogger(UniversalScanner.class.getName());
+ private static final Logger LOG = LoggerFactory.getLogger(UniversalScanner.class);
private final Context context;
@@ -117,7 +119,7 @@ private boolean documentExists(String filePath, long size) {
c = cr.query(UniversalStore.Documents.Media.CONTENT_URI, new String[] { DocumentsColumns._ID }, DocumentsColumns.DATA + "=?" + " AND " + DocumentsColumns.SIZE + "=?", new String[] { filePath, String.valueOf(size) }, null);
result = c != null && c.getCount() != 0;
} catch (Throwable e) {
- LOG.log(Level.WARNING, "Error detecting if file exists: " + filePath, e);
+ LOG.warn("Error detecting if file exists: " + filePath, e);
} finally {
if (c != null) {
c.close();
@@ -143,7 +145,7 @@ public void scan() {
connection = new MediaScannerConnection(context, this);
connection.connect();
} catch (Throwable e) {
- LOG.log(Level.WARNING, "Error scanning file with android internal scanner, one retry", e);
+ LOG.warn("Error scanning file with android internal scanner, one retry", e);
SystemClock.sleep(1000);
connection = new MediaScannerConnection(context, this);
connection.connect();
@@ -159,14 +161,13 @@ public void onMediaScannerConnected() {
}
}
} catch (IllegalStateException e) {
- LOG.log(Level.WARNING, "Scanner service wasn't really connected or service was null", e);
+ LOG.warn("Scanner service wasn't really connected or service was null", e);
//should we try to connect again? don't want to end up in endless loop
//maybe destroy connection?
}
}
public void onScanCompleted(String path, Uri uri) {
-
/** This will work if onScanCompleted is invoked after scanFile finishes. */
numCompletedScans++;
if (numCompletedScans == files.size()) {
@@ -174,16 +175,21 @@ public void onScanCompleted(String path, Uri uri) {
}
if (uri != null) {
- //Log.d(TAG, "Scanned new file: " + uri);
- shareFinishedDownload(Librarian.instance().getFileDescriptor(uri));
+ MediaType mt = MediaType.getMediaTypeForExtension(FilenameUtils.getExtension(path));
+ if (mt != null && mt.getId() == Constants.FILE_TYPE_DOCUMENTS) {
+ scanDocument(path);
+ } else {
+ //LOG.debug("Scanned new file: " + uri);
+ shareFinishedDownload(Librarian.instance().getFileDescriptor(uri));
+ }
} else {
if (path.endsWith(".apk")) {
- //Log.d(TAG, "Can't scan apk for security concerns: " + path);
+ //LOG.debug("Can't scan apk for security concerns: " + path);
} else {
scanDocument(path);
- //Log.d(TAG, "Scanned new file as document: " + path);
+ //LOG.debug("Scanned new file as document: " + path);
}
}
}
}
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.