use of org.wordpress.android.ui.prefs.SiteSettingsInterface in project WordPress-Android by wordpress-mobile.
the class EditPostActivity method addMediaVisualEditor.
private boolean addMediaVisualEditor(Uri uri, boolean isVideo) {
String path;
if (uri.toString().contains("content:")) {
path = getPathFromContentUri(uri);
} else {
// File is not in media library
path = uri.toString().replace("file://", "");
}
if (path == null) {
ToastUtils.showToast(this, R.string.file_not_found, Duration.SHORT);
return false;
}
boolean isOptimized = false;
if (!NetworkUtils.isWiFiConnected(this) && !isVideo) {
SiteSettingsInterface siteSettings = SiteSettingsInterface.getInterface(this, mSite, null);
// Site Settings are implemented on .com/Jetpack sites only
if (siteSettings != null && siteSettings.init(false).getOptimizedImage()) {
// Not on WiFi and optimize image is set to ON
// Max picture size will be 3000px wide. That's the maximum resolution you can set in the current picker.
String optimizedPath = ImageUtils.optimizeImage(this, path, 3000, 85);
if (optimizedPath == null) {
AppLog.e(T.EDITOR, "Optimized picture was null!");
// TODO: track analytics here
// AnalyticsTracker.track(Stat.EDITOR_RESIZED_PHOTO_ERROR);
} else {
// TODO: track analytics here
// AnalyticsTracker.track(Stat.EDITOR_RESIZED_PHOTO);
Uri optimizedImageUri = Uri.parse(optimizedPath);
if (optimizedImageUri != null) {
uri = optimizedImageUri;
isOptimized = true;
}
}
}
}
MediaModel media = queueFileForUpload(uri, getContentResolver().getType(uri));
MediaFile mediaFile = FluxCUtils.mediaFileFromMediaModel(media);
trackAddMediaFromDeviceEvents(isVideo, isOptimized, null, path);
if (media != null) {
mEditorFragment.appendMediaFile(mediaFile, path, mImageLoader);
}
return true;
}
Aggregations