From bc27690c6dc107738b6dd6e07848276879475e2a Mon Sep 17 00:00:00 2001 From: Tony Rankin Date: Mon, 13 Jul 2015 22:27:39 -0700 Subject: [PATCH 1/8] Updating ActionBar title. Save button is now Undo. --- .../wordpress/android/util/StringUtils.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/WordPressUtils/src/main/java/org/wordpress/android/util/StringUtils.java b/WordPressUtils/src/main/java/org/wordpress/android/util/StringUtils.java index 68e3113c3d5d..6f73e6dd6ad2 100644 --- a/WordPressUtils/src/main/java/org/wordpress/android/util/StringUtils.java +++ b/WordPressUtils/src/main/java/org/wordpress/android/util/StringUtils.java @@ -11,6 +11,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Locale; public class StringUtils { public static String[] mergeStringArrays(String array1[], String array2[]) { @@ -228,6 +229,28 @@ public static String replaceUnicodeSurrogateBlocksWithHTMLEntities(final String return out.toString(); } + /** + * Used to convert a language code ([lc]_[rc] where lc is language code (en, fr, es, etc...) + * and rc is region code (zh-CN, zh-HK, zh-TW, etc...) to a displayable string with the languages + * name. + * + * The input string must be between 2 and 6 characters, inclusive. An empty string is returned + * if that is not the case. + * + * If the input string is recognized by {@link Locale} the result of this method is the given + * + * @return + * non-null + */ + public static String getLanguageString(String languagueCode, Locale displayLocale) { + if (languagueCode == null || languagueCode.length() < 2 || languagueCode.length() > 6) { + return ""; + } + + Locale languageLocale = new Locale(languagueCode.substring(0, 2)); + return languageLocale.getDisplayLanguage(displayLocale) + languagueCode.substring(2); + } + /** * This method ensures that the output String has only * valid XML unicode characters as specified by the From 1857d7e500e7ae63c1d7bf1979ae8c3457f1cb37 Mon Sep 17 00:00:00 2001 From: Alex Forcier Date: Fri, 29 Jan 2016 17:16:35 -1000 Subject: [PATCH 2/8] Added ShortcodeUtils with methods for converting VideoPress ids to shortcodes and vice versa --- .../android/util/ShortcodeUtilsTest.java | 25 +++++++++++++++ .../android/util/ShortcodeUtils.java | 31 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 WordPressUtils/src/androidTest/java/org/wordpress/android/util/ShortcodeUtilsTest.java create mode 100644 WordPressUtils/src/main/java/org/wordpress/android/util/ShortcodeUtils.java diff --git a/WordPressUtils/src/androidTest/java/org/wordpress/android/util/ShortcodeUtilsTest.java b/WordPressUtils/src/androidTest/java/org/wordpress/android/util/ShortcodeUtilsTest.java new file mode 100644 index 000000000000..c506a452ee5d --- /dev/null +++ b/WordPressUtils/src/androidTest/java/org/wordpress/android/util/ShortcodeUtilsTest.java @@ -0,0 +1,25 @@ +package org.wordpress.android.util; + +import android.test.InstrumentationTestCase; + +public class ShortcodeUtilsTest extends InstrumentationTestCase { + public void testGetVideoPressShortcodeFromId() { + assertEquals("[wpvideo abcd1234]", ShortcodeUtils.getVideoPressShortcodeFromId("abcd1234")); + } + + public void testGetVideoPressShortcodeFromNullId() { + assertEquals("", ShortcodeUtils.getVideoPressShortcodeFromId(null)); + } + + public void testGetVideoPressIdFromCorrectShortcode() { + assertEquals("abcd1234", ShortcodeUtils.getVideoPressIdFromShortCode("[wpvideo abcd1234]")); + } + + public void testGetVideoPressIdFromInvalidShortcode() { + assertEquals("", ShortcodeUtils.getVideoPressIdFromShortCode("[other abcd1234]")); + } + + public void testGetVideoPressIdFromNullShortcode() { + assertEquals("", ShortcodeUtils.getVideoPressIdFromShortCode(null)); + } +} diff --git a/WordPressUtils/src/main/java/org/wordpress/android/util/ShortcodeUtils.java b/WordPressUtils/src/main/java/org/wordpress/android/util/ShortcodeUtils.java new file mode 100644 index 000000000000..09480f156364 --- /dev/null +++ b/WordPressUtils/src/main/java/org/wordpress/android/util/ShortcodeUtils.java @@ -0,0 +1,31 @@ +package org.wordpress.android.util; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class ShortcodeUtils { + public static String getVideoPressShortcodeFromId(String videoPressId) { + if (videoPressId == null || videoPressId.isEmpty()) { + return ""; + } + + return "[wpvideo " + videoPressId + "]"; + } + + public static String getVideoPressIdFromShortCode(String shortcode) { + String videoPressId = ""; + + if (shortcode != null) { + String videoPressShortcodeRegex = "^\\[wpvideo (.*)]$"; + + Pattern pattern = Pattern.compile(videoPressShortcodeRegex); + Matcher matcher = pattern.matcher(shortcode); + + if (matcher.find()) { + videoPressId = matcher.group(1); + } + } + + return videoPressId; + } +} From db6e3fcd16a80e69e705b751f032f3ca61323c7d Mon Sep 17 00:00:00 2001 From: Alex Forcier Date: Fri, 29 Jan 2016 17:24:52 -1000 Subject: [PATCH 3/8] Removed unused StringUtils.getLanguageString method --- .../wordpress/android/util/StringUtils.java | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/WordPressUtils/src/main/java/org/wordpress/android/util/StringUtils.java b/WordPressUtils/src/main/java/org/wordpress/android/util/StringUtils.java index ab805cedc84c..25ddd2a41226 100644 --- a/WordPressUtils/src/main/java/org/wordpress/android/util/StringUtils.java +++ b/WordPressUtils/src/main/java/org/wordpress/android/util/StringUtils.java @@ -11,7 +11,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Locale; public class StringUtils { public static String[] mergeStringArrays(String array1[], String array2[]) { @@ -219,28 +218,6 @@ public static String replaceUnicodeSurrogateBlocksWithHTMLEntities(final String return out.toString(); } - /** - * Used to convert a language code ([lc]_[rc] where lc is language code (en, fr, es, etc...) - * and rc is region code (zh-CN, zh-HK, zh-TW, etc...) to a displayable string with the languages - * name. - * - * The input string must be between 2 and 6 characters, inclusive. An empty string is returned - * if that is not the case. - * - * If the input string is recognized by {@link Locale} the result of this method is the given - * - * @return - * non-null - */ - public static String getLanguageString(String languagueCode, Locale displayLocale) { - if (languagueCode == null || languagueCode.length() < 2 || languagueCode.length() > 6) { - return ""; - } - - Locale languageLocale = new Locale(languagueCode.substring(0, 2)); - return languageLocale.getDisplayLanguage(displayLocale) + languagueCode.substring(2); - } - /** * This method ensures that the output String has only * valid XML unicode characters as specified by the From c611f1eddb7f8321be051ebb3c117f0f9af77274 Mon Sep 17 00:00:00 2001 From: Alex Forcier Date: Fri, 29 Jan 2016 18:05:30 -1000 Subject: [PATCH 4/8] 1.9.0 version bump --- WordPressUtils/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WordPressUtils/build.gradle b/WordPressUtils/build.gradle index 1b188062bde8..dc4230cfe1d4 100644 --- a/WordPressUtils/build.gradle +++ b/WordPressUtils/build.gradle @@ -32,7 +32,7 @@ android { buildToolsVersion "23.0.2" defaultConfig { - versionName "1.8.0" + versionName "1.9.0" minSdkVersion 14 targetSdkVersion 23 } From 75a7f0c4b18351a1b000b8087ef2385572777d27 Mon Sep 17 00:00:00 2001 From: Maxime Biais Date: Thu, 2 Jun 2016 19:14:13 +0200 Subject: [PATCH 5/8] new MediaUtils function: getImageWidthSettingFromString --- .../wordpress/android/util/MediaUtils.java | 53 ++++++++++++++----- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/MediaUtils.java b/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/MediaUtils.java index 8e2c773339ce..a96dadc7493e 100644 --- a/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/MediaUtils.java +++ b/libs/utils/WordPressUtils/src/main/java/org/wordpress/android/util/MediaUtils.java @@ -29,6 +29,8 @@ import java.util.TimeZone; public class MediaUtils { + private static final int DEFAULT_MAX_IMAGE_WIDTH = 1024; + public static boolean isValidImage(String url) { if (url == null) { return false; @@ -114,29 +116,52 @@ public static Uri getLastRecordedVideoUri(Activity activity) { return Uri.parse(contentUri.toString() + "/" + cursor.getLong(0)); } - // Calculate the minimun width between the blog setting and picture real width - public static int getMinimumImageWidth(Context context, Uri curStream, String imageWidthBlogSettingString) { - int imageWidthBlogSetting = Integer.MAX_VALUE; - - if (!imageWidthBlogSettingString.equals("Original Size")) { - try { - imageWidthBlogSetting = Integer.valueOf(imageWidthBlogSettingString); - } catch (NumberFormatException e) { - AppLog.e(T.POSTS, e); - } + /** + * Get image width setting from the image width site setting string. This string can be an int, in this case it's + * the maximum image width defined by the site. + * Examples: + * "1000" will return 1000 + * "Original Size" will return Integer.MAX_VALUE + * "Largeur originale" will return Integer.MAX_VALUE + * null will return Integer.MAX_VALUE + * @param imageWidthSiteSettingString Image width site setting string + * @return Integer.MAX_VALUE if image width is not defined or invalid, maximum image width in other cases. + */ + public static int getImageWidthSettingFromString(String imageWidthSiteSettingString) { + if (imageWidthSiteSettingString == null) { + return Integer.MAX_VALUE; + } + try { + return Integer.valueOf(imageWidthSiteSettingString); + } catch (NumberFormatException e) { + return Integer.MAX_VALUE; } + } - int[] dimensions = ImageUtils.getImageSize(curStream, context); - int imageWidthPictureSetting = dimensions[0] == 0 ? Integer.MAX_VALUE : dimensions[0]; + /** + * Calculate and return the maximum allowed image width by comparing the width of the image at its full size with + * the maximum upload width set in the blog settings + * @param imageWidth the image's natural (full) width + * @param imageWidthSiteSettingString the maximum upload width set in the site settings + * @return maximum allowed image width + */ + public static int getMaximumImageWidth(int imageWidth, String imageWidthSiteSettingString) { + int imageWidthBlogSetting = getImageWidthSettingFromString(imageWidthSiteSettingString); + int imageWidthPictureSetting = imageWidth == 0 ? Integer.MAX_VALUE : imageWidth; if (Math.min(imageWidthPictureSetting, imageWidthBlogSetting) == Integer.MAX_VALUE) { - // Default value in case of errors reading the picture size and the blog settings is set to Original size - return 1024; + // Default value in case of errors reading the picture size or the blog settings is set to Original size + return DEFAULT_MAX_IMAGE_WIDTH; } else { return Math.min(imageWidthPictureSetting, imageWidthBlogSetting); } } + public static int getMaximumImageWidth(Context context, Uri curStream, String imageWidthBlogSettingString) { + int[] dimensions = ImageUtils.getImageSize(curStream, context); + return getMaximumImageWidth(dimensions[0], imageWidthBlogSettingString); + } + public static boolean isInMediaStore(Uri mediaUri) { // Check if the image is externally hosted (Picasa/Google Photos for example) if (mediaUri != null && mediaUri.toString().startsWith("content://media/")) { From df1619fb4d3f3c986155fad336edc9a65587a022 Mon Sep 17 00:00:00 2001 From: Maxime Biais Date: Thu, 2 Jun 2016 19:18:09 +0200 Subject: [PATCH 6/8] use MediaUtils.getImageWidthSettingFromString instead of referring to 'Original Size' --- .../android/ui/posts/EditPostActivity.java | 3 +- .../ui/posts/services/PostUploadService.java | 7 ++-- .../org/wordpress/android/util/WPHtml.java | 15 ++++---- .../editor/ImageSettingsDialogFragment.java | 35 ++----------------- 4 files changed, 15 insertions(+), 45 deletions(-) diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java index 82c6f7cbc4c0..48e3eba365d9 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/EditPostActivity.java @@ -102,7 +102,6 @@ import org.wordpress.android.util.helpers.MediaGallery; import org.wordpress.android.util.helpers.MediaGalleryImageSpan; import org.wordpress.android.util.helpers.WPImageSpan; -import org.wordpress.android.widgets.SuggestionAutoCompleteText; import org.wordpress.android.widgets.WPViewPager; import org.wordpress.mediapicker.MediaItem; import org.wordpress.mediapicker.source.MediaSource; @@ -1560,7 +1559,7 @@ private boolean addMediaVisualEditor(Uri imageUri) { } Blog blog = WordPress.getCurrentBlog(); - if (!blog.getMaxImageWidth().equals("Original Size")) { + if (MediaUtils.getImageWidthSettingFromString(blog.getMaxImageWidth()) != Integer.MAX_VALUE) { // If the user has selected a maximum image width for uploads, rescale the image accordingly path = ImageUtils.createResizedImageWithMaxWidth(this, path, Integer.parseInt(blog.getMaxImageWidth())); } diff --git a/WordPress/src/main/java/org/wordpress/android/ui/posts/services/PostUploadService.java b/WordPress/src/main/java/org/wordpress/android/ui/posts/services/PostUploadService.java index 224db4b81540..9b62c84b2bc7 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/posts/services/PostUploadService.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/posts/services/PostUploadService.java @@ -565,8 +565,9 @@ private String uploadImage(MediaFile mediaFile) { // We won't resize gif images to keep them awesome. boolean shouldUploadResizedVersion = false; // If it's not a gif and blog don't keep original size, there is a chance we need to resize - if (!mimeType.equals("image/gif") && !mBlog.getMaxImageWidth().equals("Original Size")) { - //check the picture settings + if (!mimeType.equals("image/gif") && MediaUtils.getImageWidthSettingFromString(mBlog.getMaxImageWidth()) + != Integer.MAX_VALUE) { + // check the picture settings int pictureSettingWidth = mediaFile.getWidth(); BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; @@ -696,7 +697,7 @@ private String uploadVideo(MediaFile mediaFile) { } } else { // set the width of the video to the thumbnail width, else 640x480 - if (!mBlog.getMaxImageWidth().equals("Original Size")) { + if (MediaUtils.getImageWidthSettingFromString(mBlog.getMaxImageWidth()) != Integer.MAX_VALUE) { xRes = mBlog.getMaxImageWidth(); yRes = String.valueOf(Math.round(Integer.valueOf(mBlog.getMaxImageWidth()) * 0.75)); } else { diff --git a/WordPress/src/main/java/org/wordpress/android/util/WPHtml.java b/WordPress/src/main/java/org/wordpress/android/util/WPHtml.java index 9d31ece99d0c..337de4789e9e 100644 --- a/WordPress/src/main/java/org/wordpress/android/util/WPHtml.java +++ b/WordPress/src/main/java/org/wordpress/android/util/WPHtml.java @@ -69,6 +69,7 @@ import java.io.IOException; import java.io.StringReader; import java.util.HashMap; +import java.util.Locale; /** * This class processes HTML strings into displayable styled text. Not all HTML @@ -449,22 +450,20 @@ public static String getContent(WPImageSpan imageSpan) { String localBlogID = imageSpan.getMediaFile().getBlogId(); Blog currentBlog = WordPress.wpDB.instantiateBlogByLocalId(Integer.parseInt(localBlogID)); // If it's not a gif and blog don't keep original size, there is a chance we need to resize - if (currentBlog != null && !mediaFile.getMimeType().equals("image/gif") && - !currentBlog.getMaxImageWidth().equals("Original Size")) { - int maxImageWidth = Integer.parseInt(currentBlog.getMaxImageWidth()); - // use the correct resize settings. - width = Math.min(width, maxImageWidth); + if (currentBlog != null && !mediaFile.getMimeType().equals("image/gif") + && MediaUtils.getImageWidthSettingFromString(currentBlog.getMaxImageWidth()) != Integer.MAX_VALUE) { + width = MediaUtils.getMaximumImageWidth(width, currentBlog.getMaxImageWidth()); // Use inline CSS on self-hosted blogs to enforce picture resize settings if (!currentBlog.isDotcomFlag()) { - inlineCSS = String.format(" style=\"width:%dpx;max-width:%dpx;\" ", width, width); + inlineCSS = String.format(Locale.US, " style=\"width:%dpx;max-width:%dpx;\" ", width, width); } } - content = content + ""; if (!caption.equals("")) { - content = String.format("[caption id=\"\" align=\"%s\" width=\"%d\" caption=\"%s\"]%s[/caption]", + content = String.format(Locale.US, + "[caption id=\"\" align=\"%s\" width=\"%d\" caption=\"%s\"]%s[/caption]", alignment, width, TextUtils.htmlEncode(caption), content); } } diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/ImageSettingsDialogFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/ImageSettingsDialogFragment.java index ff8cfa7cf60d..b46200a0e909 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/ImageSettingsDialogFragment.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/ImageSettingsDialogFragment.java @@ -28,6 +28,7 @@ import org.json.JSONException; import org.json.JSONObject; import org.wordpress.android.util.AppLog; +import org.wordpress.android.util.MediaUtils; import org.wordpress.android.util.ToastUtils; import java.util.Arrays; @@ -41,12 +42,9 @@ * when the fragment is dismissed to restore it. */ public class ImageSettingsDialogFragment extends DialogFragment { - public static final int IMAGE_SETTINGS_DIALOG_REQUEST_CODE = 5; public static final String IMAGE_SETTINGS_DIALOG_TAG = "image-settings"; - private static final int DEFAULT_MAX_IMAGE_WIDTH = 1024; - private JSONObject mImageMeta; private int mMaxImageWidth; @@ -170,7 +168,8 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa mLinkTo.setText(mImageMeta.getString("linkUrl")); - mMaxImageWidth = getMaximumImageWidth(mImageMeta.getInt("naturalWidth"), bundle.getString("maxWidth")); + mMaxImageWidth = MediaUtils.getMaximumImageWidth(mImageMeta.getInt("naturalWidth"), + bundle.getString("maxWidth")); setupWidthSeekBar(widthSeekBar, mWidthText, mImageMeta.getInt("width")); @@ -396,34 +395,6 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { }); } - /** - * Calculate and return the maximum allowed image width by comparing the width of the image at its full size with - * the maximum upload width set in the blog settings - * @param naturalImageWidth the image's natural (full) width - * @param imageWidthBlogSettingString the maximum upload width set in the blog settings - * @return - */ - public static int getMaximumImageWidth(int naturalImageWidth, String imageWidthBlogSettingString) { - int imageWidthBlogSetting = Integer.MAX_VALUE; - - if (!imageWidthBlogSettingString.equals("Original Size")) { - try { - imageWidthBlogSetting = Integer.valueOf(imageWidthBlogSettingString); - } catch (NumberFormatException e) { - AppLog.e(AppLog.T.EDITOR, e); - } - } - - int imageWidthPictureSetting = naturalImageWidth == 0 ? Integer.MAX_VALUE : naturalImageWidth; - - if (Math.min(imageWidthPictureSetting, imageWidthBlogSetting) == Integer.MAX_VALUE) { - // Default value in case of errors reading the picture size and the blog settings is set to Original size - return DEFAULT_MAX_IMAGE_WIDTH; - } else { - return Math.min(imageWidthPictureSetting, imageWidthBlogSetting); - } - } - /** * Return the integer value of the width EditText, adjusted to be within the given min and max, and stripped of the * 'px' units From 09adc069b3088821b9bf72d8a15a32e3eabac9d7 Mon Sep 17 00:00:00 2001 From: Maxime Biais Date: Fri, 3 Jun 2016 08:45:06 +0200 Subject: [PATCH 7/8] Update to latest utils version --- libs/analytics/WordPressAnalytics/build.gradle | 2 +- libs/editor/WordPressEditor/build.gradle | 2 +- .../org/wordpress/android/editor/LegacyEditorFragment.java | 4 ++-- libs/networking/WordPressNetworking/build.gradle | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libs/analytics/WordPressAnalytics/build.gradle b/libs/analytics/WordPressAnalytics/build.gradle index 91f3dac4a8c0..356cf6f80cc1 100644 --- a/libs/analytics/WordPressAnalytics/build.gradle +++ b/libs/analytics/WordPressAnalytics/build.gradle @@ -18,7 +18,7 @@ repositories { dependencies { compile 'com.automattic:tracks:1.1.0' compile 'com.mixpanel.android:mixpanel-android:4.6.4' - compile 'org.wordpress:utils:1.9.0' + compile 'org.wordpress:utils:1.10.0' } android { diff --git a/libs/editor/WordPressEditor/build.gradle b/libs/editor/WordPressEditor/build.gradle index 9d362ce28be5..73fa065287cb 100644 --- a/libs/editor/WordPressEditor/build.gradle +++ b/libs/editor/WordPressEditor/build.gradle @@ -48,7 +48,7 @@ dependencies { compile 'com.android.support:appcompat-v7:23.4.0' compile 'com.android.support:support-v4:23.4.0' compile 'com.android.support:design:23.4.0' - compile 'org.wordpress:utils:1.9.0' + compile 'org.wordpress:utils:1.10.0' // Test libraries testCompile 'junit:junit:4.11' diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/LegacyEditorFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/LegacyEditorFragment.java index 698e0143b353..469dc7f788b6 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/LegacyEditorFragment.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/LegacyEditorFragment.java @@ -483,7 +483,7 @@ private WPEditImageSpan createWPEditImageSpanLocal(Context context, MediaFile me } } WPEditImageSpan imageSpan = new WPEditImageSpan(context, thumbnailBitmap, imageUri); - mediaFile.setWidth(MediaUtils.getMinimumImageWidth(context, imageUri, mBlogSettingMaxImageWidth)); + mediaFile.setWidth(MediaUtils.getMaximumImageWidth(context, imageUri, mBlogSettingMaxImageWidth)); return imageSpan; } @@ -757,7 +757,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { alignmentSpinner.setSelection(mediaFile.getHorizontalAlignment(), true); - final int maxWidth = MediaUtils.getMinimumImageWidth(getActivity(), + final int maxWidth = MediaUtils.getMaximumImageWidth(getActivity(), imageSpan.getImageSource(), mBlogSettingMaxImageWidth); seekBar.setMax(maxWidth / 10); if (mediaFile.getWidth() != 0) { diff --git a/libs/networking/WordPressNetworking/build.gradle b/libs/networking/WordPressNetworking/build.gradle index 76a09ba62a60..15d8d372b96a 100644 --- a/libs/networking/WordPressNetworking/build.gradle +++ b/libs/networking/WordPressNetworking/build.gradle @@ -29,7 +29,7 @@ android { } dependencies { - compile 'org.wordpress:utils:1.9.0' + compile 'org.wordpress:utils:1.10.0' compile 'com.automattic:rest:1.0.3' } From c925f2d27d6ed14b9c75dbdf26e03653f4aaea46 Mon Sep 17 00:00:00 2001 From: Maxime Biais Date: Fri, 3 Jun 2016 08:48:03 +0200 Subject: [PATCH 8/8] fix an issue with initial max width value in legacy image settings --- .../org/wordpress/android/editor/LegacyEditorFragment.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/LegacyEditorFragment.java b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/LegacyEditorFragment.java index 469dc7f788b6..44e728a91f35 100644 --- a/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/LegacyEditorFragment.java +++ b/libs/editor/WordPressEditor/src/main/java/org/wordpress/android/editor/LegacyEditorFragment.java @@ -69,6 +69,8 @@ import org.wordpress.android.util.helpers.WPUnderlineSpan; import org.wordpress.android.util.widgets.WPEditText; +import java.util.Locale; + public class LegacyEditorFragment extends EditorFragmentAbstract implements TextWatcher, WPEditText.OnSelectionChangedListener, View.OnTouchListener { public static final int ACTIVITY_REQUEST_CODE_CREATE_LINK = 4; @@ -741,7 +743,6 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); alignmentSpinner.setAdapter(adapter); - imageWidthText.setText(String.valueOf(mediaFile.getWidth()) + "px"); seekBar.setProgress(mediaFile.getWidth()); titleText.setText(mediaFile.getTitle()); caption.setText(mediaFile.getCaption()); @@ -760,6 +761,7 @@ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { final int maxWidth = MediaUtils.getMaximumImageWidth(getActivity(), imageSpan.getImageSource(), mBlogSettingMaxImageWidth); seekBar.setMax(maxWidth / 10); + imageWidthText.setText(String.format(Locale.US, "%dpx", maxWidth)); if (mediaFile.getWidth() != 0) { seekBar.setProgress(mediaFile.getWidth() / 10); } @@ -777,7 +779,7 @@ public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (progress == 0) { progress = 1; } - imageWidthText.setText(progress * 10 + "px"); + imageWidthText.setText(String.format(Locale.US, "%dpx", progress * 10)); } });