Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring fix images private sites solution to release 12 1 #9524

Merged
merged 3 commits into from
Apr 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2223,7 +2223,7 @@ public Fragment getItem(int position) {
case 3:
return HistoryListFragment.Companion.newInstance(mPost, mSite);
default:
return EditPostPreviewFragment.newInstance(mPost);
return EditPostPreviewFragment.newInstance(mPost, mSite);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
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.AccountStore;
import org.wordpress.android.fluxc.store.PostStore;
import org.wordpress.android.util.StringUtils;
import org.wordpress.android.util.WPWebViewClient;

import javax.inject.Inject;

Expand All @@ -26,12 +29,15 @@ public class EditPostPreviewFragment extends Fragment {
private WebView mWebView;
private int mLocalPostId;
private LoadPostPreviewTask mLoadTask;
private SiteModel mSite;

@Inject PostStore mPostStore;
@Inject AccountStore mAccountStore;

public static EditPostPreviewFragment newInstance(@NonNull PostModel post) {
public static EditPostPreviewFragment newInstance(@NonNull PostModel post, SiteModel site) {
EditPostPreviewFragment fragment = new EditPostPreviewFragment();
Bundle bundle = new Bundle();
bundle.putSerializable(WordPress.SITE, site);
bundle.putInt(ARG_LOCAL_POST_ID, post.getId());
fragment.setArguments(bundle);
return fragment;
Expand All @@ -41,6 +47,7 @@ public static EditPostPreviewFragment newInstance(@NonNull PostModel post) {
public void setArguments(Bundle args) {
super.setArguments(args);
mLocalPostId = args.getInt(ARG_LOCAL_POST_ID);
mSite = (SiteModel) args.getSerializable(WordPress.SITE);
}

@Override
Expand All @@ -54,6 +61,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
ViewGroup rootView = (ViewGroup) inflater
.inflate(R.layout.edit_post_preview_fragment, container, false);
mWebView = rootView.findViewById(R.id.post_preview_web_view);
WPWebViewClient client = new WPWebViewClient(mSite, mAccountStore.getAccessToken());
mWebView.setWebViewClient(client);
mWebView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Expand Down