diff options
author | steckbrief <steckbrief@chefmail.de> | 2015-10-30 20:05:36 +0100 |
---|---|---|
committer | steckbrief <steckbrief@chefmail.de> | 2015-10-30 20:05:36 +0100 |
commit | 11659eadb02b382804845d4e01a8536e02698468 (patch) | |
tree | 21962ec200324bda4646ae358c305259a6d68841 /src/main | |
parent | 7aed735df28984e76486f23d17d02981b268930e (diff) |
Implements FS#24: Introduce setting for picture resizing
Diffstat (limited to '')
7 files changed, 52 insertions, 1 deletions
diff --git a/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusPreferences.java b/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusPreferences.java index b20cfb8f..47daddb0 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusPreferences.java +++ b/src/main/java/de/thedevstack/conversationsplus/ConversationsPlusPreferences.java @@ -4,6 +4,7 @@ import android.content.SharedPreferences; import java.util.Set; +import de.thedevstack.conversationsplus.enums.UserDecision; import de.tzur.conversations.Settings; /** @@ -13,6 +14,14 @@ public class ConversationsPlusPreferences extends Settings { private static ConversationsPlusPreferences instance; private final SharedPreferences sharedPreferences; + public static UserDecision resizePicture() { + return getEnumFromStringPref("resize_picture", UserDecision.ASK); + } + + public static void applyResizePicture(UserDecision decision) { + applyString("resize_picture", decision.name()); + } + /** * Whether automatic downloads should only be done when connected to Wifi or not. * @return @@ -243,6 +252,10 @@ public class ConversationsPlusPreferences extends Settings { } } + protected static <T extends Enum<T>> T getEnumFromStringPref(String key, T defaultValue) { + return (T) T.valueOf(defaultValue.getClass(), defaultValue.name()); + } + private static boolean getBoolean(String key, boolean defValue) { return getSharedPreferences().getBoolean(key, defValue); } diff --git a/src/main/java/de/thedevstack/conversationsplus/enums/UserDecision.java b/src/main/java/de/thedevstack/conversationsplus/enums/UserDecision.java new file mode 100644 index 00000000..ccb658d5 --- /dev/null +++ b/src/main/java/de/thedevstack/conversationsplus/enums/UserDecision.java @@ -0,0 +1,10 @@ +package de.thedevstack.conversationsplus.enums; + +/** + * Created by tzur on 30.10.2015. + */ +public enum UserDecision { + ASK, + ALWAYS, + NEVER; +} diff --git a/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java b/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java index 4f30cda3..64d4b521 100644 --- a/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java +++ b/src/main/java/de/thedevstack/conversationsplus/ui/ConversationActivity.java @@ -1129,6 +1129,7 @@ public class ConversationActivity extends XmppActivity if (conversation == null) { return; } + //TODO Resize setting prepareFileToast = Toast.makeText(getApplicationContext(),getText(R.string.preparing_image), Toast.LENGTH_LONG); prepareFileToast.show(); xmppConnectionService.attachImageToConversation(conversation, uri, diff --git a/src/main/res/values-de/strings.xml b/src/main/res/values-de/strings.xml index 5bd93fa8..247ca4c1 100644 --- a/src/main/res/values-de/strings.xml +++ b/src/main/res/values-de/strings.xml @@ -491,4 +491,9 @@ <string name="dlg_msg_details_msg_status_unsend">In Übertragung</string> <string name="dlg_msg_details_msg_status_offered">Angeboten</string> <string name="dlg_msg_details_msg_status_failed">Fehlgeschlagen</string> + <string name="pref_resize_picture_ask">nachfragen</string> + <string name="pref_resize_picture_always">immer</string> + <string name="pref_resize_picture_never">nie</string> + <string name="pref_resize_picture_summary">Sollen Bilder vor dem Senden verkleinert werden oder nicht?</string> + <string name="pref_resize_picture">Bilder verkleinern</string> </resources> diff --git a/src/main/res/values/arrays.xml b/src/main/res/values/arrays.xml index c555d4ba..24f8790c 100644 --- a/src/main/res/values/arrays.xml +++ b/src/main/res/values/arrays.xml @@ -69,5 +69,14 @@ <item>1</item> <item>2</item> </string-array> - + <string-array name="resize_picture_setting_entries"> + <item>@string/pref_resize_picture_ask</item> + <item>@string/pref_resize_picture_always</item> + <item>@string/pref_resize_picture_never</item> + </string-array> + <string-array name="resize_picture_setting_values"> + <item>ASK</item> + <item>ALWAYS</item> + <item>NEVER</item> + </string-array> </resources> diff --git a/src/main/res/values/strings.xml b/src/main/res/values/strings.xml index d44dd76a..5f594800 100644 --- a/src/main/res/values/strings.xml +++ b/src/main/res/values/strings.xml @@ -520,4 +520,9 @@ <string name="dlg_msg_details_msg_status_unsend">Unsend</string> <string name="dlg_msg_details_msg_status_offered">Offered</string> <string name="dlg_msg_details_msg_status_failed">Failed</string> + <string name="pref_resize_picture_ask">ask</string> + <string name="pref_resize_picture_always">always</string> + <string name="pref_resize_picture_never">never</string> + <string name="pref_resize_picture_summary">Whether pictures shall be resized or not</string> + <string name="pref_resize_picture">Resize pictures</string> </resources> diff --git a/src/main/res/xml/preferences.xml b/src/main/res/xml/preferences.xml index 470cef97..29f7d841 100644 --- a/src/main/res/xml/preferences.xml +++ b/src/main/res/xml/preferences.xml @@ -44,6 +44,14 @@ </PreferenceScreen> <ListPreference + android:defaultValue="ASK" + android:entries="@array/resize_picture_setting_entries" + android:entryValues="@array/resize_picture_setting_values" + android:key="resize_picture" + android:summary="@string/pref_resize_picture_summary" + android:title="@string/pref_resize_picture"/> + + <ListPreference android:defaultValue="2" android:entries="@array/confirm_strings" android:entryValues="@array/confirm_values" |