From 5a2e8b36c848b48b331e80e495c6dfe659a0e184 Mon Sep 17 00:00:00 2001 From: laco0416 Date: Sat, 20 Sep 2014 10:29:27 +0900 Subject: Add setting for resize image --- res/values-ja/strings.xml | 2 ++ res/values/keys.xml | 1 + res/values/strings.xml | 2 ++ res/xml/setting.xml | 5 +++++ src/net/lacolaco/smileessence/twitter/TwitterApi.java | 1 + src/net/lacolaco/smileessence/twitter/task/TweetTask.java | 9 +++++---- 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index 2578e219..3b5dbbbd 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -92,6 +92,8 @@ あんふぁぼ通知 有効 無効 + 画像のリサイズ + 投稿する大きな画像を圧縮 タイムライン取得件数 更新時に新しいツイートを%s件取得する 取得件数の設定 diff --git a/res/values/keys.xml b/res/values/keys.xml index 2a0d0411..b3a3a3be 100644 --- a/res/values/keys.xml +++ b/res/values/keys.xml @@ -48,4 +48,5 @@ pageListVisibility pageListPosition extendStatusURL + resizePostImage \ No newline at end of file diff --git a/res/values/strings.xml b/res/values/strings.xml index c0272dc5..587c63ab 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -89,6 +89,8 @@ Safe mode Show confirm dialog No confirmation + Resize image + Compress large image for tweet On unfavorited Notify No Notice diff --git a/res/xml/setting.xml b/res/xml/setting.xml index 74a5ea4b..30cd6d68 100644 --- a/res/xml/setting.xml +++ b/res/xml/setting.xml @@ -68,6 +68,11 @@ android:summaryOff="@string/setting_safe_mode_summary_off" android:key="@string/key_setting_show_confirm_dialog" android:defaultValue="true"/> + // ------------------------------ FIELDS ------------------------------ - private static final int MEDIA_SIZE_LIMIT = 2 * 1024 * 1024; - private final StatusUpdate update; private final String mediaPath; private final Activity activity; @@ -75,7 +75,8 @@ public class TweetTask extends TwitterTask public File getMediaFile() { File file = new File(mediaPath); - if(file.length() >= MEDIA_SIZE_LIMIT) + boolean resizeFlag = new UserPreferenceHelper(activity).getValue(R.string.key_setting_resize_post_image, false); + if(file.length() >= TwitterApi.MEDIA_SIZE_LIMIT && resizeFlag) { BitmapFactory.Options opt = new BitmapFactory.Options(); opt.inJustDecodeBounds = true; //decoder is not return bitmap but set option @@ -86,7 +87,7 @@ public class TweetTask extends TwitterTask try { fos = new FileOutputStream(compressedFile); - float ratio = (float) file.length() / (float) MEDIA_SIZE_LIMIT; + float ratio = (float) file.length() / (float) TwitterApi.MEDIA_SIZE_LIMIT; BitmapFactory.Options resizeOpt = new BitmapFactory.Options(); resizeOpt.inPurgeable = true; resizeOpt.inSampleSize = (int) Math.ceil(ratio); -- cgit v1.2.3