Added ability to favourite comments. Added replies.
|
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
BIN
media/android/NewsBlur/res/drawable-hdpi/have_favourite.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
BIN
media/android/NewsBlur/res/drawable-mdpi/have_favourite.png
Normal file
|
After Width: | Height: | Size: 748 B |
|
Before Width: | Height: | Size: 2 KiB After Width: | Height: | Size: 2 KiB |
BIN
media/android/NewsBlur/res/drawable-xhdpi/have_favourite.png
Normal file
|
After Width: | Height: | Size: 2 KiB |
|
|
@ -2,6 +2,7 @@
|
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/item_background"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<FrameLayout
|
||||
|
|
@ -14,11 +15,11 @@
|
|||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:layout_below="@id/profile_details" />
|
||||
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="8dip"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@drawable/orangeline_shadow" />
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
@ -14,24 +14,11 @@
|
|||
android:layout_height="1dip"
|
||||
android:layout_alignParentTop="true" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/reading_floatbar"
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/reading_divider"
|
||||
android:alpha="0.7"
|
||||
android:minHeight="8dp" />
|
||||
android:layout_height="8dip"
|
||||
android:layout_alignParentTop="true"
|
||||
android:background="@drawable/orangeline_shadow" />
|
||||
|
||||
<View
|
||||
android:id="@+id/reading_divider_bottom"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dip"
|
||||
android:layout_below="@id/reading_floatbar" />
|
||||
|
||||
<View
|
||||
android:id="@+id/reading_divider_bottom"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dip"
|
||||
android:layout_below="@id/reading_floatbar" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
@ -1,15 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/item_background"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<ListView
|
||||
android:id="@+id/itemlistfragment_list"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
<TextView
|
||||
android:id="@+id/empty_view"
|
||||
android:layout_width="match_parent"
|
||||
android:background="@color/item_background"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true"
|
||||
android:gravity="center"
|
||||
android:text="@string/empty_list_notice"
|
||||
android:textColor="@color/darkgray"
|
||||
android:textSize="13dp"
|
||||
android:textStyle="italic" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/itemlistfragment_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:divider="@drawable/divider_light"
|
||||
android:dividerHeight="2dp" />
|
||||
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/list_background"
|
||||
android:orientation="vertical" >
|
||||
android:orientation="vertical"
|
||||
android:background="@color/item_background" >
|
||||
|
||||
<TextView
|
||||
android:layout_width="fill_parent"
|
||||
|
|
@ -12,14 +12,15 @@
|
|||
android:textColor="@color/white"
|
||||
android:textSize="16dp"
|
||||
android:textStyle="bold"
|
||||
android:background="@drawable/list_background"
|
||||
android:text="@string/profile_recent_actvity" />
|
||||
|
||||
<ListView
|
||||
android:id="@+id/profile_details_activitylist"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@drawable/list_background"
|
||||
android:divider="@color/transparent"
|
||||
android:dividerHeight="1dp" />
|
||||
android:background="@color/item_background"
|
||||
android:divider="@drawable/divider_light"
|
||||
android:dividerHeight="3dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
android:background="@color/item_background"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
|
|
|
|||
|
|
@ -89,13 +89,12 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:visibility="gone" >
|
||||
|
||||
<LinearLayout
|
||||
<RelativeLayout
|
||||
android:id="@+id/reading_share_bar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/list_background"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="10dp"
|
||||
android:paddingBottom="10dp" >
|
||||
|
||||
|
|
@ -105,18 +104,31 @@
|
|||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:text="@string/reading_sharedby"
|
||||
android:layout_centerVertical="true"
|
||||
android:id="@+id/reading_share_text"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12dp"
|
||||
android:textStyle="bold" />
|
||||
android:textSize="12dp" />
|
||||
|
||||
<android.support.v7.widget.GridLayout
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/reading_social_shareimages"
|
||||
android:layout_width="match_parent"
|
||||
android:id="@+id/reading_social_friendimages"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:columnCount="8"
|
||||
android:layout_alignParentRight="true"
|
||||
app:columnCount="3"
|
||||
app:useDefaultMargins="true" />
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.v7.widget.GridLayout
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/reading_social_shareimages"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@+id/reading_share_text"
|
||||
android:layout_toLeftOf="@+id/reading_social_friendimages"
|
||||
app:columnCount="3"
|
||||
app:useDefaultMargins="true" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/reading_friend_comment_container"
|
||||
|
|
|
|||
|
|
@ -1,19 +1,21 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/item_background"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="12dp"
|
||||
android:paddingBottom="12dp"
|
||||
android:background="@color/item_background">
|
||||
android:paddingBottom="8dp"
|
||||
android:paddingTop="8dp" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/comment_user_image"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:contentDescription="@string/description_comment_user"
|
||||
android:scaleType="fitCenter" />
|
||||
|
||||
|
|
@ -26,12 +28,32 @@
|
|||
android:textColor="@color/lightgray"
|
||||
android:textSize="11dp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/comment_favourite_icon"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_alignBottom="@id/comment_shareddate"
|
||||
android:layout_marginRight="8dp"
|
||||
android:layout_toLeftOf="@id/comment_shareddate"
|
||||
android:scaleType="fitCenter"
|
||||
android:src="@drawable/favourite" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/comment_favourite_count"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toLeftOf="@id/comment_favourite_icon"
|
||||
android:layout_alignBottom="@id/comment_shareddate"
|
||||
android:textColor="@color/darkgray"
|
||||
android:layout_marginRight="4dp"
|
||||
android:textSize="11dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/comment_username"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_toRightOf="@id/comment_user_image"
|
||||
android:textColor="@color/darkgray"
|
||||
android:textColor="@color/darkorange"
|
||||
android:textSize="11dp" />
|
||||
|
||||
<TextView
|
||||
|
|
@ -40,9 +62,15 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/comment_shareddate"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_toRightOf="@id/comment_user_image"
|
||||
android:textColor="@color/darkgray"
|
||||
android:textSize="14dp" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/comment_replies_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/comment_text" />
|
||||
|
||||
</RelativeLayout>
|
||||
51
media/android/NewsBlur/res/layout/include_reply.xml
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/item_background"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="12dp"
|
||||
android:paddingLeft="25dp"
|
||||
android:paddingTop="12dp" >
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/reply_user_image"
|
||||
android:layout_width="25dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginLeft="10dp"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:contentDescription="@string/description_comment_user"
|
||||
android:scaleType="fitCenter" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/reply_shareddate"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="10dp"
|
||||
android:textColor="@color/lightgray"
|
||||
android:textSize="11dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/reply_username"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/darkorange"
|
||||
android:layout_toRightOf="@id/reply_user_image"
|
||||
android:textSize="11dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/reply_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@id/reply_shareddate"
|
||||
android:layout_marginRight="10dp"
|
||||
android:layout_toRightOf="@id/reply_user_image"
|
||||
android:textColor="@color/darkgray"
|
||||
android:textSize="14dp" />
|
||||
|
||||
|
||||
</RelativeLayout>
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="1dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/white"
|
||||
android:background="@color/item_background"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingTop="12dp"
|
||||
android:textColor="@color/darkgray"
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="1dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/white"
|
||||
android:background="@color/item_background"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingTop="12dp"
|
||||
android:textColor="@color/darkgray"
|
||||
|
|
@ -41,7 +41,7 @@
|
|||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="1dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/white"
|
||||
android:background="@color/item_background"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingTop="12dp"
|
||||
android:textColor="@color/darkgray"
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="1dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/white"
|
||||
android:background="@color/item_background"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingBottom="15dp"
|
||||
android:paddingTop="3dp"
|
||||
|
|
@ -72,7 +72,7 @@
|
|||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="1dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/white"
|
||||
android:background="@color/item_background"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingBottom="15dp"
|
||||
android:paddingTop="3dp"
|
||||
|
|
@ -85,7 +85,7 @@
|
|||
android:layout_height="fill_parent"
|
||||
android:layout_marginRight="1dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@color/white"
|
||||
android:background="@color/item_background"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingBottom="15dp"
|
||||
android:paddingTop="3dp"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:background="@color/white"
|
||||
android:background="@color/item_background"
|
||||
android:paddingBottom="10dp"
|
||||
android:paddingTop="10dp" >
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<color name="darkgray">#434343</color>
|
||||
<color name="hintgray">#66bbbbbb</color>
|
||||
<color name="midgray">#bbbbbb</color>
|
||||
<color name="lightgray">#dddddd</color>
|
||||
<color name="lightgray">#ccc</color>
|
||||
<color name="lightorange">#d98800</color>
|
||||
<color name="darkorange">#b44a00</color>
|
||||
<color name="lightgreen">#3b8207</color>
|
||||
|
|
|
|||
|
|
@ -75,4 +75,6 @@
|
|||
|
||||
<string name="unsorted_folder_name">Unsorted</string>
|
||||
|
||||
<string name="empty_list_notice">There aren\'t any stories to display here right now.</string>
|
||||
|
||||
</resources>
|
||||
|
|
@ -55,11 +55,21 @@ public class BlurDatabase extends SQLiteOpenHelper {
|
|||
DatabaseConstants.COMMENT_DATE + TEXT + ", " +
|
||||
DatabaseConstants.COMMENT_SHAREDDATE + TEXT + ", " +
|
||||
DatabaseConstants.COMMENT_ID + TEXT + " PRIMARY KEY, " +
|
||||
DatabaseConstants.COMMENT_LIKING_USERS + TEXT + ", " +
|
||||
DatabaseConstants.COMMENT_STORYID + TEXT + ", " +
|
||||
DatabaseConstants.COMMENT_TEXT + TEXT + ", " +
|
||||
DatabaseConstants.COMMENT_USERID + TEXT +
|
||||
")";
|
||||
|
||||
private final String REPLY_SQL = "CREATE TABLE " + DatabaseConstants.REPLY_TABLE + " (" +
|
||||
DatabaseConstants.REPLY_DATE + TEXT + ", " +
|
||||
DatabaseConstants.REPLY_SHORTDATE + TEXT + ", " +
|
||||
DatabaseConstants.REPLY_ID + TEXT + " PRIMARY KEY, " +
|
||||
DatabaseConstants.REPLY_COMMENTID + TEXT + ", " +
|
||||
DatabaseConstants.REPLY_TEXT + TEXT + ", " +
|
||||
DatabaseConstants.REPLY_USERID + TEXT +
|
||||
")";
|
||||
|
||||
private final String OFFLINE_UPDATE_SQL = "CREATE TABLE " + DatabaseConstants.UPDATE_TABLE + " (" +
|
||||
DatabaseConstants.UPDATE_ID + INTEGER + " PRIMARY KEY, " +
|
||||
DatabaseConstants.UPDATE_TYPE + INTEGER + ", " +
|
||||
|
|
@ -117,6 +127,7 @@ public class BlurDatabase extends SQLiteOpenHelper {
|
|||
db.execSQL(FOLDER_SQL);
|
||||
db.execSQL(STORY_SQL);
|
||||
db.execSQL(COMMENT_SQL);
|
||||
db.execSQL(REPLY_SQL);
|
||||
db.execSQL(CLASSIFIER_SQL);
|
||||
db.execSQL(FEED_FOLDER_SQL);
|
||||
db.execSQL(SOCIALFEED_STORIES_SQL);
|
||||
|
|
|
|||
|
|
@ -82,9 +82,19 @@ public class DatabaseConstants {
|
|||
public static final String COMMENT_STORYID = "comment_storyid";
|
||||
public static final String COMMENT_TEXT = "comment_text";
|
||||
public static final String COMMENT_DATE = "comment_date";
|
||||
public static final String COMMENT_LIKING_USERS = "comment_liking_users";
|
||||
public static final String COMMENT_SHAREDDATE = "comment_shareddate";
|
||||
public static final String COMMENT_USERID = "comment_userid";
|
||||
|
||||
public static final String REPLY_TABLE = "comment_replies";
|
||||
|
||||
public static final String REPLY_ID = BaseColumns._ID;
|
||||
public static final String REPLY_COMMENTID = "comment_id";
|
||||
public static final String REPLY_TEXT = "reply_text";
|
||||
public static final String REPLY_USERID = "reply_userid";
|
||||
public static final String REPLY_DATE = "reply_date";
|
||||
public static final String REPLY_SHORTDATE = "reply_shortdate";
|
||||
|
||||
// Aggregated columns
|
||||
public static final String SUM_POS = "sum_postive";
|
||||
public static final String SUM_NEUT = "sum_neutral";
|
||||
|
|
@ -104,7 +114,11 @@ public class DatabaseConstants {
|
|||
};
|
||||
|
||||
public static final String[] COMMENT_COLUMNS = {
|
||||
COMMENT_ID, COMMENT_STORYID, COMMENT_TEXT, COMMENT_USERID, COMMENT_DATE, COMMENT_SHAREDDATE
|
||||
COMMENT_ID, COMMENT_STORYID, COMMENT_TEXT, COMMENT_USERID, COMMENT_DATE, COMMENT_LIKING_USERS, COMMENT_SHAREDDATE
|
||||
};
|
||||
|
||||
public static final String[] REPLY_COLUMNS = {
|
||||
REPLY_COMMENTID, REPLY_DATE, REPLY_ID, REPLY_SHORTDATE, REPLY_TEXT, REPLY_USERID
|
||||
};
|
||||
|
||||
public static final String[] FOLDER_COLUMNS = {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ public class FeedProvider extends ContentProvider {
|
|||
public static final Uri SOCIALFEED_STORIES_URI = Uri.parse("content://" + AUTHORITY + "/" + VERSION + "/stories/socialfeed/");
|
||||
public static final Uri STORY_URI = Uri.parse("content://" + AUTHORITY + "/" + VERSION + "/story/");
|
||||
public static final Uri COMMENTS_URI = Uri.parse("content://" + AUTHORITY + "/" + VERSION + "/comments/");
|
||||
public static final Uri REPLIES_URI = Uri.parse("content://" + AUTHORITY + "/" + VERSION + "/replies/");
|
||||
public static final Uri FEED_FOLDER_MAP_URI = Uri.parse("content://" + AUTHORITY + "/" + VERSION + "/feedfoldermap/");
|
||||
public static final Uri FOLDERS_URI = Uri.parse("content://" + AUTHORITY + "/" + VERSION + "/folders/");
|
||||
|
||||
|
|
@ -46,6 +47,8 @@ public class FeedProvider extends ContentProvider {
|
|||
private static final int OFFLINE_UPDATES = 12;
|
||||
private static final int DECREMENT_SOCIALFEED_COUNT = 13;
|
||||
private static final int INDIVIDUAL_SOCIAL_FEED = 14;
|
||||
private static final int REPLIES = 15;
|
||||
|
||||
|
||||
private BlurDatabase databaseHelper;
|
||||
|
||||
|
|
@ -64,6 +67,7 @@ public class FeedProvider extends ContentProvider {
|
|||
uriMatcher.addURI(AUTHORITY, VERSION + "/stories/feed/#/", FEED_STORIES);
|
||||
uriMatcher.addURI(AUTHORITY, VERSION + "/story/*/", INDIVIDUAL_STORY);
|
||||
uriMatcher.addURI(AUTHORITY, VERSION + "/comments/", STORY_COMMENTS);
|
||||
uriMatcher.addURI(AUTHORITY, VERSION + "/replies/", REPLIES);
|
||||
uriMatcher.addURI(AUTHORITY, VERSION + "/feedfoldermap/", FEED_FOLDER_MAP);
|
||||
uriMatcher.addURI(AUTHORITY, VERSION + "/feedfoldermap/*/", SPECIFIC_FEED_FOLDER_MAP);
|
||||
uriMatcher.addURI(AUTHORITY, VERSION + "/folders/", ALL_FOLDERS);
|
||||
|
|
@ -151,6 +155,14 @@ public class FeedProvider extends ContentProvider {
|
|||
db.setTransactionSuccessful();
|
||||
db.endTransaction();
|
||||
break;
|
||||
|
||||
// Inserting a reply
|
||||
case REPLIES:
|
||||
db.beginTransaction();
|
||||
db.insertWithOnConflict(DatabaseConstants.REPLY_TABLE, null, values, SQLiteDatabase.CONFLICT_REPLACE);
|
||||
db.setTransactionSuccessful();
|
||||
db.endTransaction();
|
||||
break;
|
||||
|
||||
// Inserting a story
|
||||
case FEED_STORIES:
|
||||
|
|
@ -215,6 +227,11 @@ public class FeedProvider extends ContentProvider {
|
|||
selection = DatabaseConstants.COMMENT_STORYID + " = ?";
|
||||
return db.query(DatabaseConstants.COMMENT_TABLE, DatabaseConstants.COMMENT_COLUMNS, selection, selectionArgs, null, null, null);
|
||||
|
||||
// Querying for replies to a comment
|
||||
case REPLIES:
|
||||
selection = DatabaseConstants.REPLY_COMMENTID+ " = ?";
|
||||
return db.query(DatabaseConstants.REPLY_TABLE, DatabaseConstants.REPLY_COLUMNS, selection, selectionArgs, null, null, null);
|
||||
|
||||
// Query for feeds with no folder mapping
|
||||
case FEED_FOLDER_MAP:
|
||||
String nullFolderQuery = "SELECT " + TextUtils.join(",", DatabaseConstants.FEED_COLUMNS) + " FROM " + DatabaseConstants.FEED_TABLE +
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import java.io.Serializable;
|
|||
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.newsblur.database.DatabaseConstants;
|
||||
|
|
@ -12,43 +13,51 @@ public class Comment implements Serializable {
|
|||
private static final long serialVersionUID = -2018705258520565390L;
|
||||
|
||||
public String id;
|
||||
|
||||
|
||||
@SerializedName("comments")
|
||||
public String commentText;
|
||||
|
||||
|
||||
@SerializedName("user_id")
|
||||
public String userId;
|
||||
|
||||
|
||||
@SerializedName("shared_date")
|
||||
public String sharedDate;
|
||||
|
||||
|
||||
@SerializedName("date")
|
||||
public String date;
|
||||
|
||||
@SerializedName("liking_users")
|
||||
public String[] likingUsers = new String[]{};
|
||||
|
||||
public Reply[] replies;
|
||||
|
||||
public String storyId;
|
||||
|
||||
|
||||
|
||||
public ContentValues getValues() {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(DatabaseConstants.COMMENT_DATE, date);
|
||||
values.put(DatabaseConstants.COMMENT_STORYID, storyId);
|
||||
values.put(DatabaseConstants.COMMENT_LIKING_USERS, TextUtils.join(",", likingUsers));
|
||||
values.put(DatabaseConstants.COMMENT_TEXT, commentText);
|
||||
values.put(DatabaseConstants.COMMENT_SHAREDDATE, sharedDate);
|
||||
values.put(DatabaseConstants.COMMENT_USERID, userId);
|
||||
values.put(DatabaseConstants.COMMENT_ID, id);
|
||||
return values;
|
||||
}
|
||||
|
||||
|
||||
public static Comment fromCursor(final Cursor cursor) {
|
||||
|
||||
Comment comment = new Comment();
|
||||
comment.date = cursor.getString(cursor.getColumnIndex(DatabaseConstants.COMMENT_DATE));
|
||||
comment.sharedDate = cursor.getString(cursor.getColumnIndex(DatabaseConstants.COMMENT_SHAREDDATE));
|
||||
comment.commentText = cursor.getString(cursor.getColumnIndex(DatabaseConstants.COMMENT_TEXT));
|
||||
comment.storyId = cursor.getString(cursor.getColumnIndex(DatabaseConstants.COMMENT_STORYID));
|
||||
comment.userId = cursor.getString(cursor.getColumnIndex(DatabaseConstants.COMMENT_USERID));
|
||||
String likingUsers = cursor.getString(cursor.getColumnIndex(DatabaseConstants.COMMENT_LIKING_USERS));
|
||||
comment.likingUsers = TextUtils.split(likingUsers, ",");
|
||||
comment.id = cursor.getString(cursor.getColumnIndex(DatabaseConstants.COMMENT_ID));
|
||||
|
||||
|
||||
return comment;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
50
media/android/NewsBlur/src/com/newsblur/domain/Reply.java
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
package com.newsblur.domain;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.newsblur.database.DatabaseConstants;
|
||||
|
||||
public class Reply {
|
||||
@SerializedName("reply_id")
|
||||
public String id;
|
||||
|
||||
@SerializedName("user_id")
|
||||
public String userId;
|
||||
|
||||
@SerializedName("publish_date")
|
||||
public String shortDate;
|
||||
|
||||
@SerializedName("comments")
|
||||
public String text;
|
||||
|
||||
@SerializedName("date")
|
||||
public Date date;
|
||||
|
||||
public String commentId;
|
||||
|
||||
public ContentValues getValues() {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(DatabaseConstants.REPLY_DATE, date.getTime());
|
||||
values.put(DatabaseConstants.REPLY_SHORTDATE, shortDate);
|
||||
values.put(DatabaseConstants.REPLY_TEXT, text);
|
||||
values.put(DatabaseConstants.REPLY_COMMENTID, commentId);
|
||||
values.put(DatabaseConstants.REPLY_ID, id);
|
||||
values.put(DatabaseConstants.REPLY_USERID, userId);
|
||||
return values;
|
||||
}
|
||||
|
||||
public static Reply fromCursor(Cursor cursor) {
|
||||
Reply reply = new Reply();
|
||||
reply.date = new Date(cursor.getLong(cursor.getColumnIndex(DatabaseConstants.REPLY_DATE)));
|
||||
reply.shortDate = cursor.getString(cursor.getColumnIndex(DatabaseConstants.REPLY_SHORTDATE));
|
||||
reply.text = cursor.getString(cursor.getColumnIndex(DatabaseConstants.REPLY_TEXT));
|
||||
reply.commentId = cursor.getString(cursor.getColumnIndex(DatabaseConstants.REPLY_COMMENTID));
|
||||
reply.id = cursor.getString(cursor.getColumnIndex(DatabaseConstants.REPLY_ID));
|
||||
reply.userId = cursor.getString(cursor.getColumnIndex(DatabaseConstants.REPLY_USERID));
|
||||
return reply;
|
||||
}
|
||||
}
|
||||
|
|
@ -76,6 +76,8 @@ public class FeedItemListFragment extends ItemListFragment implements LoaderMana
|
|||
View v = inflater.inflate(R.layout.fragment_itemlist, null);
|
||||
ListView itemList = (ListView) v.findViewById(R.id.itemlistfragment_list);
|
||||
|
||||
itemList.setEmptyView(v.findViewById(R.id.empty_view));
|
||||
|
||||
contentResolver = getActivity().getContentResolver();
|
||||
storiesUri = FeedProvider.FEED_STORIES_URI.buildUpon().appendPath(feedId).build();
|
||||
Cursor cursor = contentResolver.query(storiesUri, null, FeedProvider.getSelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " DESC");
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ public class ProfileDetailsFragment extends Fragment implements OnClickListener
|
|||
} else {
|
||||
followButton.setVisibility(View.GONE);
|
||||
Bitmap userPicture = PrefsUtil.getUserImage(getActivity());
|
||||
userPicture = UIUtils.roundCorners(userPicture, 10f);
|
||||
userPicture = UIUtils.roundBitmap(userPicture);
|
||||
imageView.setImageBitmap(userPicture);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,39 +1,23 @@
|
|||
package com.newsblur.fragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.graphics.Color;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.GridLayout;
|
||||
import android.text.TextUtils;
|
||||
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.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.activity.NewsBlurApplication;
|
||||
import com.newsblur.activity.Profile;
|
||||
import com.newsblur.database.FeedProvider;
|
||||
import com.newsblur.domain.Comment;
|
||||
import com.newsblur.domain.Story;
|
||||
import com.newsblur.domain.UserProfile;
|
||||
import com.newsblur.network.APIManager;
|
||||
import com.newsblur.network.domain.ProfileResponse;
|
||||
import com.newsblur.network.SetupCommentSectionTask;
|
||||
import com.newsblur.util.ImageLoader;
|
||||
import com.newsblur.util.UIUtils;
|
||||
|
||||
public class ReadingItemFragment extends Fragment {
|
||||
|
||||
|
|
@ -44,8 +28,6 @@ public class ReadingItemFragment extends Fragment {
|
|||
private ImageLoader imageLoader;
|
||||
private String feedColor;
|
||||
private String feedFade;
|
||||
private HashMap<String, UserProfile> friendUserMap = new HashMap<String, UserProfile>();
|
||||
private HashMap<String, UserProfile> publicUserMap = new HashMap<String, UserProfile>();
|
||||
private ContentResolver resolver;
|
||||
|
||||
public static ReadingItemFragment newInstance(Story story, String feedFaviconColor, String feedFaviconFade) {
|
||||
|
|
@ -93,117 +75,7 @@ public class ReadingItemFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void setupItemCommentsAndShares(final View view) {
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
private List<UserProfile> profiles = new ArrayList<UserProfile>();
|
||||
private ArrayList<View> publicCommentViews;
|
||||
private ArrayList<View> friendCommentViews;
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... arg0) {
|
||||
for (String userId : story.sharedUserIds) {
|
||||
ProfileResponse user = apiManager.getUser(userId);
|
||||
friendUserMap.put(userId, user.user);
|
||||
}
|
||||
|
||||
for (String userId : story.friendUserIds) {
|
||||
ProfileResponse user = apiManager.getUser(userId);
|
||||
friendUserMap.put(userId, user.user);
|
||||
}
|
||||
|
||||
for (String userId : story.publicUserIds) {
|
||||
ProfileResponse user = apiManager.getUser(userId);
|
||||
publicUserMap.put(userId, user.user);
|
||||
}
|
||||
|
||||
Cursor cursor = resolver.query(FeedProvider.COMMENTS_URI, null, null, new String[] { story.id }, null);
|
||||
|
||||
publicCommentViews = new ArrayList<View>();
|
||||
friendCommentViews = new ArrayList<View>();
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
Comment comment = Comment.fromCursor(cursor);
|
||||
View commentView = inflater.inflate(R.layout.include_comment, null);
|
||||
TextView commentText = (TextView) commentView.findViewById(R.id.comment_text);
|
||||
commentText.setText(comment.commentText);
|
||||
ImageView commentImage = (ImageView) commentView.findViewById(R.id.comment_user_image);
|
||||
TextView commentSharedDate = (TextView) commentView.findViewById(R.id.comment_shareddate);
|
||||
commentSharedDate.setText(comment.sharedDate);
|
||||
|
||||
if (publicUserMap.containsKey(comment.userId)) {
|
||||
UserProfile commentUser = publicUserMap.get(comment.userId);
|
||||
TextView commentUsername = (TextView) commentView.findViewById(R.id.comment_username);
|
||||
commentUsername.setText(commentUser.username);
|
||||
String userPhoto = commentUser.photoUrl;
|
||||
imageLoader.displayImage(userPhoto, commentImage);
|
||||
publicCommentViews.add(commentView);
|
||||
} else {
|
||||
UserProfile commentUser = friendUserMap.get(comment.userId);
|
||||
TextView commentUsername = (TextView) commentView.findViewById(R.id.comment_username);
|
||||
commentUsername.setText(commentUser.username);
|
||||
String userPhoto = commentUser.photoUrl;
|
||||
imageLoader.displayImage(userPhoto, commentImage);
|
||||
friendCommentViews.add(commentView);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void onPostExecute(Void result) {
|
||||
for (final String userId : story.sharedUserIds) {
|
||||
ImageView image = new ImageView(getActivity());
|
||||
int imageLength = UIUtils.convertDPsToPixels(getActivity(), 25);
|
||||
image.setMaxHeight(imageLength);
|
||||
image.setMaxWidth(imageLength);
|
||||
GridLayout.LayoutParams imageParameters = new GridLayout.LayoutParams();
|
||||
imageParameters.height = imageLength;
|
||||
imageParameters.width = imageLength;
|
||||
image.setLayoutParams(imageParameters);
|
||||
|
||||
GridLayout grid = (GridLayout) view.findViewById(R.id.reading_social_shareimages);
|
||||
imageLoader.displayImageByUid(friendUserMap.get(userId).photoUrl, image);
|
||||
image.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent i = new Intent(getActivity(), Profile.class);
|
||||
i.putExtra(Profile.USER_ID, userId);
|
||||
startActivity(i);
|
||||
}
|
||||
});
|
||||
grid.addView(image);
|
||||
}
|
||||
|
||||
for (final String userId : story.friendUserIds) {
|
||||
ImageView image = new ImageView(getActivity());
|
||||
int imageLength = UIUtils.convertDPsToPixels(getActivity(), 25);
|
||||
image.setMaxHeight(imageLength);
|
||||
image.setMaxWidth(imageLength);
|
||||
GridLayout.LayoutParams imageParameters = new GridLayout.LayoutParams();
|
||||
imageParameters.height = imageLength;
|
||||
imageParameters.width = imageLength;
|
||||
image.setLayoutParams(imageParameters);
|
||||
|
||||
GridLayout grid = (GridLayout) view.findViewById(R.id.reading_social_shareimages);
|
||||
imageLoader.displayImageByUid(friendUserMap.get(userId).photoUrl, image);
|
||||
image.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent i = new Intent(getActivity(), Profile.class);
|
||||
i.putExtra(Profile.USER_ID, userId);
|
||||
startActivity(i);
|
||||
}
|
||||
});
|
||||
grid.addView(image);
|
||||
}
|
||||
|
||||
|
||||
for (View comment : publicCommentViews) {
|
||||
((LinearLayout) view.findViewById(R.id.reading_public_comment_container)).addView(comment);
|
||||
}
|
||||
for (View comment : friendCommentViews) {
|
||||
((LinearLayout) view.findViewById(R.id.reading_friend_comment_container)).addView(comment);
|
||||
}
|
||||
};
|
||||
}.execute();
|
||||
new SetupCommentSectionTask(getActivity(), view, inflater, resolver, apiManager, story, imageLoader).execute();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -233,17 +105,6 @@ public class ReadingItemFragment extends Fragment {
|
|||
TextView itemTitle = (TextView) view.findViewById(R.id.reading_item_title);
|
||||
TextView itemDate = (TextView) view.findViewById(R.id.reading_item_date);
|
||||
TextView itemAuthors = (TextView) view.findViewById(R.id.reading_item_authors);
|
||||
// GridLayout tagContainer = (GridLayout) view.findViewById(R.id.reading_item_tags);
|
||||
//
|
||||
// if (story.tags != null || story.tags.length > 0) {
|
||||
// tagContainer.setVisibility(View.VISIBLE);
|
||||
// for (String tag : story.tags) {
|
||||
// View v = inflater.inflate(R.layout.tag_view, null);
|
||||
// TextView tagText = (TextView) v.findViewById(R.id.tag_text);
|
||||
// tagText.setText(tag);
|
||||
// tagContainer.addView(v);
|
||||
// }
|
||||
// }
|
||||
|
||||
itemDate.setText(story.shortDate);
|
||||
itemTitle.setText(story.title);
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public class SocialFeedItemListFragment extends ItemListFragment implements Load
|
|||
|
||||
setupSocialFeed();
|
||||
|
||||
Cursor cursor = contentResolver.query(storiesUri, null, FeedProvider.getSelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " DESC");
|
||||
Cursor cursor = contentResolver.query(storiesUri, null, FeedProvider.getSelectionFromState(currentState), null, DatabaseConstants.STORY_SHARED_DATE + " DESC");
|
||||
|
||||
String[] groupFrom = new String[] { DatabaseConstants.FEED_FAVICON_URL, DatabaseConstants.FEED_TITLE, DatabaseConstants.STORY_TITLE, DatabaseConstants.STORY_READ, DatabaseConstants.STORY_SHORTDATE, DatabaseConstants.STORY_INTELLIGENCE_AUTHORS};
|
||||
int[] groupTo = new int[] { R.id.row_item_feedicon, R.id.row_item_feedtitle, R.id.row_item_title, R.id.row_item_title, R.id.row_item_date, R.id.row_item_sidebar};
|
||||
|
|
@ -90,6 +90,8 @@ public class SocialFeedItemListFragment extends ItemListFragment implements Load
|
|||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
View v = inflater.inflate(R.layout.fragment_itemlist, null);
|
||||
ListView itemList = (ListView) v.findViewById(R.id.itemlistfragment_list);
|
||||
itemList.setEmptyView(v.findViewById(R.id.empty_view));
|
||||
|
||||
itemList.setOnScrollListener(this);
|
||||
itemList.setAdapter(adapter);
|
||||
itemList.setOnItemClickListener(this);
|
||||
|
|
@ -100,7 +102,7 @@ public class SocialFeedItemListFragment extends ItemListFragment implements Load
|
|||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int loaderId, Bundle bundle) {
|
||||
Uri uri = FeedProvider.SOCIALFEED_STORIES_URI.buildUpon().appendPath(userId).build();
|
||||
CursorLoader cursorLoader = new CursorLoader(getActivity(), uri, null, FeedProvider.getSelectionFromState(currentState), null, DatabaseConstants.STORY_DATE + " DESC");
|
||||
CursorLoader cursorLoader = new CursorLoader(getActivity(), uri, null, FeedProvider.getSelectionFromState(currentState), null, DatabaseConstants.STORY_SHARED_DATE + " DESC");
|
||||
return cursorLoader;
|
||||
}
|
||||
|
||||
|
|
@ -164,7 +166,7 @@ public class SocialFeedItemListFragment extends ItemListFragment implements Load
|
|||
public void changeState(int state) {
|
||||
currentState = state;
|
||||
final String selection = FeedProvider.getSelectionFromState(state);
|
||||
Cursor cursor = contentResolver.query(storiesUri, null, selection, null, DatabaseConstants.STORY_DATE + " DESC");
|
||||
Cursor cursor = contentResolver.query(storiesUri, null, selection, null, DatabaseConstants.STORY_SHARED_DATE + " DESC");
|
||||
adapter.swapCursor(cursor);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,13 +20,18 @@ public class APIConstants {
|
|||
public static final String URL_MARK_SOCIALSTORY_AS_READ = "http://newsblur.com/reader/mark_social_stories_as_read/";
|
||||
public static final String URL_SHARE_STORY = "http://newsblur.com/social/share_story";
|
||||
|
||||
public static final String URL_LIKE_COMMENT = "http://www.newsblur.com/social/like_comment";
|
||||
public static final String URL_UNLIKE_COMMENT = "http://www.newsblur.com/social/remove_like_comment";
|
||||
|
||||
public static final String PARAMETER_FEEDS = "feeds";
|
||||
public static final String PARAMETER_PASSWORD = "password";
|
||||
public static final String PARAMETER_USER_ID = "user_id";
|
||||
public static final String PARAMETER_USERNAME = "username";
|
||||
public static final String PARAMETER_USERID = "user_id";
|
||||
public static final String PARAMETER_STORYID = "story_id";
|
||||
public static final String PARAMETER_COMMENT_USERID = "comment_user_id";
|
||||
public static final String PARAMETER_FEEDID = "feed_id";
|
||||
public static final String PARAMETER_STORY_FEEDID = "story_feed_id";
|
||||
public static final String PARAMETER_SHARE_COMMENT = "comments";
|
||||
public static final String PARAMETER_SHARE_SOURCEID = "source_user_id";
|
||||
public static final String PARAMETER_MARKSOCIAL_JSON = "users_feeds_stories";
|
||||
|
|
@ -34,4 +39,5 @@ public class APIConstants {
|
|||
|
||||
public static final String NEWSBLUR_URL = "http://www.newsblur.com";
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import com.newsblur.database.FeedProvider;
|
|||
import com.newsblur.domain.Comment;
|
||||
import com.newsblur.domain.Feed;
|
||||
import com.newsblur.domain.FolderStructure;
|
||||
import com.newsblur.domain.Reply;
|
||||
import com.newsblur.domain.SocialFeed;
|
||||
import com.newsblur.domain.Story;
|
||||
import com.newsblur.domain.ValueMultimap;
|
||||
|
|
@ -187,6 +188,11 @@ public class APIManager {
|
|||
comment.storyId = story.id;
|
||||
comment.id = (builder.toString());
|
||||
contentResolver.insert(FeedProvider.COMMENTS_URI, comment.getValues());
|
||||
|
||||
for (Reply reply : comment.replies) {
|
||||
reply.commentId = comment.id;
|
||||
contentResolver.insert(FeedProvider.REPLIES_URI, reply.getValues());
|
||||
}
|
||||
}
|
||||
|
||||
for (Comment comment : story.friendsComments) {
|
||||
|
|
@ -197,6 +203,11 @@ public class APIManager {
|
|||
comment.storyId = story.id;
|
||||
comment.id = (builder.toString());
|
||||
contentResolver.insert(FeedProvider.COMMENTS_URI, comment.getValues());
|
||||
|
||||
for (Reply reply : comment.replies) {
|
||||
reply.commentId = comment.id;
|
||||
contentResolver.insert(FeedProvider.REPLIES_URI, reply.getValues());
|
||||
}
|
||||
}
|
||||
|
||||
Uri storySocialUri = FeedProvider.SOCIALFEED_STORIES_URI.buildUpon().appendPath(userId).build();
|
||||
|
|
@ -316,8 +327,27 @@ public class APIManager {
|
|||
Uri feedUri = FeedProvider.SOCIAL_FEEDS_URI.buildUpon().appendPath(userId).build();
|
||||
contentResolver.update(feedUri, feedCountUpdate.socialfeedCounts.get(socialfeedId).getValues(), null, null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public boolean favouriteComment(String storyId, String commentId, String feedId) {
|
||||
final APIClient client = new APIClient(context);
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(APIConstants.PARAMETER_STORYID, storyId);
|
||||
values.put(APIConstants.PARAMETER_STORY_FEEDID, feedId);
|
||||
values.put(APIConstants.PARAMETER_COMMENT_USERID, commentId);
|
||||
final APIResponse response = client.post(APIConstants.URL_LIKE_COMMENT, values);
|
||||
return (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected);
|
||||
}
|
||||
|
||||
public Boolean unFavouriteComment(String storyId, String commentId, String feedId) {
|
||||
final APIClient client = new APIClient(context);
|
||||
ContentValues values = new ContentValues();
|
||||
values.put(APIConstants.PARAMETER_STORYID, storyId);
|
||||
values.put(APIConstants.PARAMETER_STORY_FEEDID, feedId);
|
||||
values.put(APIConstants.PARAMETER_COMMENT_USERID, commentId);
|
||||
final APIResponse response = client.post(APIConstants.URL_UNLIKE_COMMENT, values);
|
||||
return (response.responseCode == HttpStatus.SC_OK && !response.hasRedirected);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
package com.newsblur.network;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.domain.Comment;
|
||||
|
||||
public class LikeCommentTask extends AsyncTask<Void, Void, Boolean>{
|
||||
|
||||
private static final String TAG = "LikeCommentTask";
|
||||
final WeakReference<ImageView> favouriteIconViewHolder;
|
||||
final WeakReference<View> favouriteCountViewHolder;
|
||||
|
||||
private final APIManager apiManager;
|
||||
private final String storyId;
|
||||
private final Comment comment;
|
||||
private final String feedId;
|
||||
private final Context context;
|
||||
private final String userId;
|
||||
|
||||
public LikeCommentTask(final Context context, final APIManager apiManager, final View favouriteCount, final ImageView favouriteIcon, final String storyId, final Comment comment, final String feedId, final String userId) {
|
||||
this.apiManager = apiManager;
|
||||
this.storyId = storyId;
|
||||
this.comment = comment;
|
||||
this.feedId = feedId;
|
||||
this.context = context;
|
||||
this.userId = userId;
|
||||
|
||||
favouriteIconViewHolder = new WeakReference<ImageView>(favouriteIcon);
|
||||
favouriteCountViewHolder = new WeakReference<View>(favouriteCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
return apiManager.favouriteComment(storyId, comment.userId, feedId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
if (favouriteIconViewHolder.get() != null) {
|
||||
if (result.booleanValue()) {
|
||||
favouriteIconViewHolder.get().setImageResource(R.drawable.have_favourite);
|
||||
|
||||
String[] newArray = new String[comment.likingUsers.length + 1];
|
||||
System.arraycopy(comment.likingUsers, 0, newArray, 0, comment.likingUsers.length);
|
||||
newArray[newArray.length - 1] = userId;
|
||||
comment.likingUsers = newArray;
|
||||
|
||||
((TextView) favouriteCountViewHolder.get()).setText(Integer.toString(comment.likingUsers.length));
|
||||
Toast.makeText(context, "Comment liked", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(context, "Error liking comment", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.newsblur.network;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import android.os.AsyncTask;
|
||||
import android.widget.ImageView;
|
||||
|
||||
public class MarkCommentAsFavouriteTask extends AsyncTask<Void, Void, Void> {
|
||||
|
||||
WeakReference<ImageView> referenceToView;
|
||||
private String commentId;
|
||||
|
||||
public MarkCommentAsFavouriteTask(ImageView favouriteIconView, final String commentId) {
|
||||
this.commentId = commentId;
|
||||
referenceToView = new WeakReference<ImageView>(favouriteIconView);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... params) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,213 @@
|
|||
package com.newsblur.network;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.database.Cursor;
|
||||
import android.os.AsyncTask;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import android.support.v7.widget.GridLayout;
|
||||
|
||||
import com.newsblur.util.PrefsUtil;
|
||||
import com.newsblur.util.UIUtils;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.activity.Profile;
|
||||
import com.newsblur.database.DatabaseConstants;
|
||||
import com.newsblur.database.FeedProvider;
|
||||
import com.newsblur.domain.Comment;
|
||||
import com.newsblur.domain.Reply;
|
||||
import com.newsblur.domain.Story;
|
||||
import com.newsblur.domain.UserProfile;
|
||||
import com.newsblur.network.domain.ProfileResponse;
|
||||
import com.newsblur.util.ImageLoader;
|
||||
|
||||
public class SetupCommentSectionTask extends AsyncTask<Void, Void, Void> {
|
||||
private ArrayList<View> publicCommentViews;
|
||||
private ArrayList<View> friendCommentViews;
|
||||
private final ContentResolver resolver;
|
||||
private final APIManager apiManager;
|
||||
|
||||
private HashMap<String, UserProfile> friendUserMap = new HashMap<String, UserProfile>();
|
||||
private HashMap<String, UserProfile> publicUserMap = new HashMap<String, UserProfile>();
|
||||
private final Story story;
|
||||
private final LayoutInflater inflater;
|
||||
private final ImageLoader imageLoader;
|
||||
private WeakReference<View> viewHolder;
|
||||
private final Context context;
|
||||
private UserProfile user;
|
||||
|
||||
public SetupCommentSectionTask(final Context context, final View view, LayoutInflater inflater, final ContentResolver resolver, final APIManager apiManager, final Story story, final ImageLoader imageLoader) {
|
||||
this.context = context;
|
||||
this.inflater = inflater;
|
||||
this.resolver = resolver;
|
||||
this.apiManager = apiManager;
|
||||
this.story = story;
|
||||
this.imageLoader = imageLoader;
|
||||
viewHolder = new WeakReference<View>(view);
|
||||
user = PrefsUtil.getUserDetails(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Void doInBackground(Void... arg0) {
|
||||
for (String userId : story.sharedUserIds) {
|
||||
ProfileResponse user = apiManager.getUser(userId);
|
||||
friendUserMap.put(userId, user.user);
|
||||
}
|
||||
|
||||
for (String userId : story.friendUserIds) {
|
||||
ProfileResponse user = apiManager.getUser(userId);
|
||||
friendUserMap.put(userId, user.user);
|
||||
}
|
||||
|
||||
for (String userId : story.publicUserIds) {
|
||||
ProfileResponse user = apiManager.getUser(userId);
|
||||
publicUserMap.put(userId, user.user);
|
||||
}
|
||||
|
||||
Cursor cursor = resolver.query(FeedProvider.COMMENTS_URI, null, null, new String[] { story.id }, null);
|
||||
|
||||
publicCommentViews = new ArrayList<View>();
|
||||
friendCommentViews = new ArrayList<View>();
|
||||
|
||||
while (cursor.moveToNext()) {
|
||||
final Comment comment = Comment.fromCursor(cursor);
|
||||
View commentView = inflater.inflate(R.layout.include_comment, null);
|
||||
TextView commentText = (TextView) commentView.findViewById(R.id.comment_text);
|
||||
commentText.setText(comment.commentText);
|
||||
ImageView commentImage = (ImageView) commentView.findViewById(R.id.comment_user_image);
|
||||
TextView commentSharedDate = (TextView) commentView.findViewById(R.id.comment_shareddate);
|
||||
commentSharedDate.setText(comment.sharedDate);
|
||||
|
||||
final TextView favouriteCount = (TextView) commentView.findViewById(R.id.comment_favourite_count);
|
||||
final ImageView favouriteIcon = (ImageView) commentView.findViewById(R.id.comment_favourite_icon);
|
||||
if (comment.likingUsers != null) {
|
||||
|
||||
if (Arrays.asList(comment.likingUsers).contains(user.id)) {
|
||||
favouriteIcon.setImageResource(R.drawable.have_favourite);
|
||||
}
|
||||
favouriteCount.setText(Integer.toString(comment.likingUsers.length));
|
||||
favouriteIcon.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
if (!Arrays.asList(comment.likingUsers).contains(user.id)) {
|
||||
new LikeCommentTask(context, apiManager, favouriteCount, favouriteIcon, story.id, comment, story.feedId, user.id).execute();
|
||||
} else {
|
||||
new UnLikeCommentTask(context, apiManager, favouriteCount, favouriteIcon, story.id, comment, story.feedId, user.id).execute();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Cursor replies = resolver.query(FeedProvider.REPLIES_URI, null, null, new String[] { comment.id }, DatabaseConstants.REPLY_DATE + " DESC");
|
||||
while (replies.moveToNext()) {
|
||||
Reply reply = Reply.fromCursor(replies);
|
||||
View replyView = inflater.inflate(R.layout.include_reply, null);
|
||||
TextView replyText = (TextView) replyView.findViewById(R.id.reply_text);
|
||||
replyText.setText(reply.text);
|
||||
ImageView replyImage = (ImageView) replyView.findViewById(R.id.reply_user_image);
|
||||
|
||||
ProfileResponse replyUser = apiManager.getUser(reply.userId);
|
||||
imageLoader.displayImage(replyUser.user.photoUrl, replyImage);
|
||||
TextView replyUsername = (TextView) replyView.findViewById(R.id.reply_username);
|
||||
replyUsername.setText(replyUser.user.username);
|
||||
|
||||
TextView replySharedDate = (TextView) replyView.findViewById(R.id.reply_shareddate);
|
||||
replySharedDate.setText(reply.shortDate);
|
||||
|
||||
((LinearLayout) commentView.findViewById(R.id.comment_replies_container)).addView(replyView);
|
||||
}
|
||||
|
||||
if (publicUserMap.containsKey(comment.userId)) {
|
||||
UserProfile commentUser = publicUserMap.get(comment.userId);
|
||||
TextView commentUsername = (TextView) commentView.findViewById(R.id.comment_username);
|
||||
commentUsername.setText(commentUser.username);
|
||||
String userPhoto = commentUser.photoUrl;
|
||||
imageLoader.displayImage(userPhoto, commentImage);
|
||||
publicCommentViews.add(commentView);
|
||||
} else {
|
||||
UserProfile commentUser = friendUserMap.get(comment.userId);
|
||||
if (commentUser != null) {
|
||||
TextView commentUsername = (TextView) commentView.findViewById(R.id.comment_username);
|
||||
commentUsername.setText(commentUser.username);
|
||||
String userPhoto = commentUser.photoUrl;
|
||||
imageLoader.displayImage(userPhoto, commentImage);
|
||||
friendCommentViews.add(commentView);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void onPostExecute(Void result) {
|
||||
if (viewHolder.get() != null) {
|
||||
GridLayout grid = (GridLayout) viewHolder.get().findViewById(R.id.reading_social_shareimages);
|
||||
GridLayout friendGrid = (GridLayout) viewHolder.get().findViewById(R.id.reading_social_friendimages);
|
||||
|
||||
for (final String userId : story.publicUserIds) {
|
||||
ImageView image = new ImageView(context);
|
||||
int imageLength = UIUtils.convertDPsToPixels(context, 25);
|
||||
image.setMaxHeight(imageLength);
|
||||
image.setMaxWidth(imageLength);
|
||||
GridLayout.LayoutParams imageParameters = new GridLayout.LayoutParams();
|
||||
imageParameters.height = imageLength;
|
||||
imageParameters.width = imageLength;
|
||||
image.setLayoutParams(imageParameters);
|
||||
|
||||
imageLoader.displayImageByUid(publicUserMap.get(userId).photoUrl, image);
|
||||
image.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent i = new Intent(context, Profile.class);
|
||||
i.putExtra(Profile.USER_ID, userId);
|
||||
context.startActivity(i);
|
||||
}
|
||||
});
|
||||
grid.addView(image);
|
||||
}
|
||||
|
||||
for (final String userId : story.friendUserIds) {
|
||||
ImageView image = new ImageView(context);
|
||||
int imageLength = UIUtils.convertDPsToPixels(context, 25);
|
||||
image.setMaxHeight(imageLength);
|
||||
image.setMaxWidth(imageLength);
|
||||
GridLayout.LayoutParams imageParameters = new GridLayout.LayoutParams();
|
||||
imageParameters.height = imageLength;
|
||||
imageParameters.width = imageLength;
|
||||
image.setLayoutParams(imageParameters);
|
||||
|
||||
imageLoader.displayImageByUid(friendUserMap.get(userId).photoUrl, image);
|
||||
image.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent i = new Intent(context, Profile.class);
|
||||
i.putExtra(Profile.USER_ID, userId);
|
||||
context.startActivity(i);
|
||||
}
|
||||
});
|
||||
friendGrid.addView(image);
|
||||
}
|
||||
|
||||
for (View comment : publicCommentViews) {
|
||||
((LinearLayout) viewHolder.get().findViewById(R.id.reading_public_comment_container)).addView(comment);
|
||||
}
|
||||
for (View comment : friendCommentViews) {
|
||||
((LinearLayout) viewHolder.get().findViewById(R.id.reading_friend_comment_container)).addView(comment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package com.newsblur.network;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.newsblur.R;
|
||||
import com.newsblur.domain.Comment;
|
||||
|
||||
public class UnLikeCommentTask extends AsyncTask<Void, Void, Boolean>{
|
||||
|
||||
private static final String TAG = "LikeCommentTask";
|
||||
final WeakReference<ImageView> favouriteIconViewHolder;
|
||||
final WeakReference<View> favouriteCountViewHolder;
|
||||
private final APIManager apiManager;
|
||||
private final String storyId;
|
||||
private final Comment comment;
|
||||
private final String feedId;
|
||||
private final Context context;
|
||||
private final String userId;
|
||||
|
||||
public UnLikeCommentTask(final Context context, final APIManager apiManager, final View favouriteCount, final ImageView favouriteIcon, final String storyId, final Comment comment, final String feedId, final String userId) {
|
||||
this.apiManager = apiManager;
|
||||
this.storyId = storyId;
|
||||
this.comment = comment;
|
||||
this.feedId = feedId;
|
||||
this.context = context;
|
||||
this.userId = userId;
|
||||
|
||||
favouriteIconViewHolder = new WeakReference<ImageView>(favouriteIcon);
|
||||
favouriteCountViewHolder = new WeakReference<View>(favouriteCount);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Boolean doInBackground(Void... params) {
|
||||
return apiManager.unFavouriteComment(storyId, comment.userId, feedId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
if (favouriteIconViewHolder.get() != null) {
|
||||
if (result.booleanValue()) {
|
||||
favouriteIconViewHolder.get().setImageResource(R.drawable.favourite);
|
||||
|
||||
ArrayList<String> likingUsers = new ArrayList<String>();
|
||||
for (String user : comment.likingUsers) {
|
||||
if (!TextUtils.equals(user, userId) && TextUtils.isEmpty(user)) {
|
||||
likingUsers.add(user);
|
||||
}
|
||||
}
|
||||
String[] newArray = new String[likingUsers.size()];
|
||||
likingUsers.toArray(newArray);
|
||||
comment.likingUsers = newArray;
|
||||
|
||||
((TextView) favouriteCountViewHolder.get()).setText(Integer.toString(comment.likingUsers.length));
|
||||
Toast.makeText(context, "Removed like", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(context, "Error removing like from comment", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -43,7 +43,7 @@ public class ImageLoader {
|
|||
bitmap = memoryCache.get(url);
|
||||
}
|
||||
if (bitmap != null) {
|
||||
bitmap = UIUtils.roundCorners(bitmap, 10f);
|
||||
bitmap = UIUtils.roundBitmap(bitmap);
|
||||
imageView.setImageBitmap(bitmap);
|
||||
} else {
|
||||
queuePhoto(url, imageView);
|
||||
|
|
@ -109,7 +109,7 @@ public class ImageLoader {
|
|||
bitmap = BitmapFactory.decodeStream(new FileInputStream(f));
|
||||
memoryCache.put(url, bitmap);
|
||||
outputStream.close();
|
||||
bitmap = UIUtils.roundCorners(bitmap, 10f);
|
||||
bitmap = UIUtils.roundBitmap(bitmap);
|
||||
return bitmap;
|
||||
} catch (IOException ex) {
|
||||
Log.e(TAG, "Error loading image from network", ex.fillInStackTrace());
|
||||
|
|
|
|||