From e70fc2a24326d1539d9bdc4ca965e57b78bae735 Mon Sep 17 00:00:00 2001 From: Alex Forcier Date: Fri, 28 Jul 2017 11:34:51 -0400 Subject: [PATCH 1/8] Pass the post when opening post list from error notification --- .../android/ui/posts/PostsListActivity.java | 14 ++++++++++++-- .../android/ui/posts/PostsListFragment.java | 15 ++++++++++++--- .../android/ui/uploads/PostUploadNotifier.java | 1 + 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.java index 39990d63ee84..392cb8746473 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.java @@ -11,7 +11,9 @@ import org.wordpress.android.R; import org.wordpress.android.WordPress; +import org.wordpress.android.fluxc.model.PostModel; import org.wordpress.android.fluxc.model.SiteModel; +import org.wordpress.android.fluxc.store.PostStore; import org.wordpress.android.fluxc.store.SiteStore; import org.wordpress.android.ui.ActivityId; import org.wordpress.android.ui.RequestCodes; @@ -21,6 +23,7 @@ public class PostsListActivity extends AppCompatActivity { public static final String EXTRA_VIEW_PAGES = "viewPages"; + public static final String EXTRA_TARGET_POST_ID = "targetPostId"; public static final String EXTRA_ERROR_MSG = "errorMessage"; private boolean mIsPage = false; @@ -28,6 +31,7 @@ public class PostsListActivity extends AppCompatActivity { private SiteModel mSite; @Inject SiteStore mSiteStore; + @Inject PostStore mPostStore; @Override public void onCreate(Bundle savedInstanceState) { @@ -89,10 +93,16 @@ private void handleIntent(Intent intent) { actionBar.setDisplayHomeAsUpEnabled(true); } + PostModel targetPost = null; + int targetPostId = intent.getIntExtra(EXTRA_TARGET_POST_ID, 0); + if (targetPostId > 0) { + targetPost = mPostStore.getPostByLocalPostId(intent.getIntExtra(EXTRA_TARGET_POST_ID, 0)); + } + mPostList = (PostsListFragment) getFragmentManager().findFragmentByTag(PostsListFragment.TAG); - if (mPostList == null || siteHasChanged || pageHasChanged) { + if (mPostList == null || siteHasChanged || pageHasChanged || targetPost != null) { PostsListFragment oldFragment = mPostList; - mPostList = PostsListFragment.newInstance(mSite, mIsPage); + mPostList = PostsListFragment.newInstance(mSite, mIsPage, targetPost); if (oldFragment == null) { getFragmentManager().beginTransaction() .add(R.id.post_list_container, mPostList, PostsListFragment.TAG) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java index a41932f5ce06..5e0f394d3bb7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java @@ -85,6 +85,7 @@ public class PostsListFragment extends Fragment private boolean mCanLoadMorePosts = true; private boolean mIsPage; + private PostModel mTargetPost; private boolean mIsFetchingPosts; private boolean mShouldCancelPendingDraftNotification = false; private int mPostIdForPostToBeDeleted = 0; @@ -97,11 +98,14 @@ public class PostsListFragment extends Fragment @Inject PostStore mPostStore; @Inject Dispatcher mDispatcher; - public static PostsListFragment newInstance(SiteModel site, boolean isPage) { + public static PostsListFragment newInstance(SiteModel site, boolean isPage, @Nullable PostModel targetPost) { PostsListFragment fragment = new PostsListFragment(); Bundle bundle = new Bundle(); bundle.putSerializable(WordPress.SITE, site); bundle.putBoolean(PostsListActivity.EXTRA_VIEW_PAGES, isPage); + if (targetPost != null) { + bundle.putInt(PostsListActivity.EXTRA_TARGET_POST_ID, targetPost.getId()); + } fragment.setArguments(bundle); return fragment; } @@ -130,18 +134,23 @@ private void updateSiteOrFinishActivity(Bundle savedInstanceState) { if (getArguments() != null) { mSite = (SiteModel) getArguments().getSerializable(WordPress.SITE); mIsPage = getArguments().getBoolean(PostsListActivity.EXTRA_VIEW_PAGES); + mTargetPost = mPostStore.getPostByLocalPostId( + getArguments().getInt(PostsListActivity.EXTRA_TARGET_POST_ID)); } else { mSite = (SiteModel) getActivity().getIntent().getSerializableExtra(WordPress.SITE); mIsPage = getActivity().getIntent().getBooleanExtra(PostsListActivity.EXTRA_VIEW_PAGES, false); + mTargetPost = mPostStore.getPostByLocalPostId( + getActivity().getIntent().getIntExtra(PostsListActivity.EXTRA_TARGET_POST_ID, 0)); } } else { mSite = (SiteModel) savedInstanceState.getSerializable(WordPress.SITE); mIsPage = savedInstanceState.getBoolean(PostsListActivity.EXTRA_VIEW_PAGES); + mTargetPost = mPostStore.getPostByLocalPostId( + savedInstanceState.getInt(PostsListActivity.EXTRA_TARGET_POST_ID)); } if (mSite == null) { - ToastUtils.showToast(getActivity(), R.string.blog_not_found, - ToastUtils.Duration.SHORT); + ToastUtils.showToast(getActivity(), R.string.blog_not_found, ToastUtils.Duration.SHORT); getActivity().finish(); } } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadNotifier.java b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadNotifier.java index a2c2ca2cdf15..58cd7cfa03cb 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadNotifier.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadNotifier.java @@ -188,6 +188,7 @@ void updateNotificationError(PostModel post, SiteModel site, String errorMessage notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); notificationIntent.putExtra(WordPress.SITE, site); notificationIntent.putExtra(PostsListActivity.EXTRA_VIEW_PAGES, post.isPage()); + notificationIntent.putExtra(PostsListActivity.EXTRA_TARGET_POST_ID, post.getId()); notificationIntent.putExtra(PostsListActivity.EXTRA_ERROR_MSG, errorMessage); notificationIntent.setAction(String.valueOf(notificationId)); From 3bf6a804ddb038c6bd73ccc61c31f3850c431dc6 Mon Sep 17 00:00:00 2001 From: Alex Forcier Date: Fri, 28 Jul 2017 11:39:17 -0400 Subject: [PATCH 2/8] Scroll list to failed post when opening error notification --- .../wordpress/android/ui/posts/PostsListFragment.java | 11 +++++++++++ .../android/ui/posts/adapters/PostsListAdapter.java | 8 ++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java index 5e0f394d3bb7..ce71f0cc9769 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java @@ -503,6 +503,17 @@ public void onPostsLoaded(int postCount) { } else if (postCount > 0) { hideEmptyView(); } + + // If the activity was given a target post, and this is the first time posts are loaded, scroll to that post + if (mTargetPost != null) { + if (mPostsListAdapter != null) { + final int position = mPostsListAdapter.getPositionForPost(mTargetPost); + if (position > -1) { + mRecyclerView.smoothScrollToPosition(position); + } + } + mTargetPost = null; + } } /* diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/adapters/PostsListAdapter.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/adapters/PostsListAdapter.java index 185b6f1f0a1e..947de891f2b8 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/adapters/PostsListAdapter.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/adapters/PostsListAdapter.java @@ -632,6 +632,10 @@ public void onAnimationEnd(Animator animation) { animOut.start(); } + public int getPositionForPost(PostModel post) { + return PostUtils.indexOfPostInList(post, mPosts); + } + public void loadPosts(LoadMode mode) { if (mIsLoadingPosts) { AppLog.d(AppLog.T.POSTS, "post adapter > already loading posts"); @@ -642,7 +646,7 @@ public void loadPosts(LoadMode mode) { public void updateProgressForPost(@NonNull PostModel post) { if (mRecyclerView != null) { - int position = PostUtils.indexOfPostInList(post, mPosts); + int position = getPositionForPost(post); if (position > -1) { RecyclerView.ViewHolder viewHolder = mRecyclerView.findViewHolderForAdapterPosition(position); if (viewHolder instanceof PostViewHolder) { @@ -661,7 +665,7 @@ public void updateProgressForPost(@NonNull PostModel post) { public void hidePost(PostModel post) { mHiddenPosts.add(post); - int position = PostUtils.indexOfPostInList(post, mPosts); + int position = getPositionForPost(post); if (position > -1) { mPosts.remove(position); if (mPosts.size() > 0) { From d108595865bd2f01519debb8c64f9617113b2c1e Mon Sep 17 00:00:00 2001 From: Alex Forcier Date: Fri, 28 Jul 2017 11:40:12 -0400 Subject: [PATCH 3/8] Remove post list error dialog (triggered from error notifications) --- .../android/ui/posts/PostsListActivity.java | 29 ------------------- .../ui/uploads/PostUploadNotifier.java | 1 - 2 files changed, 30 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.java index 392cb8746473..7d940b0afe49 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.java @@ -1,12 +1,10 @@ package org.wordpress.android.ui.posts; -import android.app.AlertDialog; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.ActionBar; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; -import android.text.TextUtils; import android.view.MenuItem; import org.wordpress.android.R; @@ -24,7 +22,6 @@ public class PostsListActivity extends AppCompatActivity { public static final String EXTRA_VIEW_PAGES = "viewPages"; public static final String EXTRA_TARGET_POST_ID = "targetPostId"; - public static final String EXTRA_ERROR_MSG = "errorMessage"; private boolean mIsPage = false; private PostsListFragment mPostList; @@ -113,8 +110,6 @@ private void handleIntent(Intent intent) { .commit(); } } - - showErrorDialogIfNeeded(intent.getExtras()); } @Override @@ -132,30 +127,6 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) { } } - /** - * intent extras will contain error info if this activity was started from an - * upload error notification - */ - private void showErrorDialogIfNeeded(Bundle extras) { - if (extras == null || !extras.containsKey(EXTRA_ERROR_MSG) || isFinishing()) { - return; - } - - final String errorMessage = extras.getString(EXTRA_ERROR_MSG); - - if (TextUtils.isEmpty(errorMessage)) { - return; - } - - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setTitle(getResources().getText(R.string.error)) - .setMessage(errorMessage) - .setPositiveButton(android.R.string.ok, null) - .setCancelable(true); - - builder.create().show(); - } - public boolean isRefreshing() { return mPostList.isRefreshing(); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadNotifier.java b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadNotifier.java index 58cd7cfa03cb..18dc9e53d16c 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadNotifier.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadNotifier.java @@ -189,7 +189,6 @@ void updateNotificationError(PostModel post, SiteModel site, String errorMessage notificationIntent.putExtra(WordPress.SITE, site); notificationIntent.putExtra(PostsListActivity.EXTRA_VIEW_PAGES, post.isPage()); notificationIntent.putExtra(PostsListActivity.EXTRA_TARGET_POST_ID, post.getId()); - notificationIntent.putExtra(PostsListActivity.EXTRA_ERROR_MSG, errorMessage); notificationIntent.setAction(String.valueOf(notificationId)); PendingIntent pendingIntent = PendingIntent.getActivity(mContext, From 56d8d253cb6d55f6e42150db35677461107c4244 Mon Sep 17 00:00:00 2001 From: Alex Forcier Date: Fri, 28 Jul 2017 14:02:37 -0400 Subject: [PATCH 4/8] Scroll target post to the top of the list --- .../java/org/wordpress/android/ui/posts/PostsListFragment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java index ce71f0cc9769..c3ac8567378d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java @@ -509,7 +509,7 @@ public void onPostsLoaded(int postCount) { if (mPostsListAdapter != null) { final int position = mPostsListAdapter.getPositionForPost(mTargetPost); if (position > -1) { - mRecyclerView.smoothScrollToPosition(position); + mRecyclerView.scrollToPosition(position); } } mTargetPost = null; From 08c69543102059323cf7f2383c95d2b5e906656a Mon Sep 17 00:00:00 2001 From: Alex Forcier Date: Mon, 31 Jul 2017 08:10:20 -0400 Subject: [PATCH 5/8] Smooth scroll to failed post --- .../wordpress/android/ui/posts/PostsListFragment.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java index c3ac8567378d..aa312690b8a5 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java @@ -13,6 +13,7 @@ import android.support.design.widget.Snackbar; import android.support.v7.app.AlertDialog; import android.support.v7.widget.LinearLayoutManager; +import android.support.v7.widget.LinearSmoothScroller; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; @@ -509,7 +510,15 @@ public void onPostsLoaded(int postCount) { if (mPostsListAdapter != null) { final int position = mPostsListAdapter.getPositionForPost(mTargetPost); if (position > -1) { - mRecyclerView.scrollToPosition(position); + RecyclerView.SmoothScroller smoothScroller = new LinearSmoothScroller(getActivity()) { + @Override + protected int getVerticalSnapPreference() { + return LinearSmoothScroller.SNAP_TO_START; + } + }; + + smoothScroller.setTargetPosition(position); + mRecyclerView.getLayoutManager().startSmoothScroll(smoothScroller); } } mTargetPost = null; From 711f21e835164c0530581b3011fb70b1bf003dec Mon Sep 17 00:00:00 2001 From: Alex Forcier Date: Mon, 31 Jul 2017 11:41:13 -0400 Subject: [PATCH 6/8] Offset scroll-to-post to show part of above post --- .../android/ui/posts/PostsListFragment.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java index aa312690b8a5..e5dc9c410203 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java @@ -15,6 +15,7 @@ import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearSmoothScroller; import android.support.v7.widget.RecyclerView; +import android.util.TypedValue; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -511,10 +512,21 @@ public void onPostsLoaded(int postCount) { final int position = mPostsListAdapter.getPositionForPost(mTargetPost); if (position > -1) { RecyclerView.SmoothScroller smoothScroller = new LinearSmoothScroller(getActivity()) { + private static final int SCROLL_OFFSET_DP = 23; + @Override protected int getVerticalSnapPreference() { return LinearSmoothScroller.SNAP_TO_START; } + + @Override + public int calculateDtToFit(int viewStart, int viewEnd, int boxStart, int boxEnd, + int snapPreference) { + // Assume SNAP_TO_START, and offset the scroll, so the bottom of the above post shows + int offsetPx = (int) TypedValue.applyDimension( + TypedValue.COMPLEX_UNIT_DIP, SCROLL_OFFSET_DP, getResources().getDisplayMetrics()); + return boxStart - viewStart + offsetPx; + } }; smoothScroller.setTargetPosition(position); From 3e0b6f620b3b0d75954616ce8bdf70b1a5acaa45 Mon Sep 17 00:00:00 2001 From: Alex Forcier Date: Mon, 31 Jul 2017 15:19:14 -0400 Subject: [PATCH 7/8] Rename target post id constant --- .../org/wordpress/android/ui/posts/PostsListActivity.java | 6 +++--- .../org/wordpress/android/ui/posts/PostsListFragment.java | 8 ++++---- .../wordpress/android/ui/uploads/PostUploadNotifier.java | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.java index 7d940b0afe49..77d7859fd63f 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.java @@ -21,7 +21,7 @@ public class PostsListActivity extends AppCompatActivity { public static final String EXTRA_VIEW_PAGES = "viewPages"; - public static final String EXTRA_TARGET_POST_ID = "targetPostId"; + public static final String EXTRA_TARGET_POST_LOCAL_ID = "targetPostLocalId"; private boolean mIsPage = false; private PostsListFragment mPostList; @@ -91,9 +91,9 @@ private void handleIntent(Intent intent) { } PostModel targetPost = null; - int targetPostId = intent.getIntExtra(EXTRA_TARGET_POST_ID, 0); + int targetPostId = intent.getIntExtra(EXTRA_TARGET_POST_LOCAL_ID, 0); if (targetPostId > 0) { - targetPost = mPostStore.getPostByLocalPostId(intent.getIntExtra(EXTRA_TARGET_POST_ID, 0)); + targetPost = mPostStore.getPostByLocalPostId(intent.getIntExtra(EXTRA_TARGET_POST_LOCAL_ID, 0)); } mPostList = (PostsListFragment) getFragmentManager().findFragmentByTag(PostsListFragment.TAG); diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java index e5dc9c410203..c60c53a89b8a 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListFragment.java @@ -106,7 +106,7 @@ public static PostsListFragment newInstance(SiteModel site, boolean isPage, @Nul bundle.putSerializable(WordPress.SITE, site); bundle.putBoolean(PostsListActivity.EXTRA_VIEW_PAGES, isPage); if (targetPost != null) { - bundle.putInt(PostsListActivity.EXTRA_TARGET_POST_ID, targetPost.getId()); + bundle.putInt(PostsListActivity.EXTRA_TARGET_POST_LOCAL_ID, targetPost.getId()); } fragment.setArguments(bundle); return fragment; @@ -137,18 +137,18 @@ private void updateSiteOrFinishActivity(Bundle savedInstanceState) { mSite = (SiteModel) getArguments().getSerializable(WordPress.SITE); mIsPage = getArguments().getBoolean(PostsListActivity.EXTRA_VIEW_PAGES); mTargetPost = mPostStore.getPostByLocalPostId( - getArguments().getInt(PostsListActivity.EXTRA_TARGET_POST_ID)); + getArguments().getInt(PostsListActivity.EXTRA_TARGET_POST_LOCAL_ID)); } else { mSite = (SiteModel) getActivity().getIntent().getSerializableExtra(WordPress.SITE); mIsPage = getActivity().getIntent().getBooleanExtra(PostsListActivity.EXTRA_VIEW_PAGES, false); mTargetPost = mPostStore.getPostByLocalPostId( - getActivity().getIntent().getIntExtra(PostsListActivity.EXTRA_TARGET_POST_ID, 0)); + getActivity().getIntent().getIntExtra(PostsListActivity.EXTRA_TARGET_POST_LOCAL_ID, 0)); } } else { mSite = (SiteModel) savedInstanceState.getSerializable(WordPress.SITE); mIsPage = savedInstanceState.getBoolean(PostsListActivity.EXTRA_VIEW_PAGES); mTargetPost = mPostStore.getPostByLocalPostId( - savedInstanceState.getInt(PostsListActivity.EXTRA_TARGET_POST_ID)); + savedInstanceState.getInt(PostsListActivity.EXTRA_TARGET_POST_LOCAL_ID)); } if (mSite == null) { diff --git a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadNotifier.java b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadNotifier.java index 18dc9e53d16c..733a63e251e6 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadNotifier.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/uploads/PostUploadNotifier.java @@ -188,7 +188,7 @@ void updateNotificationError(PostModel post, SiteModel site, String errorMessage notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); notificationIntent.putExtra(WordPress.SITE, site); notificationIntent.putExtra(PostsListActivity.EXTRA_VIEW_PAGES, post.isPage()); - notificationIntent.putExtra(PostsListActivity.EXTRA_TARGET_POST_ID, post.getId()); + notificationIntent.putExtra(PostsListActivity.EXTRA_TARGET_POST_LOCAL_ID, post.getId()); notificationIntent.setAction(String.valueOf(notificationId)); PendingIntent pendingIntent = PendingIntent.getActivity(mContext, From fece2bf91bf2f4e9bffec11cca606fabf0cfaed6 Mon Sep 17 00:00:00 2001 From: Alex Forcier Date: Mon, 31 Jul 2017 15:20:22 -0400 Subject: [PATCH 8/8] Show toast when tapping error notification for unknown post --- .../java/org/wordpress/android/ui/posts/PostsListActivity.java | 3 +++ WordPress/src/main/res/values/strings.xml | 1 + 2 files changed, 4 insertions(+) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.java index 77d7859fd63f..9513257598d0 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/PostsListActivity.java @@ -94,6 +94,9 @@ private void handleIntent(Intent intent) { int targetPostId = intent.getIntExtra(EXTRA_TARGET_POST_LOCAL_ID, 0); if (targetPostId > 0) { targetPost = mPostStore.getPostByLocalPostId(intent.getIntExtra(EXTRA_TARGET_POST_LOCAL_ID, 0)); + if (targetPost == null) { + ToastUtils.showToast(this, R.string.error_post_does_not_exist); + } } mPostList = (PostsListFragment) getFragmentManager().findFragmentByTag(PostsListFragment.TAG); diff --git a/WordPress/src/main/res/values/strings.xml b/WordPress/src/main/res/values/strings.xml index 6e8d459c8cd9..a08210eecbe5 100644 --- a/WordPress/src/main/res/values/strings.xml +++ b/WordPress/src/main/res/values/strings.xml @@ -1163,6 +1163,7 @@ Unable to save media Uploading media were canceled We were unable to upload this post\'s media. Please edit the post to try again. + This post no longer exists This blog is hidden and couldn\'t be loaded. Enable it again in settings and try again. An error occurred while creating the app database. Try reinstalling the app. An error occurred while copying text to clipboard