package org.fox.ttrss; import java.text.SimpleDateFormat; import java.util.Date; import org.fox.ttrss.OnlineServices.RelativeArticle; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.jsoup.select.Elements; import android.app.Activity; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.PreferenceManager; import android.support.v4.app.Fragment; import android.text.Html; import android.text.method.LinkMovementMethod; import android.util.Log; import android.view.GestureDetector; import android.view.GestureDetector.SimpleOnGestureListener; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.webkit.WebView; import android.widget.ImageView; import android.widget.TextView; import com.google.ads.AdRequest; import com.google.ads.AdView; public class ArticleFragment extends Fragment implements OnClickListener { @SuppressWarnings("unused") private final String TAG = this.getClass().getSimpleName(); private SharedPreferences m_prefs; private Article m_article; private OnlineServices m_onlineServices; private Article m_nextArticle; private Article m_prevArticle; private GestureDetector m_gestureDetector; private View.OnTouchListener m_gestureListener; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (savedInstanceState != null) { m_article = savedInstanceState.getParcelable("article"); } View view = inflater.inflate(R.layout.article_fragment, container, false); m_gestureDetector = new GestureDetector(new MyGestureDetector()); m_gestureListener = new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent aEvent) { if (m_gestureDetector.onTouchEvent(aEvent)) return true; else return false; } }; Activity activity = (Activity)getActivity(); if (activity != null) { int orientation = activity.getWindowManager().getDefaultDisplay().getOrientation(); if (!m_onlineServices.isSmallScreen()) { if (orientation % 2 == 0) { view.findViewById(R.id.splitter_horizontal).setVisibility(View.GONE); } else { view.findViewById(R.id.splitter_vertical).setVisibility(View.GONE); } } else { view.findViewById(R.id.splitter_vertical).setVisibility(View.GONE); view.findViewById(R.id.splitter_horizontal).setVisibility(View.GONE); } } else { view.findViewById(R.id.splitter_horizontal).setVisibility(View.GONE); } if (m_article != null) { TextView title = (TextView)view.findViewById(R.id.title); if (title != null) { String titleStr; if (m_article.title.length() > 200) titleStr = m_article.title.substring(0, 200) + "..."; else titleStr = m_article.title; title.setMovementMethod(LinkMovementMethod.getInstance()); title.setText(Html.fromHtml("" + titleStr + "")); } WebView web = (WebView)view.findViewById(R.id.content); if (web != null) { String content; String cssOverride = ""; //WebSettings ws = web.getSettings(); //ws.setSupportZoom(true); //ws.setBuiltInZoomControls(true); if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) { cssOverride = "body { background : black; color : #e0e0e0}\n"; web.setBackgroundColor(android.R.color.black); } else { cssOverride = ""; } String articleContent = m_article.content; Document doc = Jsoup.parse(articleContent); if (doc != null) { // thanks webview for crashing on