Skip to content

Commit

Permalink
show stock options only for wp.com or jetpack sites (#10745)
Browse files Browse the repository at this point in the history
  • Loading branch information
marecar3 authored Nov 7, 2019
1 parent 5540d67 commit c9e3eb1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2158,7 +2158,12 @@ public Fragment getItem(int position) {
setGutenbergEnabledIfNeeded();
String languageString = LocaleManager.getLanguage(EditPostActivity.this);
String wpcomLocaleSlug = languageString.replace("_", "-").toLowerCase(Locale.ENGLISH);
return GutenbergEditorFragment.newInstance("", "", mIsNewPost, wpcomLocaleSlug);
boolean supportsStockPhotos = mSite.isUsingWpComRestApi();
return GutenbergEditorFragment.newInstance("",
"",
mIsNewPost,
wpcomLocaleSlug,
supportsStockPhotos);
} else {
// If gutenberg editor is not selected, default to Aztec.
return AztecEditorFragment.newInstance("", "", AppPrefs.isAztecEditorToolbarExpanded());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public class GutenbergEditorFragment extends EditorFragmentAbstract implements
private static final String KEY_EDITOR_DID_MOUNT = "KEY_EDITOR_DID_MOUNT";
private static final String ARG_IS_NEW_POST = "param_is_new_post";
private static final String ARG_LOCALE_SLUG = "param_locale_slug";
private static final String ARG_SUPPORT_STOCK_PHOTOS = "param_support_stock_photos";

private static final int CAPTURE_PHOTO_PERMISSION_REQUEST_CODE = 101;
private static final int CAPTURE_VIDEO_PERMISSION_REQUEST_CODE = 102;
Expand Down Expand Up @@ -94,13 +95,15 @@ public class GutenbergEditorFragment extends EditorFragmentAbstract implements
public static GutenbergEditorFragment newInstance(String title,
String content,
boolean isNewPost,
String localeSlug) {
String localeSlug,
boolean supportStockPhotos) {
GutenbergEditorFragment fragment = new GutenbergEditorFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM_TITLE, title);
args.putString(ARG_PARAM_CONTENT, content);
args.putBoolean(ARG_IS_NEW_POST, isNewPost);
args.putString(ARG_LOCALE_SLUG, localeSlug);
args.putBoolean(ARG_SUPPORT_STOCK_PHOTOS, supportStockPhotos);
fragment.setArguments(args);
return fragment;
}
Expand Down Expand Up @@ -361,10 +364,13 @@ public void run() {
private ArrayList<MediaOption> initOtherMediaImageOptions() {
ArrayList<MediaOption> otherMediaOptions = new ArrayList<>();

String packageName = getActivity().getApplication().getPackageName();
int stockMediaResourceId = getResources().getIdentifier("photo_picker_stock_media", "string", packageName);
boolean supportStockPhotos = getArguments().getBoolean(ARG_SUPPORT_STOCK_PHOTOS);
if (supportStockPhotos) {
String packageName = getActivity().getApplication().getPackageName();
int stockMediaResourceId = getResources().getIdentifier("photo_picker_stock_media", "string", packageName);

otherMediaOptions.add(new MediaOption(MEDIA_SOURCE_STOCK_MEDIA, getString(stockMediaResourceId)));
otherMediaOptions.add(new MediaOption(MEDIA_SOURCE_STOCK_MEDIA, getString(stockMediaResourceId)));
}

return otherMediaOptions;
}
Expand Down

0 comments on commit c9e3eb1

Please sign in to comment.