Merge pull request #1098 from AntennaPod/version_1.3

Version 1.3 merging back in to develop so we're all on the same page.
This commit is contained in:
Tom Hennen 2015-08-15 18:43:19 -04:00
commit fd2633e42f
4 changed files with 48 additions and 62 deletions

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="de.danoeh.antennapod" package="de.danoeh.antennapod"
android:versionCode="1030006" android:versionCode="1030100"
android:versionName="1.3"> android:versionName="1.3.1">
<!-- <!--
Version code schema: Version code schema:
"1.2.3-SNAPSHOT" -> 1020300 "1.2.3-SNAPSHOT" -> 1020300

View File

@ -1,13 +1,11 @@
package de.danoeh.antennapod; package de.danoeh.antennapod;
import android.app.Application; import android.app.Application;
import android.content.Intent;
import android.content.res.Configuration; import android.content.res.Configuration;
import de.danoeh.antennapod.core.feed.EventDistributor; import de.danoeh.antennapod.core.feed.EventDistributor;
import de.danoeh.antennapod.core.preferences.PlaybackPreferences; import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
import de.danoeh.antennapod.core.preferences.UserPreferences; import de.danoeh.antennapod.core.preferences.UserPreferences;
import de.danoeh.antennapod.core.service.FeedMediaSizeService;
import de.danoeh.antennapod.core.util.NetworkUtils; import de.danoeh.antennapod.core.util.NetworkUtils;
import de.danoeh.antennapod.spa.SPAUtil; import de.danoeh.antennapod.spa.SPAUtil;
@ -47,7 +45,7 @@ public class PodcastApp extends Application {
SPAUtil.sendSPAppsQueryFeedsIntent(this); SPAUtil.sendSPAppsQueryFeedsIntent(this);
startService(new Intent(this, FeedMediaSizeService.class)); // startService(new Intent(this, FeedMediaSizeService.class));
} }
public static float getLogicalDensity() { public static float getLogicalDensity() {

View File

@ -4,19 +4,6 @@ import android.app.IntentService;
import android.content.Intent; import android.content.Intent;
import android.util.Log; import android.util.Log;
import java.io.File;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import de.danoeh.antennapod.core.event.FeedMediaEvent;
import de.danoeh.antennapod.core.feed.FeedMedia;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.core.util.NetworkUtils;
import de.greenrobot.event.EventBus;
public class FeedMediaSizeService extends IntentService { public class FeedMediaSizeService extends IntentService {
private final static String TAG = "FeedMediaSizeService"; private final static String TAG = "FeedMediaSizeService";
@ -28,49 +15,50 @@ public class FeedMediaSizeService extends IntentService {
@Override @Override
protected void onHandleIntent(Intent intent) { protected void onHandleIntent(Intent intent) {
Log.d(TAG, "onHandleIntent()"); Log.d(TAG, "onHandleIntent()");
if(false == NetworkUtils.isDownloadAllowed()) {
return; return;
} // if(false == NetworkUtils.isDownloadAllowed()) {
List<FeedMedia> list = DBReader.getFeedMediaUnknownSize(this); // return;
for (FeedMedia media : list) { // }
Log.d(TAG, "Getting size currently " + media.getSize() + " for " + media.getDownload_url()); // List<FeedMedia> list = DBReader.getFeedMediaUnknownSize(this);
if(false == NetworkUtils.isDownloadAllowed()) { // for (FeedMedia media : list) {
return; // Log.d(TAG, "Getting size currently " + media.getSize() + " for " + media.getDownload_url());
} // if(false == NetworkUtils.isDownloadAllowed()) {
long size = Integer.MIN_VALUE; // return;
if (media.isDownloaded()) { // }
File mediaFile = new File(media.getLocalMediaUrl()); // long size = Integer.MIN_VALUE;
if(mediaFile.exists()) { // if (media.isDownloaded()) {
size = mediaFile.length(); // File mediaFile = new File(media.getLocalMediaUrl());
} // if(mediaFile.exists()) {
} else if (false == media.checkedOnSizeButUnknown()) { // size = mediaFile.length();
// only query the network if we haven't already checked // }
HttpURLConnection conn = null; // } else if (false == media.checkedOnSizeButUnknown()) {
try { // // only query the network if we haven't already checked
URL url = new URL(media.getDownload_url()); // HttpURLConnection conn = null;
conn = (HttpURLConnection) url.openConnection(); // try {
conn.setRequestProperty("Accept-Encoding", ""); // URL url = new URL(media.getDownload_url());
conn.setRequestMethod("HEAD"); // conn = (HttpURLConnection) url.openConnection();
size = conn.getContentLength(); // conn.setRequestProperty("Accept-Encoding", "");
} catch (IOException e) { // conn.setRequestMethod("HEAD");
Log.d(TAG, media.getDownload_url()); // size = conn.getContentLength();
e.printStackTrace(); // } catch (IOException e) {
} finally { // Log.d(TAG, media.getDownload_url());
if (conn != null) { // e.printStackTrace();
conn.disconnect(); // } finally {
} // if (conn != null) {
} // conn.disconnect();
} // }
if (size <= 0) { // }
// they didn't tell us the size, but we don't want to keep querying on it // }
media.setCheckedOnSizeButUnknown(); // if (size <= 0) {
} else { // // they didn't tell us the size, but we don't want to keep querying on it
media.setSize(size); // media.setCheckedOnSizeButUnknown();
} // } else {
Log.d(TAG, "Size now: " + media.getSize()); // media.setSize(size);
DBWriter.setFeedMedia(this, media); // }
EventBus.getDefault().post(FeedMediaEvent.update(media)); // Log.d(TAG, "Size now: " + media.getSize());
} // DBWriter.setFeedMedia(this, media);
// EventBus.getDefault().post(FeedMediaEvent.update(media));
// }
} }
} }

View File

@ -578,7 +578,7 @@ public final class DBTasks {
EventDistributor.getInstance().sendFeedUpdateBroadcast(); EventDistributor.getInstance().sendFeedUpdateBroadcast();
context.startService(new Intent(context, FeedMediaSizeService.class)); // context.startService(new Intent(context, FeedMediaSizeService.class));
return resultFeeds; return resultFeeds;
} }