From 2c64848fc6ad6db317980746bceb00adce8fd304 Mon Sep 17 00:00:00 2001 From: Aagam Shah Date: Tue, 14 May 2013 17:49:02 +0530 Subject: [PATCH 1/3] added swipe featured and bug fix #456 --- res/layout/viewpost.xml | 3 +- res/values/strings.xml | 2 + .../android/ui/comments/CommentsActivity.java | 54 ++++++++++--- .../android/ui/posts/ViewPostFragment.java | 79 ++++++++++++++++++- .../android/ui/posts/ViewPostsFragment.java | 25 +++++- 5 files changed, 147 insertions(+), 16 deletions(-) diff --git a/res/layout/viewpost.xml b/res/layout/viewpost.xml index 847e200f8575..fdd981e47afa 100644 --- a/res/layout/viewpost.xml +++ b/res/layout/viewpost.xml @@ -3,7 +3,8 @@ android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" - android:background="#FFFFFF" > + android:background="#FFFFFF" + android:id="@+id/postHead"> Delete Approve Unapprove + Confirm Deletion + Are you sure to delete the Comment ? Account Setup diff --git a/src/org/wordpress/android/ui/comments/CommentsActivity.java b/src/org/wordpress/android/ui/comments/CommentsActivity.java index 4fcf7bf66fbb..f7eb95bd970a 100644 --- a/src/org/wordpress/android/ui/comments/CommentsActivity.java +++ b/src/org/wordpress/android/ui/comments/CommentsActivity.java @@ -212,20 +212,50 @@ public void run() { } }.start(); } else if (status.equals("delete")) { - showDialog(ID_DIALOG_DELETING); - // pop out of the detail view if on a smaller screen - FragmentManager fm = getSupportFragmentManager(); - CommentFragment f = (CommentFragment) fm - .findFragmentById(R.id.commentDetail); - if (f == null) { - fm.popBackStack(); - } - new Thread() { + + Thread action3 = new Thread() { public void run() { - deleteComment(commentID); + AlertDialog.Builder dialogBuilder = new AlertDialog.Builder( + CommentsActivity.this); + dialogBuilder.setTitle(getResources().getText( + R.string.confirm_delete)); + dialogBuilder.setMessage(getResources().getText(R.string.confirm_delete_data)); + dialogBuilder.setPositiveButton("Yes", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int whichButton) { + showDialog(ID_DIALOG_DELETING); + // pop out of the detail view if on a smaller screen + FragmentManager fm = getSupportFragmentManager(); + CommentFragment f = (CommentFragment) fm + .findFragmentById(R.id.commentDetail); + if (f == null) { + fm.popBackStack(); + } + new Thread() { + public void run() { + deleteComment(commentID); + } + }.start(); + + + } + }); + dialogBuilder.setNegativeButton("No", + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, + int whichButton) { + //Don't delete Comment + } + }); + dialogBuilder.setCancelable(true); + if (!isFinishing()) { + dialogBuilder.create().show(); + } } - }.start(); - } else if (status.equals("reply")) { + }; + runOnUiThread(action3); + } else if (status.equals("reply")) { Intent i = new Intent(CommentsActivity.this, AddCommentActivity.class); i.putExtra("commentID", commentID); diff --git a/src/org/wordpress/android/ui/posts/ViewPostFragment.java b/src/org/wordpress/android/ui/posts/ViewPostFragment.java index aff01a3e11bb..30d8d95a3a14 100644 --- a/src/org/wordpress/android/ui/posts/ViewPostFragment.java +++ b/src/org/wordpress/android/ui/posts/ViewPostFragment.java @@ -4,11 +4,16 @@ import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; +import android.view.GestureDetector; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; +import android.view.View.OnTouchListener; import android.view.ViewGroup; import android.webkit.WebView; import android.widget.ImageButton; +import android.widget.RelativeLayout; +import android.widget.ScrollView; import android.widget.TextView; import org.wordpress.android.R; @@ -135,19 +140,65 @@ public void onAttach(Activity activity) { + " must implement Callback"); } } + + private class GestureListener extends GestureDetector.SimpleOnGestureListener { + + private final int SWIPE_MIN_DISTANCE = 50; + private final int SWIPE_THRESHOLD_VELOCITY = 60; + + @Override + public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { + if(e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { + // Right to left + swipePost(1); //Pass 1 for nextpost + return true; + } + else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { + // Left to right + swipePost(0); //Pass 0 for prevpost + return true; + } + + return false; + } + } + + + public void swipePost(int motionEvent){ + ViewPostsFragment vpf = new ViewPostsFragment(); + String prevpostid,nextpostid; + long newid; + + if(motionEvent==0){ + prevpostid = vpf.getprevID(); + int previd= Integer.parseInt(prevpostid); + newid = (long)previd; + } + else{ + nextpostid = vpf.getnextID(); + int nextid= Integer.parseInt(nextpostid); + newid=(long)nextid; + } + Post post = new Post(WordPress.currentBlog.getId(),newid + , false); + loadPost(post); + } + + + public GestureDetector gesturedetector; public void loadPost(Post post) { // Don't load if the Post object of title are null, see #395 if (post == null || post.getTitle() == null) return; - + gesturedetector = new GestureDetector(new GestureListener()); TextView title = (TextView) getActivity().findViewById(R.id.postTitle); if (post.getTitle().equals("")) title.setText("(" + getResources().getText(R.string.untitled) + ")"); else title.setText(EscapeUtils.unescapeHtml(post.getTitle())); - + RelativeLayout layout = (RelativeLayout)getActivity().findViewById(R.id.postHead); WebView webView = (WebView) getActivity().findViewById( R.id.viewPostWebView); TextView tv = (TextView) getActivity().findViewById( @@ -158,6 +209,30 @@ public void loadPost(Post post) { R.id.viewPost); ImageButton addCommentButton = (ImageButton) getActivity().findViewById( R.id.addComment); + layout.setOnTouchListener(new OnTouchListener() { + + @Override + public boolean onTouch(View v, MotionEvent event) { + // TODO Auto-generated method stub + gesturedetector.onTouchEvent(event); + return true; + } + + + }); + webView.setOnTouchListener(new OnTouchListener() { + + @Override + public boolean onTouch(View v, MotionEvent event) { + // TODO Auto-generated method stub + gesturedetector.onTouchEvent(event); + return true; + } + + + }); + + tv.setVisibility(View.GONE); webView.setVisibility(View.VISIBLE); diff --git a/src/org/wordpress/android/ui/posts/ViewPostsFragment.java b/src/org/wordpress/android/ui/posts/ViewPostsFragment.java index e8c3be8da055..a9ab20f102ea 100644 --- a/src/org/wordpress/android/ui/posts/ViewPostsFragment.java +++ b/src/org/wordpress/android/ui/posts/ViewPostsFragment.java @@ -45,7 +45,7 @@ public class ViewPostsFragment extends ListFragment { /** Called when the activity is first created. */ - private String[] mPostIDs, mTitles, mDateCreated, mDateCreatedFormatted, + private static String[] mPostIDs, mTitles, mDateCreated, mDateCreatedFormatted, mDraftIDs, mDraftTitles, mDraftDateCreated, mStatuses, mDraftStatuses; private int[] mUploaded; private int mRowID = 0; @@ -64,6 +64,28 @@ public class ViewPostsFragment extends ListFragment { public int numRecords = 20; public ViewSwitcher switcher; public getRecentPostsTask getPostsTask; + public static int curr_position=0; + + public String getnextID(){ + if(curr_position+1>=mPostIDs.length) + return mPostIDs[curr_position]; + + else{ + curr_position=curr_position+1; + return mPostIDs[curr_position]; + } + } + + public String getprevID(){ + if(curr_position-1<0) + return mPostIDs[curr_position]; + + else{ + curr_position=curr_position-1; + return mPostIDs[curr_position]; + } + + } @Override public void onCreate(Bundle icicle) { @@ -273,6 +295,7 @@ public void onItemClick(AdapterView arg0, View v, .getId(), mSelectedID, isPage); if (post.getId() >= 0) { WordPress.currentPost = post; + curr_position=position; mOnPostSelectedListener.onPostSelected(post); mPostListAdapter.notifyDataSetChanged(); } else { From fb20a244551acfbd1572cf1612d2067813bd0556 Mon Sep 17 00:00:00 2001 From: Aagam Shah Date: Tue, 14 May 2013 20:52:06 +0530 Subject: [PATCH 2/3] improved delete confirmation text --- res/values/strings.xml | 2 +- res/values/strings.xml~ | 397 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 398 insertions(+), 1 deletion(-) create mode 100644 res/values/strings.xml~ diff --git a/res/values/strings.xml b/res/values/strings.xml index 3c980d6e05e3..89c55d681d69 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -216,7 +216,7 @@ Approve Unapprove Confirm Deletion - Are you sure to delete the Comment ? + Are you sure you want to delete this comment? Account Setup diff --git a/res/values/strings.xml~ b/res/values/strings.xml~ new file mode 100644 index 000000000000..3c980d6e05e3 --- /dev/null +++ b/res/values/strings.xml~ @@ -0,0 +1,397 @@ + + + + + Required Fields + Required Field + Please fill in all of the fields before submitting. + Could not connect. Please enter the full path to xmlrpc.php on your site and try again. + No Blogs Found + No %s blogs were found for that account. + additional + Add All + Add Selected + Select Blogs + Enable blogs + No network available + There is no network available. Please connect to a network and try again. + + + Select Categories + Tags & Categories + Tags (separate tags with commas) + Content (tap to add text and media) + Don\'t yet have a blog? + Default image width + Password + Get a free blog at WordPress.com + Start blogging in seconds. + Add blog hosted at WordPress.com + Add self-hosted WordPress blog + Start a new blog at WordPress.com + Blogs + Account Details + Status + + + Comment Content + Anonymous + + + Post + Page + Posts + Pages + About + Username + Cancel + Save + Add + Selected categories: + Publish? + Add Blog + Play notification sound + Vibrate + Blink notification light + Are you sure you want to remove this blog? + Yes + No + Error + Could not remove blog. + Edit Page + Edit Post + Add Comment + Refreshing Categories + Attempting to refresh categories + Connection Error + A connection error has occurred. Please try again later. + Categories refreshed + Category refresh error + Incorrect username or password. + No Content Found + Please enter some post content or attach a media item. + Cancel Edit + Are you sure you want to cancel editing this post? + New Account + Upload and link to full image + Upload and link to scaled image + Please enter a valid scaled width value + Scaled image width + Load More + Load settings now? + Immediately + Uploading + Uploading media item # + Sorry, the media item could not be retrieved from the Gallery. + Refresh + Home + More + Sorry, an error occurred when attempting to access this blog. + Sorry, an error occurred when attempting to load the post. Please refresh your posts and try again. + + + Comments + Posts + Pages + Stats + + + + URL + Link Text (optional) + Create a Link + + + Title + Tap to add text and media + Are you sure you want to cancel editing this page? + + + Untitled + Local Draft + + Local Drafts + + + Post + Upload Failed + Password (optional) + Caption (optional) + Horizontal Alignment + Width + Use as featured image + Include image in post content + Device out of memory. + Could not find the media file for upload. Was it deleted or moved? + + + Page + + + Enter comment: + Send Comment + Write Comment + Required Field + Please enter something in the comment field. + Enter a reply: + Send Reply + Reply to Comment + Please enter something in the reply field. + + + Loading… + + + on + Approved + Unapproved + Spam + Moderating comment + Moderating comments + Replying to comment + Deleting comment + Deleting comments + Comment Moderated Successfully + Comments Moderated Successfully + Reply Added Successfully + Comment from + Edit Comment + + + Name + E-mail + URL + Update Comment + Saving Changes + Are you sure you want to cancel editing this comment? + The comment body is required. + + + Remove Blog + Blog Removed Successfully + + + Draft Actions + Edit Draft + Delete Draft + Are you sure you want to delete the draft + + + Page Actions + View Page + Delete Page + Page Deleted Successfully + Are you sure you want to delete the page + Attempting to delete page + + + Post Actions + View Post + Delete Post + Post Deleted Successfully + Comment Added Successfully + Attempting to post comment + Are you sure you want to delete the post + Attempting to delete post + Share Post + Share Page + Share Link + Attempting to fetch URL + Post status is not published + Page status is not published + View in Browser + Post signature + Add a signature to new posts + Posted from WordPress for Android + Posted from WordPress for BlackBerry + Preview + + + Comment Actions + Mark Approved + Mark Unapproved + Spam + Reply + Delete + Approve + Unapprove + Confirm Deletion + Are you sure to delete the Comment ? + + + Account Setup + Logging in… + Sorry, could not connect to the WordPress site. Please try again later. + + + Cancel Draft + + + Comment Notifications + Update interval + + + Select a photo from gallery + Take a new photo + Select a video from gallery + Take a new video + Media + + + Add New Category + Category Name + Category Slug (optional) + Category Description (optional) + Category Parent (optional): + None + Adding category failed. + Please check your settings and try again. + Category added successfully. + The Category Name field is required. + Adding Category + Attempting to add category + + + Select a Blog + No WordPress account found, please add an account and try again. + + + An error occurred while setting up the captured media. + Could not create temp file for media upload. Please make sure there is enough free space on your device. + + + SD Card Required + A mounted SD card is required to upload media. + + + Location + Geotag Posts + Location data not yet available, please wait. + View Map + Update + Unknown Location + Remove + + + Preferences + Open Source Licenses + + + Username and Password are required fields. + Need help? + Username + Password + Incorrect Login + Incorrect login, or blog is not linked to this WordPress.com account. + or site not found. + Sorry. There was an error trying to connect to your stats. Please try again. + + + ABC + link + U + + + Invalid blog URL + Please check that the blog URL entered is valid. + + + + Publish + Pending Review + Draft + Private + Published + Scheduled + + + Select blog for QuickPress shortcut + Shortcut name can\'t be empty + Set shortcut name + + + HTTP username + HTTP password + Settings + Optional Settings + HTTP Credentials (optional) + + + Publish + Edit + Post Format + Log In + + + Reader + Topics + + + + Aside + Audio + Chat + Gallery + Image + Link + Quote + Standard + Status + Video + + + + New Post + New Page + Quick Photo + Quick Video + Dashboard + View Site + View Admin + + + Alignment + + None + Left + Center + Right + + + + WordPress for Android + WordPress for BlackBerry + Publisher: Automattic, Inc + ©2013 Automattic, Inc + Version + Terms of Service + Privacy Policy + www.automattic.com + + + Local Changes + You\'ve made changes to an uploaded post that haven\'t been saved yet. Proceed with the refresh and overwrite local changes? + + OK + Image Settings + Blog URL + WordPress Blog + blogusername + Column 1 + Column 2 + + + Sorry, an error occurred while attempting to delete the %s. + Sorry, %s could not be refreshed at this time. Please try again later. + Sorry, an error occurred. Please try again later. + Sorry, an error occurred while attempting to moderate. Please try again later. + Sorry, an error occurred while editing the comment. Please try again later. + Sorry, an error occurred while uploading the %s. + An error occurred while uploading media + You have exceeded the login limit. Please ensure your login credentials are correct and try again in a few minutes. + So sorry, but an error occurred while attempting to create the app database. Please try reinstalling the app. + + + Add media + + From 620b01c43931747906fede2b49c356276f6f76d3 Mon Sep 17 00:00:00 2001 From: Aagam Shah Date: Tue, 14 May 2013 21:02:35 +0530 Subject: [PATCH 3/3] improved delete confirmation text --- res/values/strings.xml~ | 397 ---------------------------------------- 1 file changed, 397 deletions(-) delete mode 100644 res/values/strings.xml~ diff --git a/res/values/strings.xml~ b/res/values/strings.xml~ deleted file mode 100644 index 3c980d6e05e3..000000000000 --- a/res/values/strings.xml~ +++ /dev/null @@ -1,397 +0,0 @@ - - - - - Required Fields - Required Field - Please fill in all of the fields before submitting. - Could not connect. Please enter the full path to xmlrpc.php on your site and try again. - No Blogs Found - No %s blogs were found for that account. - additional - Add All - Add Selected - Select Blogs - Enable blogs - No network available - There is no network available. Please connect to a network and try again. - - - Select Categories - Tags & Categories - Tags (separate tags with commas) - Content (tap to add text and media) - Don\'t yet have a blog? - Default image width - Password - Get a free blog at WordPress.com - Start blogging in seconds. - Add blog hosted at WordPress.com - Add self-hosted WordPress blog - Start a new blog at WordPress.com - Blogs - Account Details - Status - - - Comment Content - Anonymous - - - Post - Page - Posts - Pages - About - Username - Cancel - Save - Add - Selected categories: - Publish? - Add Blog - Play notification sound - Vibrate - Blink notification light - Are you sure you want to remove this blog? - Yes - No - Error - Could not remove blog. - Edit Page - Edit Post - Add Comment - Refreshing Categories - Attempting to refresh categories - Connection Error - A connection error has occurred. Please try again later. - Categories refreshed - Category refresh error - Incorrect username or password. - No Content Found - Please enter some post content or attach a media item. - Cancel Edit - Are you sure you want to cancel editing this post? - New Account - Upload and link to full image - Upload and link to scaled image - Please enter a valid scaled width value - Scaled image width - Load More - Load settings now? - Immediately - Uploading - Uploading media item # - Sorry, the media item could not be retrieved from the Gallery. - Refresh - Home - More - Sorry, an error occurred when attempting to access this blog. - Sorry, an error occurred when attempting to load the post. Please refresh your posts and try again. - - - Comments - Posts - Pages - Stats - - - - URL - Link Text (optional) - Create a Link - - - Title - Tap to add text and media - Are you sure you want to cancel editing this page? - - - Untitled - Local Draft - - Local Drafts - - - Post - Upload Failed - Password (optional) - Caption (optional) - Horizontal Alignment - Width - Use as featured image - Include image in post content - Device out of memory. - Could not find the media file for upload. Was it deleted or moved? - - - Page - - - Enter comment: - Send Comment - Write Comment - Required Field - Please enter something in the comment field. - Enter a reply: - Send Reply - Reply to Comment - Please enter something in the reply field. - - - Loading… - - - on - Approved - Unapproved - Spam - Moderating comment - Moderating comments - Replying to comment - Deleting comment - Deleting comments - Comment Moderated Successfully - Comments Moderated Successfully - Reply Added Successfully - Comment from - Edit Comment - - - Name - E-mail - URL - Update Comment - Saving Changes - Are you sure you want to cancel editing this comment? - The comment body is required. - - - Remove Blog - Blog Removed Successfully - - - Draft Actions - Edit Draft - Delete Draft - Are you sure you want to delete the draft - - - Page Actions - View Page - Delete Page - Page Deleted Successfully - Are you sure you want to delete the page - Attempting to delete page - - - Post Actions - View Post - Delete Post - Post Deleted Successfully - Comment Added Successfully - Attempting to post comment - Are you sure you want to delete the post - Attempting to delete post - Share Post - Share Page - Share Link - Attempting to fetch URL - Post status is not published - Page status is not published - View in Browser - Post signature - Add a signature to new posts - Posted from WordPress for Android - Posted from WordPress for BlackBerry - Preview - - - Comment Actions - Mark Approved - Mark Unapproved - Spam - Reply - Delete - Approve - Unapprove - Confirm Deletion - Are you sure to delete the Comment ? - - - Account Setup - Logging in… - Sorry, could not connect to the WordPress site. Please try again later. - - - Cancel Draft - - - Comment Notifications - Update interval - - - Select a photo from gallery - Take a new photo - Select a video from gallery - Take a new video - Media - - - Add New Category - Category Name - Category Slug (optional) - Category Description (optional) - Category Parent (optional): - None - Adding category failed. - Please check your settings and try again. - Category added successfully. - The Category Name field is required. - Adding Category - Attempting to add category - - - Select a Blog - No WordPress account found, please add an account and try again. - - - An error occurred while setting up the captured media. - Could not create temp file for media upload. Please make sure there is enough free space on your device. - - - SD Card Required - A mounted SD card is required to upload media. - - - Location - Geotag Posts - Location data not yet available, please wait. - View Map - Update - Unknown Location - Remove - - - Preferences - Open Source Licenses - - - Username and Password are required fields. - Need help? - Username - Password - Incorrect Login - Incorrect login, or blog is not linked to this WordPress.com account. - or site not found. - Sorry. There was an error trying to connect to your stats. Please try again. - - - ABC - link - U - - - Invalid blog URL - Please check that the blog URL entered is valid. - - - - Publish - Pending Review - Draft - Private - Published - Scheduled - - - Select blog for QuickPress shortcut - Shortcut name can\'t be empty - Set shortcut name - - - HTTP username - HTTP password - Settings - Optional Settings - HTTP Credentials (optional) - - - Publish - Edit - Post Format - Log In - - - Reader - Topics - - - - Aside - Audio - Chat - Gallery - Image - Link - Quote - Standard - Status - Video - - - - New Post - New Page - Quick Photo - Quick Video - Dashboard - View Site - View Admin - - - Alignment - - None - Left - Center - Right - - - - WordPress for Android - WordPress for BlackBerry - Publisher: Automattic, Inc - ©2013 Automattic, Inc - Version - Terms of Service - Privacy Policy - www.automattic.com - - - Local Changes - You\'ve made changes to an uploaded post that haven\'t been saved yet. Proceed with the refresh and overwrite local changes? - - OK - Image Settings - Blog URL - WordPress Blog - blogusername - Column 1 - Column 2 - - - Sorry, an error occurred while attempting to delete the %s. - Sorry, %s could not be refreshed at this time. Please try again later. - Sorry, an error occurred. Please try again later. - Sorry, an error occurred while attempting to moderate. Please try again later. - Sorry, an error occurred while editing the comment. Please try again later. - Sorry, an error occurred while uploading the %s. - An error occurred while uploading media - You have exceeded the login limit. Please ensure your login credentials are correct and try again in a few minutes. - So sorry, but an error occurred while attempting to create the app database. Please try reinstalling the app. - - - Add media - -