display the article content in a webview

This commit is contained in:
Kevin Meyer 2014-08-19 12:37:38 +02:00
parent e2210e8a40
commit 4c5c27fedc
4 changed files with 50 additions and 12 deletions

View File

@ -51,7 +51,25 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates" /> <excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/coverage-instrumented-classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dex-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaResources" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/libs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/lint" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/ndk" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/proguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" /> <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
</content> </content>
<orderEntry type="jdk" jdkName="Android API 20 Platform" jdkType="Android SDK" /> <orderEntry type="jdk" jdkName="Android API 20 Platform" jdkType="Android SDK" />

View File

@ -32,11 +32,10 @@
android:layout_marginTop="5sp" android:layout_marginTop="5sp"
android:background="#000000" /> android:background="#000000" />
<TextView <WebView
android:id="@+id/txtContent" android:id="@+id/webViewContent"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content" />
android:textSize="18sp" />
<View <View
android:id="@+id/view1" android:id="@+id/view1"

View File

@ -461,10 +461,10 @@ import static fr.gaulupeau.apps.Poche.ArticlesSQLiteOpenHelper.ARTICLE_DATE;
} }
ContentValues values = new ContentValues(); ContentValues values = new ContentValues();
values.put(ARTICLE_TITLE, Html.fromHtml(arrays.PodcastTitle[i]).toString()); values.put(ARTICLE_TITLE, arrays.PodcastTitle[i]);
values.put(ARTICLE_CONTENT, Html.fromHtml(arrays.PodcastContent[i]).toString()); values.put(ARTICLE_CONTENT, arrays.PodcastContent[i]);
//values.put(ARTICLE_ID, Html.fromHtml(article.getString("id")).toString()); //values.put(ARTICLE_ID, Html.fromHtml(article.getString("id")).toString());
values.put(ARTICLE_URL, Html.fromHtml(arrays.PodcastURL[i]).toString()); values.put(ARTICLE_URL, arrays.PodcastURL[i]);
values.put(ARTICLE_DATE, arrays.PodcastDate[i]); values.put(ARTICLE_DATE, arrays.PodcastDate[i]);
values.put(ARCHIVE, 0); values.put(ARCHIVE, 0);
values.put(ARTICLE_SYNC, 0); values.put(ARTICLE_SYNC, 0);

View File

@ -27,7 +27,7 @@ import fr.gaulupeau.apps.InThePoche.R;
public class ReadArticle extends Activity { public class ReadArticle extends Activity {
TextView txtTitre; TextView txtTitre;
TextView txtContent; WebView webViewContent;
TextView txtAuthor; TextView txtAuthor;
Button btnMarkRead; Button btnMarkRead;
SQLiteDatabase database; SQLiteDatabase database;
@ -49,8 +49,29 @@ public class ReadArticle extends Activity {
ac.moveToFirst(); ac.moveToFirst();
txtTitre = (TextView)findViewById(R.id.txtTitre); txtTitre = (TextView)findViewById(R.id.txtTitre);
txtTitre.setText(ac.getString(2)); txtTitre.setText(ac.getString(2));
txtContent = (TextView)findViewById(R.id.txtContent);
txtContent.setText(ac.getString(3)); String htmlHeader = "<html>\n" +
"\t<head>\n" +
"\t\t<meta name=\"viewport\" content=\"initial-scale=1.0, maximum-scale=1.0, user-scalable=no\" />\n" +
"\t\t<meta charset=\"utf-8\">\n" +
"\t</head>\n" +
"\t\t<div id=\"main\">\n" +
"\t\t\t<body>\n" +
"\t\t\t\t<div id=\"content\" class=\"w600p center\">\n" +
"\t\t\t\t\t<div id=\"article\">\n" +
"\t\t\t\t\t\t<article>";
String htmlFooter = "</article>\n" +
"\t\t\t\t\t</div>\n" +
"\t\t\t\t</div>\n" +
"\t\t\t</body>\n" +
"\t\t</div>\n" +
"</html>";
String htmlContent = ac.getString(3);
webViewContent = (WebView)findViewById(R.id.webViewContent);
webViewContent.loadData(htmlHeader + htmlContent + htmlFooter, "text/html; charset=utf-8", null);
txtAuthor = (TextView)findViewById(R.id.txtAuthor); txtAuthor = (TextView)findViewById(R.id.txtAuthor);
txtAuthor.setText(ac.getString(0)); txtAuthor.setText(ac.getString(0));