From 3375a76f28f3a7c9ed1941223d9216e08d65b6d9 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Mon, 27 Oct 2014 19:50:04 +0100 Subject: [PATCH] Corrected RSS parser package declaration and updated import statements accordingly. Removed unnecessary extra HTTP helper class. --- .../core/gui/rss/RssfeedLoader.java | 4 +- .../transdroid/core/gui/rss/RssfeedView.java | 5 - .../core/gui/rss/RssfeedsActivity.java | 4 +- .../core/gui/rss/RssfeedsAdapter.java | 3 +- .../transdroid/core/gui/rss/RssitemView.java | 2 +- .../core/gui/rss/RssitemsActivity.java | 2 +- .../core/gui/rss/RssitemsAdapter.java | 6 +- .../core/gui/rss/RssitemsFragment.java | 4 +- .../transdroid/core/rssparser/Channel.java | 2 +- .../transdroid/core/rssparser/HttpHelper.java | 150 ------------------ .../org/transdroid/core/rssparser/Item.java | 2 +- .../transdroid/core/rssparser/RssParser.java | 3 +- .../core/service/RssCheckerService.java | 6 +- app/src/main/res/values-fa/strings.xml | 22 +-- app/src/main/res/values-ko/strings.xml | 2 +- 15 files changed, 21 insertions(+), 196 deletions(-) delete mode 100644 app/src/main/java/org/transdroid/core/rssparser/HttpHelper.java diff --git a/app/src/main/java/org/transdroid/core/gui/rss/RssfeedLoader.java b/app/src/main/java/org/transdroid/core/gui/rss/RssfeedLoader.java index adab8722..b6007d58 100644 --- a/app/src/main/java/org/transdroid/core/gui/rss/RssfeedLoader.java +++ b/app/src/main/java/org/transdroid/core/gui/rss/RssfeedLoader.java @@ -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}, diff --git a/app/src/main/java/org/transdroid/core/gui/rss/RssfeedView.java b/app/src/main/java/org/transdroid/core/gui/rss/RssfeedView.java index 70403220..545d5ebd 100644 --- a/app/src/main/java/org/transdroid/core/gui/rss/RssfeedView.java +++ b/app/src/main/java/org/transdroid/core/gui/rss/RssfeedView.java @@ -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 { } - public Channel getChannel() { - return null; - } - } diff --git a/app/src/main/java/org/transdroid/core/gui/rss/RssfeedsActivity.java b/app/src/main/java/org/transdroid/core/gui/rss/RssfeedsActivity.java index 9415a669..263d45bd 100644 --- a/app/src/main/java/org/transdroid/core/gui/rss/RssfeedsActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/rss/RssfeedsActivity.java @@ -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; diff --git a/app/src/main/java/org/transdroid/core/gui/rss/RssfeedsAdapter.java b/app/src/main/java/org/transdroid/core/gui/rss/RssfeedsAdapter.java index ff6f6777..dab9e60a 100644 --- a/app/src/main/java/org/transdroid/core/gui/rss/RssfeedsAdapter.java +++ b/app/src/main/java/org/transdroid/core/gui/rss/RssfeedsAdapter.java @@ -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; 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 diff --git a/app/src/main/java/org/transdroid/core/gui/rss/RssitemView.java b/app/src/main/java/org/transdroid/core/gui/rss/RssitemView.java index b6e8ee92..ba121a0d 100644 --- a/app/src/main/java/org/transdroid/core/gui/rss/RssitemView.java +++ b/app/src/main/java/org/transdroid/core/gui/rss/RssitemView.java @@ -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; diff --git a/app/src/main/java/org/transdroid/core/gui/rss/RssitemsActivity.java b/app/src/main/java/org/transdroid/core/gui/rss/RssitemsActivity.java index 8de1bbce..50c69460 100644 --- a/app/src/main/java/org/transdroid/core/gui/rss/RssitemsActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/rss/RssitemsActivity.java @@ -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; diff --git a/app/src/main/java/org/transdroid/core/gui/rss/RssitemsAdapter.java b/app/src/main/java/org/transdroid/core/gui/rss/RssitemsAdapter.java index 216d5796..7ebd0c7d 100644 --- a/app/src/main/java/org/transdroid/core/gui/rss/RssitemsAdapter.java +++ b/app/src/main/java/org/transdroid/core/gui/rss/RssitemsAdapter.java @@ -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 { /** * 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; diff --git a/app/src/main/java/org/transdroid/core/gui/rss/RssitemsFragment.java b/app/src/main/java/org/transdroid/core/gui/rss/RssitemsFragment.java index be5607ad..3115bc7e 100644 --- a/app/src/main/java/org/transdroid/core/gui/rss/RssitemsFragment.java +++ b/app/src/main/java/org/transdroid/core/gui/rss/RssitemsFragment.java @@ -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; diff --git a/app/src/main/java/org/transdroid/core/rssparser/Channel.java b/app/src/main/java/org/transdroid/core/rssparser/Channel.java index b55eb9f4..68d105ed 100644 --- a/app/src/main/java/org/transdroid/core/rssparser/Channel.java +++ b/app/src/main/java/org/transdroid/core/rssparser/Channel.java @@ -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; diff --git a/app/src/main/java/org/transdroid/core/rssparser/HttpHelper.java b/app/src/main/java/org/transdroid/core/rssparser/HttpHelper.java deleted file mode 100644 index ecef9115..00000000 --- a/app/src/main/java/org/transdroid/core/rssparser/HttpHelper.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * This file is part of Transdroid Torrent 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 . - */ -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; - } - } - -} \ No newline at end of file diff --git a/app/src/main/java/org/transdroid/core/rssparser/Item.java b/app/src/main/java/org/transdroid/core/rssparser/Item.java index 20fe13b0..42f80ea9 100644 --- a/app/src/main/java/org/transdroid/core/rssparser/Item.java +++ b/app/src/main/java/org/transdroid/core/rssparser/Item.java @@ -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; diff --git a/app/src/main/java/org/transdroid/core/rssparser/RssParser.java b/app/src/main/java/org/transdroid/core/rssparser/RssParser.java index ef628d02..baba1c46 100644 --- a/app/src/main/java/org/transdroid/core/rssparser/RssParser.java +++ b/app/src/main/java/org/transdroid/core/rssparser/RssParser.java @@ -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; 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; diff --git a/app/src/main/java/org/transdroid/core/service/RssCheckerService.java b/app/src/main/java/org/transdroid/core/service/RssCheckerService.java index 7517a3f9..c5cd5459 100644 --- a/app/src/main/java/org/transdroid/core/service/RssCheckerService.java +++ b/app/src/main/java/org/transdroid/core/service/RssCheckerService.java @@ -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 { // 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) diff --git a/app/src/main/res/values-fa/strings.xml b/app/src/main/res/values-fa/strings.xml index daa64e7e..e11e053b 100644 --- a/app/src/main/res/values-fa/strings.xml +++ b/app/src/main/res/values-fa/strings.xml @@ -111,18 +111,6 @@ along with Transdroid. If not, see . KB / S تنظیم مجدد بروز رسانی - -New torrent added -%1$s new torrents added - - -Torrent is finished -%1$s torrents are finished - - -%1$s added, %2$s finished torrent -%1$s added, %2$s finished torrents - ٪ 1 $ s و دیگران تمام برچسب ها @@ -167,14 +155,6 @@ along with Transdroid. If not, see . خوراک آر اس اس در دسترس نیست یا شامل هیچ مواردی نیست با عرض پوزش، لطفا صبر کنید تا خوراک آر اس اس لود شود با عرض پوزش، این خوراک آر اس اس نمی تواند در این زمان لود شود - -%1$d item selected -%1$d items selected - - -New RSS feed torrent available -%1$s new RSS feed torrents - مشابه جدید برای٪ 1 $ ثانیه در حال بارگیری #8230 @@ -213,7 +193,7 @@ along with Transdroid. If not, see . آی پی محلی و یا میزبان هنگامی که به شبکه محلی مشخص متصل شده شبکه محلی -توسط سرور \ 'SSID شبکه محلی +توسط سرور \'SSID شبکه محلی پوشه معمولا خالی است تنظیمات اختیاری diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 70f7456e..399d4fb5 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -223,7 +223,7 @@ along with Transdroid. If not, see . 직접 검색 URL %s가 검색어로 대체됩니다 쿠키 -선택적; 'key1=value1;key2=value2' 형식을 사용하세요 +선택적; \'key1=value1;key2=value2\' 형식을 사용하세요 피드 URL 인증 필요 사용자 로그인을 위해 링크를 웹 브라우저로 엽니다