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

Show stock photos only for wpcom or jetpack sites #10745

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 @@ -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