support article comments for API 4 server (closes #490)

This commit is contained in:
Andrew Dolgov 2012-10-09 19:36:23 +04:00
parent 2424b72246
commit 00b80487b4
5 changed files with 49 additions and 1 deletions

View File

@ -22,6 +22,16 @@
android:text="There are many variations of passages of Lorem Ipsum available"
android:textSize="16sp" />
<TextView
android:id="@+id/comments"
android:textColor="?linkColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="24 comments"
android:textSize="13sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"

View File

@ -145,4 +145,5 @@
<string name="error_ssl_hostname_rejected">Error: SSL hostname not verified</string>
<string name="offline_oldest_first">Show oldest articles first</string>
<string name="prefs_dim_status_bar">Dim status bar when reading</string>
<string name="article_comments">%1$d comments</string>
</resources>

View File

@ -141,6 +141,35 @@ public class ArticleFragment extends Fragment {
registerForContextMenu(title);
}
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);
}
}
WebView web = (WebView)view.findViewById(R.id.content);
if (web != null) {

View File

@ -143,6 +143,12 @@ public class OfflineArticleFragment extends Fragment {
registerForContextMenu(title);
}
TextView comments = (TextView)view.findViewById(R.id.comments);
if (comments != null) {
comments.setVisibility(View.GONE);
}
WebView web = (WebView)view.findViewById(R.id.content);
if (web != null) {

View File

@ -21,7 +21,9 @@ public class Article implements Parcelable {
public List<Attachment> attachments;
public String content;
public List<List<String>> labels;
public String feed_title;
public String feed_title;
public int comments_count;
public String comments_link;
public Article(Parcel in) {
readFromParcel(in);