2011-09-09 11:58:11 +00:00
|
|
|
|
package org.fox.ttrss;
|
|
|
|
|
|
2012-02-06 11:05:56 +00:00
|
|
|
|
import java.net.MalformedURLException;
|
|
|
|
|
import java.net.URL;
|
2011-11-25 09:10:56 +00:00
|
|
|
|
import java.text.SimpleDateFormat;
|
2012-03-12 11:57:57 +00:00
|
|
|
|
import java.util.ArrayList;
|
2011-11-25 09:10:56 +00:00
|
|
|
|
import java.util.Date;
|
2011-11-23 16:38:21 +00:00
|
|
|
|
|
2012-06-19 10:18:00 +00:00
|
|
|
|
import org.fox.ttrss.types.Article;
|
|
|
|
|
import org.fox.ttrss.types.Attachment;
|
2011-12-07 12:25:50 +00:00
|
|
|
|
import org.jsoup.Jsoup;
|
|
|
|
|
import org.jsoup.nodes.Document;
|
|
|
|
|
import org.jsoup.nodes.Element;
|
|
|
|
|
import org.jsoup.select.Elements;
|
2011-11-28 09:45:19 +00:00
|
|
|
|
|
2012-05-02 05:54:45 +00:00
|
|
|
|
import android.annotation.SuppressLint;
|
2012-12-14 15:37:05 +00:00
|
|
|
|
import android.app.ActionBar;
|
2011-09-09 11:58:11 +00:00
|
|
|
|
import android.app.Activity;
|
2012-03-12 11:57:57 +00:00
|
|
|
|
import android.content.Intent;
|
2011-09-09 11:58:11 +00:00
|
|
|
|
import android.content.SharedPreferences;
|
2012-09-19 19:23:26 +00:00
|
|
|
|
import android.graphics.Paint;
|
2012-03-12 11:57:57 +00:00
|
|
|
|
import android.net.Uri;
|
2011-09-09 11:58:11 +00:00
|
|
|
|
import android.os.Bundle;
|
2011-11-25 11:03:14 +00:00
|
|
|
|
import android.preference.PreferenceManager;
|
2012-06-19 14:24:22 +00:00
|
|
|
|
import android.support.v4.app.Fragment;
|
2012-09-16 16:46:54 +00:00
|
|
|
|
import android.util.Log;
|
2012-02-01 06:57:07 +00:00
|
|
|
|
import android.util.TypedValue;
|
2012-12-14 15:37:05 +00:00
|
|
|
|
import android.view.GestureDetector;
|
2012-03-12 08:51:57 +00:00
|
|
|
|
import android.view.ContextMenu;
|
2012-06-22 11:37:08 +00:00
|
|
|
|
import android.view.ContextMenu.ContextMenuInfo;
|
2011-09-09 11:58:11 +00:00
|
|
|
|
import android.view.LayoutInflater;
|
2012-09-16 16:46:54 +00:00
|
|
|
|
import android.view.MenuItem;
|
2012-12-14 15:37:05 +00:00
|
|
|
|
import android.view.MotionEvent;
|
2011-09-09 11:58:11 +00:00
|
|
|
|
import android.view.View;
|
2012-03-12 11:57:57 +00:00
|
|
|
|
import android.view.View.OnClickListener;
|
2011-11-28 10:01:04 +00:00
|
|
|
|
import android.view.ViewGroup;
|
2012-09-19 12:01:31 +00:00
|
|
|
|
import android.webkit.WebChromeClient;
|
2011-12-19 11:08:40 +00:00
|
|
|
|
import android.webkit.WebSettings;
|
2012-06-26 17:45:35 +00:00
|
|
|
|
import android.webkit.WebSettings.LayoutAlgorithm;
|
2011-09-09 16:36:09 +00:00
|
|
|
|
import android.webkit.WebView;
|
2012-03-12 11:57:57 +00:00
|
|
|
|
import android.widget.ArrayAdapter;
|
|
|
|
|
import android.widget.Button;
|
|
|
|
|
import android.widget.Spinner;
|
2011-09-09 16:36:09 +00:00
|
|
|
|
import android.widget.TextView;
|
2011-09-09 11:58:11 +00:00
|
|
|
|
|
2012-12-14 15:37:05 +00:00
|
|
|
|
public class ArticleFragment extends Fragment implements GestureDetector.OnDoubleTapListener {
|
2011-09-09 16:36:09 +00:00
|
|
|
|
private final String TAG = this.getClass().getSimpleName();
|
|
|
|
|
|
2011-11-25 11:03:14 +00:00
|
|
|
|
private SharedPreferences m_prefs;
|
2011-11-23 16:38:21 +00:00
|
|
|
|
private Article m_article;
|
2012-09-17 12:28:32 +00:00
|
|
|
|
private OnlineActivity m_activity;
|
2011-12-09 20:49:55 +00:00
|
|
|
|
//private Article m_nextArticle;
|
|
|
|
|
//private Article m_prevArticle;
|
2012-12-14 15:37:05 +00:00
|
|
|
|
private GestureDetector m_detector;
|
|
|
|
|
|
2011-12-09 20:49:55 +00:00
|
|
|
|
public ArticleFragment() {
|
|
|
|
|
super();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ArticleFragment(Article article) {
|
|
|
|
|
super();
|
|
|
|
|
|
|
|
|
|
m_article = article;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-28 10:01:04 +00:00
|
|
|
|
private View.OnTouchListener m_gestureListener;
|
2011-09-09 11:58:11 +00:00
|
|
|
|
|
2012-09-16 16:46:54 +00:00
|
|
|
|
@Override
|
|
|
|
|
public boolean onContextItemSelected(MenuItem item) {
|
2012-09-19 09:37:12 +00:00
|
|
|
|
/* AdapterContextMenuInfo info = (AdapterContextMenuInfo) item
|
|
|
|
|
.getMenuInfo(); */
|
2012-09-16 16:46:54 +00:00
|
|
|
|
|
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
|
case R.id.article_link_share:
|
|
|
|
|
if (true) {
|
|
|
|
|
((OnlineActivity) getActivity()).shareArticle(m_article);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
case R.id.article_link_copy:
|
|
|
|
|
if (true) {
|
|
|
|
|
((OnlineActivity) getActivity()).copyToClipboard(m_article.link);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
Log.d(TAG, "onContextItemSelected, unhandled id=" + item.getItemId());
|
|
|
|
|
return super.onContextItemSelected(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-12 08:51:57 +00:00
|
|
|
|
@Override
|
|
|
|
|
public void onCreateContextMenu(ContextMenu menu, View v,
|
|
|
|
|
ContextMenuInfo menuInfo) {
|
|
|
|
|
|
|
|
|
|
getActivity().getMenuInflater().inflate(R.menu.article_link_context_menu, menu);
|
|
|
|
|
menu.setHeaderTitle(m_article.title);
|
|
|
|
|
|
|
|
|
|
super.onCreateContextMenu(menu, v, menuInfo);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2012-05-02 05:54:45 +00:00
|
|
|
|
@SuppressLint("NewApi")
|
2011-09-09 11:58:11 +00:00
|
|
|
|
@Override
|
|
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
|
|
|
|
|
2012-09-19 12:01:31 +00:00
|
|
|
|
m_activity.setProgressBarVisibility(true);
|
|
|
|
|
|
2011-09-09 11:58:11 +00:00
|
|
|
|
if (savedInstanceState != null) {
|
2011-11-25 10:32:32 +00:00
|
|
|
|
m_article = savedInstanceState.getParcelable("article");
|
2011-09-09 11:58:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
View view = inflater.inflate(R.layout.article_fragment, container, false);
|
2011-11-28 10:01:04 +00:00
|
|
|
|
|
2011-11-23 16:38:21 +00:00
|
|
|
|
if (m_article != null) {
|
|
|
|
|
|
|
|
|
|
TextView title = (TextView)view.findViewById(R.id.title);
|
|
|
|
|
|
|
|
|
|
if (title != null) {
|
2011-11-30 09:02:26 +00:00
|
|
|
|
|
|
|
|
|
String titleStr;
|
|
|
|
|
|
|
|
|
|
if (m_article.title.length() > 200)
|
2012-12-09 11:06:48 +00:00
|
|
|
|
titleStr = m_article.title.substring(0, 200) + "<EFBFBD>";
|
2011-11-30 09:02:26 +00:00
|
|
|
|
else
|
|
|
|
|
titleStr = m_article.title;
|
|
|
|
|
|
2012-09-19 19:23:26 +00:00
|
|
|
|
title.setText(titleStr);
|
|
|
|
|
title.setPaintFlags(title.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
|
|
|
|
title.setOnClickListener(new OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
try {
|
|
|
|
|
Intent intent = new Intent(Intent.ACTION_VIEW,
|
|
|
|
|
Uri.parse(m_article.link.trim()));
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
m_activity.toast(R.string.error_other_error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
registerForContextMenu(title);
|
2011-11-23 16:38:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2012-10-09 15:36:23 +00:00
|
|
|
|
TextView comments = (TextView)view.findViewById(R.id.comments);
|
|
|
|
|
|
|
|
|
|
if (comments != null) {
|
|
|
|
|
if (m_activity.getApiLevel() >= 4 && m_article.comments_count > 0) {
|
|
|
|
|
String commentsTitle = getString(R.string.article_comments, m_article.comments_count);
|
|
|
|
|
comments.setText(commentsTitle);
|
|
|
|
|
comments.setPaintFlags(title.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
|
|
|
|
|
comments.setOnClickListener(new OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
try {
|
|
|
|
|
String link = (m_article.comments_link != null && m_article.comments_link.length() > 0) ?
|
|
|
|
|
m_article.comments_link : m_article.link;
|
|
|
|
|
|
|
|
|
|
Intent intent = new Intent(Intent.ACTION_VIEW,
|
|
|
|
|
Uri.parse(link.trim()));
|
|
|
|
|
startActivity(intent);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
m_activity.toast(R.string.error_other_error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
comments.setVisibility(View.GONE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-23 16:38:21 +00:00
|
|
|
|
WebView web = (WebView)view.findViewById(R.id.content);
|
|
|
|
|
|
|
|
|
|
if (web != null) {
|
2012-09-19 12:01:31 +00:00
|
|
|
|
web.setWebChromeClient(new WebChromeClient() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onProgressChanged(WebView view, int progress) {
|
2012-09-19 12:16:38 +00:00
|
|
|
|
m_activity.setProgress(Math.round(((float)progress / 100f) * 10000));
|
2012-09-19 12:01:31 +00:00
|
|
|
|
if (progress == 100) {
|
|
|
|
|
m_activity.setProgressBarVisibility(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2011-11-23 16:38:21 +00:00
|
|
|
|
|
2012-12-14 15:37:05 +00:00
|
|
|
|
web.setOnTouchListener(new View.OnTouchListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onTouch(View v, MotionEvent event) {
|
|
|
|
|
return m_detector.onTouchEvent(event);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2011-11-25 09:10:56 +00:00
|
|
|
|
String content;
|
2011-11-29 04:03:38 +00:00
|
|
|
|
String cssOverride = "";
|
|
|
|
|
|
2011-12-19 11:08:40 +00:00
|
|
|
|
WebSettings ws = web.getSettings();
|
|
|
|
|
ws.setSupportZoom(true);
|
2012-12-09 11:10:00 +00:00
|
|
|
|
ws.setBuiltInZoomControls(false);
|
2011-11-30 16:04:31 +00:00
|
|
|
|
|
2012-06-26 17:45:35 +00:00
|
|
|
|
web.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
|
|
|
|
|
|
2012-02-01 11:25:35 +00:00
|
|
|
|
TypedValue tv = new TypedValue();
|
|
|
|
|
getActivity().getTheme().resolveAttribute(R.attr.linkColor, tv, true);
|
2012-02-03 06:05:42 +00:00
|
|
|
|
|
|
|
|
|
// prevent flicker in ics
|
2012-02-03 06:22:15 +00:00
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= 11) {
|
|
|
|
|
web.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
|
|
|
|
}
|
2012-02-01 06:57:07 +00:00
|
|
|
|
|
2012-02-01 11:25:35 +00:00
|
|
|
|
if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) {
|
2012-02-03 06:05:42 +00:00
|
|
|
|
cssOverride = "body { background : transparent; color : #e0e0e0}";
|
|
|
|
|
//view.setBackgroundColor(android.R.color.black);
|
2012-05-02 05:54:45 +00:00
|
|
|
|
web.setBackgroundColor(getResources().getColor(android.R.color.transparent));
|
2011-11-30 16:04:31 +00:00
|
|
|
|
} else {
|
2011-12-03 18:21:57 +00:00
|
|
|
|
cssOverride = "";
|
2011-11-25 09:10:56 +00:00
|
|
|
|
}
|
2012-06-26 17:45:35 +00:00
|
|
|
|
|
2012-02-01 11:25:35 +00:00
|
|
|
|
String hexColor = String.format("#%06X", (0xFFFFFF & tv.data));
|
2012-02-01 06:57:07 +00:00
|
|
|
|
cssOverride += " a:link {color: "+hexColor+";} a:visited { color: "+hexColor+";}";
|
|
|
|
|
|
2011-12-13 12:43:40 +00:00
|
|
|
|
String articleContent = m_article.content != null ? m_article.content : "";
|
2011-12-07 12:25:50 +00:00
|
|
|
|
|
|
|
|
|
Document doc = Jsoup.parse(articleContent);
|
|
|
|
|
|
|
|
|
|
if (doc != null) {
|
|
|
|
|
// thanks webview for crashing on <video> tag
|
|
|
|
|
Elements videos = doc.select("video");
|
|
|
|
|
|
|
|
|
|
for (Element video : videos)
|
|
|
|
|
video.remove();
|
|
|
|
|
|
|
|
|
|
articleContent = doc.toString();
|
|
|
|
|
}
|
2011-11-23 16:38:21 +00:00
|
|
|
|
|
2012-03-21 06:18:20 +00:00
|
|
|
|
String align = m_prefs.getBoolean("justify_article_text", true) ? "text-align : justify;" : "";
|
|
|
|
|
|
2012-02-25 11:05:37 +00:00
|
|
|
|
switch (Integer.parseInt(m_prefs.getString("font_size", "0"))) {
|
|
|
|
|
case 0:
|
2012-03-21 06:18:20 +00:00
|
|
|
|
cssOverride += "body { "+align+" font-size : 14px; } ";
|
2012-02-25 11:05:37 +00:00
|
|
|
|
break;
|
|
|
|
|
case 1:
|
2012-03-21 06:18:20 +00:00
|
|
|
|
cssOverride += "body { "+align+" font-size : 18px; } ";
|
2012-02-25 11:05:37 +00:00
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2012-03-21 06:18:20 +00:00
|
|
|
|
cssOverride += "body { "+align+" font-size : 21px; } ";
|
2012-02-25 11:05:37 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-29 04:03:38 +00:00
|
|
|
|
content =
|
|
|
|
|
"<html>" +
|
|
|
|
|
"<head>" +
|
|
|
|
|
"<meta content=\"text/html; charset=utf-8\" http-equiv=\"content-type\">" +
|
|
|
|
|
"<style type=\"text/css\">" +
|
2012-06-21 20:35:53 +00:00
|
|
|
|
"body { padding : 0px; margin : 0px; }" +
|
2011-11-29 04:03:38 +00:00
|
|
|
|
cssOverride +
|
2012-06-26 17:45:35 +00:00
|
|
|
|
/* "img { max-width : 98%; height : auto; }" + */
|
2011-11-29 04:03:38 +00:00
|
|
|
|
"</style>" +
|
|
|
|
|
"</head>" +
|
2012-02-06 11:05:56 +00:00
|
|
|
|
"<body>" + articleContent;
|
|
|
|
|
|
2012-03-12 11:57:57 +00:00
|
|
|
|
final Spinner spinner = (Spinner) view.findViewById(R.id.attachments);
|
|
|
|
|
|
2012-02-06 11:21:56 +00:00
|
|
|
|
if (m_article.attachments != null && m_article.attachments.size() != 0) {
|
2012-03-12 11:57:57 +00:00
|
|
|
|
ArrayList<Attachment> spinnerArray = new ArrayList<Attachment>();
|
|
|
|
|
|
|
|
|
|
ArrayAdapter<Attachment> spinnerArrayAdapter = new ArrayAdapter<Attachment>(
|
|
|
|
|
getActivity(), android.R.layout.simple_spinner_item, spinnerArray);
|
|
|
|
|
|
|
|
|
|
spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
2012-10-10 10:15:53 +00:00
|
|
|
|
|
2012-10-10 12:45:33 +00:00
|
|
|
|
String flatContent = articleContent.replaceAll("[\r\n]", "");
|
|
|
|
|
boolean hasImages = flatContent.matches(".*?<img[^>+].*?");
|
|
|
|
|
|
2012-02-06 11:05:56 +00:00
|
|
|
|
for (Attachment a : m_article.attachments) {
|
2012-03-11 06:31:16 +00:00
|
|
|
|
if (a.content_type != null && a.content_url != null) {
|
2012-02-06 11:05:56 +00:00
|
|
|
|
|
|
|
|
|
try {
|
2012-10-10 12:45:33 +00:00
|
|
|
|
if (a.content_type.indexOf("image") != -1 &&
|
|
|
|
|
(!hasImages || m_article.always_display_attachments)) {
|
|
|
|
|
|
|
|
|
|
URL url = new URL(a.content_url.trim());
|
|
|
|
|
String strUrl = url.toString().trim();
|
|
|
|
|
|
2012-09-19 05:45:03 +00:00
|
|
|
|
content += "<p><img src=\"" + strUrl.replace("\"", "\\\"") + "\"></p>";
|
2012-03-11 06:31:16 +00:00
|
|
|
|
}
|
2012-02-06 11:05:56 +00:00
|
|
|
|
|
|
|
|
|
} catch (MalformedURLException e) {
|
|
|
|
|
//
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
2012-10-10 10:15:53 +00:00
|
|
|
|
|
|
|
|
|
spinnerArray.add(a);
|
2012-02-06 11:05:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2012-03-12 11:57:57 +00:00
|
|
|
|
|
|
|
|
|
spinner.setAdapter(spinnerArrayAdapter);
|
|
|
|
|
|
|
|
|
|
Button attachmentsView = (Button) view.findViewById(R.id.attachment_view);
|
|
|
|
|
|
|
|
|
|
attachmentsView.setOnClickListener(new OnClickListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
Attachment attachment = (Attachment) spinner.getSelectedItem();
|
|
|
|
|
|
|
|
|
|
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(attachment.content_url));
|
|
|
|
|
startActivity(browserIntent);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Button attachmentsCopy = (Button) view.findViewById(R.id.attachment_copy);
|
|
|
|
|
|
|
|
|
|
attachmentsCopy.setOnClickListener(new OnClickListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
Attachment attachment = (Attachment) spinner.getSelectedItem();
|
|
|
|
|
|
|
|
|
|
if (attachment != null) {
|
2012-09-17 12:28:32 +00:00
|
|
|
|
m_activity.copyToClipboard(attachment.content_url);
|
2012-03-12 11:57:57 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
2012-09-19 05:45:03 +00:00
|
|
|
|
|
|
|
|
|
Button attachmentsShare = (Button) view.findViewById(R.id.attachment_share);
|
2012-03-12 11:57:57 +00:00
|
|
|
|
|
2012-09-19 05:45:03 +00:00
|
|
|
|
if (!m_activity.isPortrait()) {
|
|
|
|
|
attachmentsShare.setOnClickListener(new OnClickListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
Attachment attachment = (Attachment) spinner.getSelectedItem();
|
|
|
|
|
|
|
|
|
|
if (attachment != null) {
|
|
|
|
|
m_activity.shareText(attachment.content_url);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
attachmentsShare.setVisibility(View.GONE);
|
|
|
|
|
}
|
|
|
|
|
|
2012-03-12 11:57:57 +00:00
|
|
|
|
} else {
|
|
|
|
|
view.findViewById(R.id.attachments_holder).setVisibility(View.GONE);
|
2012-02-06 11:05:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
content += "</body></html>";
|
2011-11-29 04:03:38 +00:00
|
|
|
|
|
2011-12-07 12:13:58 +00:00
|
|
|
|
try {
|
|
|
|
|
web.loadDataWithBaseURL(null, content, "text/html", "utf-8", null);
|
|
|
|
|
} catch (RuntimeException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
2011-11-28 10:01:04 +00:00
|
|
|
|
|
2012-09-17 12:28:32 +00:00
|
|
|
|
if (m_activity.isSmallScreen())
|
2011-11-28 10:01:04 +00:00
|
|
|
|
web.setOnTouchListener(m_gestureListener);
|
2011-11-23 16:38:21 +00:00
|
|
|
|
}
|
2011-11-24 12:08:02 +00:00
|
|
|
|
|
2011-11-25 09:10:56 +00:00
|
|
|
|
TextView dv = (TextView)view.findViewById(R.id.date);
|
|
|
|
|
|
|
|
|
|
if (dv != null) {
|
|
|
|
|
Date d = new Date(m_article.updated * 1000L);
|
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy, HH:mm");
|
|
|
|
|
dv.setText(df.format(d));
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-28 09:45:19 +00:00
|
|
|
|
TextView tagv = (TextView)view.findViewById(R.id.tags);
|
|
|
|
|
|
|
|
|
|
if (tagv != null) {
|
2012-06-20 10:16:24 +00:00
|
|
|
|
if (m_article.feed_title != null) {
|
|
|
|
|
tagv.setText(m_article.feed_title);
|
|
|
|
|
} else if (m_article.tags != null) {
|
2011-11-28 09:45:19 +00:00
|
|
|
|
String tagsStr = "";
|
|
|
|
|
|
|
|
|
|
for (String tag : m_article.tags)
|
|
|
|
|
tagsStr += tag + ", ";
|
|
|
|
|
|
|
|
|
|
tagsStr = tagsStr.replaceAll(", $", "");
|
|
|
|
|
|
|
|
|
|
tagv.setText(tagsStr);
|
|
|
|
|
} else {
|
|
|
|
|
tagv.setVisibility(View.GONE);
|
|
|
|
|
}
|
2011-11-25 09:10:56 +00:00
|
|
|
|
}
|
2011-11-23 16:38:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
2011-09-09 11:58:11 +00:00
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDestroy() {
|
2011-09-11 09:04:48 +00:00
|
|
|
|
super.onDestroy();
|
2011-09-09 11:58:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2011-09-09 16:36:09 +00:00
|
|
|
|
public void onSaveInstanceState (Bundle out) {
|
2011-09-09 11:58:11 +00:00
|
|
|
|
super.onSaveInstanceState(out);
|
2011-12-07 12:25:50 +00:00
|
|
|
|
|
2011-11-25 10:32:32 +00:00
|
|
|
|
out.putParcelable("article", m_article);
|
2011-09-09 11:58:11 +00:00
|
|
|
|
}
|
2011-12-09 20:49:55 +00:00
|
|
|
|
|
2011-09-09 11:58:11 +00:00
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onAttach(Activity activity) {
|
|
|
|
|
super.onAttach(activity);
|
2011-11-23 16:38:21 +00:00
|
|
|
|
|
2011-11-25 11:03:14 +00:00
|
|
|
|
m_prefs = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
|
2012-09-17 12:28:32 +00:00
|
|
|
|
m_activity = (OnlineActivity)activity;
|
2011-12-09 20:49:55 +00:00
|
|
|
|
//m_article = m_onlineServices.getSelectedArticle();
|
2012-12-14 15:37:05 +00:00
|
|
|
|
|
|
|
|
|
m_detector = new GestureDetector(m_activity, new GestureDetector.OnGestureListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onSingleTapUp(MotionEvent e) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onShowPress(MotionEvent e) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX,
|
|
|
|
|
float distanceY) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onLongPress(MotionEvent e) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
|
|
|
|
|
float velocityY) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onDown(MotionEvent e) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
m_detector.setOnDoubleTapListener(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onDoubleTap(MotionEvent arg0) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onDoubleTapEvent(MotionEvent arg0) {
|
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onLeftSideTapped() {
|
|
|
|
|
ArticlePager ap = (ArticlePager) m_activity.getSupportFragmentManager().findFragmentByTag(CommonActivity.FRAG_ARTICLE);
|
|
|
|
|
|
|
|
|
|
if (ap != null && ap.isAdded()) {
|
|
|
|
|
ap.selectArticle(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onRightSideTapped() {
|
|
|
|
|
ArticlePager ap = (ArticlePager) m_activity.getSupportFragmentManager().findFragmentByTag(CommonActivity.FRAG_ARTICLE);
|
|
|
|
|
|
|
|
|
|
if (ap != null && ap.isAdded()) {
|
|
|
|
|
ap.selectArticle(true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onSingleTapConfirmed(MotionEvent e) {
|
|
|
|
|
|
|
|
|
|
int width = getView().getWidth();
|
|
|
|
|
int x = Math.round(e.getX());
|
|
|
|
|
|
|
|
|
|
if (x <= width/15) {
|
|
|
|
|
onLeftSideTapped();
|
|
|
|
|
return true;
|
|
|
|
|
} else if (x >= width-(width/15)) {
|
|
|
|
|
onRightSideTapped();
|
|
|
|
|
return true;
|
|
|
|
|
} /* else if (!m_activity.isCompatMode()) {
|
|
|
|
|
ActionBar bar = m_activity.getActionBar();
|
|
|
|
|
|
|
|
|
|
if (bar.isShowing()) {
|
|
|
|
|
bar.hide();
|
|
|
|
|
} else {
|
|
|
|
|
bar.show();
|
|
|
|
|
}
|
|
|
|
|
} */
|
|
|
|
|
return false;
|
2011-09-09 11:58:11 +00:00
|
|
|
|
}
|
2011-11-28 10:01:04 +00:00
|
|
|
|
|
2011-09-09 11:58:11 +00:00
|
|
|
|
}
|