rework combined mode to use textviews to prevent graphical glitches
This commit is contained in:
parent
e057f881b1
commit
ea51e68b5b
@ -9,7 +9,7 @@
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
||||
<application android:icon="@drawable/icon" android:label="@string/app_name" android:hardwareAccelerated="true">
|
||||
<activity android:name=".LoginActivity"
|
||||
android:label="@string/app_name">
|
||||
</activity>
|
||||
|
@ -95,7 +95,7 @@
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<WebView
|
||||
<TextView
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -98,8 +98,9 @@
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<WebView
|
||||
<TextView
|
||||
android:id="@+id/content"
|
||||
android:text="Article content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1" />
|
||||
|
@ -98,7 +98,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<WebView
|
||||
<TextView
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
@ -100,12 +100,12 @@
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<WebView
|
||||
<TextView
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:padding="3dip" >
|
||||
</WebView>
|
||||
</TextView>
|
||||
|
||||
</LinearLayout>
|
@ -98,12 +98,12 @@
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<WebView
|
||||
<TextView
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:padding="3dip" >
|
||||
</WebView>
|
||||
</TextView>
|
||||
|
||||
</LinearLayout>
|
@ -98,12 +98,12 @@
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<WebView
|
||||
<TextView
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:padding="3dip" >
|
||||
</WebView>
|
||||
</TextView>
|
||||
|
||||
</LinearLayout>
|
@ -100,12 +100,12 @@
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<WebView
|
||||
<TextView
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:padding="3dip" >
|
||||
</WebView>
|
||||
</TextView>
|
||||
|
||||
</LinearLayout>
|
@ -98,12 +98,12 @@
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<WebView
|
||||
<TextView
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:padding="3dip" >
|
||||
</WebView>
|
||||
</TextView>
|
||||
|
||||
</LinearLayout>
|
@ -98,12 +98,12 @@
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<WebView
|
||||
<TextView
|
||||
android:id="@+id/content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:padding="3dip" >
|
||||
</WebView>
|
||||
</TextView>
|
||||
|
||||
</LinearLayout>
|
@ -88,6 +88,6 @@
|
||||
<string name="error_api_unknown">Error: unknown API error (see log)</string>
|
||||
<string name="error_login_failed">Error: username or password incorrect</string>
|
||||
<string name="error_invalid_api_url">Error: invalid API URL</string>
|
||||
<string name="combined_mode_summary">Displays articles inline, instead of a separate panel</string>
|
||||
<string name="combined_mode_summary">Displays full article text inline, instead of a separate panel</string>
|
||||
<string name="combined_mode">Combined mode</string>
|
||||
</resources>
|
@ -19,7 +19,6 @@ import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
@ -1,6 +1,9 @@
|
||||
package org.fox.ttrss;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.MalformedURLException;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
@ -9,26 +12,31 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
import org.jsoup.Jsoup;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.Html;
|
||||
import android.text.Html.ImageGetter;
|
||||
import android.text.Spanned;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
import android.view.ContextMenu;
|
||||
import android.view.ContextMenu.ContextMenuInfo;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.ViewGroup;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebView;
|
||||
import android.widget.AbsListView;
|
||||
import android.widget.AbsListView.OnScrollListener;
|
||||
import android.widget.AdapterView;
|
||||
@ -67,6 +75,15 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
|
||||
private ArticleOps m_articleOps;
|
||||
|
||||
private ImageGetter m_dummyGetter = new ImageGetter() {
|
||||
|
||||
@Override
|
||||
public Drawable getDrawable(String source) {
|
||||
return new BitmapDrawable();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public ArticleList getSelectedArticles() {
|
||||
return m_selectedArticles;
|
||||
}
|
||||
@ -330,7 +347,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
View v = convertView;
|
||||
|
||||
final Article article = items.get(position);
|
||||
int webBgResource = R.attr.headlineNormalBackground;
|
||||
|
||||
if (v == null) {
|
||||
int layoutId = R.layout.headlines_row;
|
||||
@ -341,11 +357,9 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
break;
|
||||
case VIEW_UNREAD:
|
||||
layoutId = R.layout.headlines_row_unread;
|
||||
webBgResource = R.attr.headlineUnreadBackground;
|
||||
break;
|
||||
case VIEW_SELECTED:
|
||||
layoutId = R.layout.headlines_row_selected;
|
||||
webBgResource = R.attr.headlineSelectedBackground;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -416,46 +430,19 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
||||
}
|
||||
}
|
||||
|
||||
WebView web = (WebView)v.findViewById(R.id.content);
|
||||
TextView content = (TextView)v.findViewById(R.id.content);
|
||||
|
||||
if (web != null) {
|
||||
if (content != null) {
|
||||
if (m_combinedMode) {
|
||||
String content;
|
||||
String cssOverride = "";
|
||||
|
||||
TypedValue tv = new TypedValue();
|
||||
getActivity().getTheme().resolveAttribute(webBgResource, tv, true);
|
||||
int webColor = tv.data;
|
||||
|
||||
web.setBackgroundColor(webColor);
|
||||
|
||||
//WebSettings ws = web.getSettings();
|
||||
//ws.setBlockNetworkLoads(true);
|
||||
content.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) {
|
||||
cssOverride = "body { background : transparent; color : #e0e0e0}\n";
|
||||
} else {
|
||||
cssOverride = "body { background : transparent; }\n";
|
||||
}
|
||||
//content.setText(Html.fromHtml(article.content, new URLImageGetter(content, getActivity()), null));
|
||||
content.setText(Html.fromHtml(article.content, m_dummyGetter, null));
|
||||
|
||||
content =
|
||||
"<html>" +
|
||||
"<head>" +
|
||||
"<meta content=\"text/html; charset=utf-8\" http-equiv=\"content-type\" />" +
|
||||
"<meta name=\"viewport\" content=\"target-densitydpi=device-dpi\" />" +
|
||||
"<style type=\"text/css\">" +
|
||||
cssOverride +
|
||||
"img { max-width : 98%; height : auto; }" +
|
||||
"body { text-align : justify; }" +
|
||||
"</style>" +
|
||||
"</head>" +
|
||||
"<body>" + article.content + "</body></html>";
|
||||
|
||||
web.loadDataWithBaseURL(null, content, "text/html", "utf-8", null);
|
||||
//web.setOnTouchListener(new WebViewClickListener(web, parent, position));
|
||||
} else {
|
||||
web.setVisibility(View.GONE);
|
||||
content.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TextView dv = (TextView) v.findViewById(R.id.date);
|
||||
|
Loading…
Reference in New Issue
Block a user