Upgrade to latest versions
This commit is contained in:
parent
0c973e3ea7
commit
810b2c2df5
|
@ -14,7 +14,7 @@ dependencies {
|
|||
compile "com.android.support:gridlayout-v7:$supportVersion"
|
||||
compile "com.android.support:cardview-v7:$supportVersion"
|
||||
compile "com.android.support:design:$supportVersion"
|
||||
compile "com.android.support:recyclerview-v7:22.2.+"
|
||||
compile "com.android.support:recyclerview-v7:$supportVersion"
|
||||
compile "org.apache.commons:commons-lang3:$commonslangVersion"
|
||||
compile("org.shredzone.flattr4j:flattr4j-core:$flattr4jVersion") {
|
||||
exclude group: "org.json", module: "json"
|
||||
|
@ -31,9 +31,12 @@ dependencies {
|
|||
compile "io.reactivex:rxjava:$rxJavaVersion"
|
||||
// And ProGuard rules for RxJava!
|
||||
compile "com.artemzin.rxjava:proguard-rules:$rxJavaRulesVersion"
|
||||
compile "com.joanzapata.iconify:android-iconify-fontawesome:2.1.0"
|
||||
compile "com.afollestad:material-dialogs:0.7.8.1"
|
||||
compile "com.yqritc:recyclerview-flexibledivider:1.2.6"
|
||||
compile "com.joanzapata.iconify:android-iconify-fontawesome:$iconifyFontawesomeVersion"
|
||||
compile "com.joanzapata.iconify:android-iconify-material:$iconifyFontawesomeVersion"
|
||||
compile("com.github.afollestad.material-dialogs:commons:$materialDialogsVersion") {
|
||||
transitive = true
|
||||
}
|
||||
compile "com.yqritc:recyclerview-flexibledivider:$recyclerviewFlexibledividerVersion"
|
||||
|
||||
compile "com.github.AntennaPod:AntennaPod-AudioPlayer:$audioPlayerVersion"
|
||||
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
package de.test.antennapod.ui;
|
||||
|
||||
import android.test.InstrumentationTestCase;
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
import org.apache.http.HttpStatus;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
|
||||
import de.danoeh.antennapod.core.feed.Feed;
|
||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
||||
|
||||
/**
|
||||
* Test for the UITestUtils. Makes sure that all URLs are reachable and that the class does not cause any crashes.
|
||||
*/
|
||||
|
@ -55,7 +55,7 @@ public class UITestUtilsTest extends InstrumentationTestCase {
|
|||
conn.setRequestMethod("GET");
|
||||
conn.connect();
|
||||
int rc = conn.getResponseCode();
|
||||
assertEquals(HttpStatus.SC_OK, rc);
|
||||
assertEquals(HttpURLConnection.HTTP_OK, rc);
|
||||
conn.disconnect();
|
||||
}
|
||||
|
||||
|
|
|
@ -2,21 +2,20 @@ package de.danoeh.antennapod.fragment;
|
|||
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.GridView;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import com.squareup.okhttp.OkHttpClient;
|
||||
import com.squareup.okhttp.Request;
|
||||
import com.squareup.okhttp.Response;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
@ -30,13 +29,23 @@ import java.util.List;
|
|||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.OnlineFeedViewActivity;
|
||||
import de.danoeh.antennapod.adapter.itunes.ItunesAdapter;
|
||||
import de.danoeh.antennapod.core.ClientConfig;
|
||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.core.service.download.AntennapodHttpClient;
|
||||
import rx.Observable;
|
||||
import rx.Subscription;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
import static de.danoeh.antennapod.adapter.itunes.ItunesAdapter.Podcast;
|
||||
|
||||
//Searches iTunes store for given string and displays results in a list
|
||||
public class ItunesSearchFragment extends Fragment {
|
||||
final String TAG = "ItunesSearchFragment";
|
||||
|
||||
private static final String TAG = "ItunesSearchFragment";
|
||||
|
||||
private static final String API_URL = "https://itunes.apple.com/search?media=podcast&term=%s";
|
||||
|
||||
/**
|
||||
* Search input field
|
||||
*/
|
||||
|
@ -52,6 +61,8 @@ public class ItunesSearchFragment extends Fragment {
|
|||
*/
|
||||
private List<Podcast> searchResults;
|
||||
|
||||
private Subscription subscription;
|
||||
|
||||
/**
|
||||
* Replace adapter data with provided search results from SearchTask.
|
||||
* @param result List of Podcast objects containing search results
|
||||
|
@ -117,7 +128,7 @@ public class ItunesSearchFragment extends Fragment {
|
|||
//This prevents onQueryTextSubmit() from being called twice when keyboard is used
|
||||
//to submit the query.
|
||||
searchView.clearFocus();
|
||||
new SearchTask(s).execute();
|
||||
search(s);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -137,77 +148,59 @@ public class ItunesSearchFragment extends Fragment {
|
|||
return view;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search the iTunes store for podcasts using the given query
|
||||
*/
|
||||
class SearchTask extends AsyncTask<Void,Void,Void> {
|
||||
/**
|
||||
* Incomplete iTunes API search URL
|
||||
*/
|
||||
final String apiUrl = "https://itunes.apple.com/search?media=podcast&term=%s";
|
||||
|
||||
/**
|
||||
* Search terms
|
||||
*/
|
||||
final String query;
|
||||
|
||||
/**
|
||||
* Search result
|
||||
*/
|
||||
final List<Podcast> taskData = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param query Search string
|
||||
*/
|
||||
public SearchTask(String query) {
|
||||
String encodedQuery = null;
|
||||
try {
|
||||
encodedQuery = URLEncoder.encode(query, "UTF-8");
|
||||
} catch(UnsupportedEncodingException e) {
|
||||
// this won't ever be thrown
|
||||
}
|
||||
if(encodedQuery != null) {
|
||||
this.query = encodedQuery;
|
||||
} else {
|
||||
this.query = query; // failsafe
|
||||
}
|
||||
private void search(String query) {
|
||||
if (subscription != null) {
|
||||
subscription.unsubscribe();
|
||||
}
|
||||
subscription = rx.Observable.create((Observable.OnSubscribe<List<Podcast>>) subscriber -> {
|
||||
String encodedQuery = null;
|
||||
try {
|
||||
encodedQuery = URLEncoder.encode(query, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// this won't ever be thrown
|
||||
}
|
||||
if (encodedQuery == null) {
|
||||
encodedQuery = query; // failsafe
|
||||
}
|
||||
|
||||
//Get the podcast data
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
//Spaces in the query need to be replaced with '+' character.
|
||||
String formattedUrl = String.format(API_URL, query).replace(' ', '+');
|
||||
|
||||
//Spaces in the query need to be replaced with '+' character.
|
||||
String formattedUrl = String.format(apiUrl, query).replace(' ', '+');
|
||||
OkHttpClient client = AntennapodHttpClient.getHttpClient();
|
||||
Request.Builder httpReq = new Request.Builder()
|
||||
.url(formattedUrl)
|
||||
.header("User-Agent", ClientConfig.USER_AGENT);
|
||||
List<Podcast> podcasts = new ArrayList<>();
|
||||
try {
|
||||
Response response = client.newCall(httpReq.build()).execute();
|
||||
|
||||
HttpClient client = new DefaultHttpClient();
|
||||
HttpGet get = new HttpGet(formattedUrl);
|
||||
if(response.isSuccessful()) {
|
||||
String resultString = response.body().string();
|
||||
JSONObject result = new JSONObject(resultString);
|
||||
JSONArray j = result.getJSONArray("results");
|
||||
|
||||
try {
|
||||
HttpResponse response = client.execute(get);
|
||||
String resultString = EntityUtils.toString(response.getEntity());
|
||||
JSONObject result = new JSONObject(resultString);
|
||||
JSONArray j = result.getJSONArray("results");
|
||||
|
||||
for (int i = 0; i < j.length(); i++){
|
||||
JSONObject podcastJson = j.getJSONObject(i);
|
||||
Podcast podcast = new Podcast(podcastJson);
|
||||
taskData.add(podcast);
|
||||
}
|
||||
|
||||
} catch (IOException | JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
//Save the data and update the list
|
||||
@Override
|
||||
protected void onPostExecute(Void aVoid) {
|
||||
super.onPostExecute(aVoid);
|
||||
updateData(taskData);
|
||||
}
|
||||
for (int i = 0; i < j.length(); i++) {
|
||||
JSONObject podcastJson = j.getJSONObject(i);
|
||||
Podcast podcast = new Podcast(podcastJson);
|
||||
podcasts.add(podcast);
|
||||
}
|
||||
}
|
||||
else {
|
||||
subscriber.onError(new IOException("Unexpected error: " + response));
|
||||
}
|
||||
} catch (IOException | JSONException e) {
|
||||
Log.e(TAG, Log.getStackTraceString(e));
|
||||
}
|
||||
subscriber.onNext(podcasts);
|
||||
subscriber.onCompleted();
|
||||
})
|
||||
.subscribeOn(Schedulers.newThread())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(podcasts -> {
|
||||
updateData(podcasts);
|
||||
}, error -> {
|
||||
Log.e(TAG, Log.getStackTraceString(error));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
17
build.gradle
17
build.gradle
|
@ -6,7 +6,7 @@ buildscript {
|
|||
}
|
||||
dependencies {
|
||||
classpath "com.android.tools.build:gradle:1.5.0"
|
||||
classpath "me.tatarka:gradle-retrolambda:3.2.3"
|
||||
classpath "me.tatarka:gradle-retrolambda:3.2.4"
|
||||
classpath "me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2"
|
||||
|
||||
// Exclude the version that the android plugin depends on.
|
||||
|
@ -36,27 +36,30 @@ subprojects {
|
|||
}
|
||||
|
||||
project.ext {
|
||||
compileSdkVersion = 22
|
||||
buildToolsVersion = "22.0.1"
|
||||
compileSdkVersion = 23
|
||||
buildToolsVersion = "23.0.2"
|
||||
minSdkVersion = 10
|
||||
targetSdkVersion = 22
|
||||
targetSdkVersion = 23
|
||||
|
||||
supportVersion = "22.2.1"
|
||||
supportVersion = "23.1.1"
|
||||
commonsioVersion = "2.4"
|
||||
commonslangVersion = "3.4"
|
||||
eventbusVersion = "2.4.0"
|
||||
flattr4jVersion = "2.12"
|
||||
glideVersion = "3.6.1"
|
||||
jsoupVersion = "1.7.3"
|
||||
iconifyFontawesomeVersion = "2.1.1"
|
||||
materialDialogsVersion = "0.8.5.1@aar"
|
||||
recyclerviewFlexibledividerVersion = "1.2.6"
|
||||
rxAndroidVersion = "1.0.1"
|
||||
rxJavaVersion = "1.0.16"
|
||||
rxJavaRulesVersion = "1.0.16.1"
|
||||
okhttpVersion = "2.5.0"
|
||||
okhttpVersion = "2.6.0"
|
||||
okioVersion = "1.6.0"
|
||||
|
||||
audioPlayerVersion = "v1.0.7"
|
||||
}
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion = "2.4"
|
||||
gradleVersion = "2.9"
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ dependencies {
|
|||
exclude group: "org.json", module: "json"
|
||||
}
|
||||
compile "commons-io:commons-io:$commonsioVersion"
|
||||
compile "com.jayway.android.robotium:robotium-solo:5.5.2"
|
||||
compile "com.jayway.android.robotium:robotium-solo:5.5.3"
|
||||
compile "org.jsoup:jsoup:$jsoupVersion"
|
||||
compile "com.github.bumptech.glide:glide:$glideVersion"
|
||||
compile "com.github.bumptech.glide:okhttp-integration:1.3.1"
|
||||
|
|
|
@ -10,8 +10,6 @@ import com.squareup.okhttp.RequestBody;
|
|||
import com.squareup.okhttp.Response;
|
||||
import com.squareup.okhttp.ResponseBody;
|
||||
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.apache.http.client.ClientProtocolException;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
@ -19,6 +17,7 @@ import org.json.JSONObject;
|
|||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
|
@ -602,10 +601,7 @@ public class GpodnetService {
|
|||
checkStatusCode(response);
|
||||
body = response.body();
|
||||
result = getStringFromResponseBody(body);
|
||||
} catch (ClientProtocolException e) {
|
||||
e.printStackTrace();
|
||||
throw new GpodnetServiceException(e);
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new GpodnetServiceException(e);
|
||||
} finally {
|
||||
|
@ -652,12 +648,12 @@ public class GpodnetService {
|
|||
private void checkStatusCode(@NonNull Response response)
|
||||
throws GpodnetServiceException {
|
||||
int responseCode = response.code();
|
||||
if (responseCode != HttpStatus.SC_OK) {
|
||||
if (responseCode == HttpStatus.SC_UNAUTHORIZED) {
|
||||
if (responseCode != HttpURLConnection.HTTP_OK) {
|
||||
if (responseCode == HttpURLConnection.HTTP_UNAUTHORIZED) {
|
||||
throw new GpodnetServiceAuthenticationException("Wrong username or password");
|
||||
} else {
|
||||
throw new GpodnetServiceBadStatusCodeException(
|
||||
"Bad response code: " + responseCode, responseCode);
|
||||
throw new GpodnetServiceBadStatusCodeException("Bad response code: "
|
||||
+ responseCode, responseCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,54 +0,0 @@
|
|||
package de.danoeh.antennapod.core.service.download;
|
||||
|
||||
import android.util.Log;
|
||||
import de.danoeh.antennapod.core.BuildConfig;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.impl.client.DefaultRedirectHandler;
|
||||
import org.apache.http.protocol.HttpContext;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
public class APRedirectHandler extends DefaultRedirectHandler {
|
||||
// Identifier for logger
|
||||
private static final String TAG = "APRedirectHandler";
|
||||
// Header field, which has to be potentially fixed
|
||||
private static final String LOC = "Location";
|
||||
// Regular expressions for character strings, which should not appear in URLs
|
||||
private static final String CHi[] = { "\\{", "\\}", "\\|", "\\\\", "\\^", "~", "\\[", "\\]", "\\`"};
|
||||
private static final String CHo[] = { "%7B", "%7D", "%7C", "%5C", "%5E", "%7E", "%5B", "%5D", "%60"};
|
||||
|
||||
/**
|
||||
* Workaround for broken URLs in redirection.
|
||||
* Proper solution involves LaxRedirectStrategy() which is not available in
|
||||
* current API yet.
|
||||
*/
|
||||
@Override
|
||||
public URI getLocationURI(HttpResponse response, HttpContext context)
|
||||
throws org.apache.http.ProtocolException {
|
||||
|
||||
Header h[] = response.getHeaders(LOC);
|
||||
if (h.length>0) {
|
||||
String s = h[0].getValue();
|
||||
|
||||
// Fix broken URL
|
||||
for(int i=0; i<CHi.length;i++)
|
||||
s = s.replaceAll(CHi[i], CHo[i]);
|
||||
|
||||
// If anything had to be fixed, then replace the header
|
||||
if (!s.equals(h[0].getValue()))
|
||||
{
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Original URL: " + h[0].getValue());
|
||||
|
||||
response.setHeader(LOC, s);
|
||||
|
||||
if (BuildConfig.DEBUG)
|
||||
Log.d(TAG, "Fixed URL: " + s);
|
||||
}
|
||||
}
|
||||
|
||||
// call DefaultRedirectHandler with fixed URL
|
||||
return super.getLocationURI(response, context);
|
||||
}
|
||||
}
|
|
@ -22,7 +22,6 @@ import android.util.Log;
|
|||
import android.webkit.URLUtil;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -187,7 +186,7 @@ public class DownloadService extends Service {
|
|||
if (status.getReason() == DownloadError.ERROR_UNAUTHORIZED) {
|
||||
postAuthenticationNotification(downloader.getDownloadRequest());
|
||||
} else if (status.getReason() == DownloadError.ERROR_HTTP_DATA_ERROR
|
||||
&& Integer.valueOf(status.getReasonDetailed()) == HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE) {
|
||||
&& Integer.valueOf(status.getReasonDetailed()) == 416) {
|
||||
|
||||
Log.d(TAG, "Requested invalid range, restarting download from the beginning");
|
||||
FileUtils.deleteQuietly(new File(downloader.getDownloadRequest().getDestination()));
|
||||
|
|
|
@ -11,7 +11,6 @@ import com.squareup.okhttp.ResponseBody;
|
|||
import com.squareup.okhttp.internal.http.HttpDate;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.HttpStatus;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
|
@ -171,7 +170,7 @@ public class HttpDownloader extends Downloader {
|
|||
|
||||
String contentRangeHeader = (fileExists) ? response.header("Content-Range") : null;
|
||||
|
||||
if (fileExists && response.code() == HttpStatus.SC_PARTIAL_CONTENT
|
||||
if (fileExists && response.code() == HttpURLConnection.HTTP_PARTIAL
|
||||
&& !TextUtils.isEmpty(contentRangeHeader)) {
|
||||
String start = contentRangeHeader.substring("bytes ".length(),
|
||||
contentRangeHeader.indexOf("-"));
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.hardware.Sensor;
|
|||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.util.FloatMath;
|
||||
import android.util.Log;
|
||||
|
||||
public class ShakeListener implements SensorEventListener
|
||||
|
@ -50,8 +49,8 @@ public class ShakeListener implements SensorEventListener
|
|||
float gY = event.values[1] / SensorManager.GRAVITY_EARTH;
|
||||
float gZ = event.values[2] / SensorManager.GRAVITY_EARTH;
|
||||
|
||||
float gForce = FloatMath.sqrt(gX*gX + gY*gY + gZ*gZ);
|
||||
if (gForce > 2.25f) {
|
||||
double gForce = Math.sqrt(gX*gX + gY*gY + gZ*gZ);
|
||||
if (gForce > 2.25) {
|
||||
Log.d(TAG, "Detected shake " + gForce);
|
||||
mSleepTimer.onShake();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue