Browse Source

Corrected RSS parser package declaration and updated import statements accordingly. Removed unnecessary extra HTTP helper class.

pull/177/head
Eric Kok 10 years ago
parent
commit
3375a76f28
  1. 4
      app/src/main/java/org/transdroid/core/gui/rss/RssfeedLoader.java
  2. 5
      app/src/main/java/org/transdroid/core/gui/rss/RssfeedView.java
  3. 4
      app/src/main/java/org/transdroid/core/gui/rss/RssfeedsActivity.java
  4. 3
      app/src/main/java/org/transdroid/core/gui/rss/RssfeedsAdapter.java
  5. 2
      app/src/main/java/org/transdroid/core/gui/rss/RssitemView.java
  6. 2
      app/src/main/java/org/transdroid/core/gui/rss/RssitemsActivity.java
  7. 6
      app/src/main/java/org/transdroid/core/gui/rss/RssitemsAdapter.java
  8. 4
      app/src/main/java/org/transdroid/core/gui/rss/RssitemsFragment.java
  9. 2
      app/src/main/java/org/transdroid/core/rssparser/Channel.java
  10. 150
      app/src/main/java/org/transdroid/core/rssparser/HttpHelper.java
  11. 2
      app/src/main/java/org/transdroid/core/rssparser/Item.java
  12. 3
      app/src/main/java/org/transdroid/core/rssparser/RssParser.java
  13. 6
      app/src/main/java/org/transdroid/core/service/RssCheckerService.java
  14. 20
      app/src/main/res/values-fa/strings.xml
  15. 2
      app/src/main/res/values-ko/strings.xml

4
app/src/main/java/org/transdroid/core/gui/rss/RssfeedLoader.java

@ -22,8 +22,8 @@ import java.util.Date; @@ -22,8 +22,8 @@ import java.util.Date;
import java.util.List;
import org.transdroid.core.app.settings.RssfeedSetting;
import org.transdroid.Rssparser.Channel;
import org.transdroid.Rssparser.Item;
import org.transdroid.core.rssparser.Channel;
import org.transdroid.core.rssparser.Item;
/**
* A container class that holds RSS feed settings and, after they have been retrieved, the contents as {@link Channel},

5
app/src/main/java/org/transdroid/core/gui/rss/RssfeedView.java

@ -21,7 +21,6 @@ import org.androidannotations.annotations.EViewGroup; @@ -21,7 +21,6 @@ import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;
import org.transdroid.core.app.settings.RssfeedSetting;
import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.Rssparser.Channel;
import android.content.Context;
import android.view.View;
@ -76,8 +75,4 @@ public class RssfeedView extends LinearLayout { @@ -76,8 +75,4 @@ public class RssfeedView extends LinearLayout {
}
public Channel getChannel() {
return null;
}
}

4
app/src/main/java/org/transdroid/core/gui/rss/RssfeedsActivity.java

@ -32,8 +32,8 @@ import org.transdroid.core.app.settings.*; @@ -32,8 +32,8 @@ import org.transdroid.core.app.settings.*;
import org.transdroid.core.gui.*;
import org.transdroid.core.gui.log.Log;
import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.Rssparser.Channel;
import org.transdroid.Rssparser.RssParser;
import org.transdroid.core.rssparser.Channel;
import org.transdroid.core.rssparser.RssParser;
import android.annotation.TargetApi;
import android.app.Activity;

3
app/src/main/java/org/transdroid/core/gui/rss/RssfeedsAdapter.java

@ -21,7 +21,6 @@ import java.util.List; @@ -21,7 +21,6 @@ import java.util.List;
import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;
import org.transdroid.core.app.settings.RssfeedSetting;
import org.transdroid.Rssparser.Channel;
import android.content.Context;
import android.view.View;
@ -29,7 +28,7 @@ import android.view.ViewGroup; @@ -29,7 +28,7 @@ import android.view.ViewGroup;
import android.widget.BaseAdapter;
/**
* Adapter that contains a list of {@link RssfeedSetting}s, each with associated loaded RSS feed {@link Channel}.
* Adapter that contains a list of {@link RssfeedSetting}s, each with associated loaded RSS feed {@link org.transdroid.core.rssparser.Channel}.
* @author Eric Kok
*/
@EBean

2
app/src/main/java/org/transdroid/core/gui/rss/RssitemView.java

@ -18,7 +18,7 @@ package org.transdroid.core.gui.rss; @@ -18,7 +18,7 @@ package org.transdroid.core.gui.rss;
import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;
import org.transdroid.Rssparser.Item;
import org.transdroid.core.rssparser.Item;
import android.content.Context;
import android.text.format.DateUtils;

2
app/src/main/java/org/transdroid/core/gui/rss/RssitemsActivity.java

@ -25,7 +25,7 @@ import org.transdroid.R; @@ -25,7 +25,7 @@ import org.transdroid.R;
import org.transdroid.core.app.settings.*;
import org.transdroid.core.gui.*;
import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.Rssparser.Channel;
import org.transdroid.core.rssparser.Channel;
import android.annotation.TargetApi;
import android.app.Activity;

6
app/src/main/java/org/transdroid/core/gui/rss/RssitemsAdapter.java

@ -18,8 +18,8 @@ package org.transdroid.core.gui.rss; @@ -18,8 +18,8 @@ package org.transdroid.core.gui.rss;
import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;
import org.transdroid.Rssparser.Channel;
import org.transdroid.Rssparser.Item;
import org.transdroid.core.rssparser.Channel;
import org.transdroid.core.rssparser.Item;
import android.content.Context;
import android.view.View;
@ -40,7 +40,7 @@ public class RssitemsAdapter extends BaseAdapter { @@ -40,7 +40,7 @@ public class RssitemsAdapter extends BaseAdapter {
/**
* Allows updating the full RSS feed (channel and contained items), replacing the old data
* @param newRssfeeds The new RSS feed contents
* @param rssfeed The new RSS feed contents
*/
public void update(Channel rssfeed) {
this.rssfeed = rssfeed;

4
app/src/main/java/org/transdroid/core/gui/rss/RssitemsFragment.java

@ -30,8 +30,8 @@ import org.transdroid.core.gui.TorrentsActivity_; @@ -30,8 +30,8 @@ import org.transdroid.core.gui.TorrentsActivity_;
import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.navigation.SelectionManagerMode;
import org.transdroid.core.gui.search.SearchActivity_;
import org.transdroid.Rssparser.Channel;
import org.transdroid.Rssparser.Item;
import org.transdroid.core.rssparser.Channel;
import org.transdroid.core.rssparser.Item;
import android.app.AlertDialog;
import android.app.Dialog;

2
app/src/main/java/org/transdroid/core/rssparser/Channel.java

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
* Taken from the 'Learning Android' project, released as Public Domain software at
* http://github.com/digitalspaghetti/learning-android and modified heavily for Transdroid
*/
package org.transdroid.Rssparser;
package org.transdroid.core.rssparser;
import java.util.ArrayList;
import java.util.Date;

150
app/src/main/java/org/transdroid/core/rssparser/HttpHelper.java

@ -1,150 +0,0 @@ @@ -1,150 +0,0 @@
/*
* This file is part of Transdroid Torrent Search
* <http://code.google.com/p/transdroid-search/>
*
* Transdroid Torrent Search is free software: you can redistribute
* it and/or modify it under the terms of the GNU Lesser General
* Public License as published by the Free Software Foundation,
* either version 3 of the License, or (at your option) any later
* version.
*
* Transdroid Torrent Search is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
*/
package org.transdroid.Rssparser;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.zip.GZIPInputStream;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
import org.apache.http.HttpEntity;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpRequestInterceptor;
import org.apache.http.HttpResponse;
import org.apache.http.HttpResponseInterceptor;
import org.apache.http.entity.HttpEntityWrapper;
import org.apache.http.protocol.HttpContext;
/**
* Provides a set of general helper methods that can be used in web-based communication.
*
* @author erickok
*
*/
public class HttpHelper {
/**
* HTTP request interceptor to allow for GZip-encoded data transfer
*/
public static HttpRequestInterceptor gzipRequestInterceptor = new HttpRequestInterceptor() {
public void process(final HttpRequest request, final HttpContext context) throws HttpException, IOException {
if (!request.containsHeader("Accept-Encoding")) {
request.addHeader("Accept-Encoding", "gzip");
}
}
};
/**
* HTTP response interceptor that decodes GZipped data
*/
public static HttpResponseInterceptor gzipResponseInterceptor = new HttpResponseInterceptor() {
public void process(final HttpResponse response, final HttpContext context) throws HttpException, IOException {
HttpEntity entity = response.getEntity();
Header ceheader = entity.getContentEncoding();
if (ceheader != null) {
HeaderElement[] codecs = ceheader.getElements();
for (int i = 0; i < codecs.length; i++) {
if (codecs[i].getName().equalsIgnoreCase("gzip")) {
response.setEntity(new HttpHelper.GzipDecompressingEntity(response.getEntity()));
return;
}
}
}
}
};
/**
* HTTP entity wrapper to decompress GZipped HTTP responses
*/
private static class GzipDecompressingEntity extends HttpEntityWrapper {
public GzipDecompressingEntity(final HttpEntity entity) {
super(entity);
}
@Override
public InputStream getContent() throws IOException, IllegalStateException {
// the wrapped entity's getContent() decides about repeatability
InputStream wrappedin = wrappedEntity.getContent();
return new GZIPInputStream(wrappedin);
}
@Override
public long getContentLength() {
// length of ungzipped content is not known
return -1;
}
}
/*
* To convert the InputStream to String we use the BufferedReader.readLine()
* method. We iterate until the BufferedReader return null which means
* there's no more data to read. Each line will appended to a StringBuilder
* and returned as String.
*
* Taken from http://senior.ceng.metu.edu.tr/2009/praeda/2009/01/11/a-simple-restful-client-at-android/
*/
public static String convertStreamToString(InputStream is, String encoding) throws UnsupportedEncodingException {
InputStreamReader isr;
if (encoding != null) {
isr = new InputStreamReader(is, encoding);
} else {
isr = new InputStreamReader(is);
}
BufferedReader reader = new BufferedReader(isr);
StringBuilder sb = new StringBuilder();
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return sb.toString();
}
public static String convertStreamToString(InputStream is) {
try {
return convertStreamToString(is, null);
} catch (UnsupportedEncodingException e) {
// Since this is going to use the default encoding, it is never going to crash on an UnsupportedEncodingException
e.printStackTrace();
return null;
}
}
}

2
app/src/main/java/org/transdroid/core/rssparser/Item.java

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
* Taken from the 'Learning Android' project, released as Public Domain software at
* http://github.com/digitalspaghetti/learning-android and modified heavily for Transdroid
*/
package org.transdroid.Rssparser;
package org.transdroid.core.rssparser;
import java.util.Date;

3
app/src/main/java/org/transdroid/core/rssparser/RssParser.java

@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
* Taken from the 'Learning Android' project, released as Public Domain software at
* http://github.com/digitalspaghetti/learning-android and modified heavily for Transdroid
*/
package org.transdroid.Rssparser;
package org.transdroid.core.rssparser;
import java.io.IOException;
import java.util.Date;
@ -22,6 +22,7 @@ import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; @@ -22,6 +22,7 @@ import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.transdroid.daemon.util.HttpHelper;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;

6
app/src/main/java/org/transdroid/core/service/RssCheckerService.java

@ -28,8 +28,8 @@ import org.transdroid.core.app.settings.NotificationSettings; @@ -28,8 +28,8 @@ import org.transdroid.core.app.settings.NotificationSettings;
import org.transdroid.core.app.settings.RssfeedSetting;
import org.transdroid.core.gui.log.Log;
import org.transdroid.core.gui.rss.RssfeedsActivity_;
import org.transdroid.Rssparser.Item;
import org.transdroid.Rssparser.RssParser;
import org.transdroid.core.rssparser.Item;
import org.transdroid.core.rssparser.RssParser;
import org.transdroid.daemon.util.Collections2;
import android.app.IntentService;
@ -112,7 +112,7 @@ public class RssCheckerService extends IntentService { @@ -112,7 +112,7 @@ public class RssCheckerService extends IntentService {
// Provide a notification, since there are new RSS items
PendingIntent pi = PendingIntent.getActivity(this, 80000, new Intent(this, RssfeedsActivity_.class),
Intent.FLAG_ACTIVITY_NEW_TASK);
PendingIntent.FLAG_UPDATE_CURRENT);
String title = getResources().getQuantityString(R.plurals.rss_service_new, unread, Integer.toString(unread));
String forString = Collections2.joinString(hasUnread, ", ");
Builder builder = new Notification.Builder(this).setSmallIcon(R.drawable.ic_stat_notification)

20
app/src/main/res/values-fa/strings.xml

@ -111,18 +111,6 @@ along with Transdroid. If not, see <http://www.gnu.org/licenses/>. @@ -111,18 +111,6 @@ along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
<string name="status_maxspeed_unit">KB / S </string>
<string name="status_maxspeed_reset">تنظیم مجدد </string>
<string name="status_update">بروز رسانی</string>
<plurals name="status_service_added">
<item quantity="one">New torrent added</item>
<item quantity="other">%1$s new torrents added</item>
</plurals>
<plurals name="status_service_finished">
<item quantity="one">Torrent is finished</item>
<item quantity="other">%1$s torrents are finished</item>
</plurals>
<plurals name="status_service_addedfinished">
<item quantity="one">%1$s added, %2$s finished torrent</item>
<item quantity="other">%1$s added, %2$s finished torrents</item>
</plurals>
<string name="status_service_andothers">٪ 1 $ s و دیگران </string>
<string name="labels_showall">تمام برچسب ها </string>
@ -167,14 +155,6 @@ along with Transdroid. If not, see <http://www.gnu.org/licenses/>. @@ -167,14 +155,6 @@ along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
<string name="rss_empty">خوراک آر اس اس در دسترس نیست یا شامل هیچ مواردی نیست </string>
<string name="rss_notloaded">با عرض پوزش، لطفا صبر کنید تا خوراک آر اس اس لود شود </string>
<string name="rss_error">با عرض پوزش، این خوراک آر اس اس نمی تواند در این زمان لود شود </string>
<plurals name="rss_itemsselected">
<item quantity="one">%1$d item selected</item>
<item quantity="other">%1$d items selected</item>
</plurals>
<plurals name="rss_service_new">
<item quantity="one">New RSS feed torrent available</item>
<item quantity="other">%1$s new RSS feed torrents</item>
</plurals>
<string name="rss_service_newfor">مشابه جدید برای٪ 1 $ ثانیه </string>
<string name="widget_loading">در حال بارگیری #8230</string>

2
app/src/main/res/values-ko/strings.xml

@ -223,7 +223,7 @@ along with Transdroid. If not, see <http://www.gnu.org/licenses/>. @@ -223,7 +223,7 @@ along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
<string name="pref_searchurl">직접 검색 URL</string>
<string name="pref_searchurl_info">%s가 검색어로 대체됩니다</string>
<string name="pref_cookies">쿠키</string>
<string name="pref_cookies_info">선택적; 'key1=value1;key2=value2' 형식을 사용하세요</string>
<string name="pref_cookies_info">선택적; \'key1=value1;key2=value2\' 형식을 사용하세요</string>
<string name="pref_feedurl">피드 URL</string>
<string name="pref_reqauth">인증 필요</string>
<string name="pref_reqauth_info">사용자 로그인을 위해 링크를 웹 브라우저로 엽니다</string>

Loading…
Cancel
Save