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

GIF Support - EditPostSettings #7968

Closed
wants to merge 3 commits into from
Closed
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 @@ -9,7 +9,6 @@
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.view.menu.MenuPopupHelper;
import android.support.v7.widget.CardView;
import android.support.v7.widget.PopupMenu;
Expand All @@ -21,6 +20,8 @@
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.LinearLayout;
import android.widget.TextView;

Expand All @@ -39,6 +40,7 @@
import org.wordpress.android.R;
import org.wordpress.android.WordPress;
import org.wordpress.android.fluxc.Dispatcher;
import org.wordpress.android.fluxc.action.TaxonomyAction;
import org.wordpress.android.fluxc.generated.SiteActionBuilder;
import org.wordpress.android.fluxc.generated.TaxonomyActionBuilder;
import org.wordpress.android.fluxc.model.MediaModel;
Expand All @@ -54,6 +56,7 @@
import org.wordpress.android.fluxc.store.TaxonomyStore;
import org.wordpress.android.fluxc.store.TaxonomyStore.OnTaxonomyChanged;
import org.wordpress.android.ui.ActivityLauncher;
import org.wordpress.android.ui.ImageManager;
import org.wordpress.android.ui.RequestCodes;
import org.wordpress.android.ui.media.MediaBrowserType;
import org.wordpress.android.ui.posts.PostDatePickerDialogFragment.PickerDialogType;
Expand All @@ -69,8 +72,6 @@
import org.wordpress.android.util.PhotonUtils;
import org.wordpress.android.util.SiteUtils;
import org.wordpress.android.util.ToastUtils;
import org.wordpress.android.util.WPMediaUtils;
import org.wordpress.android.widgets.WPNetworkImageView;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -112,7 +113,7 @@ public class EditPostSettingsFragment extends Fragment {
private TextView mPostFormatTextView;
private TextView mPasswordTextView;
private TextView mPublishDateTextView;
private WPNetworkImageView mFeaturedImageView;
private ImageView mFeaturedImageView;
private Button mFeaturedImageButton;

private PostLocation mPostLocation;
Expand All @@ -124,6 +125,7 @@ public class EditPostSettingsFragment extends Fragment {
@Inject MediaStore mMediaStore;
@Inject TaxonomyStore mTaxonomyStore;
@Inject Dispatcher mDispatcher;
@Inject ImageManager mImageManager;


interface EditPostActivityHook {
Expand Down Expand Up @@ -210,26 +212,27 @@ public void onDestroy() {
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.edit_post_settings_fragment, container, false);

if (rootView == null) {
return null;
}

mExcerptTextView = (TextView) rootView.findViewById(R.id.post_excerpt);
mSlugTextView = (TextView) rootView.findViewById(R.id.post_slug);
mLocationTextView = (TextView) rootView.findViewById(R.id.post_location);
mCategoriesTextView = (TextView) rootView.findViewById(R.id.post_categories);
mTagsTextView = (TextView) rootView.findViewById(R.id.post_tags);
mStatusTextView = (TextView) rootView.findViewById(R.id.post_status);
mPostFormatTextView = (TextView) rootView.findViewById(R.id.post_format);
mPasswordTextView = (TextView) rootView.findViewById(R.id.post_password);
mPublishDateTextView = (TextView) rootView.findViewById(R.id.publish_date);
mExcerptTextView = rootView.findViewById(R.id.post_excerpt);
mSlugTextView = rootView.findViewById(R.id.post_slug);
mLocationTextView = rootView.findViewById(R.id.post_location);
mCategoriesTextView = rootView.findViewById(R.id.post_categories);
mTagsTextView = rootView.findViewById(R.id.post_tags);
mStatusTextView = rootView.findViewById(R.id.post_status);
mPostFormatTextView = rootView.findViewById(R.id.post_format);
mPasswordTextView = rootView.findViewById(R.id.post_password);
mPublishDateTextView = rootView.findViewById(R.id.publish_date);

mFeaturedImageView = (WPNetworkImageView) rootView.findViewById(R.id.post_featured_image);
mFeaturedImageButton = (Button) rootView.findViewById(R.id.post_add_featured_image_button);
CardView featuredImageCardView = (CardView) rootView.findViewById(R.id.post_featured_image_card_view);
mFeaturedImageView = rootView.findViewById(R.id.post_featured_image);
mFeaturedImageButton = rootView.findViewById(R.id.post_add_featured_image_button);
CardView featuredImageCardView = rootView.findViewById(R.id.post_featured_image_card_view);

if (AppPrefs.isVisualEditorEnabled() || AppPrefs.isAztecEditorEnabled()) {
registerForContextMenu(mFeaturedImageView);
Expand All @@ -249,71 +252,71 @@ public void onClick(View view) {
featuredImageCardView.setVisibility(View.GONE);
}

mExcerptContainer = (LinearLayout) rootView.findViewById(R.id.post_excerpt_container);
mExcerptContainer = rootView.findViewById(R.id.post_excerpt_container);
mExcerptContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showPostExcerptDialog();
}
});

final LinearLayout slugContainer = (LinearLayout) rootView.findViewById(R.id.post_slug_container);
final LinearLayout slugContainer = rootView.findViewById(R.id.post_slug_container);
slugContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showSlugDialog();
}
});

final LinearLayout locationContainer = (LinearLayout) rootView.findViewById(R.id.post_location_container);
final LinearLayout locationContainer = rootView.findViewById(R.id.post_location_container);
locationContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showLocationPickerOrPopupMenu(view);
}
});

mCategoriesContainer = (LinearLayout) rootView.findViewById(R.id.post_categories_container);
mCategoriesContainer = rootView.findViewById(R.id.post_categories_container);
mCategoriesContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showCategoriesActivity();
}
});

mTagsContainer = (LinearLayout) rootView.findViewById(R.id.post_tags_container);
mTagsContainer = rootView.findViewById(R.id.post_tags_container);
mTagsContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showTagsActivity();
}
});

final LinearLayout statusContainer = (LinearLayout) rootView.findViewById(R.id.post_status_container);
final LinearLayout statusContainer = rootView.findViewById(R.id.post_status_container);
statusContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showStatusDialog();
}
});

mFormatContainer = (LinearLayout) rootView.findViewById(R.id.post_format_container);
mFormatContainer = rootView.findViewById(R.id.post_format_container);
mFormatContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showPostFormatDialog();
}
});

final LinearLayout passwordContainer = (LinearLayout) rootView.findViewById(R.id.post_password_container);
final LinearLayout passwordContainer = rootView.findViewById(R.id.post_password_container);
passwordContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showPostPasswordDialog();
}
});

final LinearLayout publishDateContainer = (LinearLayout) rootView.findViewById(R.id.publish_date_container);
final LinearLayout publishDateContainer = rootView.findViewById(R.id.publish_date_container);
publishDateContainer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Expand Down Expand Up @@ -511,7 +514,7 @@ private void showStatusDialog() {
}

int index = getCurrentPostStatusIndex();
FragmentManager fm = ((AppCompatActivity) getActivity()).getSupportFragmentManager();
FragmentManager fm = getActivity().getSupportFragmentManager();
PostSettingsListDialogFragment fragment =
PostSettingsListDialogFragment.newInstance(DialogType.POST_STATUS, index);
fragment.show(fm, PostSettingsListDialogFragment.TAG);
Expand All @@ -533,7 +536,7 @@ private void showPostFormatDialog() {
}
}

FragmentManager fm = ((AppCompatActivity) getActivity()).getSupportFragmentManager();
FragmentManager fm = getActivity().getSupportFragmentManager();
PostSettingsListDialogFragment fragment =
PostSettingsListDialogFragment.newInstance(DialogType.POST_FORMAT, checkedIndex);
fragment.show(fm, PostSettingsListDialogFragment.TAG);
Expand Down Expand Up @@ -564,7 +567,7 @@ private void showPostDateSelectionDialog() {
Calendar calendar = getCurrentPublishDateAsCalendar();
PostDatePickerDialogFragment fragment =
PostDatePickerDialogFragment.newInstance(PickerDialogType.DATE_PICKER, getPost(), calendar);
FragmentManager fm = ((AppCompatActivity) getActivity()).getSupportFragmentManager();
FragmentManager fm = getActivity().getSupportFragmentManager();
fragment.show(fm, PostDatePickerDialogFragment.TAG_DATE);
}

Expand All @@ -576,7 +579,7 @@ private void showPostTimeSelectionDialog() {
Calendar calendar = getCurrentPublishDateAsCalendar();
PostDatePickerDialogFragment fragment =
PostDatePickerDialogFragment.newInstance(PickerDialogType.TIME_PICKER, getPost(), calendar);
FragmentManager fm = ((AppCompatActivity) getActivity()).getSupportFragmentManager();
FragmentManager fm = getActivity().getSupportFragmentManager();
fragment.show(fm, PostDatePickerDialogFragment.TAG_TIME);
}

Expand Down Expand Up @@ -762,8 +765,15 @@ private int getCurrentPostStatusIndex() {
return 2;
case PRIVATE:
return 3;
case TRASHED:
// fallthrough
case UNKNOWN:
// fallthrough
case PUBLISHED:
// fallthrough
case SCHEDULED:
// fallthrough
default:
// PUBLISHED, SCHEDULED, UNKNOWN
return 0;
}
}
Expand Down Expand Up @@ -851,12 +861,12 @@ private void updateFeaturedImageView() {
int height = DisplayUtils.getDisplayPixelHeight(getActivity());
int size = Math.max(width, height);

String mediaUri = media.getThumbnailUrl();
String mediaUri = media.getUrl();
if (SiteUtils.isPhotonCapable(siteModel)) {
mediaUri = PhotonUtils.getPhotonImageUrl(mediaUri, size, 0);
}

WPMediaUtils.loadNetworkImage(mediaUri, mFeaturedImageView);
mImageManager.load(mFeaturedImageView, mediaUri, null, ScaleType.FIT_CENTER);
}

private void launchFeaturedMediaPicker() {
Expand Down Expand Up @@ -899,10 +909,8 @@ public void onTaxonomyChanged(OnTaxonomyChanged event) {
AppLog.e(T.POSTS, "An error occurred while updating taxonomy with type: " + event.error.type);
return;
}
switch (event.causeOfChange) {
case FETCH_CATEGORIES:
updateCategoriesTextView();
break;
if (event.causeOfChange == TaxonomyAction.FETCH_CATEGORIES) {
updateCategoriesTextView();
}
}

Expand Down
5 changes: 3 additions & 2 deletions WordPress/src/main/res/layout/edit_post_settings_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,14 @@
android:layout_height="wrap_content"
android:text="@string/post_settings_set_featured_image"/>

<org.wordpress.android.widgets.WPNetworkImageView
<ImageView
android:id="@+id/post_featured_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxHeight="@dimen/post_settings_featured_image_height_max"
android:minHeight="@dimen/post_settings_featured_image_height_min"
android:scaleType="fitStart"
android:contentDescription="@string/post_settings_featured_desc"
android:adjustViewBounds="true"
android:visibility="gone"/>
</LinearLayout>

Expand Down
1 change: 1 addition & 0 deletions WordPress/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2118,6 +2118,7 @@
<string name="plugin_detail_banner_desc">plugin banner</string>
<string name="plugin_detail_logo_desc">plugin logo</string>
<string name="post_cardview_featured_desc">featured image</string>
<string name="post_settings_featured_desc">featured image</string>
<string name="reader_cardview_post_play_video_desc">play featured video</string>
<string name="photo_picker_thumbnail_desc">Play video</string>
<string name="reader_list_item_suggestion_remove_desc">delete</string>
Expand Down