diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..54e493c0 --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/src/org/fox/ttrss/FeedsFragment.java b/src/org/fox/ttrss/FeedsFragment.java index a6dcf056..1b1cec44 100644 --- a/src/org/fox/ttrss/FeedsFragment.java +++ b/src/org/fox/ttrss/FeedsFragment.java @@ -69,7 +69,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh private FeedsActivity m_activity; private Feed m_selectedFeed; private FeedCategory m_activeCategory; - private static final String ICON_PATH = "/data/org.fox.ttrss/icons/"; + private static final String ICON_PATH = "/icons/"; private boolean m_enableFeedIcons; private boolean m_feedIconsChecked = false; @@ -514,7 +514,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh if (m_enableFeedIcons) { - File storage = Environment.getExternalStorageDirectory(); + File storage = m_activity.getExternalCacheDir(); File iconFile = new File(storage.getAbsolutePath() + ICON_PATH + feed.id + ".ico"); if (iconFile.exists()) { @@ -570,7 +570,7 @@ public class FeedsFragment extends Fragment implements OnItemClickListener, OnSh protected Integer doInBackground(FeedList... params) { try { - File storage = Environment.getExternalStorageDirectory(); + File storage = m_activity.getExternalCacheDir(); final File iconPath = new File(storage.getAbsolutePath() + ICON_PATH); if (!iconPath.exists()) iconPath.mkdirs(); diff --git a/src/org/fox/ttrss/offline/OfflineArticleFragment.java b/src/org/fox/ttrss/offline/OfflineArticleFragment.java index 65933b61..a1b22094 100644 --- a/src/org/fox/ttrss/offline/OfflineArticleFragment.java +++ b/src/org/fox/ttrss/offline/OfflineArticleFragment.java @@ -202,8 +202,8 @@ public class OfflineArticleFragment extends Fragment { for (Element img : images) { String url = img.attr("src"); - if (ImageCacheService.isUrlCached(url)) { - img.attr("src", "file://" + ImageCacheService.getCacheFileName(url)); + if (ImageCacheService.isUrlCached(m_activity, url)) { + img.attr("src", "file://" + ImageCacheService.getCacheFileName(m_activity, url)); } } } diff --git a/src/org/fox/ttrss/offline/OfflineDownloadService.java b/src/org/fox/ttrss/offline/OfflineDownloadService.java index b2e3ecb0..c3a0444c 100644 --- a/src/org/fox/ttrss/offline/OfflineDownloadService.java +++ b/src/org/fox/ttrss/offline/OfflineDownloadService.java @@ -402,7 +402,7 @@ public class OfflineDownloadService extends Service { String url = img.attr("src"); if (url.indexOf("://") != -1) { - if (!ImageCacheService.isUrlCached(url)) { + if (!ImageCacheService.isUrlCached(OfflineDownloadService.this, url)) { Intent intent = new Intent(OfflineDownloadService.this, ImageCacheService.class); @@ -472,7 +472,7 @@ public class OfflineDownloadService extends Service { m_sessionId = intent.getStringExtra("sessionId"); if (!m_downloadInProgress) { - if (m_downloadImages) ImageCacheService.cleanupCache(false); + if (m_downloadImages) ImageCacheService.cleanupCache(this, false); updateNotification(R.string.notify_downloading_init); m_downloadInProgress = true; diff --git a/src/org/fox/ttrss/util/ImageCacheService.java b/src/org/fox/ttrss/util/ImageCacheService.java index b699c569..96342d60 100644 --- a/src/org/fox/ttrss/util/ImageCacheService.java +++ b/src/org/fox/ttrss/util/ImageCacheService.java @@ -20,6 +20,7 @@ import android.app.IntentService; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; +import android.content.Context; import android.content.Intent; import android.os.Environment; @@ -30,7 +31,7 @@ public class ImageCacheService extends IntentService { public static final int NOTIFY_DOWNLOADING = 1; - private static final String CACHE_PATH = "/data/org.fox.ttrss/image-cache/"; + private static final String CACHE_PATH = "/image-cache/"; private int m_imagesDownloaded = 0; @@ -57,29 +58,29 @@ public class ImageCacheService extends IntentService { m_nmgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE); } - public static boolean isUrlCached(String url) { + public static boolean isUrlCached(Context context, String url) { String hashedUrl = md5(url); - File storage = Environment.getExternalStorageDirectory(); + File storage = context.getExternalCacheDir(); File file = new File(storage.getAbsolutePath() + CACHE_PATH + "/" + hashedUrl + ".png"); return file.exists(); } - public static String getCacheFileName(String url) { + public static String getCacheFileName(Context context, String url) { String hashedUrl = md5(url); - File storage = Environment.getExternalStorageDirectory(); + File storage = context.getExternalCacheDir(); File file = new File(storage.getAbsolutePath() + CACHE_PATH + "/" + hashedUrl + ".png"); return file.getAbsolutePath(); } - public static void cleanupCache(boolean deleteAll) { + public static void cleanupCache(Context context, boolean deleteAll) { if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) { - File storage = Environment.getExternalStorageDirectory(); + File storage = context.getExternalCacheDir(); File cachePath = new File(storage.getAbsolutePath() + CACHE_PATH); long now = new Date().getTime(); @@ -155,7 +156,7 @@ public class ImageCacheService extends IntentService { String hashedUrl = md5(url); - File storage = Environment.getExternalStorageDirectory(); + File storage = getExternalCacheDir(); File cachePath = new File(storage.getAbsolutePath() + CACHE_PATH); if (!cachePath.exists()) cachePath.mkdirs();