Permalink
Browse files

eliminated need for httprequest to grab pages, uses content given by …

…api to create a readable page
  • Loading branch information...
1 parent d3e4f46 commit 42b69dfb571086bf9793da22de4312895d841cec @fahimk committed May 6, 2011
View
Binary file not shown.
View
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
View
Binary file not shown.
@@ -2,12 +2,12 @@
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost" android:layout_width="fill_parent"
android:layout_height="fill_parent">
- <LinearLayout android:background="#FFFFFF" android:orientation="vertical"
+ <LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
- <TabWidget android:id="@android:id/tabs"
+ <TabWidget android:layout_marginTop="20dp" android:id="@android:id/tabs"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
<FrameLayout android:id="@android:id/tabcontent"
- android:layout_width="fill_parent" android:layout_height="fill_parent">
+ android:background="#FFFFFF" android:layout_width="fill_parent" android:layout_height="fill_parent">
<ListView android:cacheColorHint="#00000000" android:id="@+id/list_read" android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<ListView android:cacheColorHint="#00000000" android:id="@+id/list_fav" android:layout_width="fill_parent"
View
@@ -3,7 +3,7 @@
android:id="@+id/tabsLayout" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/tab_bg_selector"
- android:paddingTop="20dp" android:paddingBottom="20dp" android:paddingLeft="10dp" android:paddingRight="10dp" android:gravity="center" android:orientation="vertical">
+ android:padding="10dp" android:gravity="center" android:orientation="vertical">
<TextView android:id="@+id/tabsText" android:layout_width="wrap_content"
android:textStyle="bold" android:typeface="serif" android:layout_height="wrap_content" android:text="Title" android:textColor="@drawable/tab_text_selector"
android:textSize="14dip" />
@@ -69,10 +69,6 @@ public void setupViews() {
public void onClick(View v) {
database.delete(ARTICLE_TABLE, null, null);
- SharedPreferences preferences = getBaseContext().getSharedPreferences(PREF_NAME, 0);
- SharedPreferences.Editor editor = preferences.edit();
- editor.putString("previous_update", "0");
- editor.commit();
}
});
@@ -105,14 +101,12 @@ public void onClick(View v) {
String oauthToken;
String oauthTokenSecret;
String oauthVerifier;
- String previousUpdate;
SharedPreferences preferences;
protected void onPreExecute() {
preferences = getBaseContext().getSharedPreferences(PREF_NAME, 0);
oauthToken = preferences.getString("oauth_token", null);
oauthTokenSecret = preferences.getString("oauth_token_secret", null);
oauthVerifier = preferences.getString("oauth_verifier", null);
- previousUpdate = preferences.getString("previous_update", "0");
tempDialog = new ProgressDialog(MainMenu.this);
tempDialog.setMessage("Connecting to server...");
@@ -178,10 +172,8 @@ protected Boolean doInBackground(Void... params) {
new String[] {MY_ID},
whereIDSame, null, null, null, null);
if(articleCursor.getCount() > 0) {
- if(bm.date_updated.compareTo(previousUpdate) >= 0) {
database.update(ARTICLE_TABLE, values, whereIDSame, null);
Log.e("updated", bm.article.title);
- }
}
else {
String params2 = String.format("&oauth_nonce=%s&oauth_timestamp=%s" +
@@ -194,17 +186,18 @@ protected Boolean doInBackground(Void... params) {
Reader articleReader = new InputStreamReader(articlesSource);
SearchArticle articleResponse = articleGson.fromJson(articleReader, SearchArticle.class);
values.put(ARTICLE_AUTHOR, articleResponse.author);
- if(!bm.archive) {
- try {
- String html = parseHTML("https://readability.com/mobile/articles/"+articleResponse.id);
- values.put(ARTICLE_CONTENT, html);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- else {
+ Log.e("content", articleResponse.content);
+ //if(!bm.archive) {
+ // try {
+ // String html = parseHTML("https://readability.com/mobile/articles/"+articleResponse.id);
+ // values.put(ARTICLE_CONTENT, html);
+ // } catch (Exception e) {
+ // e.printStackTrace();
+ // }
+ //}
+ //else {
values.put(ARTICLE_CONTENT, articleResponse.content);
- }
+ //}
//values.put(ARTICLE_CONTENT, articleResponse.content);
values.put(ARTICLE_CONTENT_SIZE, articleResponse.content_size);
values.put(ARTICLE_SHORT_URL, articleResponse.short_url);
@@ -116,6 +116,7 @@ public void onItemClick(AdapterView<?> parent, View view, int position,
Intent i = new Intent(getBaseContext(), WebActivity.class);
//i.putExtra("article_content", readArticleContent.get(position));
i.putExtra("local", true);
+ i.putExtra("article_content", readArticlesInfo.get(position).content);
//i.putExtra("scroll_position", readArticleScroll.get(position));
startActivity(i);
}
@@ -2,6 +2,8 @@
import static com.fahimk.readabilityclient.JavascriptModifyFunctions.*;
import static com.fahimk.readabilityclient.HelperMethods.*;
+import static com.fahimk.readabilityclient.HTMLOutline.*;
+
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
@@ -63,8 +65,8 @@ public void onProgressChanged(WebView view, int progress)
Log.e("exception loading url", e.getMessage());
}
}
-
- Log.e("content", content);
+ content = header+content+footer;
+ //Log.e("content", content);
webView.getSettings().setCacheMode(WebSettings.LOAD_NORMAL);
webView.getSettings().setJavaScriptEnabled(true);
@@ -133,18 +135,18 @@ public void onPageFinished(WebView view, String url){
// "$(\".article-back-link\").attr(\"href\", \"##\")" +
// "})()");
//
- view.loadUrl("javascript:(function() { " +
- //"$(\"a[class='article-back-link']\").attr(\"href\", \"backButton#\");" +
- //"var images = document.getElementsByTagName('img'); var l = images.length; for (var i = 0; i < l; i++) {images[0].parentNode.removeChild(images[0])}" +
- "var readBar = document.getElementById('read-bar'); readBar.parentNode.removeChild(readBar);"+
-
- "var footNote = document.getElementById('article-marketing'); footNote.parentNode.removeChild(footNote);"+
- //"var hLink=document.getElementsByTagName(\"a\"); for (i=0;i<hLink.length;i++){ if(!hLink[i].href){ hLink[i].href = '#'; }}" +
- //"$('a:not([href*=\"#\"])').contents().unwrap();"+
- "})()");
+// view.loadUrl("javascript:(function() { " +
+// //"$(\"a[class='article-back-link']\").attr(\"href\", \"backButton#\");" +
+// //"var images = document.getElementsByTagName('img'); var l = images.length; for (var i = 0; i < l; i++) {images[0].parentNode.removeChild(images[0])}" +
+// "var readBar = document.getElementById('read-bar'); readBar.parentNode.removeChild(readBar);"+
+//
+// "var footNote = document.getElementById('article-marketing'); footNote.parentNode.removeChild(footNote);"+
+// //"var hLink=document.getElementsByTagName(\"a\"); for (i=0;i<hLink.length;i++){ if(!hLink[i].href){ hLink[i].href = '#'; }}" +
+// //"$('a:not([href*=\"#\"])').contents().unwrap();"+
+// "})()");
//need better algorithm for this based on number of words
- view.scrollTo(0, (int) (scrollPosition * view.getContentHeight() + view.getHeight()));
+ //view.scrollTo(0, (int) (scrollPosition * view.getContentHeight() + view.getHeight()));
addButtonListeners(findViewById(R.id.mainFrame), webView);
setupCustomPanel();
setupDefaultTheme(webView);

0 comments on commit 42b69df

Please sign in to comment.